Something went wrong. Try again.
Local-first knowledge base made for Typst and the Atmosphere. typbase.at
Something went wrong. Try again.
1234567891011121314151617181920212223242526import type { FileId, TypstState } from "@typbase/engine";
import { type Extension, EditorState } from "@codemirror/state";
import type { TextRef } from "./types";
/** * Keeps the engine's sources in step with the editor, without rendering. */export const typstSourceSync = ( fileId: FileId, prelude: TextRef, typstState: TypstState,): Extension => EditorState.transactionExtender.of((transaction) => { if (!transaction.docChanged) return null;
try { typstState.syncSource(fileId, transaction.newDoc.toString(), prelude.value); } catch (error) { console.error("[typst] source sync panicked:", error); }
return null; });