@damiro/stylo 0.15.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/{InPlaceView-BLlGJ9mh.js → InPlaceView-CC5hZCcI.js} +787 -750
  2. package/dist/InPlaceView-CC5hZCcI.js.map +1 -0
  3. package/dist/Preview-5lm2uUVj.js +319 -0
  4. package/dist/Preview-5lm2uUVj.js.map +1 -0
  5. package/dist/Stylo.d.ts.map +1 -1
  6. package/dist/editor/useCodeMirror.d.ts.map +1 -1
  7. package/dist/embed-DKKeCE1Y.js +109 -0
  8. package/dist/embed-DKKeCE1Y.js.map +1 -0
  9. package/dist/embed-cache-CcBfVrc9.js +176 -0
  10. package/dist/embed-cache-CcBfVrc9.js.map +1 -0
  11. package/dist/inplace/context-menu-helpers.d.ts +3 -4
  12. package/dist/inplace/context-menu-helpers.d.ts.map +1 -1
  13. package/dist/inplace/decorate.d.ts.map +1 -1
  14. package/dist/inplace/edit-line-prefix.d.ts.map +1 -1
  15. package/dist/inplace/embed.d.ts.map +1 -1
  16. package/dist/inplace/extension.d.ts.map +1 -1
  17. package/dist/inplace/inline-md.d.ts.map +1 -1
  18. package/dist/inplace/link-row.d.ts +14 -13
  19. package/dist/inplace/link-row.d.ts.map +1 -1
  20. package/dist/inplace/list-guides.d.ts.map +1 -1
  21. package/dist/inplace/math.d.ts +18 -3
  22. package/dist/inplace/math.d.ts.map +1 -1
  23. package/dist/inplace/table-widget-keys.d.ts +46 -0
  24. package/dist/inplace/table-widget-keys.d.ts.map +1 -0
  25. package/dist/inplace/table-widget.d.ts +1 -2
  26. package/dist/inplace/table-widget.d.ts.map +1 -1
  27. package/dist/inplace/tables.d.ts.map +1 -1
  28. package/dist/inplace/wikilinks.d.ts +1 -1
  29. package/dist/inplace/wikilinks.d.ts.map +1 -1
  30. package/dist/render/Embed.d.ts.map +1 -1
  31. package/dist/render/Preview.d.ts.map +1 -1
  32. package/dist/render/embed-cache.d.ts +13 -0
  33. package/dist/render/embed-cache.d.ts.map +1 -1
  34. package/dist/render/preview-components.d.ts +22 -0
  35. package/dist/render/preview-components.d.ts.map +1 -0
  36. package/dist/render/remark-wikilink.d.ts.map +1 -1
  37. package/dist/render/taskCheckbox.d.ts +30 -0
  38. package/dist/render/taskCheckbox.d.ts.map +1 -1
  39. package/dist/styles.css +1 -1
  40. package/dist/stylo.js +208 -196
  41. package/dist/stylo.js.map +1 -1
  42. package/dist/toolbar/Toolbar.d.ts.map +1 -1
  43. package/dist/toolbar/command-helpers.d.ts +27 -0
  44. package/dist/toolbar/command-helpers.d.ts.map +1 -1
  45. package/dist/toolbar/heading.d.ts +3 -0
  46. package/dist/toolbar/heading.d.ts.map +1 -1
  47. package/dist/toolbar/inline-ops.d.ts +6 -0
  48. package/dist/toolbar/inline-ops.d.ts.map +1 -1
  49. package/dist/toolbar/table.d.ts.map +1 -1
  50. package/dist/types/core.d.ts +200 -0
  51. package/dist/types/core.d.ts.map +1 -0
  52. package/dist/types/inplace.d.ts +91 -0
  53. package/dist/types/inplace.d.ts.map +1 -0
  54. package/dist/types/sources.d.ts +66 -0
  55. package/dist/types/sources.d.ts.map +1 -0
  56. package/dist/types/toolbar.d.ts +72 -0
  57. package/dist/types/toolbar.d.ts.map +1 -0
  58. package/dist/types.d.ts +11 -406
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/{useCodeMirror-QmbR0rQM.js → useCodeMirror-TAWSJQiZ.js} +345 -304
  61. package/dist/useCodeMirror-TAWSJQiZ.js.map +1 -0
  62. package/package.json +1 -1
  63. package/dist/InPlaceView-BLlGJ9mh.js.map +0 -1
  64. package/dist/Preview-DKOoZ-vr.js +0 -295
  65. package/dist/Preview-DKOoZ-vr.js.map +0 -1
  66. package/dist/embed-Dsu6b-MV.js +0 -131
  67. package/dist/embed-Dsu6b-MV.js.map +0 -1
  68. package/dist/highlight-BLVSvron.js +0 -133
  69. package/dist/highlight-BLVSvron.js.map +0 -1
  70. package/dist/inplace/table-widget-caret.d.ts +0 -11
  71. package/dist/inplace/table-widget-caret.d.ts.map +0 -1
  72. package/dist/useCodeMirror-QmbR0rQM.js.map +0 -1
package/dist/stylo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"stylo.js","names":[],"sources":["../src/editor/SourceView.tsx","../src/inplace/lazyInPlace.ts","../src/render/lazyPreview.ts","../src/SplitView.tsx","../src/toolbar/floating-watchdog.ts","../src/toolbar/keyboard-inset.ts","../src/toolbar/Toolbar.tsx","../src/Stylo.tsx"],"sourcesContent":["import { useRef, useState, useSyncExternalStore } from \"react\"\nimport type { ReactNode } from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { showPanel } from \"@codemirror/view\"\nimport type { EditorView } from \"@codemirror/view\"\nimport styles from \"../styles/stylo.module.css\"\nimport type { CodeLanguages, ResolveErrorInfo, TagSource, WikiLinkSource } from \"../types\"\nimport { CanvasHeaderHost } from \"./canvas-header-panel\"\nimport { useCodeMirror } from \"./useCodeMirror\"\n\nconst noopSubscribe = () => () => {}\nconst noopSnapshot = () => null\n\nexport interface SourceViewProps {\n value: string\n onChange: (next: string) => void\n readOnly?: boolean\n placeholder?: string\n /** Fenced-code grammars, forwarded to the Markdown language. Read once. */\n codeLanguages?: CodeLanguages\n /** `[[wikilink]]` autocomplete source. Read once. */\n wikiLinkSource?: WikiLinkSource\n /** `#tag` autocomplete source. Read once. */\n tagSource?: TagSource\n /** Notified when `wikiLinkSource` or `tagSource` rejects. */\n onResolveError?: (error: unknown, info: ResolveErrorInfo) => void\n /** Called with the doc string on `Mod-s`. */\n onSave?: (value: string) => void\n /** Called with the `EditorView` once created, and with `null` on teardown. */\n onViewChange?: (view: EditorView | null) => void\n /** Host content docked after the search panel, before the document. Read once. */\n canvasHeader?: (ctx: { view: EditorView | null }) => ReactNode\n}\n\n/** Raw CodeMirror 6 Markdown surface bound to the canonical string. */\nexport function SourceView({\n value,\n onChange,\n readOnly,\n placeholder,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n onResolveError,\n onSave,\n onViewChange,\n canvasHeader,\n}: SourceViewProps) {\n const [editorView, setEditorView] = useState<EditorView | null>(null)\n const onViewChangeRef = useRef(onViewChange)\n onViewChangeRef.current = onViewChange\n const handleViewChange = useRef((view: EditorView | null) => {\n setEditorView(view)\n onViewChangeRef.current?.(view)\n }).current\n\n // `canvasHeader` itself is read through a ref (a changed render prop needs\n // no editor rebuild); whether it was passed at all is read once, at mount,\n // to decide whether the panel extension exists at all.\n const canvasHeaderRef = useRef(canvasHeader)\n canvasHeaderRef.current = canvasHeader\n const [headerHost] = useState(() => (canvasHeader ? new CanvasHeaderHost() : null))\n const headerDom = useSyncExternalStore(\n headerHost?.subscribe ?? noopSubscribe,\n headerHost?.getSnapshot ?? noopSnapshot,\n )\n const [extensions] = useState(() => (headerHost ? [showPanel.of(headerHost.panel)] : []))\n\n const ref = useCodeMirror({\n value,\n onChange,\n readOnly,\n placeholder,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n onResolveError,\n onSave,\n onViewChange: handleViewChange,\n extensions,\n })\n return (\n <div className={styles.source} ref={ref}>\n {headerDom &&\n canvasHeaderRef.current &&\n createPortal(canvasHeaderRef.current({ view: editorView }), headerDom)}\n </div>\n )\n}\n","import { lazy } from \"react\"\n\n/**\n * The in-place canvas carries the decoration plugin (and, in later increments,\n * its KaTeX widgets). It loads only when `mode` resolves to `in-place`, so\n * `source` consumers never fetch it.\n */\nexport const LazyInPlaceView = lazy(async () => ({\n default: (await import(\"./InPlaceView\")).InPlaceView,\n}))\n","import { lazy } from \"react\"\n\n/**\n * Preview pulls in react-markdown + remark/rehype + KaTeX. It is loaded only\n * when a rendered mode (`preview`, `split`) is actually used, so `mode=\"source\"`\n * consumers never pay for it. Both callers share this one wrapper, so the render\n * pipeline stays a single lazy chunk.\n */\nexport const LazyPreview = lazy(async () => ({\n default: (await import(\"./Preview\")).Preview,\n}))\n","import { Suspense, useEffect, useRef, useState } from \"react\"\nimport type { ReactNode } from \"react\"\nimport type { EditorView } from \"@codemirror/view\"\nimport { SourceView } from \"./editor/SourceView\"\nimport { LazyPreview } from \"./render/lazyPreview\"\nimport styles from \"./styles/stylo.module.css\"\nimport type {\n CodeLanguages,\n EmbedSource,\n FrontmatterDisplay,\n ResolveErrorInfo,\n TagSource,\n TaskToggleInfo,\n WikiLinkSource,\n} from \"./types\"\n\nexport interface SplitViewProps {\n value: string\n onChange: (next: string) => void\n onWikiLinkClick?: (target: string) => void\n readOnly?: boolean\n placeholder?: string\n codeLanguages?: CodeLanguages\n wikiLinkSource?: WikiLinkSource\n tagSource?: TagSource\n embedSource?: EmbedSource\n onResolveError?: (error: unknown, info: ResolveErrorInfo) => void\n frontmatter?: FrontmatterDisplay\n softBreaks?: boolean\n onTaskToggle?: (info: TaskToggleInfo) => void\n /** Called with the doc string on `Mod-s`. */\n onSave?: (value: string) => void\n /** Forwarded the source pane's `EditorView` for the shared toolbar. */\n onViewChange?: (view: EditorView | null) => void\n /** Host content docked in the source pane, after its search panel. Read once. */\n canvasHeader?: (ctx: { view: EditorView | null }) => ReactNode\n}\n\n/**\n * Source and preview side by side. Both panes are a pure function of the same\n * string; the only link between them is a proportional scroll sync. Expects the\n * Stylo root to have a bounded height — otherwise both panes grow and the page\n * scrolls instead.\n */\nexport function SplitView({\n value,\n onChange,\n onWikiLinkClick,\n readOnly,\n placeholder,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n embedSource,\n onResolveError,\n frontmatter,\n softBreaks,\n onTaskToggle,\n onSave,\n onViewChange,\n canvasHeader,\n}: SplitViewProps) {\n const [view, setView] = useState<EditorView | null>(null)\n const previewPane = useRef<HTMLDivElement | null>(null)\n const syncing = useRef(false)\n\n const handleView = (next: EditorView | null) => {\n setView(next)\n onViewChange?.(next)\n }\n\n useEffect(() => {\n const source = view?.scrollDOM\n const preview = previewPane.current\n if (!source || !preview) return\n\n const sync = (from: HTMLElement, to: HTMLElement) => {\n if (syncing.current) return\n const range = from.scrollHeight - from.clientHeight\n if (range <= 0) return\n syncing.current = true\n to.scrollTop = (from.scrollTop / range) * (to.scrollHeight - to.clientHeight)\n requestAnimationFrame(() => {\n syncing.current = false\n })\n }\n\n const fromSource = () => sync(source, preview)\n const fromPreview = () => sync(preview, source)\n source.addEventListener(\"scroll\", fromSource, { passive: true })\n preview.addEventListener(\"scroll\", fromPreview, { passive: true })\n return () => {\n source.removeEventListener(\"scroll\", fromSource)\n preview.removeEventListener(\"scroll\", fromPreview)\n }\n }, [view])\n\n return (\n <div className={styles.split}>\n <div className={styles.splitPane}>\n <SourceView\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n onResolveError={onResolveError}\n onSave={onSave}\n onViewChange={handleView}\n canvasHeader={canvasHeader}\n />\n </div>\n <div className={styles.splitPane} ref={previewPane}>\n <Suspense fallback={<div className={styles.preview} aria-busy=\"true\" />}>\n <LazyPreview\n value={value}\n onWikiLinkClick={onWikiLinkClick}\n embedSource={embedSource}\n onResolveError={onResolveError}\n frontmatter={frontmatter}\n codeLanguages={codeLanguages}\n softBreaks={softBreaks}\n onTaskToggle={onTaskToggle}\n />\n </Suspense>\n </div>\n </div>\n )\n}\n","import { useEffect, type RefObject } from \"react\"\n\n/**\n * Continuously re-asserts a `transform` on a `position: fixed` element,\n * alternating an imperceptible sub-pixel jitter every animation frame,\n * instead of trusting the browser to keep it correctly composited on its\n * own. Several rounds of on-device testing found iOS Safari losing track of\n * this exact kind of element — across its own address-bar animation, and in\n * at least one report tied to the keyboard opening — in ways a one-time\n * static fix (a plain `translateZ(0)`) did not reliably prevent. A value\n * that never changes gives the browser nothing to recompute; alternating it\n * every frame forces a fresh compositor pass regardless of what triggered\n * the drift, so it can't stay wrong for more than one frame (~16ms).\n *\n * Writes to the DOM directly rather than through React state, so this never\n * causes a re-render — the transform is the only thing touched.\n */\nexport function useFloatingWatchdog(ref: RefObject<HTMLElement | null>, enabled: boolean): void {\n useEffect(() => {\n if (!enabled) return\n let raf = 0\n let jitter = false\n const tick = () => {\n const el = ref.current\n if (el) {\n jitter = !jitter\n el.style.transform = jitter ? \"translate3d(0, 0.01px, 0)\" : \"translate3d(0, 0, 0)\"\n }\n raf = requestAnimationFrame(tick)\n }\n raf = requestAnimationFrame(tick)\n return () => cancelAnimationFrame(raf)\n }, [ref, enabled])\n}\n","import { useEffect, useState } from \"react\"\n\n/**\n * How far the on-screen keyboard eats into the window, tracked through the\n * `visualViewport` API. 0 when `enabled` is false or the browser has no\n * `visualViewport` (older Safari, SSR, most desktop browsers). A mobile\n * keyboard shrinks the *visual* viewport, not the layout viewport a plain\n * `position: fixed` bottom offset is computed against — this is what lets the\n * sticky toolbar ride up above the keyboard instead of hiding behind it.\n */\nexport function useKeyboardInset(enabled: boolean): number {\n const [inset, setInset] = useState(0)\n\n useEffect(() => {\n const vv = typeof window === \"undefined\" ? null : window.visualViewport\n if (!enabled || !vv) {\n setInset(0)\n return\n }\n const update = () => setInset(Math.max(0, window.innerHeight - vv.height - vv.offsetTop))\n update()\n vv.addEventListener(\"resize\", update)\n vv.addEventListener(\"scroll\", update)\n return () => {\n vv.removeEventListener(\"resize\", update)\n vv.removeEventListener(\"scroll\", update)\n }\n }, [enabled])\n\n return inset\n}\n","import { useEffect, useReducer, useRef, useState } from \"react\"\nimport type { ReactNode } from \"react\"\nimport type { EditorState } from \"@codemirror/state\"\nimport type { EditorView } from \"@codemirror/view\"\nimport styles from \"../styles/stylo.module.css\"\nimport type { ToolbarCommandId } from \"../types\"\nimport { BUILTIN_BY_ID } from \"./commands\"\nimport type { ToolbarItem } from \"./config\"\nimport { useFloatingWatchdog } from \"./floating-watchdog\"\nimport { DEFAULT_ICONS } from \"./icons\"\nimport { useKeyboardInset } from \"./keyboard-inset\"\n\nexport interface ToolbarProps {\n /** The surface the commands act on. `null` while a lazy view is mounting. */\n view: EditorView | null\n /** Ordered items to render; `\"|\"` is a separator. */\n items: ToolbarItem[]\n /** Per-id glyph overrides; any id left out keeps its built-in icon. */\n icons?: Partial<Record<ToolbarCommandId, ReactNode>>\n /** Render every button inert (e.g. a read-only surface). */\n disabled?: boolean\n /** Fix the bar to a window edge (normalised from `ToolbarConfig.sticky`; the\n * caller resolves `true` to `\"bottom\"`). */\n sticky?: \"top\" | \"bottom\" | false\n /** Fade the bar out while the editing surface is unfocused (`ToolbarConfig.stickyVisibility`). */\n stickyVisibility?: \"consistent\" | \"dynamic\"\n}\n\n/** A button to render, normalised from a built-in id or a custom item. */\ninterface Btn {\n key: string\n icon: ReactNode\n title: string\n run: (view: EditorView) => unknown\n isActive?: (state: EditorState) => boolean\n disabled?: (state: EditorState) => boolean\n}\n\n/**\n * Splits `items` into the runs a `\"|\"` already delimits, keeping each\n * separator as its own entry. A run renders as one flex child so wrapping\n * (on narrow hosts) breaks between groups, never in the middle of one — the\n * default bar's `undo, redo | h1, h2, h3 | ...` shape becomes the wrap unit\n * for free, no separate grouping config needed.\n */\nfunction groupItems(items: ToolbarItem[]): (Exclude<ToolbarItem, \"|\">[] | \"|\")[] {\n const groups: (Exclude<ToolbarItem, \"|\">[] | \"|\")[] = []\n let run: Exclude<ToolbarItem, \"|\">[] = []\n for (const item of items) {\n if (item !== \"|\") {\n run.push(item)\n continue\n }\n if (run.length) groups.push(run)\n run = []\n groups.push(\"|\")\n }\n if (run.length) groups.push(run)\n return groups\n}\n\n/** Resolve one non-separator item to a renderable button, or `null` to skip it. */\nfunction toButton(item: Exclude<ToolbarItem, \"|\">, icons: ToolbarProps[\"icons\"]): Btn | null {\n if (typeof item !== \"string\") {\n const { id, icon, title, run, isActive, disabled } = item\n return { key: id, icon, title, run, isActive, disabled }\n }\n const cmd = BUILTIN_BY_ID[item]\n if (!cmd) return null\n return {\n key: item,\n icon: icons?.[item] ?? DEFAULT_ICONS[item],\n title: cmd.title,\n run: cmd.run,\n isActive: cmd.isActive,\n disabled: cmd.disabled,\n }\n}\n\n/**\n * Formatting bar above the editing surface. It holds no document state — each\n * button runs a command against the live `EditorView`. Pressed states are read\n * back from the view whenever the selection, keys, or pointer move. Built-in\n * ids and consumer-supplied {@link ToolbarCustomItem}s render through the same\n * button path.\n */\nexport function Toolbar({ view, items, icons, disabled, sticky, stickyVisibility }: ToolbarProps) {\n const [, refresh] = useReducer((n: number) => n + 1, 0)\n const [focused, setFocused] = useState(false)\n // Only \"bottom\" needs keyboard tracking — nothing eats into the top of the\n // screen the way a keyboard eats the bottom.\n const keyboardInset = useKeyboardInset(sticky === \"bottom\")\n const barRef = useRef<HTMLDivElement>(null)\n useFloatingWatchdog(barRef, sticky === \"top\")\n\n useEffect(() => {\n if (!view) return\n const el = view.contentDOM\n setFocused(view.hasFocus)\n const onFocus = () => {\n setFocused(true)\n refresh()\n }\n const onBlur = () => {\n setFocused(false)\n refresh()\n }\n const events = [\"keyup\", \"mouseup\", \"input\"] as const\n for (const ev of events) el.addEventListener(ev, refresh)\n el.addEventListener(\"focus\", onFocus)\n el.addEventListener(\"blur\", onBlur)\n return () => {\n for (const ev of events) el.removeEventListener(ev, refresh)\n el.removeEventListener(\"focus\", onFocus)\n el.removeEventListener(\"blur\", onBlur)\n }\n }, [view])\n\n // \"dynamic\" fades the bar out while nothing is focused, so it doesn't sit\n // over the content while the caret is elsewhere (e.g. scrolling to read).\n const dynamicHidden = Boolean(sticky) && stickyVisibility === \"dynamic\" && !focused\n\n const className = [\n styles.toolbar,\n sticky && styles.toolbarSticky,\n sticky === \"top\" && styles.toolbarStickyTop,\n sticky === \"bottom\" && styles.toolbarStickyBottom,\n dynamicHidden && styles.toolbarStickyHidden,\n ]\n .filter(Boolean)\n .join(\" \")\n // `transform`, not `bottom` — a `position: fixed` element repositioned via\n // `bottom` doesn't reliably repaint in step with the keyboard animation on\n // iOS Safari; `translateY` forces a compositor update on every\n // `visualViewport` event instead. The bar's resting position (keyboard\n // closed) is `bottom: 0` in CSS; this only nudges it up. `\"top\"` needs no\n // offset at all.\n const stickyStyle =\n sticky === \"bottom\" ? { transform: `translateY(-${keyboardInset}px)` } : undefined\n\n return (\n <div\n ref={barRef}\n className={className}\n role=\"toolbar\"\n aria-label=\"Formatting\"\n aria-hidden={dynamicHidden || undefined}\n style={stickyStyle}\n >\n {groupItems(items).map((group, i) => {\n if (group === \"|\") {\n return <span key={`sep-${i}`} className={styles.toolbarSep} aria-hidden=\"true\" />\n }\n return (\n <div key={`group-${i}`} className={styles.toolbarGroup}>\n {group.map((item) => {\n const btn = toButton(item, icons)\n if (!btn) return null\n const off = disabled || !view || Boolean(btn.disabled?.(view.state))\n const active = Boolean(!off && view && btn.isActive?.(view.state))\n return (\n <button\n key={btn.key}\n type=\"button\"\n className={styles.toolbarButton}\n data-command={btn.key}\n title={btn.title}\n aria-label={btn.title}\n aria-pressed={btn.isActive ? active : undefined}\n data-active={active ? \"\" : undefined}\n disabled={off}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n if (!view) return\n btn.run(view)\n refresh()\n }}\n >\n {btn.icon}\n </button>\n )\n })}\n </div>\n )\n })}\n </div>\n )\n}\n","import { forwardRef, Suspense, useEffect, useImperativeHandle, useRef, useState } from \"react\"\nimport { EditorView } from \"@codemirror/view\"\nimport { SourceView } from \"./editor/SourceView\"\nimport { LazyInPlaceView } from \"./inplace/lazyInPlace\"\nimport { LazyPreview } from \"./render/lazyPreview\"\nimport { SplitView } from \"./SplitView\"\nimport styles from \"./styles/stylo.module.css\"\nimport { Toolbar } from \"./toolbar/Toolbar\"\nimport { resolveToolbarItems } from \"./toolbar/config\"\nimport { splitFrontmatter } from \"./frontmatter\"\nimport \"./styles/tokens.css\"\nimport type { ResolveErrorInfo, StyloHandle, StyloProps } from \"./types\"\n\n/**\n * Plain-text-first Markdown editor. `value` is the canonical Markdown string;\n * every view is a pure function of it.\n *\n * The default `mode` is `in-place`, the live decoration canvas (ADR-002 §1,\n * ADR-004). Pass `mode=\"source\"` for the plain surface with no lazy render\n * chunk. `preview` and `split` are also available.\n *\n * A formatting `toolbar` sits above every editing surface (all modes but\n * `preview`); pass `toolbar={false}` to drop it or a `ToolbarConfig` to trim it.\n */\nexport const Stylo = forwardRef<StyloHandle, StyloProps>(function Stylo(\n {\n value,\n onChange,\n mode = \"in-place\",\n onSave,\n onFrontmatter,\n onWikiLinkClick,\n onLinkClick,\n readOnly,\n placeholder,\n className,\n inPlace,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n embedSource,\n onResolveError,\n toolbar,\n icons,\n frontmatter,\n softBreaks,\n onTaskToggle,\n canvasHeader,\n },\n ref,\n) {\n const resolved = mode === \"preview\" || mode === \"split\" || mode === \"in-place\" ? mode : \"source\"\n\n const [view, setView] = useState<EditorView | null>(null)\n const toolbarItems = resolved === \"preview\" ? null : resolveToolbarItems(toolbar)\n const toolbarRender = toolbar && typeof toolbar === \"object\" ? toolbar.render : undefined\n const stickyConfig = toolbar && typeof toolbar === \"object\" ? toolbar.sticky : undefined\n const stickyToolbar: \"top\" | \"bottom\" | false =\n stickyConfig === \"top\" ? \"top\" : stickyConfig ? \"bottom\" : false\n const stickyVisibility =\n toolbar && typeof toolbar === \"object\" ? toolbar.stickyVisibility : undefined\n\n // Report the raw frontmatter block on mount and whenever it changes. Stylo\n // does not parse it — the host passes `raw` to its own YAML parser.\n const onFrontmatterRef = useRef(onFrontmatter)\n onFrontmatterRef.current = onFrontmatter\n\n // Stable wrapper so a changed `onResolveError` needs no editor rebuild and\n // does not thrash the embed effect. Passed to every surface.\n const onResolveErrorRef = useRef(onResolveError)\n onResolveErrorRef.current = onResolveError\n const resolveError = useRef((error: unknown, info: ResolveErrorInfo) => {\n onResolveErrorRef.current?.(error, info)\n }).current\n const lastFrontmatter = useRef<string | null | undefined>(undefined)\n useEffect(() => {\n const raw = splitFrontmatter(value)?.frontmatter ?? null\n if (raw === lastFrontmatter.current) return\n lastFrontmatter.current = raw\n onFrontmatterRef.current?.(raw)\n }, [value])\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => view?.focus(),\n getView: () => view,\n insertAtCursor: (md) => {\n if (!view) return\n view.dispatch(view.state.replaceSelection(md))\n view.focus()\n },\n scrollToHeading: (text) => {\n if (!view) return false\n const target = text.trim().toLowerCase()\n const { doc } = view.state\n for (let n = 1; n <= doc.lines; n++) {\n const line = doc.line(n)\n const m = /^ {0,3}#{1,6}[ \\t]+(.*?)(?:[ \\t]+#+)?[ \\t]*$/.exec(line.text)\n if (!m || m[1] === undefined) continue\n if (m[1].trim().toLowerCase() !== target) continue\n view.dispatch({\n selection: { anchor: line.from },\n effects: EditorView.scrollIntoView(line.from, { y: \"start\" }),\n })\n view.focus()\n return true\n }\n return false\n },\n }),\n [view],\n )\n\n const rootClass = [\n styles.root,\n stickyToolbar === \"bottom\" && styles.stickyToolbarRootBottom,\n stickyToolbar === \"top\" && styles.stickyToolbarRootTop,\n \"stylo\",\n className,\n ]\n .filter(Boolean)\n .join(\" \")\n\n return (\n <div className={rootClass} data-stylo-mode={resolved}>\n {toolbarItems &&\n (() => {\n const bar = (\n <Toolbar\n view={view}\n items={toolbarItems}\n icons={icons}\n disabled={readOnly}\n sticky={stickyToolbar}\n stickyVisibility={stickyVisibility}\n />\n )\n return toolbarRender ? toolbarRender(bar, { view }) : bar\n })()}\n\n {resolved === \"source\" && (\n <SourceView\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n onResolveError={resolveError}\n onSave={onSave}\n onViewChange={setView}\n canvasHeader={canvasHeader}\n />\n )}\n\n {resolved === \"preview\" && (\n <Suspense fallback={<div className={styles.preview} aria-busy=\"true\" />}>\n <LazyPreview\n value={value}\n onWikiLinkClick={onWikiLinkClick}\n embedSource={embedSource}\n onResolveError={resolveError}\n frontmatter={frontmatter}\n codeLanguages={codeLanguages}\n softBreaks={softBreaks}\n onTaskToggle={onTaskToggle}\n />\n </Suspense>\n )}\n\n {resolved === \"split\" && (\n <SplitView\n value={value}\n onChange={onChange}\n onWikiLinkClick={onWikiLinkClick}\n readOnly={readOnly}\n placeholder={placeholder}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n embedSource={embedSource}\n onResolveError={resolveError}\n frontmatter={frontmatter}\n softBreaks={softBreaks}\n onTaskToggle={onTaskToggle}\n onSave={onSave}\n onViewChange={setView}\n canvasHeader={canvasHeader}\n />\n )}\n\n {resolved === \"in-place\" && (\n <Suspense fallback={<div className={styles.inplace} aria-busy=\"true\" />}>\n <LazyInPlaceView\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n onWikiLinkClick={onWikiLinkClick}\n onLinkClick={onLinkClick}\n inPlace={inPlace}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n embedSource={embedSource}\n onResolveError={resolveError}\n onSave={onSave}\n onViewChange={setView}\n canvasHeader={canvasHeader}\n />\n </Suspense>\n )}\n </div>\n )\n})\n\nStylo.displayName = \"Stylo\"\n"],"mappings":";;;;;;;;AAUA,IAAM,gBAA4B,CAAC,GAC7B,UAAqB;AAwB3B,SAAgB,EAAW,EACzB,UACA,aACA,aACA,gBACA,kBACA,mBACA,cACA,mBACA,WACA,iBACA,mBACkB;CAClB,IAAM,CAAC,GAAY,KAAiB,EAA4B,IAAI,GAC9D,IAAkB,EAAO,CAAY;CAC3C,EAAgB,UAAU;CAC1B,IAAM,IAAmB,GAAQ,MAA4B;EAE3D,AADA,EAAc,CAAI,GAClB,EAAgB,UAAU,CAAI;CAChC,CAAC,CAAC,CAAC,SAKG,IAAkB,EAAO,CAAY;CAC3C,EAAgB,UAAU;CAC1B,IAAM,CAAC,KAAc,QAAgB,IAAe,IAAI,EAAiB,IAAI,IAAK,GAC5E,IAAY,EAChB,GAAY,aAAa,GACzB,GAAY,eAAe,CAC7B,GACM,CAAC,KAAc,QAAgB,IAAa,CAAC,EAAU,GAAG,EAAW,KAAK,CAAC,IAAI,CAAC,CAAE,GAElF,IAAM,EA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ACpE,UAAA,kBAAC,GAAD;KACS;KACU;KACJ;KACb,gBAAgB;KACH;KACE;KACH;KACE;IACf,CAAA;GACO,CAAA;GAGX,MAAa,WACZ,kBAAC,GAAD;IACS;IACG;IACO;IACP;IACG;IACE;IACC;IACL;IACE;IACb,gBAAgB;IACH;IACD;IACE;IACN;IACR,cAAc;IACA;GACf,CAAA;GAGF,MAAa,cACZ,kBAAC,GAAD;IAAU,UAAU,kBAAC,OAAD;KAAK,WAAW,EAAO;KAAS,aAAU;IAAQ,CAAA;IACpE,UAAA,kBAAC,GAAD;KACS;KACG;KACA;KACG;KACI;KACJ;KACJ;KACM;KACC;KACL;KACE;KACb,gBAAgB;KACR;KACR,cAAc;KACA;IACf,CAAA;GACO,CAAA;EAET;;AAET,CAAC;AAED,EAAM,cAAc"}
1
+ {"version":3,"file":"stylo.js","names":[],"sources":["../src/editor/SourceView.tsx","../src/inplace/lazyInPlace.ts","../src/render/lazyPreview.ts","../src/SplitView.tsx","../src/toolbar/floating-watchdog.ts","../src/toolbar/keyboard-inset.ts","../src/toolbar/Toolbar.tsx","../src/Stylo.tsx"],"sourcesContent":["import { useRef, useState, useSyncExternalStore } from \"react\"\nimport type { ReactNode } from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { showPanel } from \"@codemirror/view\"\nimport type { EditorView } from \"@codemirror/view\"\nimport styles from \"../styles/stylo.module.css\"\nimport type { CodeLanguages, ResolveErrorInfo, TagSource, WikiLinkSource } from \"../types\"\nimport { CanvasHeaderHost } from \"./canvas-header-panel\"\nimport { useCodeMirror } from \"./useCodeMirror\"\n\nconst noopSubscribe = () => () => {}\nconst noopSnapshot = () => null\n\nexport interface SourceViewProps {\n value: string\n onChange: (next: string) => void\n readOnly?: boolean\n placeholder?: string\n /** Fenced-code grammars, forwarded to the Markdown language. Read once. */\n codeLanguages?: CodeLanguages\n /** `[[wikilink]]` autocomplete source. Read once. */\n wikiLinkSource?: WikiLinkSource\n /** `#tag` autocomplete source. Read once. */\n tagSource?: TagSource\n /** Notified when `wikiLinkSource` or `tagSource` rejects. */\n onResolveError?: (error: unknown, info: ResolveErrorInfo) => void\n /** Called with the doc string on `Mod-s`. */\n onSave?: (value: string) => void\n /** Called with the `EditorView` once created, and with `null` on teardown. */\n onViewChange?: (view: EditorView | null) => void\n /** Host content docked after the search panel, before the document. Read once. */\n canvasHeader?: (ctx: { view: EditorView | null }) => ReactNode\n}\n\n/** Raw CodeMirror 6 Markdown surface bound to the canonical string. */\nexport function SourceView({\n value,\n onChange,\n readOnly,\n placeholder,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n onResolveError,\n onSave,\n onViewChange,\n canvasHeader,\n}: SourceViewProps) {\n const [editorView, setEditorView] = useState<EditorView | null>(null)\n const onViewChangeRef = useRef(onViewChange)\n onViewChangeRef.current = onViewChange\n const handleViewChange = useRef((view: EditorView | null) => {\n setEditorView(view)\n onViewChangeRef.current?.(view)\n }).current\n\n // `canvasHeader` itself is read through a ref (a changed render prop needs\n // no editor rebuild); whether it was passed at all is read once, at mount,\n // to decide whether the panel extension exists at all.\n const canvasHeaderRef = useRef(canvasHeader)\n canvasHeaderRef.current = canvasHeader\n const [headerHost] = useState(() => (canvasHeader ? new CanvasHeaderHost() : null))\n const headerDom = useSyncExternalStore(\n headerHost?.subscribe ?? noopSubscribe,\n headerHost?.getSnapshot ?? noopSnapshot,\n )\n const [extensions] = useState(() => (headerHost ? [showPanel.of(headerHost.panel)] : []))\n\n const ref = useCodeMirror({\n value,\n onChange,\n readOnly,\n placeholder,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n onResolveError,\n onSave,\n onViewChange: handleViewChange,\n extensions,\n })\n return (\n <div className={styles.source} ref={ref}>\n {headerDom &&\n canvasHeaderRef.current &&\n createPortal(canvasHeaderRef.current({ view: editorView }), headerDom)}\n </div>\n )\n}\n","import { lazy } from \"react\"\n\n/**\n * The in-place canvas carries the decoration plugin (and, in later increments,\n * its KaTeX widgets). It loads only when `mode` resolves to `in-place`, so\n * `source` consumers never fetch it.\n */\nexport const LazyInPlaceView = lazy(async () => ({\n default: (await import(\"./InPlaceView\")).InPlaceView,\n}))\n","import { lazy } from \"react\"\n\n/**\n * Preview pulls in react-markdown + remark/rehype + KaTeX. It is loaded only\n * when a rendered mode (`preview`, `split`) is actually used, so `mode=\"source\"`\n * consumers never pay for it. Both callers share this one wrapper, so the render\n * pipeline stays a single lazy chunk.\n */\nexport const LazyPreview = lazy(async () => ({\n default: (await import(\"./Preview\")).Preview,\n}))\n","import { Suspense, useEffect, useRef, useState } from \"react\"\nimport type { ReactNode } from \"react\"\nimport type { EditorView } from \"@codemirror/view\"\nimport { SourceView } from \"./editor/SourceView\"\nimport { LazyPreview } from \"./render/lazyPreview\"\nimport styles from \"./styles/stylo.module.css\"\nimport type {\n CodeLanguages,\n EmbedSource,\n FrontmatterDisplay,\n ResolveErrorInfo,\n TagSource,\n TaskToggleInfo,\n WikiLinkSource,\n} from \"./types\"\n\nexport interface SplitViewProps {\n value: string\n onChange: (next: string) => void\n onWikiLinkClick?: (target: string) => void\n readOnly?: boolean\n placeholder?: string\n codeLanguages?: CodeLanguages\n wikiLinkSource?: WikiLinkSource\n tagSource?: TagSource\n embedSource?: EmbedSource\n onResolveError?: (error: unknown, info: ResolveErrorInfo) => void\n frontmatter?: FrontmatterDisplay\n softBreaks?: boolean\n onTaskToggle?: (info: TaskToggleInfo) => void\n /** Called with the doc string on `Mod-s`. */\n onSave?: (value: string) => void\n /** Forwarded the source pane's `EditorView` for the shared toolbar. */\n onViewChange?: (view: EditorView | null) => void\n /** Host content docked in the source pane, after its search panel. Read once. */\n canvasHeader?: (ctx: { view: EditorView | null }) => ReactNode\n}\n\n/**\n * Source and preview side by side. Both panes are a pure function of the same\n * string; the only link between them is a proportional scroll sync. Expects the\n * Stylo root to have a bounded height — otherwise both panes grow and the page\n * scrolls instead.\n */\nexport function SplitView({\n value,\n onChange,\n onWikiLinkClick,\n readOnly,\n placeholder,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n embedSource,\n onResolveError,\n frontmatter,\n softBreaks,\n onTaskToggle,\n onSave,\n onViewChange,\n canvasHeader,\n}: SplitViewProps) {\n const [view, setView] = useState<EditorView | null>(null)\n const previewPane = useRef<HTMLDivElement | null>(null)\n const syncing = useRef(false)\n\n const handleView = (next: EditorView | null) => {\n setView(next)\n onViewChange?.(next)\n }\n\n useEffect(() => {\n const source = view?.scrollDOM\n const preview = previewPane.current\n if (!source || !preview) return\n\n const sync = (from: HTMLElement, to: HTMLElement) => {\n if (syncing.current) return\n const range = from.scrollHeight - from.clientHeight\n if (range <= 0) return\n syncing.current = true\n to.scrollTop = (from.scrollTop / range) * (to.scrollHeight - to.clientHeight)\n requestAnimationFrame(() => {\n syncing.current = false\n })\n }\n\n const fromSource = () => sync(source, preview)\n const fromPreview = () => sync(preview, source)\n source.addEventListener(\"scroll\", fromSource, { passive: true })\n preview.addEventListener(\"scroll\", fromPreview, { passive: true })\n return () => {\n source.removeEventListener(\"scroll\", fromSource)\n preview.removeEventListener(\"scroll\", fromPreview)\n }\n }, [view])\n\n return (\n <div className={styles.split}>\n <div className={styles.splitPane}>\n <SourceView\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n onResolveError={onResolveError}\n onSave={onSave}\n onViewChange={handleView}\n canvasHeader={canvasHeader}\n />\n </div>\n <div className={styles.splitPane} ref={previewPane}>\n <Suspense fallback={<div className={styles.preview} aria-busy=\"true\" />}>\n <LazyPreview\n value={value}\n onWikiLinkClick={onWikiLinkClick}\n embedSource={embedSource}\n onResolveError={onResolveError}\n frontmatter={frontmatter}\n codeLanguages={codeLanguages}\n softBreaks={softBreaks}\n onTaskToggle={onTaskToggle}\n />\n </Suspense>\n </div>\n </div>\n )\n}\n","import { useEffect, type RefObject } from \"react\"\n\n/**\n * Continuously re-asserts a `transform` on a `position: fixed` element,\n * alternating an imperceptible sub-pixel jitter every animation frame,\n * instead of trusting the browser to keep it correctly composited on its\n * own. Several rounds of on-device testing found iOS Safari losing track of\n * this exact kind of element — across its own address-bar animation, and in\n * at least one report tied to the keyboard opening — in ways a one-time\n * static fix (a plain `translateZ(0)`) did not reliably prevent. A value\n * that never changes gives the browser nothing to recompute; alternating it\n * every frame forces a fresh compositor pass regardless of what triggered\n * the drift, so it can't stay wrong for more than one frame (~16ms).\n *\n * Writes to the DOM directly rather than through React state, so this never\n * causes a re-render — the transform is the only thing touched.\n */\nexport function useFloatingWatchdog(ref: RefObject<HTMLElement | null>, enabled: boolean): void {\n useEffect(() => {\n if (!enabled) return\n let raf = 0\n let jitter = false\n const tick = () => {\n const el = ref.current\n if (el) {\n jitter = !jitter\n el.style.transform = jitter ? \"translate3d(0, 0.01px, 0)\" : \"translate3d(0, 0, 0)\"\n }\n raf = requestAnimationFrame(tick)\n }\n raf = requestAnimationFrame(tick)\n return () => cancelAnimationFrame(raf)\n }, [ref, enabled])\n}\n","import { useEffect, useState } from \"react\"\n\n/**\n * How far the on-screen keyboard eats into the window, tracked through the\n * `visualViewport` API. 0 when `enabled` is false or the browser has no\n * `visualViewport` (older Safari, SSR, most desktop browsers). A mobile\n * keyboard shrinks the *visual* viewport, not the layout viewport a plain\n * `position: fixed` bottom offset is computed against — this is what lets the\n * sticky toolbar ride up above the keyboard instead of hiding behind it.\n */\nexport function useKeyboardInset(enabled: boolean): number {\n const [inset, setInset] = useState(0)\n\n useEffect(() => {\n const vv = typeof window === \"undefined\" ? null : window.visualViewport\n if (!enabled || !vv) {\n setInset(0)\n return\n }\n const update = () => setInset(Math.max(0, window.innerHeight - vv.height - vv.offsetTop))\n update()\n vv.addEventListener(\"resize\", update)\n vv.addEventListener(\"scroll\", update)\n return () => {\n vv.removeEventListener(\"resize\", update)\n vv.removeEventListener(\"scroll\", update)\n }\n }, [enabled])\n\n return inset\n}\n","import { useEffect, useReducer, useRef, useState } from \"react\"\nimport type { ReactNode } from \"react\"\nimport type { EditorState } from \"@codemirror/state\"\nimport type { EditorView } from \"@codemirror/view\"\nimport styles from \"../styles/stylo.module.css\"\nimport type { ToolbarCommandId } from \"../types\"\nimport { activeTableCell } from \"./cell-inline\"\nimport { resolveForCell } from \"./command-helpers\"\nimport { BUILTIN_BY_ID } from \"./commands\"\nimport type { ToolbarItem } from \"./config\"\nimport { useFloatingWatchdog } from \"./floating-watchdog\"\nimport { DEFAULT_ICONS } from \"./icons\"\nimport { useKeyboardInset } from \"./keyboard-inset\"\n\nexport interface ToolbarProps {\n /** The surface the commands act on. `null` while a lazy view is mounting. */\n view: EditorView | null\n /** Ordered items to render; `\"|\"` is a separator. */\n items: ToolbarItem[]\n /** Per-id glyph overrides; any id left out keeps its built-in icon. */\n icons?: Partial<Record<ToolbarCommandId, ReactNode>>\n /** Render every button inert (e.g. a read-only surface). */\n disabled?: boolean\n /** Fix the bar to a window edge (normalised from `ToolbarConfig.sticky`; the\n * caller resolves `true` to `\"bottom\"`). */\n sticky?: \"top\" | \"bottom\" | false\n /** Fade the bar out while the editing surface is unfocused (`ToolbarConfig.stickyVisibility`). */\n stickyVisibility?: \"consistent\" | \"dynamic\"\n}\n\n/** A button to render, normalised from a built-in id or a custom item. */\ninterface Btn {\n key: string\n icon: ReactNode\n title: string\n run: (view: EditorView) => unknown\n isActive?: (state: EditorState) => boolean\n disabled?: (state: EditorState) => boolean\n}\n\n/**\n * Splits `items` into the runs a `\"|\"` already delimits, keeping each\n * separator as its own entry. A run renders as one flex child so wrapping\n * (on narrow hosts) breaks between groups, never in the middle of one — the\n * default bar's `undo, redo | h1, h2, h3 | ...` shape becomes the wrap unit\n * for free, no separate grouping config needed.\n */\nfunction groupItems(items: ToolbarItem[]): (Exclude<ToolbarItem, \"|\">[] | \"|\")[] {\n const groups: (Exclude<ToolbarItem, \"|\">[] | \"|\")[] = []\n let run: Exclude<ToolbarItem, \"|\">[] = []\n for (const item of items) {\n if (item !== \"|\") {\n run.push(item)\n continue\n }\n if (run.length) groups.push(run)\n run = []\n groups.push(\"|\")\n }\n if (run.length) groups.push(run)\n return groups\n}\n\n/** Resolve one non-separator item to a renderable button, or `null` to skip it. */\nfunction toButton(item: Exclude<ToolbarItem, \"|\">, icons: ToolbarProps[\"icons\"]): Btn | null {\n if (typeof item !== \"string\") {\n const { id, icon, title, run, isActive, disabled } = item\n return { key: id, icon, title, run, isActive, disabled }\n }\n const cmd = BUILTIN_BY_ID[item]\n if (!cmd) return null\n return {\n key: item,\n icon: icons?.[item] ?? DEFAULT_ICONS[item],\n title: cmd.title,\n run: cmd.run,\n isActive: cmd.isActive,\n disabled: cmd.disabled,\n }\n}\n\n/**\n * Formatting bar above the editing surface. It holds no document state — each\n * button runs a command against the live `EditorView`. Pressed states are read\n * back from the view whenever the selection, keys, or pointer move. Built-in\n * ids and consumer-supplied {@link ToolbarCustomItem}s render through the same\n * button path.\n */\nexport function Toolbar({ view, items, icons, disabled, sticky, stickyVisibility }: ToolbarProps) {\n const [, refresh] = useReducer((n: number) => n + 1, 0)\n const [focused, setFocused] = useState(false)\n // Only \"bottom\" needs keyboard tracking — nothing eats into the top of the\n // screen the way a keyboard eats the bottom.\n const keyboardInset = useKeyboardInset(sticky === \"bottom\")\n const barRef = useRef<HTMLDivElement>(null)\n useFloatingWatchdog(barRef, sticky === \"top\")\n\n useEffect(() => {\n if (!view) return\n const el = view.contentDOM\n setFocused(view.hasFocus)\n const onFocus = () => {\n setFocused(true)\n refresh()\n }\n const onBlur = () => {\n setFocused(false)\n refresh()\n }\n const events = [\"keyup\", \"mouseup\", \"input\"] as const\n for (const ev of events) el.addEventListener(ev, refresh)\n el.addEventListener(\"focus\", onFocus)\n el.addEventListener(\"blur\", onBlur)\n return () => {\n for (const ev of events) el.removeEventListener(ev, refresh)\n el.removeEventListener(\"focus\", onFocus)\n el.removeEventListener(\"blur\", onBlur)\n }\n }, [view])\n\n // \"dynamic\" fades the bar out while nothing is focused, so it doesn't sit\n // over the content while the caret is elsewhere (e.g. scrolling to read).\n const dynamicHidden = Boolean(sticky) && stickyVisibility === \"dynamic\" && !focused\n\n // `state.selection` never follows the caret into an editable table cell's\n // `contentEditable` DOM (see `extension.ts`'s mousedown handler), so a\n // built-in command's own `disabled` / `isActive` would otherwise read a\n // selection that may point anywhere else in the document while the user is\n // actually typing in a cell. `resolveForCell` below re-derives both from the\n // real DOM focus in that case instead.\n const inCell = view ? Boolean(activeTableCell(view)) : false\n\n const className = [\n styles.toolbar,\n sticky && styles.toolbarSticky,\n sticky === \"top\" && styles.toolbarStickyTop,\n sticky === \"bottom\" && styles.toolbarStickyBottom,\n dynamicHidden && styles.toolbarStickyHidden,\n ]\n .filter(Boolean)\n .join(\" \")\n // `transform`, not `bottom` — a `position: fixed` element repositioned via\n // `bottom` doesn't reliably repaint in step with the keyboard animation on\n // iOS Safari; `translateY` forces a compositor update on every\n // `visualViewport` event instead. The bar's resting position (keyboard\n // closed) is `bottom: 0` in CSS; this only nudges it up. `\"top\"` needs no\n // offset at all.\n const stickyStyle =\n sticky === \"bottom\" ? { transform: `translateY(-${keyboardInset}px)` } : undefined\n\n return (\n <div\n ref={barRef}\n className={className}\n role=\"toolbar\"\n aria-label=\"Formatting\"\n aria-hidden={dynamicHidden || undefined}\n style={stickyStyle}\n >\n {groupItems(items).map((group, i) => {\n if (group === \"|\") {\n return <span key={`sep-${i}`} className={styles.toolbarSep} aria-hidden=\"true\" />\n }\n return (\n <div key={`group-${i}`} className={styles.toolbarGroup}>\n {group.map((item) => {\n const btn = toButton(item, icons)\n if (!btn) return null\n // Only a built-in command is cell-aware — a host's own\n // `ToolbarCustomItem` keeps reading `state` exactly as before;\n // it has no notion of a table cell to degrade into.\n const builtin = typeof item === \"string\" ? BUILTIN_BY_ID[item] : undefined\n const resolved = view\n ? builtin\n ? resolveForCell(view.state, builtin, inCell)\n : {\n disabled: Boolean(btn.disabled?.(view.state)),\n active: Boolean(btn.isActive?.(view.state)),\n }\n : { disabled: true, active: false }\n const off = disabled || !view || resolved.disabled\n const active = !off && resolved.active\n return (\n <button\n key={btn.key}\n type=\"button\"\n className={styles.toolbarButton}\n data-command={btn.key}\n title={btn.title}\n aria-label={btn.title}\n aria-pressed={btn.isActive ? active : undefined}\n data-active={active ? \"\" : undefined}\n disabled={off}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n if (!view) return\n btn.run(view)\n refresh()\n }}\n >\n {btn.icon}\n </button>\n )\n })}\n </div>\n )\n })}\n </div>\n )\n}\n","import { forwardRef, Suspense, useEffect, useImperativeHandle, useRef, useState } from \"react\"\nimport { EditorView } from \"@codemirror/view\"\nimport { SourceView } from \"./editor/SourceView\"\nimport { LazyInPlaceView } from \"./inplace/lazyInPlace\"\nimport { LazyPreview } from \"./render/lazyPreview\"\nimport { SplitView } from \"./SplitView\"\nimport styles from \"./styles/stylo.module.css\"\nimport { Toolbar } from \"./toolbar/Toolbar\"\nimport { resolveToolbarItems } from \"./toolbar/config\"\nimport { splitFrontmatter } from \"./frontmatter\"\nimport { invalidateEmbed } from \"./render/embed-cache\"\nimport \"./styles/tokens.css\"\nimport type { ResolveErrorInfo, StyloHandle, StyloProps } from \"./types\"\n\n/**\n * Plain-text-first Markdown editor. `value` is the canonical Markdown string;\n * every view is a pure function of it.\n *\n * The default `mode` is `in-place`, the live decoration canvas (ADR-002 §1,\n * ADR-004). Pass `mode=\"source\"` for the plain surface with no lazy render\n * chunk. `preview` and `split` are also available.\n *\n * A formatting `toolbar` sits above every editing surface (all modes but\n * `preview`); pass `toolbar={false}` to drop it or a `ToolbarConfig` to trim it.\n */\nexport const Stylo = forwardRef<StyloHandle, StyloProps>(function Stylo(\n {\n value,\n onChange,\n mode = \"in-place\",\n onSave,\n onFrontmatter,\n onWikiLinkClick,\n onLinkClick,\n readOnly,\n placeholder,\n className,\n inPlace,\n codeLanguages,\n wikiLinkSource,\n tagSource,\n embedSource,\n onResolveError,\n toolbar,\n icons,\n frontmatter,\n softBreaks,\n onTaskToggle,\n canvasHeader,\n },\n ref,\n) {\n const resolved = mode === \"preview\" || mode === \"split\" || mode === \"in-place\" ? mode : \"source\"\n\n const [view, setView] = useState<EditorView | null>(null)\n const toolbarItems = resolved === \"preview\" ? null : resolveToolbarItems(toolbar)\n const toolbarConfig = toolbar && typeof toolbar === \"object\" ? toolbar : undefined\n const toolbarRender = toolbarConfig?.render\n const stickyToolbar: \"top\" | \"bottom\" | false =\n toolbarConfig?.sticky === \"top\" ? \"top\" : toolbarConfig?.sticky ? \"bottom\" : false\n const stickyVisibility = toolbarConfig?.stickyVisibility\n\n // Report the raw frontmatter block on mount and whenever it changes. Stylo\n // does not parse it — the host passes `raw` to its own YAML parser.\n const onFrontmatterRef = useRef(onFrontmatter)\n onFrontmatterRef.current = onFrontmatter\n\n // Stable wrapper so a changed `onResolveError` needs no editor rebuild and\n // does not thrash the embed effect. Passed to every surface.\n const onResolveErrorRef = useRef(onResolveError)\n onResolveErrorRef.current = onResolveError\n const resolveError = useRef((error: unknown, info: ResolveErrorInfo) => {\n onResolveErrorRef.current?.(error, info)\n }).current\n\n // Read by `invalidateEmbed` below — kept current without needing the\n // imperative handle itself to be rebuilt when `embedSource` changes.\n const embedSourceRef = useRef(embedSource)\n embedSourceRef.current = embedSource\n const lastFrontmatter = useRef<string | null | undefined>(undefined)\n useEffect(() => {\n const raw = splitFrontmatter(value)?.frontmatter ?? null\n if (raw === lastFrontmatter.current) return\n lastFrontmatter.current = raw\n onFrontmatterRef.current?.(raw)\n }, [value])\n\n useImperativeHandle(\n ref,\n () => ({\n focus: () => view?.focus(),\n getView: () => view,\n insertAtCursor: (md) => {\n if (!view) return\n view.dispatch(view.state.replaceSelection(md))\n view.focus()\n },\n scrollToHeading: (text) => {\n if (!view) return false\n const target = text.trim().toLowerCase()\n const { doc } = view.state\n for (let n = 1; n <= doc.lines; n++) {\n const line = doc.line(n)\n const m = /^ {0,3}#{1,6}[ \\t]+(.*?)(?:[ \\t]+#+)?[ \\t]*$/.exec(line.text)\n if (!m || m[1] === undefined) continue\n if (m[1].trim().toLowerCase() !== target) continue\n view.dispatch({\n selection: { anchor: line.from },\n effects: EditorView.scrollIntoView(line.from, { y: \"start\" }),\n })\n view.focus()\n return true\n }\n return false\n },\n invalidateEmbed: (ref) => {\n const source = embedSourceRef.current\n if (source) invalidateEmbed(source, ref)\n },\n }),\n [view],\n )\n\n const rootClass = [\n styles.root,\n stickyToolbar === \"bottom\" && styles.stickyToolbarRootBottom,\n stickyToolbar === \"top\" && styles.stickyToolbarRootTop,\n \"stylo\",\n className,\n ]\n .filter(Boolean)\n .join(\" \")\n\n return (\n <div className={rootClass} data-stylo-mode={resolved}>\n {toolbarItems &&\n (() => {\n const bar = (\n <Toolbar\n view={view}\n items={toolbarItems}\n icons={icons}\n disabled={readOnly}\n sticky={stickyToolbar}\n stickyVisibility={stickyVisibility}\n />\n )\n return toolbarRender ? toolbarRender(bar, { view }) : bar\n })()}\n\n {resolved === \"source\" && (\n <SourceView\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n onResolveError={resolveError}\n onSave={onSave}\n onViewChange={setView}\n canvasHeader={canvasHeader}\n />\n )}\n\n {resolved === \"preview\" && (\n <Suspense fallback={<div className={styles.preview} aria-busy=\"true\" />}>\n <LazyPreview\n value={value}\n onWikiLinkClick={onWikiLinkClick}\n embedSource={embedSource}\n onResolveError={resolveError}\n frontmatter={frontmatter}\n codeLanguages={codeLanguages}\n softBreaks={softBreaks}\n onTaskToggle={onTaskToggle}\n />\n </Suspense>\n )}\n\n {resolved === \"split\" && (\n <SplitView\n value={value}\n onChange={onChange}\n onWikiLinkClick={onWikiLinkClick}\n readOnly={readOnly}\n placeholder={placeholder}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n embedSource={embedSource}\n onResolveError={resolveError}\n frontmatter={frontmatter}\n softBreaks={softBreaks}\n onTaskToggle={onTaskToggle}\n onSave={onSave}\n onViewChange={setView}\n canvasHeader={canvasHeader}\n />\n )}\n\n {resolved === \"in-place\" && (\n <Suspense fallback={<div className={styles.inplace} aria-busy=\"true\" />}>\n <LazyInPlaceView\n value={value}\n onChange={onChange}\n readOnly={readOnly}\n placeholder={placeholder}\n onWikiLinkClick={onWikiLinkClick}\n onLinkClick={onLinkClick}\n inPlace={inPlace}\n codeLanguages={codeLanguages}\n wikiLinkSource={wikiLinkSource}\n tagSource={tagSource}\n embedSource={embedSource}\n onResolveError={resolveError}\n onSave={onSave}\n onViewChange={setView}\n canvasHeader={canvasHeader}\n />\n </Suspense>\n )}\n </div>\n )\n})\n\nStylo.displayName = \"Stylo\"\n"],"mappings":";;;;;;;;AAUA,IAAM,gBAA4B,CAAC,GAC7B,UAAqB;AAwB3B,SAAgB,EAAW,EACzB,UACA,aACA,aACA,gBACA,kBACA,mBACA,cACA,mBACA,WACA,iBACA,mBACkB;CAClB,IAAM,CAAC,GAAY,KAAiB,EAA4B,IAAI,GAC9D,IAAkB,EAAO,CAAY;CAC3C,EAAgB,UAAU;CAC1B,IAAM,IAAmB,GAAQ,MAA4B;EAE3D,AADA,EAAc,CAAI,GAClB,EAAgB,UAAU,CAAI;CAChC,CAAC,CAAC,CAAC,SAKG,IAAkB,EAAO,CAAY;CAC3C,EAAgB,UAAU;CAC1B,IAAM,CAAC,KAAc,QAAgB,IAAe,IAAI,EAAiB,IAAI,IAAK,GAC5E,IAAY,EAChB,GAAY,aAAa,GACzB,GAAY,eAAe,CAC7B,GACM,CAAC,KAAc,QAAgB,IAAa,CAAC,EAAU,GAAG,EAAW,KAAK,CAAC,IAAI,CAAC,CAAE,GAElF,IAAM,EAAc;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;CACF,CAAC;CACD,OACE,kBAAC,OAAD;EAAK,WAAW,EAAO;EAAa;EACjC,UAAA,KACC,EAAgB,WAChB,EAAa,EAAgB,QAAQ,EAAE,MAAM,EAAW,CAAC,GAAG,CAAS;CACpE,CAAA;AAET;;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GAAD;IAAU,UAAU,kBAAC,OAAD;KAAK,WAAW,EAAO;KAAS,aAAU;IAAQ,CAAA;IACpE,UAAA,kBAAC,GAAD;KACS;KACU;KACJ;KACb,gBAAgB;KACH;KACE;KACH;KACE;IACf,CAAA;GACO,CAAA;GAGX,MAAa,WACZ,kBAAC,GAAD;IACS;IACG;IACO;IACP;IACG;IACE;IACC;IACL;IACE;IACb,gBAAgB;IACH;IACD;IACE;IACN;IACR,cAAc;IACA;GACf,CAAA;GAGF,MAAa,cACZ,kBAAC,GAAD;IAAU,UAAU,kBAAC,OAAD;KAAK,WAAW,EAAO;KAAS,aAAU;IAAQ,CAAA;IACpE,UAAA,kBAAC,GAAD;KACS;KACG;KACA;KACG;KACI;KACJ;KACJ;KACM;KACC;KACL;KACE;KACb,gBAAgB;KACR;KACR,cAAc;KACA;IACf,CAAA;GACO,CAAA;EAET;;AAET,CAAC;AAED,EAAM,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/Toolbar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAK3C,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IACvB,qDAAqD;IACrD,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAA;IACpD,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;iDAC6C;IAC7C,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAA;IACjC,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAC5C;AAqDD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,YAAY,+BAqG/F"}
1
+ {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/Toolbar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAIhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAK3C,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IACvB,qDAAqD;IACrD,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAA;IACpD,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;iDAC6C;IAC7C,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAA;IACjC,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAC5C;AAqDD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,YAAY,+BAyH/F"}
@@ -46,6 +46,10 @@ export interface ToolbarCommand {
46
46
  /** Default key bindings in CodeMirror `key` syntax. */
47
47
  keys?: string[];
48
48
  }
49
+ /** Any list marker — bullet, ordered, or task — with `[1]` capturing the
50
+ * indent. Ordered accepts both `1.` and `1)`, per CommonMark's actual
51
+ * grammar — shared with `ORDERED.match` below so the two can't drift again. */
52
+ export declare const LIST_MARKER: RegExp;
49
53
  export declare const QUOTE: LinePrefixSpec;
50
54
  export declare const BULLET: LinePrefixSpec;
51
55
  export declare const ORDERED: LinePrefixSpec;
@@ -53,5 +57,28 @@ export declare const TASK: LinePrefixSpec;
53
57
  export declare function history(id: "undo" | "redo", title: string, cmd: Command): ToolbarCommand;
54
58
  export declare function wrap(id: ToolbarCommandId, title: string, mark: string, keys?: string[]): ToolbarCommand;
55
59
  export declare function heading(level: 1 | 2 | 3): ToolbarCommand;
60
+ /**
61
+ * Ids whose `run` already degrades to an inline edit inside a table cell (via
62
+ * `runInlineInCell`) — the only commands still usable while the DOM caret is
63
+ * actually focused in one. Shared by the toolbar and the context menu so a
64
+ * table cell's "what works here" answer can't drift between the two.
65
+ */
66
+ export declare const CELL_CAPABLE_IDS: ReadonlySet<ToolbarCommandId>;
67
+ /**
68
+ * A command's effective `disabled` / `isActive` for the current DOM focus.
69
+ * `state.selection` never moves into an editable table cell's `contentEditable`
70
+ * DOM — a click there is deliberately left undispatched (see `extension.ts`) —
71
+ * so while the caret is actually inside one, checking `cmd.disabled?.(state)` /
72
+ * `cmd.isActive?.(state)` reads a selection that may point anywhere else in
73
+ * the document. There: a cell-capable command stays live, always reported as
74
+ * neither active nor disabled (`run` degrades to an inline edit on the cell
75
+ * regardless of the model selection, and detecting an existing mark inside the
76
+ * cell's own text isn't implemented); every other command is disabled outright
77
+ * rather than acting on that stale selection.
78
+ */
79
+ export declare function resolveForCell(state: EditorState, cmd: Pick<ToolbarCommand, "id" | "disabled" | "isActive">, inCell: boolean): {
80
+ disabled: boolean;
81
+ active: boolean;
82
+ };
56
83
  export declare function prefix(id: ToolbarCommandId, title: string, spec: LinePrefixSpec, ...extra: ((s: EditorState) => boolean)[]): ToolbarCommand;
57
84
  //# sourceMappingURL=command-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../../src/toolbar/command-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAUjF,uDAAuD;AACvD,eAAO,MAAM,SAAS,MAAO,WAAW,KAAG,OAC8B,CAAA;AAEzE,oDAAoD;AACpD,eAAO,MAAM,aAAa,MAAO,WAAW,KAAG,OAG9C,CAAA;AAED,yEAAyE;AACzE,eAAO,MAAM,SAAS,MAAO,WAAW,KAAG,OACoB,CAAA;AAE/D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,SACxB,MAAM,SACT,WAAW,KAAG,OAC4D,CAAA;AAEhF;;;;GAIG;AACH,eAAO,MAAM,aAAa,MAAO,WAAW,KAAG,OACa,CAAA;AAE5D,sEAAsE;AACtE,eAAO,MAAM,YAAY,cACX,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,EAAE,SACvC,WAAW,KAAG,OACQ,CAAA;AAE5B,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,gBAAgB,CAAA;IACpB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,4EAA4E;IAC5E,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAA;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;IAC1C,uDAAu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C,EAAE,MAAM,EAAE,GACd,cAAc,CAUhB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,cAAc,CAUxD;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,CAWzD,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,EACzD,MAAM,EAAE,OAAO,GACd;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAUxC;AAED,wBAAgB,MAAM,CACpB,EAAE,EAAE,gBAAgB,EACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,cAAc,EACpB,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,EAAE,GACxC,cAAc,CAQhB"}
@@ -1,4 +1,7 @@
1
1
  import type { EditorView } from "@codemirror/view";
2
+ /** An ATX heading's `#` … `###### ` prefix — the single source of truth for
3
+ * the toolbar and the in-place canvas's Backspace-unwrap alike. */
4
+ export declare const HEADING_PREFIX: RegExp;
2
5
  /**
3
6
  * Set, swap, or clear an ATX heading prefix on every line the selection touches.
4
7
  * A line already at `level` is cleared; any other level (or none) is set to it.
@@ -1 +1 @@
1
- {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/toolbar/heading.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAmBtE;AAED;iFACiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAatD"}
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/toolbar/heading.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;oEACoE;AACpE,eAAO,MAAM,cAAc,QAAgB,CAAA;AAE3C;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAmBtE;AAED;iFACiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAatD"}
@@ -26,6 +26,12 @@ export interface InlineStr {
26
26
  * to)` of `text`: unwrap a span already wrapped (marks inside or just around the
27
27
  * selection), else wrap it; an empty range gets an empty pair. Applying `*` to
28
28
  * `**bold**` (or `**` to `*em*`) nests rather than eating a marker.
29
+ *
30
+ * A collapsed `[from, to)` (a bare caret, no selection) sitting inside a word
31
+ * expands to that whole word first — otherwise the two inserts below would
32
+ * land at the very same point and split the word in two (`wo****rd` instead
33
+ * of `**word**`). `nothingToWrap` (`command-helpers.ts`) already disables the
34
+ * button/shortcut when there is no word to expand to.
29
35
  */
30
36
  export declare function wrapOp(text: string, from: number, to: number, mark: string): InlineOp;
31
37
  /** Apply non-overlapping {@link InlineOp} changes to a string (right to left). */
@@ -1 +1 @@
1
- {"version":3,"file":"inline-ops.d.ts","sourceRoot":"","sources":["../../src/toolbar/inline-ops.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE9E,kEAAkE;AAClE,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAErC;AAED,mEAAmE;AACnE,eAAO,MAAM,UAAU,SAAS,CAAA;AA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AAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkB9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/toolbar/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAyClD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAiBrD;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAEvD;AA2CD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,SAIxB,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,SAqBzB,CAAA"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/toolbar/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAyClD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAiBrD;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAEvD;AA2CD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,SAIxB,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,SAyBzB,CAAA"}
@@ -0,0 +1,200 @@
1
+ import type { ReactNode } from "react";
2
+ import type { Language, LanguageDescription } from "@codemirror/language";
3
+ import type { EditorView } from "@codemirror/view";
4
+ import type { EmbedSource, ResolveErrorInfo, TagSource, WikiLinkSource } from "./sources";
5
+ import type { InPlaceConfig } from "./inplace";
6
+ import type { ToolbarCommandId, ToolbarConfig } from "./toolbar";
7
+ export type StyloMode = "in-place" | "source" | "preview" | "split";
8
+ /**
9
+ * How `preview` (and the preview pane of `split`) treats the leading `---` YAML
10
+ * block. `"hidden"` (default) drops it from the render; `"code"` renders it as a
11
+ * styled `<pre class="stylo-frontmatter">` a consumer can restyle with its own
12
+ * CSS. A parsed key/value panel is deferred (ADR-001, needs a YAML parser).
13
+ */
14
+ export type FrontmatterDisplay = "hidden" | "code";
15
+ /**
16
+ * Grammars for fenced-code sub-highlighting. Stylo ships none by default — a
17
+ * consumer opts in with exactly the set they want (`codeLanguages={languages}`
18
+ * from `@codemirror/language-data`, or a hand-built list). Forwarded verbatim
19
+ * to `@codemirror/lang-markdown` for the CodeMirror surfaces (`source`,
20
+ * `split`, `in-place`); `preview` resolves a fence's language the same way
21
+ * (same fuzzy `LanguageDescription` match, or the function form called with
22
+ * the same name) and colours it with the same `--stylo-syntax-*` tokens, so a
23
+ * block reads identically whether it's being read or edited. See the ADR-001
24
+ * amendment and ADR-002 §3's 2026-09-13 amendment.
25
+ */
26
+ export type CodeLanguages = readonly LanguageDescription[] | ((info: string) => Language | LanguageDescription | null);
27
+ /**
28
+ * Reported by `onTaskToggle` when a `preview` task-list checkbox is clicked.
29
+ * `start`/`end` are raw offsets into `value` bracketing the `[ ]` / `[x]`
30
+ * marker itself (`end - start === 3`); splice in the new marker text to apply
31
+ * the toggle: `value.slice(0, start) + (checked ? "[x]" : "[ ]") +
32
+ * value.slice(end)`. `checked` is the box's new state, not its state before
33
+ * the click.
34
+ */
35
+ export interface TaskToggleInfo {
36
+ /** Offset of the marker's opening `[` in `value`. */
37
+ start: number;
38
+ /** Offset just past the marker's closing `]` in `value`. */
39
+ end: number;
40
+ /** The checkbox's new state. */
41
+ checked: boolean;
42
+ }
43
+ export interface StyloProps {
44
+ /** The canonical Markdown document. Stylo never holds a parsed model of it. */
45
+ value: string;
46
+ /** Called with the complete Markdown string on every edit. */
47
+ onChange: (next: string) => void;
48
+ /**
49
+ * Interaction layout. Defaults to `"in-place"` — the live decoration canvas.
50
+ * `"source"` is the plain surface and avoids loading the render chunk.
51
+ */
52
+ mode?: StyloMode;
53
+ /**
54
+ * Called with the full Markdown string when `Mod-s` is pressed on any editing
55
+ * surface; the browser's own save dialog is then suppressed. Omit it and
56
+ * `Mod-s` keeps its default browser behaviour. Stylo holds no dirty state —
57
+ * `value` is yours, so compare it against your last-saved copy.
58
+ */
59
+ onSave?: (value: string) => void;
60
+ /**
61
+ * Called on mount and whenever the leading `---` YAML block changes, with its
62
+ * inner text (no fences), or `null` when there is no block. Stylo does not
63
+ * parse it — pass `raw` to your own YAML parser for a structured panel. The
64
+ * same split is available synchronously as the exported `splitFrontmatter`.
65
+ */
66
+ onFrontmatter?: (raw: string | null) => void;
67
+ /** Invoked when a `[[wikilink]]` is activated in the preview or in-place canvas. */
68
+ onWikiLinkClick?: (target: string) => void;
69
+ /**
70
+ * Invoked by the in-place link editor's "Open link" action with the link's
71
+ * `href`. Stylo does not navigate on its own.
72
+ */
73
+ onLinkClick?: (href: string) => void;
74
+ /** Configures the in-place canvas (ADR-005). Applied when it mounts. */
75
+ inPlace?: InPlaceConfig;
76
+ /**
77
+ * How `preview` (and `split`'s preview pane) shows the leading `---` YAML
78
+ * block. `"hidden"` (default) drops it; `"code"` renders it as a styled
79
+ * `<pre class="stylo-frontmatter">`.
80
+ */
81
+ frontmatter?: FrontmatterDisplay;
82
+ /**
83
+ * Turn a single line ending into a real `<br>` in `preview` (and `split`'s
84
+ * preview pane), instead of CommonMark's default — a blank line required to
85
+ * start a new paragraph, so consecutive lines join into one run. Obsidian's
86
+ * Live Preview reads this way. Off by default: a real, visible change to
87
+ * every existing render, so a host opts in deliberately rather than
88
+ * inheriting it. No effect on `in-place` / `source` — CodeMirror already
89
+ * decorates each source line independently there.
90
+ */
91
+ softBreaks?: boolean;
92
+ /**
93
+ * Makes `preview` (and `split`'s preview pane) task-list checkboxes
94
+ * clickable instead of `disabled`. Fired with a {@link TaskToggleInfo} — raw
95
+ * offsets into `value` bracketing the clicked `[ ]` / `[x]` marker, and its
96
+ * new state. Stylo never mutates `value` itself; splice the marker and pass
97
+ * the result to `onChange`, same division of labour as `onWikiLinkClick`.
98
+ * Off by default: every checkbox stays `disabled`, exactly like today,
99
+ * until a host opts in.
100
+ */
101
+ onTaskToggle?: (info: TaskToggleInfo) => void;
102
+ /**
103
+ * Grammars for fenced-code sub-highlighting on the CodeMirror surfaces
104
+ * (`source`, `split`, `in-place`). None by default. Read once, at mount.
105
+ */
106
+ codeLanguages?: CodeLanguages;
107
+ /**
108
+ * Enables `[[wikilink]]` autocomplete on the CodeMirror surfaces. Called with
109
+ * the target typed so far; return your index's matches, ordered. Off when
110
+ * omitted. Read once, at mount. See `WikiLinkSource`.
111
+ */
112
+ wikiLinkSource?: WikiLinkSource;
113
+ /**
114
+ * Enables `#tag` autocomplete on the CodeMirror surfaces. Called with the tag
115
+ * typed so far; return your index's matches, ordered. Off when omitted. Read
116
+ * once, at mount. See `TagSource`.
117
+ */
118
+ tagSource?: TagSource;
119
+ /**
120
+ * Resolves `![[ref]]` embeds (transclusion) for `preview` and `split`. Called
121
+ * with the raw reference; return a node to render in its place, or `null` to
122
+ * leave it as literal text. May be async. Off when omitted. See
123
+ * {@link EmbedSource}.
124
+ */
125
+ embedSource?: EmbedSource;
126
+ /**
127
+ * Called when `embedSource`, `wikiLinkSource`, or `tagSource` throws or
128
+ * returns a rejected promise. Purely for observation — logging, a toast — the
129
+ * resolver still falls back (literal `![[ref]]` text, or no completions)
130
+ * either way. A `null` return is a valid result, not an error, and does not
131
+ * fire this. Reactive; see {@link ResolveErrorInfo}.
132
+ */
133
+ onResolveError?: (error: unknown, info: ResolveErrorInfo) => void;
134
+ /**
135
+ * Formatting toolbar above the editing surface (`source`, `in-place`,
136
+ * `split`; never `preview`). Omit or `true` for the default bar, `false` to
137
+ * hide it, or an object to choose and order the buttons. See ADR-002 §2.
138
+ */
139
+ toolbar?: boolean | ToolbarConfig;
140
+ /**
141
+ * Replace individual toolbar glyphs, keyed by command id. Any id left out
142
+ * keeps its built-in inline-SVG icon — Stylo ships no icon dependency.
143
+ */
144
+ icons?: Partial<Record<ToolbarCommandId, ReactNode>>;
145
+ /** Render the source surface read-only. */
146
+ readOnly?: boolean;
147
+ /** Placeholder text shown when the document is empty (source surface). */
148
+ placeholder?: string;
149
+ /** Extra class on the root element, alongside the internal classes. */
150
+ className?: string;
151
+ /**
152
+ * Host content docked inside the editing surface (`source`, `in-place`,
153
+ * `split`'s source pane; never `preview`) — after the find/replace panel,
154
+ * before the document body. Unlike `toolbar.render`, which wraps content
155
+ * *before* the whole canvas, this reaches the seam between CodeMirror's own
156
+ * top panels and its scroller, so host chrome (e.g. a frontmatter card) can
157
+ * sit under find/replace instead of always above it. `view` is `null` until
158
+ * the surface has mounted. Read once, at mount.
159
+ */
160
+ canvasHeader?: (ctx: {
161
+ view: EditorView | null;
162
+ }) => ReactNode;
163
+ }
164
+ /**
165
+ * Imperative handle exposed on a `ref` to `<Stylo>`. Every method but
166
+ * `invalidateEmbed` is a no-op — returning `null` / `false` where it has a
167
+ * return value — in `preview` mode or before the editing surface has mounted,
168
+ * since there is no editor then.
169
+ */
170
+ export interface StyloHandle {
171
+ /** Move keyboard focus into the editing surface. */
172
+ focus(): void;
173
+ /**
174
+ * Put the caret at the start of the first ATX heading (`#` … `######`) whose
175
+ * text matches `text` (trimmed, case-insensitive) and scroll it to the top of
176
+ * the viewport. Returns `true` when a heading matched.
177
+ */
178
+ scrollToHeading(text: string): boolean;
179
+ /**
180
+ * Replace the current selection — or insert at the caret when the selection is
181
+ * empty — with `md`. No effect on a `readOnly` surface.
182
+ */
183
+ insertAtCursor(md: string): void;
184
+ /**
185
+ * The underlying CodeMirror `EditorView`, or `null` in `preview` mode or
186
+ * before mount. An escape hatch: not covered by semver.
187
+ */
188
+ getView(): EditorView | null;
189
+ /**
190
+ * Drops the cached result for an `![[ref]]` embed — or, with no `ref`, every
191
+ * cached embed — so the next render re-invokes `embedSource` instead of
192
+ * showing what it returned before. Call this when you know the content
193
+ * behind a reference changed while the editor is open; Stylo has no way to
194
+ * detect that on its own (see `EmbedSource`). Works in every mode, including
195
+ * `preview`, since it targets the embed cache rather than the editor. A
196
+ * no-op when `embedSource` isn't set.
197
+ */
198
+ invalidateEmbed(ref?: string): void;
199
+ }
200
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEhE,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAA;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,MAAM,CAAA;AAElD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GACvB,SAAS,mBAAmB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,GAAG,mBAAmB,GAAG,IAAI,CAAC,CAAA;AAE5F;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAA;IACX,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAA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,CAAC,CAAA;IACpD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,KAAK,SAAS,CAAA;CAC/D;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,KAAK,IAAI,IAAI,CAAA;IACb;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtC;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC;;;OAGG;IACH,OAAO,IAAI,UAAU,GAAG,IAAI,CAAA;IAC5B;;;;;;;;OAQG;IACH,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
@@ -0,0 +1,91 @@
1
+ import type { ToolbarCommandId } from "./toolbar";
2
+ /**
3
+ * Per-construct on/off switches for the in-place canvas. Each key defaults to
4
+ * `true`; setting one `false` leaves that construct as plain source — no
5
+ * decoration, no cursor-reveal behaviour. See ADR-005.
6
+ */
7
+ export interface InPlaceDecorationToggles {
8
+ headings?: boolean;
9
+ emphasis?: boolean;
10
+ links?: boolean;
11
+ wikilinks?: boolean;
12
+ math?: boolean;
13
+ lists?: boolean;
14
+ tasks?: boolean;
15
+ blockquote?: boolean;
16
+ horizontalRule?: boolean;
17
+ code?: boolean;
18
+ frontmatter?: boolean;
19
+ tables?: boolean;
20
+ /** `![[ref]]` transclusion blocks. Needs `embedSource` set; see ADR-009. */
21
+ embeds?: boolean;
22
+ }
23
+ /**
24
+ * How the in-place canvas handles editing a table.
25
+ * `"source"` (default) reveals the aligned pipe source under the caret;
26
+ * `"cells"` keeps the rendered `<table>` and edits its cells in place.
27
+ */
28
+ export type TableEditing = "source" | "cells";
29
+ /**
30
+ * Whether the in-place canvas shows a construct's Markdown markers when the
31
+ * caret is on its line. `"caret"` (default) reveals them for editing and
32
+ * re-hides them on the way out — Obsidian's Live Preview. `"never"` keeps every
33
+ * inline marker hidden at all times; formatting is changed through the toolbar,
34
+ * the right-click menu, shortcuts, and autoformat-on-type instead. See ADR-007;
35
+ * `"never"` is being rolled out in stages.
36
+ */
37
+ export type RevealMode = "caret" | "never";
38
+ /**
39
+ * What appears when text is selected in the in-place canvas. `"menu"` (default)
40
+ * puts the inline-formatting group in the right-click menu and shows no floating
41
+ * bar; `"bar"` shows a floating bar above the selection and drops that group
42
+ * from the menu so nothing is doubled; `"none"` shows neither and leaves the
43
+ * main toolbar as the only formatting surface. The toolbar is independent of
44
+ * this setting — it is always available (unless hidden via `toolbar`) and always
45
+ * acts on the selection.
46
+ */
47
+ export type SelectionUI = "menu" | "bar" | "none";
48
+ /**
49
+ * The right-click menu's top-level groups. `link` is the internal / external
50
+ * link field rows; `format` the inline-mark submenu; `paragraph` the block-type
51
+ * submenu; `insert` the new-block submenu; `clipboard` cut / copy / paste.
52
+ */
53
+ export type MenuGroupId = "link" | "format" | "paragraph" | "insert" | "clipboard";
54
+ export interface ContextMenuConfig {
55
+ /**
56
+ * Which top-level groups the menu shows, in order. Omit for all five in their
57
+ * default order. `link` and `format` still yield to `selectionUI` when it is
58
+ * not `"menu"` (they move to the floating bar / toolbar).
59
+ */
60
+ groups?: MenuGroupId[];
61
+ }
62
+ export interface InPlaceConfig {
63
+ /** Which decoration types the in-place canvas renders. Read once, at mount. */
64
+ decorations?: InPlaceDecorationToggles;
65
+ /** Table editing mode (see `TableEditing`). Read once, at mount. */
66
+ table?: TableEditing;
67
+ /**
68
+ * Marker reveal behaviour (see `RevealMode`). Optional, defaults to
69
+ * `"caret"`. Read once, at mount.
70
+ */
71
+ reveal?: RevealMode;
72
+ /**
73
+ * Right-click a block for a context menu (inline actions on a selection,
74
+ * block + insert actions otherwise). `false` keeps the browser's own menu; an
75
+ * object picks and orders the menu's groups. Defaults to `true`. Read once,
76
+ * at mount.
77
+ */
78
+ contextMenu?: boolean | ContextMenuConfig;
79
+ /**
80
+ * What a non-empty selection offers (see `SelectionUI`). Defaults to
81
+ * `"menu"`. Read once, at mount.
82
+ */
83
+ selectionUI?: SelectionUI;
84
+ /**
85
+ * Which buttons the floating selection bar shows (`selectionUI: "bar"`), in
86
+ * order. Any of `bold` / `italic` / `strike` / `code` / `link` / `wikilink` /
87
+ * `math`. Omit for all seven. Read once, at mount.
88
+ */
89
+ selectionBarItems?: ToolbarCommandId[];
90
+ }
91
+ //# sourceMappingURL=inplace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inplace.d.ts","sourceRoot":"","sources":["../../src/types/inplace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,MAAM,UA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