@llui/markdown-editor 0.2.6 → 0.2.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAM9F,OAAO,EAAmC,KAAK,MAAM,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAUjG,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAKrE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,SAAS,EAEd,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,YAAY;IAC3B;2FACuF;IACvF,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACtB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,uEAAuE;IACvE,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IAC9C,mFAAmF;IACnF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAA;IACzC,6EAA6E;IA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IAAI,CAAA;CACjC;AAED,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,aAAa,CAAA;AAEjE,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;IAC7B,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;CAC5B;AAOD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,GAAE,YAAiB,GACxB,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,CAAC,CAwL1D"}
package/dist/editor.js CHANGED
@@ -11,6 +11,7 @@ import { corePlugin } from './plugins/core.js';
11
11
  import { linkPlugin } from './plugins/link.js';
12
12
  import { toolbar as renderToolbar } from './surfaces/toolbar.js';
13
13
  import { buildTransformers } from './transformers/registry.js';
14
+ import { mergeTheme } from './theme.js';
14
15
  import { computeFormatState } from './format.js';
15
16
  import { makeOnEffect } from './effects.js';
16
17
  import { countWords, init, update, } from './state.js';
@@ -109,7 +110,7 @@ export function markdownEditor(config = {}) {
109
110
  : null;
110
111
  const host = lexicalForeign({
111
112
  namespace: config.namespace ?? 'llui-markdown',
112
- theme: config.theme,
113
+ theme: mergeTheme(config.theme),
113
114
  plugins,
114
115
  serialize: (editor) => editor.getEditorState().read(() => $convertToMarkdownString(transformers)),
115
116
  deserialize: (_editor, value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,qEAAqE;AAErE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAA+C,MAAM,SAAS,CAAA;AAC9F,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,GAA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,EAAE,SAAS;aAClB,CAAC,CAAA;YACF,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,CAAA;QAClD,OAAO;YACL,GAAG,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;gBACtD,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtF,GAAG,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;aACnE,CAAC;YACF,GAAG,WAAW;SACf,CAAA;IACH,CAAC,CAAA;IAED,OAAO,SAAS,CAAuC;QACrD,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,cAAc;QACtB,IAAI;QACJ,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// `markdownEditor(config)` — the high-level component. Lexical owns the live\n// document; this wires the foreign seam to the markdown transformer converters,\n// surfaces the format state for the chrome, routes command intents back to the\n// live editor through effects, and COMPOSES plugin UI extensions (each plugin's\n// state slice + reducer + view + effects) into the single component.\n\nimport { $getRoot, $setSelection, type EditorThemeClasses, type LexicalEditor } from 'lexical'\nimport {\n $convertFromMarkdownString,\n $convertToMarkdownString,\n registerMarkdownShortcuts,\n} from '@lexical/markdown'\nimport { component, div, type Renderable, type Signal, type SignalComponentDef } from '@llui/dom'\nimport {\n lexicalForeign,\n registerDecoratorBridges,\n PROGRAMMATIC_TAG,\n type DecoratorBridge,\n} from '@llui/lexical'\nimport { corePlugin } from './plugins/core.js'\nimport { linkPlugin } from './plugins/link.js'\nimport { toolbar as renderToolbar } from './surfaces/toolbar.js'\nimport type { CommandItem, MarkdownPlugin } from './plugins/types.js'\nimport type { PluginUI } from './plugins/ui.js'\nimport { buildTransformers } from './transformers/registry.js'\nimport { computeFormatState } from './format.js'\nimport { makeOnEffect } from './effects.js'\nimport {\n countWords,\n init,\n update,\n type EditorEffect,\n type EditorMsg,\n type EditorOutMsg,\n type EditorState,\n type FormatState,\n} from './state.js'\n\nexport interface EditorConfig {\n /** Plugins composing the feature set; order defines transformer precedence.\n * Defaults to `[corePlugin(), linkPlugin()]` so the minimal editor has GFM + links. */\n plugins?: readonly MarkdownPlugin[]\n /** Initial markdown (uncontrolled seed). */\n defaultValue?: string\n /** Controlled: the consumer owns this signal; the editor follows it. */\n value?: Signal<string>\n /** Debounced markdown-emission window (ms). Default 300. */\n changeDebounceMs?: number\n placeholder?: string\n readonly?: boolean\n /** Lexical theme class map. */\n theme?: EditorThemeClasses\n /** Editor namespace (instance isolation). */\n namespace?: string\n /** Outbound markdown (after debounce). */\n onChange?: (markdown: string) => void\n /** Outbound format surface (for chrome built outside this package). */\n onFormatChange?: (format: FormatState) => void\n /** Receives the live Lexical editor at mount (imperative access, collab hooks). */\n onReady?: (editor: LexicalEditor) => void\n /** Render the built-in toolbar above the editor. Default false (minimal). */\n toolbar?: boolean\n /** Enable collaborative editing. The editor hands you a markdown `seed` and\n * status sinks; return a binding (build it with `yjsCollab` from\n * `@llui/lexical-collab`, wiring your own provider). Mutually exclusive with\n * `value` — the shared CRDT document, not a markdown signal, owns the content.\n * `defaultValue` becomes the seed the bootstrapping peer writes. */\n collab?: CollabFactory\n}\n\n/** Disposer-returning binding the collab layer installs on the live editor.\n * `@llui/lexical-collab`'s `YjsCollab` satisfies this structurally, so\n * `@llui/markdown-editor` needs no Yjs dependency of its own. */\nexport interface CollabBinding {\n register: (editor: LexicalEditor) => () => void\n}\n\n/** Hooks the editor injects into the {@link CollabFactory}: a markdown `seed`\n * (run once by the bootstrapping peer to fill an empty shared doc from\n * `defaultValue`) plus status sinks the editor mirrors into `state.collab`.\n * Spread straight into `yjsCollab({ id, provider, user, ...hooks })`. */\nexport interface CollabHooks {\n seed: (editor: LexicalEditor) => void\n onStatus: (connected: boolean) => void\n onSync: (synced: boolean) => void\n onPeers: (count: number) => void\n}\n\n/** Builds the collab binding from the editor-supplied hooks. */\nexport type CollabFactory = (hooks: CollabHooks) => CollabBinding\n\n/** Hooks the chrome layer (toolbar/menus) uses to compose around the editor. */\nexport interface EditorParts {\n /** The merged, surface-filtered command items. */\n items: readonly CommandItem[]\n /** Reactive format signal for `connect`-style toolbars. */\n format: Signal<FormatState>\n}\n\n/** Default plugin set when the consumer supplies none. */\nfunction defaultPlugins(): MarkdownPlugin[] {\n return [corePlugin(), linkPlugin()]\n}\n\n/**\n * Build the markdown editor component. Embed it with `mountApp(el, markdownEditor(...))`\n * or compose it inside a larger component.\n */\nexport function markdownEditor(\n config: EditorConfig = {},\n): SignalComponentDef<EditorState, EditorMsg, EditorEffect> {\n const plugins = config.plugins && config.plugins.length > 0 ? config.plugins : defaultPlugins()\n const transformers = buildTransformers(plugins)\n\n const items: CommandItem[] = plugins.flatMap((p) => p.items ?? [])\n const itemsById = new Map(items.map((i) => [i.id, i]))\n // Share the merged item list with plugins that want it (e.g. the slash menu).\n for (const plugin of plugins) plugin.onItems?.(items)\n const decorators: DecoratorBridge[] = plugins.flatMap((p) => p.decorators ?? [])\n const pluginUIs: Array<{ name: string; ui: PluginUI }> = plugins\n .filter((p): p is MarkdownPlugin & { ui: PluginUI } => p.ui !== undefined)\n .map((p) => ({ name: p.name, ui: p.ui }))\n const pluginUIByName = new Map(pluginUIs.map((p) => [p.name, p.ui]))\n\n // The live editor, captured at mount; effects dispatch through it.\n let editorRef: LexicalEditor | null = null\n const getEditor = (): LexicalEditor | null => editorRef\n\n const baseOnEffect = makeOnEffect(getEditor, itemsById, {\n onChange: config.onChange,\n onFormatChange: config.onFormatChange,\n applyValue: (editor, value) =>\n editor.update(\n () => {\n $convertFromMarkdownString(value, transformers)\n // Clear selection so the reconciler doesn't pull DOM focus into the\n // editor on an external push (e.g. typing in a bound source textarea).\n $setSelection(null)\n },\n { tag: PROGRAMMATIC_TAG },\n ),\n })\n\n if (config.collab && config.value) {\n throw new Error(\n 'markdownEditor: `collab` and `value` are mutually exclusive — in a collaborative ' +\n 'session the shared CRDT document owns the content, not a markdown signal. ' +\n 'Use `defaultValue` as the bootstrap seed instead.',\n )\n }\n\n const collabEnabled = !!config.collab\n const seedValue = config.value ? config.value.peek() : (config.defaultValue ?? '')\n\n // ── Composed TEA: core + plugin UI slices ──────────────────────────────────\n const composedInit = (): [EditorState, EditorEffect[]] => {\n const [core, effects] = init({\n value: seedValue,\n readonly: config.readonly ?? false,\n collab: collabEnabled,\n })\n const slices: Record<string, unknown> = {}\n for (const { name, ui } of pluginUIs) slices[name] = ui.init()\n return [{ ...core, plugins: slices }, effects]\n }\n\n const composedUpdate = (state: EditorState, msg: EditorMsg): [EditorState, EditorEffect[]] => {\n if (msg.type === 'plugin') {\n const ui = pluginUIByName.get(msg.name)\n if (!ui?.update) return [state, []]\n const result = ui.update(state.plugins[msg.name], msg.msg)\n const [slice, effects] = (Array.isArray(result) ? result : [result, []]) as [\n unknown,\n unknown[],\n ]\n return [\n { ...state, plugins: { ...state.plugins, [msg.name]: slice } },\n effects.map((effect) => ({ type: 'pluginEffect' as const, name: msg.name, effect })),\n ]\n }\n return update(state, msg)\n }\n\n const composedOnEffect = (\n effect: EditorEffect,\n api: { send: (msg: EditorMsg) => void; state: Signal<EditorState> },\n ): void => {\n if (effect.type === 'pluginEffect') {\n const ui = pluginUIByName.get(effect.name)\n ui?.onEffect?.(effect.effect, {\n editor: getEditor,\n send: (msg) => api.send({ type: 'plugin', name: effect.name, msg }),\n emit: (msg) => api.send(msg as EditorMsg),\n })\n return\n }\n baseOnEffect(effect, api)\n }\n\n const view = ({\n state,\n send,\n }: {\n state: Signal<EditorState>\n send: (msg: EditorMsg) => void\n }): Renderable => {\n // Build the collab binding (once, at mount) from the consumer's factory,\n // injecting the markdown seed + status sinks that mirror into `state.collab`.\n const collabBinding: CollabBinding | null = config.collab\n ? config.collab({\n seed: () => {\n $convertFromMarkdownString(seedValue, transformers)\n $setSelection(null)\n },\n onStatus: (connected) => send({ type: 'collabStatus', connected }),\n onSync: (synced) => send({ type: 'collabSync', synced }),\n onPeers: (peers) => send({ type: 'collabPeers', peers }),\n })\n : null\n\n const host = lexicalForeign<EditorOutMsg>({\n namespace: config.namespace ?? 'llui-markdown',\n theme: config.theme,\n plugins,\n serialize: (editor) =>\n editor.getEditorState().read(() => $convertToMarkdownString(transformers)),\n deserialize: (_editor, value) => {\n $convertFromMarkdownString(value, transformers)\n $setSelection(null)\n },\n // In collab mode the shared CRDT owns the document: the local undo stack\n // and the boot-time seed are disabled — the binding supplies a scoped undo\n // manager and a sync-gated bootstrap instead.\n ...(collabBinding ? { history: false, seedMode: 'deferred' as const } : {}),\n defaultValue: collabBinding || config.value ? undefined : (config.defaultValue ?? ''),\n ...(config.value && !collabBinding ? { value: config.value } : {}),\n readonly: state.at('readonly'),\n ...(config.changeDebounceMs !== undefined\n ? { changeDebounceMs: config.changeDebounceMs }\n : {}),\n register: (editor) => {\n const disposers = [registerMarkdownShortcuts(editor, transformers)]\n if (decorators.length > 0) disposers.push(registerDecoratorBridges(editor, decorators))\n if (collabBinding) disposers.push(collabBinding.register(editor))\n return () => {\n for (const dispose of disposers) dispose()\n }\n },\n onReady: (editor) => {\n editorRef = editor\n if (config.placeholder) {\n editor.getRootElement()?.setAttribute('data-placeholder', config.placeholder)\n }\n config.onReady?.(editor)\n },\n onChange: (value) => send({ type: 'markdownChanged', value }),\n onSelectionChange: (ctx) => {\n const format = computeFormatState(ctx.editor, ctx)\n const text = ctx.editor.getEditorState().read(() => $getRoot().getTextContent())\n // Toggle an empty marker so CSS can show the placeholder.\n ctx.editor.getRootElement()?.setAttribute('data-empty', text === '' ? 'true' : 'false')\n send({ type: 'formatChanged', format, wordCount: countWords(text), charCount: text.length })\n },\n emit: (msg) => send(msg),\n })\n\n // Plugin view contributions (overlays/panels) — each gets its own slice + send.\n const pluginViews: Renderable = pluginUIs.flatMap(({ name, ui }) => {\n if (!ui.view) return []\n const rendered = ui.view({\n state: state.at(`plugins.${name}`),\n send: (msg) => send({ type: 'plugin', name, msg }),\n editor: getEditor,\n })\n return Array.isArray(rendered) ? rendered : [rendered]\n })\n\n if (!config.toolbar) return [host, ...pluginViews]\n return [\n div({ 'data-scope': 'md-editor', 'data-part': 'root' }, [\n renderToolbar({ format: state.at('format'), send, items, collab: state.at('collab') }),\n div({ 'data-scope': 'md-editor', 'data-part': 'surface' }, [host]),\n ]),\n ...pluginViews,\n ]\n }\n\n return component<EditorState, EditorMsg, EditorEffect>({\n name: 'MarkdownEditor',\n init: composedInit,\n update: composedUpdate,\n view,\n onEffect: composedOnEffect,\n })\n}\n"]}
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,qEAAqE;AAErE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAA+C,MAAM,SAAS,CAAA;AAC9F,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,GAAG,EAAyD,MAAM,WAAW,CAAA;AACjG,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,gBAAgB,GAEjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAA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C,OAAO;YAAE,OAAO,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,CAAA;QAClD,OAAO;YACL,GAAG,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;gBACtD,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtF,GAAG,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;aACnE,CAAC;YACF,GAAG,WAAW;SACf,CAAA;IACH,CAAC,CAAA;IAED,OAAO,SAAS,CAAuC;QACrD,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,cAAc;QACtB,IAAI;QACJ,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// `markdownEditor(config)` — the high-level component. Lexical owns the live\n// document; this wires the foreign seam to the markdown transformer converters,\n// surfaces the format state for the chrome, routes command intents back to the\n// live editor through effects, and COMPOSES plugin UI extensions (each plugin's\n// state slice + reducer + view + effects) into the single component.\n\nimport { $getRoot, $setSelection, type EditorThemeClasses, type LexicalEditor } from 'lexical'\nimport {\n $convertFromMarkdownString,\n $convertToMarkdownString,\n registerMarkdownShortcuts,\n} from '@lexical/markdown'\nimport { component, div, type Renderable, type Signal, type SignalComponentDef } from '@llui/dom'\nimport {\n lexicalForeign,\n registerDecoratorBridges,\n PROGRAMMATIC_TAG,\n type DecoratorBridge,\n} from '@llui/lexical'\nimport { corePlugin } from './plugins/core.js'\nimport { linkPlugin } from './plugins/link.js'\nimport { toolbar as renderToolbar } from './surfaces/toolbar.js'\nimport type { CommandItem, MarkdownPlugin } from './plugins/types.js'\nimport type { PluginUI } from './plugins/ui.js'\nimport { buildTransformers } from './transformers/registry.js'\nimport { mergeTheme } from './theme.js'\nimport { computeFormatState } from './format.js'\nimport { makeOnEffect } from './effects.js'\nimport {\n countWords,\n init,\n update,\n type EditorEffect,\n type EditorMsg,\n type EditorOutMsg,\n type EditorState,\n type FormatState,\n} from './state.js'\n\nexport interface EditorConfig {\n /** Plugins composing the feature set; order defines transformer precedence.\n * Defaults to `[corePlugin(), linkPlugin()]` so the minimal editor has GFM + links. */\n plugins?: readonly MarkdownPlugin[]\n /** Initial markdown (uncontrolled seed). */\n defaultValue?: string\n /** Controlled: the consumer owns this signal; the editor follows it. */\n value?: Signal<string>\n /** Debounced markdown-emission window (ms). Default 300. */\n changeDebounceMs?: number\n placeholder?: string\n readonly?: boolean\n /** Lexical theme class map. */\n theme?: EditorThemeClasses\n /** Editor namespace (instance isolation). */\n namespace?: string\n /** Outbound markdown (after debounce). */\n onChange?: (markdown: string) => void\n /** Outbound format surface (for chrome built outside this package). */\n onFormatChange?: (format: FormatState) => void\n /** Receives the live Lexical editor at mount (imperative access, collab hooks). */\n onReady?: (editor: LexicalEditor) => void\n /** Render the built-in toolbar above the editor. Default false (minimal). */\n toolbar?: boolean\n /** Enable collaborative editing. The editor hands you a markdown `seed` and\n * status sinks; return a binding (build it with `yjsCollab` from\n * `@llui/lexical-collab`, wiring your own provider). Mutually exclusive with\n * `value` — the shared CRDT document, not a markdown signal, owns the content.\n * `defaultValue` becomes the seed the bootstrapping peer writes. */\n collab?: CollabFactory\n}\n\n/** Disposer-returning binding the collab layer installs on the live editor.\n * `@llui/lexical-collab`'s `YjsCollab` satisfies this structurally, so\n * `@llui/markdown-editor` needs no Yjs dependency of its own. */\nexport interface CollabBinding {\n register: (editor: LexicalEditor) => () => void\n}\n\n/** Hooks the editor injects into the {@link CollabFactory}: a markdown `seed`\n * (run once by the bootstrapping peer to fill an empty shared doc from\n * `defaultValue`) plus status sinks the editor mirrors into `state.collab`.\n * Spread straight into `yjsCollab({ id, provider, user, ...hooks })`. */\nexport interface CollabHooks {\n seed: (editor: LexicalEditor) => void\n onStatus: (connected: boolean) => void\n onSync: (synced: boolean) => void\n onPeers: (count: number) => void\n}\n\n/** Builds the collab binding from the editor-supplied hooks. */\nexport type CollabFactory = (hooks: CollabHooks) => CollabBinding\n\n/** Hooks the chrome layer (toolbar/menus) uses to compose around the editor. */\nexport interface EditorParts {\n /** The merged, surface-filtered command items. */\n items: readonly CommandItem[]\n /** Reactive format signal for `connect`-style toolbars. */\n format: Signal<FormatState>\n}\n\n/** Default plugin set when the consumer supplies none. */\nfunction defaultPlugins(): MarkdownPlugin[] {\n return [corePlugin(), linkPlugin()]\n}\n\n/**\n * Build the markdown editor component. Embed it with `mountApp(el, markdownEditor(...))`\n * or compose it inside a larger component.\n */\nexport function markdownEditor(\n config: EditorConfig = {},\n): SignalComponentDef<EditorState, EditorMsg, EditorEffect> {\n const plugins = config.plugins && config.plugins.length > 0 ? config.plugins : defaultPlugins()\n const transformers = buildTransformers(plugins)\n\n const items: CommandItem[] = plugins.flatMap((p) => p.items ?? [])\n const itemsById = new Map(items.map((i) => [i.id, i]))\n // Share the merged item list with plugins that want it (e.g. the slash menu).\n for (const plugin of plugins) plugin.onItems?.(items)\n const decorators: DecoratorBridge[] = plugins.flatMap((p) => p.decorators ?? [])\n const pluginUIs: Array<{ name: string; ui: PluginUI }> = plugins\n .filter((p): p is MarkdownPlugin & { ui: PluginUI } => p.ui !== undefined)\n .map((p) => ({ name: p.name, ui: p.ui }))\n const pluginUIByName = new Map(pluginUIs.map((p) => [p.name, p.ui]))\n\n // The live editor, captured at mount; effects dispatch through it.\n let editorRef: LexicalEditor | null = null\n const getEditor = (): LexicalEditor | null => editorRef\n\n const baseOnEffect = makeOnEffect(getEditor, itemsById, {\n onChange: config.onChange,\n onFormatChange: config.onFormatChange,\n applyValue: (editor, value) =>\n editor.update(\n () => {\n $convertFromMarkdownString(value, transformers)\n // Clear selection so the reconciler doesn't pull DOM focus into the\n // editor on an external push (e.g. typing in a bound source textarea).\n $setSelection(null)\n },\n { tag: PROGRAMMATIC_TAG },\n ),\n })\n\n if (config.collab && config.value) {\n throw new Error(\n 'markdownEditor: `collab` and `value` are mutually exclusive — in a collaborative ' +\n 'session the shared CRDT document owns the content, not a markdown signal. ' +\n 'Use `defaultValue` as the bootstrap seed instead.',\n )\n }\n\n const collabEnabled = !!config.collab\n const seedValue = config.value ? config.value.peek() : (config.defaultValue ?? '')\n\n // ── Composed TEA: core + plugin UI slices ──────────────────────────────────\n const composedInit = (): [EditorState, EditorEffect[]] => {\n const [core, effects] = init({\n value: seedValue,\n readonly: config.readonly ?? false,\n collab: collabEnabled,\n })\n const slices: Record<string, unknown> = {}\n for (const { name, ui } of pluginUIs) slices[name] = ui.init()\n return [{ ...core, plugins: slices }, effects]\n }\n\n const composedUpdate = (state: EditorState, msg: EditorMsg): [EditorState, EditorEffect[]] => {\n if (msg.type === 'plugin') {\n const ui = pluginUIByName.get(msg.name)\n if (!ui?.update) return [state, []]\n const result = ui.update(state.plugins[msg.name], msg.msg)\n const [slice, effects] = (Array.isArray(result) ? result : [result, []]) as [\n unknown,\n unknown[],\n ]\n return [\n { ...state, plugins: { ...state.plugins, [msg.name]: slice } },\n effects.map((effect) => ({ type: 'pluginEffect' as const, name: msg.name, effect })),\n ]\n }\n return update(state, msg)\n }\n\n const composedOnEffect = (\n effect: EditorEffect,\n api: { send: (msg: EditorMsg) => void; state: Signal<EditorState> },\n ): void => {\n if (effect.type === 'pluginEffect') {\n const ui = pluginUIByName.get(effect.name)\n ui?.onEffect?.(effect.effect, {\n editor: getEditor,\n send: (msg) => api.send({ type: 'plugin', name: effect.name, msg }),\n emit: (msg) => api.send(msg as EditorMsg),\n })\n return\n }\n baseOnEffect(effect, api)\n }\n\n const view = ({\n state,\n send,\n }: {\n state: Signal<EditorState>\n send: (msg: EditorMsg) => void\n }): Renderable => {\n // Build the collab binding (once, at mount) from the consumer's factory,\n // injecting the markdown seed + status sinks that mirror into `state.collab`.\n const collabBinding: CollabBinding | null = config.collab\n ? config.collab({\n seed: () => {\n $convertFromMarkdownString(seedValue, transformers)\n $setSelection(null)\n },\n onStatus: (connected) => send({ type: 'collabStatus', connected }),\n onSync: (synced) => send({ type: 'collabSync', synced }),\n onPeers: (peers) => send({ type: 'collabPeers', peers }),\n })\n : null\n\n const host = lexicalForeign<EditorOutMsg>({\n namespace: config.namespace ?? 'llui-markdown',\n theme: mergeTheme(config.theme),\n plugins,\n serialize: (editor) =>\n editor.getEditorState().read(() => $convertToMarkdownString(transformers)),\n deserialize: (_editor, value) => {\n $convertFromMarkdownString(value, transformers)\n $setSelection(null)\n },\n // In collab mode the shared CRDT owns the document: the local undo stack\n // and the boot-time seed are disabled — the binding supplies a scoped undo\n // manager and a sync-gated bootstrap instead.\n ...(collabBinding ? { history: false, seedMode: 'deferred' as const } : {}),\n defaultValue: collabBinding || config.value ? undefined : (config.defaultValue ?? ''),\n ...(config.value && !collabBinding ? { value: config.value } : {}),\n readonly: state.at('readonly'),\n ...(config.changeDebounceMs !== undefined\n ? { changeDebounceMs: config.changeDebounceMs }\n : {}),\n register: (editor) => {\n const disposers = [registerMarkdownShortcuts(editor, transformers)]\n if (decorators.length > 0) disposers.push(registerDecoratorBridges(editor, decorators))\n if (collabBinding) disposers.push(collabBinding.register(editor))\n return () => {\n for (const dispose of disposers) dispose()\n }\n },\n onReady: (editor) => {\n editorRef = editor\n if (config.placeholder) {\n editor.getRootElement()?.setAttribute('data-placeholder', config.placeholder)\n }\n config.onReady?.(editor)\n },\n onChange: (value) => send({ type: 'markdownChanged', value }),\n onSelectionChange: (ctx) => {\n const format = computeFormatState(ctx.editor, ctx)\n const text = ctx.editor.getEditorState().read(() => $getRoot().getTextContent())\n // Toggle an empty marker so CSS can show the placeholder.\n ctx.editor.getRootElement()?.setAttribute('data-empty', text === '' ? 'true' : 'false')\n send({ type: 'formatChanged', format, wordCount: countWords(text), charCount: text.length })\n },\n emit: (msg) => send(msg),\n })\n\n // Plugin view contributions (overlays/panels) — each gets its own slice + send.\n const pluginViews: Renderable = pluginUIs.flatMap(({ name, ui }) => {\n if (!ui.view) return []\n const rendered = ui.view({\n state: state.at(`plugins.${name}`),\n send: (msg) => send({ type: 'plugin', name, msg }),\n editor: getEditor,\n })\n return Array.isArray(rendered) ? rendered : [rendered]\n })\n\n if (!config.toolbar) return [host, ...pluginViews]\n return [\n div({ 'data-scope': 'md-editor', 'data-part': 'root' }, [\n renderToolbar({ format: state.at('format'), send, items, collab: state.at('collab') }),\n div({ 'data-scope': 'md-editor', 'data-part': 'surface' }, [host]),\n ]),\n ...pluginViews,\n ]\n }\n\n return component<EditorState, EditorMsg, EditorEffect>({\n name: 'MarkdownEditor',\n init: composedInit,\n update: composedUpdate,\n view,\n onEffect: composedOnEffect,\n })\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export { tablePlugin } from './plugins/table.js';
19
19
  export { GFM_NODES, GFM_TRANSFORMERS } from './transformers/gfm.js';
20
20
  export { buildTransformers, orderTransformers } from './transformers/registry.js';
21
21
  export { computeFormatState } from './format.js';
22
+ export { STRIKETHROUGH_CLASS, UNDERLINE_CLASS, UNDERLINE_STRIKETHROUGH_CLASS, defaultTheme, mergeTheme, } from './theme.js';
22
23
  export { type ToolbarItemParts, type ToolbarParts, type ToolbarOptions, DEFAULT_GLYPHS, connectToolbar, toolbar, } from './surfaces/toolbar.js';
23
24
  export { type LinkDialogOptions, linkDialog } from './surfaces/link-dialog.js';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,K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ACL,mBAAmB,EACnB,eAAe,EACf,6BAA6B,EAC7B,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,cAAc,EACd,cAAc,EACd,OAAO,GACR,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export { tablePlugin } from './plugins/table.js';
20
20
  export { GFM_NODES, GFM_TRANSFORMERS } from './transformers/gfm.js';
21
21
  export { buildTransformers, orderTransformers } from './transformers/registry.js';
22
22
  export { computeFormatState } from './format.js';
23
+ export { STRIKETHROUGH_CLASS, UNDERLINE_CLASS, UNDERLINE_STRIKETHROUGH_CLASS, defaultTheme, mergeTheme, } from './theme.js';
23
24
  export { DEFAULT_GLYPHS, connectToolbar, toolbar, } from './surfaces/toolbar.js';
24
25
  export { linkDialog } from './surfaces/link-dialog.js';
25
26
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAML,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EAUL,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,MAAM,EACN,UAAU,GACX,MAAM,YAAY,CAAA;AAEnB,OAAO,EAKN,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAKL,cAAc,GACf,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAA0B,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAGL,iBAAiB,GAClB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAA0B,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAIL,aAAa,EACb,cAAc,GACf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAA0B,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAA6B,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAA2C,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAC7F,OAAO,EAA2B,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACxF,OAAO,EAA2B,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAEjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAIL,cAAc,EACd,cAAc,EACd,OAAO,GACR,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAA0B,UAAU,EAAE,MAAM,2BAA2B,CAAA","sourcesContent":["// `@llui/markdown-editor` — WYSIWYG Markdown editor for LLui, built on Lexical.\n\nexport {\n type EditorConfig,\n type EditorParts,\n type CollabBinding,\n type CollabHooks,\n type CollabFactory,\n markdownEditor,\n} from './editor.js'\n\nexport {\n type BlockType,\n type FormatState,\n type OverlayKind,\n type CollabStatus,\n type EditorState,\n type EditorMsg,\n type EditorOutMsg,\n type EditorEffect,\n type InitOptions,\n EMPTY_FORMAT,\n COLLAB_OFF,\n init,\n update,\n countWords,\n} from './state.js'\n\nexport {\n type ItemSurface,\n type CommandItem,\n type CommandContext,\n type MarkdownPlugin,\n} from './plugins/types.js'\n\nexport {\n type PluginUI,\n type PluginUISpec,\n type PluginViewArgs,\n type PluginEffectContext,\n definePluginUI,\n} from './plugins/ui.js'\n\nexport { type CorePluginOptions, corePlugin } from './plugins/core.js'\nexport {\n type InlineFormat,\n type SingleBlockPluginOptions,\n singleBlockPlugin,\n} from './plugins/single-block.js'\nexport { type LinkPluginOptions, linkPlugin } from './plugins/link.js'\nexport {\n type CalloutKind,\n type CalloutData,\n type CalloutPluginOptions,\n calloutPlugin,\n $insertCallout,\n} from './plugins/callout.js'\nexport { hrPlugin, $insertHorizontalRule } from './plugins/hr.js'\nexport { slashPlugin } from './plugins/slash.js'\nexport { contextMenuPlugin } from './plugins/context-menu.js'\nexport { floatingToolbarPlugin } from './plugins/floating-toolbar.js'\nexport { type MathPluginOptions, mathPlugin } from './plugins/math.js'\nexport { type MermaidPluginOptions, mermaidPlugin } from './plugins/mermaid.js'\nexport { type Mention, type MentionPluginOptions, mentionPlugin } from './plugins/mention.js'\nexport { type EmojiPluginOptions, DEFAULT_EMOJI, emojiPlugin } from './plugins/emoji.js'\nexport { type ImagePluginOptions, imagePlugin } from './plugins/image.js'\nexport { tablePlugin } from './plugins/table.js'\n\nexport { GFM_NODES, GFM_TRANSFORMERS } from './transformers/gfm.js'\nexport { buildTransformers, orderTransformers } from './transformers/registry.js'\n\nexport { computeFormatState } from './format.js'\n\nexport {\n type ToolbarItemParts,\n type ToolbarParts,\n type ToolbarOptions,\n DEFAULT_GLYPHS,\n connectToolbar,\n toolbar,\n} from './surfaces/toolbar.js'\n\nexport { type LinkDialogOptions, linkDialog } from './surfaces/link-dialog.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAML,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,OAAO,EAUL,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,MAAM,EACN,UAAU,GACX,MAAM,YAAY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,EAA0B,UAAU,EAAE,MAAM,2BAA2B,CAAA","sourcesContent":["// `@llui/markdown-editor` — WYSIWYG Markdown editor for LLui, built on Lexical.\n\nexport {\n type EditorConfig,\n type EditorParts,\n type CollabBinding,\n type CollabHooks,\n type CollabFactory,\n markdownEditor,\n} from './editor.js'\n\nexport {\n type BlockType,\n type FormatState,\n type OverlayKind,\n type CollabStatus,\n type EditorState,\n type EditorMsg,\n type EditorOutMsg,\n type EditorEffect,\n type InitOptions,\n EMPTY_FORMAT,\n COLLAB_OFF,\n init,\n update,\n countWords,\n} from './state.js'\n\nexport {\n type ItemSurface,\n type CommandItem,\n type CommandContext,\n type MarkdownPlugin,\n} from './plugins/types.js'\n\nexport {\n type PluginUI,\n type PluginUISpec,\n type PluginViewArgs,\n type PluginEffectContext,\n definePluginUI,\n} from './plugins/ui.js'\n\nexport { type CorePluginOptions, corePlugin } from './plugins/core.js'\nexport {\n type InlineFormat,\n type SingleBlockPluginOptions,\n singleBlockPlugin,\n} from './plugins/single-block.js'\nexport { type LinkPluginOptions, linkPlugin } from './plugins/link.js'\nexport {\n type CalloutKind,\n type CalloutData,\n type CalloutPluginOptions,\n calloutPlugin,\n $insertCallout,\n} from './plugins/callout.js'\nexport { hrPlugin, $insertHorizontalRule } from './plugins/hr.js'\nexport { slashPlugin } from './plugins/slash.js'\nexport { contextMenuPlugin } from './plugins/context-menu.js'\nexport { floatingToolbarPlugin } from './plugins/floating-toolbar.js'\nexport { type MathPluginOptions, mathPlugin } from './plugins/math.js'\nexport { type MermaidPluginOptions, mermaidPlugin } from './plugins/mermaid.js'\nexport { type Mention, type MentionPluginOptions, mentionPlugin } from './plugins/mention.js'\nexport { type EmojiPluginOptions, DEFAULT_EMOJI, emojiPlugin } from './plugins/emoji.js'\nexport { type ImagePluginOptions, imagePlugin } from './plugins/image.js'\nexport { tablePlugin } from './plugins/table.js'\n\nexport { GFM_NODES, GFM_TRANSFORMERS } from './transformers/gfm.js'\nexport { buildTransformers, orderTransformers } from './transformers/registry.js'\n\nexport { computeFormatState } from './format.js'\n\nexport {\n STRIKETHROUGH_CLASS,\n UNDERLINE_CLASS,\n UNDERLINE_STRIKETHROUGH_CLASS,\n defaultTheme,\n mergeTheme,\n} from './theme.js'\n\nexport {\n type ToolbarItemParts,\n type ToolbarParts,\n type ToolbarOptions,\n DEFAULT_GLYPHS,\n connectToolbar,\n toolbar,\n} from './surfaces/toolbar.js'\n\nexport { type LinkDialogOptions, linkDialog } from './surfaces/link-dialog.js'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/plugins/overlay.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA8C,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAEpG,eAAO,MAAM,SAAS;;;;;CAKZ,CAAA;AAIV,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACrB,2CAA2C;IAC3C,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACjB,2CAA2C;IAC3C,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACjB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,UAAU,CAAA;IACzB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,UAAU,CAAA;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,iBAAiB,GAAG,UAAU,CAgB9D;AAED;mDACmD;AACnD,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAoB5D"}
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/plugins/overlay.ts"],"names":[],"mappings":"AAsBA,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,MAAM,EACZ,MAAM,WAAW,CAAA;AAGlB,eAAO,MAAM,SAAS;;;;;CAKZ,CAAA;AAWV,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACrB,2CAA2C;IAC3C,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACjB,2CAA2C;IAC3C,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACjB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,UAAU,CAAA;IACzB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,UAAU,CAAA;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,iBAAiB,GAAG,UAAU,CA2B9D;AAED;mDACmD;AACnD,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAoB5D"}
@@ -19,7 +19,8 @@
19
19
  // 62 — floating selection toolbar — selection-anchored bubble
20
20
  // 63 — table tools — element-anchored, sits over a table
21
21
  // The values live with each plugin's view; this comment is the source of truth.
22
- import { div, derived, portal, show } from '@llui/dom';
22
+ import { div, derived, onMount, portal, show, } from '@llui/dom';
23
+ import { registerNestedLayer } from '@llui/components/utils';
23
24
  export const OVERLAY_Z = {
24
25
  typeahead: 60,
25
26
  contextMenu: 61,
@@ -27,6 +28,12 @@ export const OVERLAY_Z = {
27
28
  tableTools: 63,
28
29
  };
29
30
  const toMountables = (r) => [...r];
31
+ // Unique marker per overlay instance so its portal root can be located while
32
+ // open. Every overlayRoot is a body-level sibling portal; without declaring it
33
+ // as a nested layer, a host `dialog.overlay()` mis-reads an interaction inside
34
+ // it as "outside" and dismisses (see @llui/components registerNestedLayer).
35
+ let layerSeq = 0;
36
+ const NESTED_LAYER_ATTR = 'data-llui-nested-layer';
30
37
  /**
31
38
  * A portaled, `position:fixed` overlay placed at `(x, y)` and shown while `open`.
32
39
  * Returns the `Renderable` a plugin's `view` yields directly. The emitted style is
@@ -36,11 +43,21 @@ const toMountables = (r) => [...r];
36
43
  export function overlayRoot(cfg) {
37
44
  const style = derived(cfg.x, cfg.y, (x, y) => `position:fixed;left:${x}px;top:${y}px;z-index:${cfg.zIndex}` +
38
45
  (cfg.transform ? `;${cfg.transform}` : ''));
46
+ const layerId = `mdo-${++layerSeq}`;
39
47
  return [
48
+ // Register once for the overlay's lifetime; the resolver returns the live
49
+ // portal root only while open (and nothing when closed/unmounted), so the
50
+ // single registration tracks open/closed without per-toggle churn.
51
+ onMount(() => registerNestedLayer(() => {
52
+ if (typeof document === 'undefined')
53
+ return [];
54
+ const el = document.querySelector(`[${NESTED_LAYER_ATTR}="${layerId}"]`);
55
+ return el ? [el] : [];
56
+ })),
40
57
  show(cfg.open, () => [
41
58
  portal(() => [
42
59
  ...(cfg.before ? toMountables(cfg.before()) : []),
43
- div({ ...cfg.attrs, style }, toMountables(cfg.children())),
60
+ div({ ...cfg.attrs, [NESTED_LAYER_ATTR]: layerId, style }, toMountables(cfg.children())),
44
61
  ]),
45
62
  ]),
46
63
  ];
@@ -1 +1 @@
1
- {"version":3,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ent":["// Shared overlay primitive for plugin-UI surfaces (context menu, slash/mention\n// typeaheads, floating toolbar, table tools). Every one of these is a portaled,\n// viewport-positioned panel whose `{ open, x, y }` lives in pure, JSON state and\n// is rendered with `show → portal → fixed-positioned div`. Factoring that single\n// shape here keeps positioning testable (a plain style string, not imperative\n// floating-ui calls) and removes the copy-paste that otherwise accumulates one\n// near-identical state machine per overlay plugin.\n//\n// Anchored positioning via `@llui/components`' `attachFloating` (floating-ui) was\n// considered: it gives flip/shift/auto-update for free but needs a live element\n// ref and async, jsdom-untestable DOM writes — a poor fit for overlays whose\n// position is derived from a transient caret/pointer/element rect each `register`\n// tick. The pure-state idiom below covers scroll/resize via {@link onViewportChange}.\n//\n// ## Stacking order (z-index)\n// A single documented scale so overlays never tie and obscure each other:\n// 60 — typeaheads (slash, mention) — caret-anchored, lowest\n// 61 — context menu — pointer-anchored\n// 62 — floating selection toolbar — selection-anchored bubble\n// 63 — table tools — element-anchored, sits over a table\n// The values live with each plugin's view; this comment is the source of truth.\n\nimport { div, derived, portal, show, type Mountable, type Renderable, type Signal } from '@llui/dom'\n\nexport const OVERLAY_Z = {\n typeahead: 60,\n contextMenu: 61,\n floatingToolbar: 62,\n tableTools: 63,\n} as const\n\nconst toMountables = (r: Renderable): Mountable[] => [...r]\n\nexport interface OverlayRootConfig {\n /** Whether the overlay is shown. */\n open: Signal<boolean>\n /** Viewport x of the anchor point (px). */\n x: Signal<number>\n /** Viewport y of the anchor point (px). */\n y: Signal<number>\n /** Stacking level — use {@link OVERLAY_Z}. */\n zIndex: number\n /** Extra CSS appended after positioning (e.g. a centering/lift transform). */\n transform?: string\n /** Attributes for the positioned element (`data-scope`/`data-part`, handlers). */\n attrs: Record<string, unknown>\n /** Optional siblings rendered inside the portal before the root (e.g. a backdrop). */\n before?: () => Renderable\n /** The positioned element's children. */\n children: () => Renderable\n}\n\n/**\n * A portaled, `position:fixed` overlay placed at `(x, y)` and shown while `open`.\n * Returns the `Renderable` a plugin's `view` yields directly. The emitted style is\n * a deterministic string — `position:fixed;left:${x}px;top:${y}px;z-index:${z}` plus\n * an optional `transform` — so positioning is unit-testable.\n */\nexport function overlayRoot(cfg: OverlayRootConfig): Renderable {\n const style = derived(\n cfg.x,\n cfg.y,\n (x, y) =>\n `position:fixed;left:${x}px;top:${y}px;z-index:${cfg.zIndex}` +\n (cfg.transform ? `;${cfg.transform}` : ''),\n ) as Signal<string>\n return [\n show(cfg.open, () => [\n portal(() => [\n ...(cfg.before ? toMountables(cfg.before()) : []),\n div({ ...cfg.attrs, style }, toMountables(cfg.children())),\n ]),\n ]),\n ]\n}\n\n/** Guarded close: collapse `open` to false, preserving the reference when already\n * closed so the host doesn't reconcile a no-op. */\nexport function hideOverlay<S extends { open: boolean }>(state: S): S {\n return state.open ? { ...state, open: false } : state\n}\n\n/**\n * Run `run` (debounced to one call per animation frame) whenever the viewport\n * changes — any ancestor scroll or a window resize. Overlays anchored to a\n * persistent element (a table) or a live selection must reposition on scroll;\n * editor update listeners alone never fire for a plain scroll. Returns a cleanup\n * that removes the listeners. No-op (and cleanup is a no-op) outside the browser.\n */\nexport function onViewportChange(run: () => void): () => void {\n if (typeof window === 'undefined' || typeof requestAnimationFrame !== 'function') {\n return () => {}\n }\n let pending = 0\n const handler = (): void => {\n if (pending) return\n pending = requestAnimationFrame(() => {\n pending = 0\n run()\n })\n }\n // Capture phase so scrolls in any nested scroll container are caught.\n window.addEventListener('scroll', handler, true)\n window.addEventListener('resize', handler)\n return () => {\n window.removeEventListener('scroll', handler, true)\n window.removeEventListener('resize', handler)\n if (pending) cancelAnimationFrame(pending)\n }\n}\n"]}
1
+ {"version":3,"file":"overlay.js","sourceRoot":"","sources":["../../src/plugins/overlay.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gFAAgF;AAChF,iFAAiF;AACjF,iFAAiF;AACjF,8EAA8E;AAC9E,+EAA+E;AAC/E,mDAAmD;AACnD,EAAE;AACF,kFAAkF;AAClF,gFAAgF;AAChF,6EAA6E;AA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,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,sEAAsE;IACtE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;IAChD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC1C,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QACnD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAC7C,IAAI,OAAO;YAAE,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC,CAAA;AACH,CAAC","sourcesContent":["// Shared overlay primitive for plugin-UI surfaces (context menu, slash/mention\n// typeaheads, floating toolbar, table tools). Every one of these is a portaled,\n// viewport-positioned panel whose `{ open, x, y }` lives in pure, JSON state and\n// is rendered with `show → portal → fixed-positioned div`. Factoring that single\n// shape here keeps positioning testable (a plain style string, not imperative\n// floating-ui calls) and removes the copy-paste that otherwise accumulates one\n// near-identical state machine per overlay plugin.\n//\n// Anchored positioning via `@llui/components`' `attachFloating` (floating-ui) was\n// considered: it gives flip/shift/auto-update for free but needs a live element\n// ref and async, jsdom-untestable DOM writes — a poor fit for overlays whose\n// position is derived from a transient caret/pointer/element rect each `register`\n// tick. The pure-state idiom below covers scroll/resize via {@link onViewportChange}.\n//\n// ## Stacking order (z-index)\n// A single documented scale so overlays never tie and obscure each other:\n// 60 — typeaheads (slash, mention) — caret-anchored, lowest\n// 61 — context menu — pointer-anchored\n// 62 — floating selection toolbar — selection-anchored bubble\n// 63 — table tools — element-anchored, sits over a table\n// The values live with each plugin's view; this comment is the source of truth.\n\nimport {\n div,\n derived,\n onMount,\n portal,\n show,\n type Mountable,\n type Renderable,\n type Signal,\n} from '@llui/dom'\nimport { registerNestedLayer } from '@llui/components/utils'\n\nexport const OVERLAY_Z = {\n typeahead: 60,\n contextMenu: 61,\n floatingToolbar: 62,\n tableTools: 63,\n} as const\n\nconst toMountables = (r: Renderable): Mountable[] => [...r]\n\n// Unique marker per overlay instance so its portal root can be located while\n// open. Every overlayRoot is a body-level sibling portal; without declaring it\n// as a nested layer, a host `dialog.overlay()` mis-reads an interaction inside\n// it as \"outside\" and dismisses (see @llui/components registerNestedLayer).\nlet layerSeq = 0\nconst NESTED_LAYER_ATTR = 'data-llui-nested-layer'\n\nexport interface OverlayRootConfig {\n /** Whether the overlay is shown. */\n open: Signal<boolean>\n /** Viewport x of the anchor point (px). */\n x: Signal<number>\n /** Viewport y of the anchor point (px). */\n y: Signal<number>\n /** Stacking level — use {@link OVERLAY_Z}. */\n zIndex: number\n /** Extra CSS appended after positioning (e.g. a centering/lift transform). */\n transform?: string\n /** Attributes for the positioned element (`data-scope`/`data-part`, handlers). */\n attrs: Record<string, unknown>\n /** Optional siblings rendered inside the portal before the root (e.g. a backdrop). */\n before?: () => Renderable\n /** The positioned element's children. */\n children: () => Renderable\n}\n\n/**\n * A portaled, `position:fixed` overlay placed at `(x, y)` and shown while `open`.\n * Returns the `Renderable` a plugin's `view` yields directly. The emitted style is\n * a deterministic string — `position:fixed;left:${x}px;top:${y}px;z-index:${z}` plus\n * an optional `transform` — so positioning is unit-testable.\n */\nexport function overlayRoot(cfg: OverlayRootConfig): Renderable {\n const style = derived(\n cfg.x,\n cfg.y,\n (x, y) =>\n `position:fixed;left:${x}px;top:${y}px;z-index:${cfg.zIndex}` +\n (cfg.transform ? `;${cfg.transform}` : ''),\n ) as Signal<string>\n const layerId = `mdo-${++layerSeq}`\n return [\n // Register once for the overlay's lifetime; the resolver returns the live\n // portal root only while open (and nothing when closed/unmounted), so the\n // single registration tracks open/closed without per-toggle churn.\n onMount(() =>\n registerNestedLayer(() => {\n if (typeof document === 'undefined') return []\n const el = document.querySelector(`[${NESTED_LAYER_ATTR}=\"${layerId}\"]`)\n return el ? [el] : []\n }),\n ),\n show(cfg.open, () => [\n portal(() => [\n ...(cfg.before ? toMountables(cfg.before()) : []),\n div({ ...cfg.attrs, [NESTED_LAYER_ATTR]: layerId, style }, toMountables(cfg.children())),\n ]),\n ]),\n ]\n}\n\n/** Guarded close: collapse `open` to false, preserving the reference when already\n * closed so the host doesn't reconcile a no-op. */\nexport function hideOverlay<S extends { open: boolean }>(state: S): S {\n return state.open ? { ...state, open: false } : state\n}\n\n/**\n * Run `run` (debounced to one call per animation frame) whenever the viewport\n * changes — any ancestor scroll or a window resize. Overlays anchored to a\n * persistent element (a table) or a live selection must reposition on scroll;\n * editor update listeners alone never fire for a plain scroll. Returns a cleanup\n * that removes the listeners. No-op (and cleanup is a no-op) outside the browser.\n */\nexport function onViewportChange(run: () => void): () => void {\n if (typeof window === 'undefined' || typeof requestAnimationFrame !== 'function') {\n return () => {}\n }\n let pending = 0\n const handler = (): void => {\n if (pending) return\n pending = requestAnimationFrame(() => {\n pending = 0\n run()\n })\n }\n // Capture phase so scrolls in any nested scroll container are caught.\n window.addEventListener('scroll', handler, true)\n window.addEventListener('resize', handler)\n return () => {\n window.removeEventListener('scroll', handler, true)\n window.removeEventListener('resize', handler)\n if (pending) cancelAnimationFrame(pending)\n }\n}\n"]}
@@ -78,6 +78,18 @@
78
78
  overflow: auto;
79
79
  }
80
80
 
81
+ /* Text-decoration formats Lexical renders as a bare <span> (no semantic tag):
82
+ * the runtime tags them with the default theme classes — see src/theme.ts. */
83
+ [data-lexical-editor] .md-strikethrough {
84
+ text-decoration: line-through;
85
+ }
86
+ [data-lexical-editor] .md-underline {
87
+ text-decoration: underline;
88
+ }
89
+ [data-lexical-editor] .md-underline-strikethrough {
90
+ text-decoration: underline line-through;
91
+ }
92
+
81
93
  /* Task-list items (li[role="checkbox"]) with a clickable checkbox. */
82
94
  [data-lexical-editor] li[role='checkbox'] {
83
95
  position: relative;
@@ -0,0 +1,18 @@
1
+ import type { EditorThemeClasses } from 'lexical';
2
+ export declare const STRIKETHROUGH_CLASS = "md-strikethrough";
3
+ export declare const UNDERLINE_CLASS = "md-underline";
4
+ export declare const UNDERLINE_STRIKETHROUGH_CLASS = "md-underline-strikethrough";
5
+ /** The class hooks Lexical needs for text-decoration formats it renders as a
6
+ * plain <span>. (`underlineStrikethrough` is Lexical's special composite key for
7
+ * the case where both apply — both want `text-decoration`.) */
8
+ export declare const defaultTheme: EditorThemeClasses;
9
+ /** Merge a consumer theme over the default. `text` is merged per-key so a
10
+ * consumer overriding (say) `strikethrough` keeps the default `underline`.
11
+ *
12
+ * Always returns a FRESH theme (never the shared `defaultTheme` singleton):
13
+ * Lexical caches resolved class arrays by MUTATING the `text` object it is
14
+ * handed (`text.__lexicalClassNameCache`). Handing it a fresh copy keeps the
15
+ * exported singleton clean, and stripping any inherited cache prevents a stale
16
+ * entry from a previously-used theme object shadowing an overridden class. */
17
+ export declare function mergeTheme(theme?: EditorThemeClasses): EditorThemeClasses;
18
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,eAAO,MAAM,mBAAmB,qBAAqB,CAAA;AACrD,eAAO,MAAM,eAAe,iBAAiB,CAAA;AAC7C,eAAO,MAAM,6BAA6B,+BAA+B,CAAA;AAEzE;;+DAE+D;AAC/D,eAAO,MAAM,YAAY,EAAE,kBAM1B,CAAA;AAED;;;;;;;8EAO8E;AAC9E,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,CAIzE"}
package/dist/theme.js ADDED
@@ -0,0 +1,38 @@
1
+ // Default Lexical theme for the markdown editor.
2
+ //
3
+ // Lexical styles most inline formats through semantic tags that carry
4
+ // browser-default styling — bold→<strong>, italic→<em>, code→<code>. But
5
+ // `strikethrough` (and `underline`) render as a bare <span> whose ONLY styling
6
+ // hook is a `theme.text.<format>` class. With no theme the format is applied to
7
+ // the model but is visually invisible. This default theme supplies those class
8
+ // names; the bundled `styles/editor.css` gives them their `text-decoration`.
9
+ //
10
+ // Consumers can override any entry via `markdownEditor({ theme })` — the user's
11
+ // theme is merged over this default (see `mergeTheme`).
12
+ export const STRIKETHROUGH_CLASS = 'md-strikethrough';
13
+ export const UNDERLINE_CLASS = 'md-underline';
14
+ export const UNDERLINE_STRIKETHROUGH_CLASS = 'md-underline-strikethrough';
15
+ /** The class hooks Lexical needs for text-decoration formats it renders as a
16
+ * plain <span>. (`underlineStrikethrough` is Lexical's special composite key for
17
+ * the case where both apply — both want `text-decoration`.) */
18
+ export const defaultTheme = {
19
+ text: {
20
+ strikethrough: STRIKETHROUGH_CLASS,
21
+ underline: UNDERLINE_CLASS,
22
+ underlineStrikethrough: UNDERLINE_STRIKETHROUGH_CLASS,
23
+ },
24
+ };
25
+ /** Merge a consumer theme over the default. `text` is merged per-key so a
26
+ * consumer overriding (say) `strikethrough` keeps the default `underline`.
27
+ *
28
+ * Always returns a FRESH theme (never the shared `defaultTheme` singleton):
29
+ * Lexical caches resolved class arrays by MUTATING the `text` object it is
30
+ * handed (`text.__lexicalClassNameCache`). Handing it a fresh copy keeps the
31
+ * exported singleton clean, and stripping any inherited cache prevents a stale
32
+ * entry from a previously-used theme object shadowing an overridden class. */
33
+ export function mergeTheme(theme) {
34
+ const text = { ...defaultTheme.text, ...theme?.text };
35
+ delete text.__lexicalClassNameCache;
36
+ return { ...theme, text };
37
+ }
38
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,EAAE;AACF,gFAAgF;AAChF,wDAAwD;AAIxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA;AAC7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAA4B,CAAA;AAEzE;;+DAE+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAuB;IAC9C,IAAI,EAAE;QACJ,aAAa,EAAE,mBAAmB;QAClC,SAAS,EAAE,eAAe;QAC1B,sBAAsB,EAAE,6BAA6B;KACtD;CACF,CAAA;AAED;;;;;;;8EAO8E;AAC9E,MAAM,UAAU,UAAU,CAAC,KAA0B;IACnD,MAAM,IAAI,GAAG,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;IACrD,OAAQ,IAA8C,CAAC,uBAAuB,CAAA;IAC9E,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["// Default Lexical theme for the markdown editor.\n//\n// Lexical styles most inline formats through semantic tags that carry\n// browser-default styling — bold→<strong>, italic→<em>, code→<code>. But\n// `strikethrough` (and `underline`) render as a bare <span> whose ONLY styling\n// hook is a `theme.text.<format>` class. With no theme the format is applied to\n// the model but is visually invisible. This default theme supplies those class\n// names; the bundled `styles/editor.css` gives them their `text-decoration`.\n//\n// Consumers can override any entry via `markdownEditor({ theme })` — the user's\n// theme is merged over this default (see `mergeTheme`).\n\nimport type { EditorThemeClasses } from 'lexical'\n\nexport const STRIKETHROUGH_CLASS = 'md-strikethrough'\nexport const UNDERLINE_CLASS = 'md-underline'\nexport const UNDERLINE_STRIKETHROUGH_CLASS = 'md-underline-strikethrough'\n\n/** The class hooks Lexical needs for text-decoration formats it renders as a\n * plain <span>. (`underlineStrikethrough` is Lexical's special composite key for\n * the case where both apply — both want `text-decoration`.) */\nexport const defaultTheme: EditorThemeClasses = {\n text: {\n strikethrough: STRIKETHROUGH_CLASS,\n underline: UNDERLINE_CLASS,\n underlineStrikethrough: UNDERLINE_STRIKETHROUGH_CLASS,\n },\n}\n\n/** Merge a consumer theme over the default. `text` is merged per-key so a\n * consumer overriding (say) `strikethrough` keeps the default `underline`.\n *\n * Always returns a FRESH theme (never the shared `defaultTheme` singleton):\n * Lexical caches resolved class arrays by MUTATING the `text` object it is\n * handed (`text.__lexicalClassNameCache`). Handing it a fresh copy keeps the\n * exported singleton clean, and stripping any inherited cache prevents a stale\n * entry from a previously-used theme object shadowing an overridden class. */\nexport function mergeTheme(theme?: EditorThemeClasses): EditorThemeClasses {\n const text = { ...defaultTheme.text, ...theme?.text }\n delete (text as { __lexicalClassNameCache?: unknown }).__lexicalClassNameCache\n return { ...theme, text }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llui/markdown-editor",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,9 +24,9 @@
24
24
  "./styles/editor.css": "./dist/styles/editor.css"
25
25
  },
26
26
  "peerDependencies": {
27
- "@llui/dom": "^0.11.3",
28
- "@llui/lexical": "^0.2.4",
29
- "@llui/components": "^0.11.7",
27
+ "@llui/dom": "^0.11.4",
28
+ "@llui/lexical": "^0.2.5",
29
+ "@llui/components": "^0.12.1",
30
30
  "lexical": "^0.45.0",
31
31
  "@lexical/markdown": "^0.45.0",
32
32
  "@lexical/rich-text": "^0.45.0",
@@ -50,9 +50,9 @@
50
50
  "typescript": "^6.0.0",
51
51
  "vitest": "^4.1.2",
52
52
  "@lexical/code-core": "^0.45.0",
53
- "@llui/dom": "0.11.3",
54
- "@llui/components": "0.11.7",
55
- "@llui/lexical": "0.2.4"
53
+ "@llui/dom": "0.11.4",
54
+ "@llui/lexical": "0.2.5",
55
+ "@llui/components": "0.12.1"
56
56
  },
57
57
  "sideEffects": [
58
58
  "./dist/styles/editor.css"