tinymist/tools/editor-tools/src/features/exporter/components/inout.ts
QuadnucYard a42700c04b
feat: export tool with page/text preview features (#2182)
Added an editor tool to export and preview documents, with all
configurable options.

Not supported: output path customization (requires changes in server)

<img width="1381" height="1458" alt="image"
src="https://github.com/user-attachments/assets/d27e6e19-bcf4-4d1a-a20e-9bea0258be24"
/>
<img width="1392" height="877" alt="image"
src="https://github.com/user-attachments/assets/53d93601-3e05-4e36-b4fd-26384fda1347"
/>

---------

Co-authored-by: Myriad-Dreamin <camiyoru@gmail.com>
2025-11-17 21:59:12 +08:00

50 lines
1.4 KiB
TypeScript

import van, { type ChildDom, type State } from "vanjs-core";
import { lastFocusedTypstDoc } from "@/vscode";
const { div, h3, input } = van.tags;
interface InputSectionProps {
inputPath: State<string>;
outputPath: State<string>;
actionButton?: ChildDom;
}
export const InputSection = ({ inputPath, actionButton }: InputSectionProps) => {
return div(
{ class: "flex flex-col gap-sm" },
h3(
{ class: "mb-xs", title: "Configure and export your Typst documents to various formats" },
"Export Document",
),
// Input Path Section
div(
{ class: "flex flex-row items-center gap-sm" },
input({
class: "input flex-1",
type: "text",
placeholder: () => lastFocusedTypstDoc.val || "Document Path",
value: inputPath,
oninput: (e: Event) => {
const target = e.target as HTMLInputElement;
inputPath.val = target.value;
},
}),
actionButton,
),
// Output Path Section (not supported yet)
/* div(
{ class: "flex flex-col gap-xs" },
h3({ class: "mb-xs" }, "Output Path"),
input({
class: "input",
type: "text",
placeholder: "Automatically decided based on input path",
value: outputPath,
oninput: (e: Event) => {
const target = e.target as HTMLInputElement;
outputPath.val = target.value;
},
}),
), */
);
};