/** * The CodeMirror half of live preview: descriptors → decorations, * two widgets, and a theme that reads Charcuterie tokens. * * `livePreviewRanges.ts` decided *what* to decorate and is pure. * This file owns everything that needs `@codemirror/view`, which is * also everything that cannot be tested in this package's Node-only * Vitest project — so it is kept deliberately thin and mechanical. * * ### Why the theme uses `var(--color-…)` and not Tailwind classes * * Every other visual in this package is a Tailwind utility reading * a token. CodeMirror is the exception, and for a structural * reason: it generates its own scoped class names and injects its * own stylesheet, so the DOM these decorations land on is not DOM * Tailwind ever scans. Referencing the custom properties directly * keeps a scheme flip a repaint — the same behaviour, one layer * lower — and avoids a `safelist` that would rot the first time a * class here changed. * * The properties below are the generated token names, not invented * ones. That distinction has already cost this fleet a release: * Docket shipped invisible priority bars from `--color-danger-9`, a * scale that does not exist, and nothing errored. A custom property * that resolves to nothing paints nothing, silently. */ import type { Extension } from "@codemirror/state"; import { Facet, StateField } from "@codemirror/state"; import type { ViewUpdate } from "@codemirror/view"; /** * What kind of surface this is, and what its checkboxes may do. * * A facet rather than closure state, for the same reason raw mode is * a `StateField`: the decoration builders below are module-level * singletons — one `ViewPlugin`, one `StateField` — and rebuilding * them per instance would mean a second copy of the whole live * preview for every surface on the page. They read the answer out of * the state they were already handed. * * It is also what lets `MarkdownView` put the task flag in a * `Compartment` and flip it without discarding the view, exactly as * the editors already flip editability. */ export type LivePreviewOptions = { /** * Draw a **document** rather than an editing surface: real * anchors, heading roles, and a table that is a table instead of a * way back into the markdown behind it. * * Off by default, because the editors are the surface this module * was written for and every one of these would be wrong inside a * `contenteditable`. */ hasDocumentSemantics?: boolean; /** Whether a `- [ ]` checkbox can be ticked. Defaults to `true`. */ isTaskListInteractive?: boolean; /** * Re-point a link before it becomes an `href` — see * `ToLivePreviewRangesOptions.resolveUrl`, which this is handed * to. Links only, and the document's URL has already been through * the scheme guard when it arrives. */ resolveUrl?: (url: string) => string | undefined; }; /** * The facet itself is exported so a consumer can put **only this** * in a `Compartment` and flip one answer without reconfiguring the * whole extension — which would tear down and recreate the * `StateField`s beside it. * * A later input wins per key, and a key nobody stated keeps the * default. That is a merge rather than "the last one wins outright", * so an override that only cares about checkboxes cannot silently * turn document semantics back off. */ export declare const livePreviewOptions: Facet>; /** Toggle the "edit Markdown" mode. */ export declare const setLivePreviewRawMode: import("@codemirror/state").StateEffectType; /** * Raw mode as editor state rather than a React prop threaded down. * * It has to live here because the decoration plugin reads it on * every update, and because a keybinding should be able to flip it * without a round trip through React. */ export declare const livePreviewRawModeField: StateField; /** * Whether the inline decorations are stale after `update`. * * Exported for its test: the tree clause was missing here for months * while `livePreviewTableField` had it. Without it, a document whose * background parse finished after mount painted its last lines raw — * a fence and a link as plain text — until the reader clicked, and a * busy VRT runner photographed exactly that. */ export declare const isInlineDecorationStale: (update: Pick) => boolean; export declare const livePreview: (options?: LivePreviewOptions) => Extension; //# sourceMappingURL=livePreview.d.ts.map