Skip to content

Editor and Preview

@quillmark/svelte gives an app the form a quill declares and the page it prints, side by side. This is the invoice quill from the home page, running in this page. Type in the form, or click a word on the page.

Terminal window
npm install @quillmark/svelte @quillmark/wasm @quillmark/fonts

createWorkspace opens the session, recompiles as the writer types and links the form to the page. The component above is this, plus loading states:

<script lang="ts">
import { Engine } from '@quillmark/wasm';
import { loadSuite } from '@quillmark/fonts';
import { createWorkspace, init, Preview, VisualEditor } from '@quillmark/svelte';
const { files, markdown } = $props();
let editor = $state.raw();
let preview = $state.raw();
let quill = $state.raw();
let doc = $state.raw();
let ws = $state.raw();
let now = $state.raw();
const engine = loadSuite().then((fonts) => new Engine({ fonts }));
init().then(({ Quill }) => {
quill = Quill.fromTree(files); // Map<string, Uint8Array> of the quill directory
doc = quill.parse(markdown);
ws = createWorkspace({
engine,
quill,
doc,
editor: () => editor,
preview: () => preview,
onState: (next) => (now = next)
});
now = ws.state;
});
</script>
{#if ws && now}
<VisualEditor bind:this={editor} {doc} {quill} diagnostics={now.diagnostics} {...ws.editor} />
{#if now.session}
<Preview bind:this={preview} session={now.session} {...ws.preview} />
{/if}
{/if}

A real component also frees the workspace, the document and the quill when it unmounts, which the README shows.

Each package’s README is its reference.

Package What it is
@quillmark/svelte The editor, the preview and the workspace, and how to theme them
@quillmark/fonts The fonts the engine sets a page in
@quillmark/quiver Loading a collection of quills in Node and the browser
@quillmark/collab Several people editing one document over Yjs

Quillmark is maintained by birdorbs