@haklex/rich-editor 0.4.1 → 0.6.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 (70) hide show
  1. package/README.md +51 -2
  2. package/dist/{AlertQuoteEditNode-bJolZMh7.js → AlertQuoteEditNode-DjObnJI6.js} +3 -3
  3. package/dist/{KaTeXRenderer-CQQT3BMw.js → KaTeXRenderer-CqnhvDmj.js} +37 -3
  4. package/dist/{MermaidPlugin-BRyrtUBj.js → MermaidPlugin-_gPgU34D.js} +2 -2
  5. package/dist/{extractPolls-DO31LNrp.js → PresentDialogContext-DKNicgia.js} +1 -43
  6. package/dist/{SubmitShortcutPlugin-DtHHlBnh.js → SubmitShortcutPlugin-CHn_HBJM.js} +6 -6
  7. package/dist/commands-entry.mjs +2 -2
  8. package/dist/components/RendererWrapper.d.ts +14 -4
  9. package/dist/components/RendererWrapper.d.ts.map +1 -1
  10. package/dist/components/decorators/AlertEditDecorator.d.ts.map +1 -1
  11. package/dist/components/decorators/BannerEditDecorator.d.ts.map +1 -1
  12. package/dist/components/decorators/CodeBlockEditDecorator.d.ts.map +1 -1
  13. package/dist/components/renderers/AlertStaticDecorator.d.ts.map +1 -1
  14. package/dist/components/renderers/BannerStaticDecorator.d.ts.map +1 -1
  15. package/dist/{config-CTD7-xAy.js → config-EJe68p4h.js} +10 -397
  16. package/dist/config-edit.d.ts.map +1 -1
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/index.d.ts +1 -4
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.mjs +8 -8
  21. package/dist/{node-registry-BmeHYCtG.js → node-registry-D9t5vPfY.js} +9 -318
  22. package/dist/nodes/CodeBlockNode.d.ts.map +1 -1
  23. package/dist/nodes/FootnoteNode.d.ts.map +1 -1
  24. package/dist/nodes/FootnoteSectionNode.d.ts.map +1 -1
  25. package/dist/nodes/ImageNode.d.ts.map +1 -1
  26. package/dist/nodes/KaTeXBlockNode.d.ts.map +1 -1
  27. package/dist/nodes/KaTeXInlineNode.d.ts.map +1 -1
  28. package/dist/nodes/LinkCardNode.d.ts.map +1 -1
  29. package/dist/nodes/MentionNode.d.ts.map +1 -1
  30. package/dist/nodes/MermaidNode.d.ts.map +1 -1
  31. package/dist/nodes/VideoNode.d.ts.map +1 -1
  32. package/dist/nodes-entry.d.ts +0 -3
  33. package/dist/nodes-entry.d.ts.map +1 -1
  34. package/dist/nodes-entry.mjs +5 -5
  35. package/dist/plugins-entry.mjs +2 -2
  36. package/dist/renderers-entry.d.ts +1 -2
  37. package/dist/renderers-entry.d.ts.map +1 -1
  38. package/dist/renderers-entry.mjs +2 -2
  39. package/dist/rich-editor.css +1 -1
  40. package/dist/static-entry.d.ts +1 -5
  41. package/dist/static-entry.d.ts.map +1 -1
  42. package/dist/static-entry.mjs +5 -5
  43. package/dist/styles/index.d.ts +0 -2
  44. package/dist/styles/index.d.ts.map +1 -1
  45. package/dist/{theme-QqiMxW5u.js → theme-DG7I1YM5.js} +8 -8
  46. package/dist/types/renderer-config.d.ts +28 -33
  47. package/dist/types/renderer-config.d.ts.map +1 -1
  48. package/dist/types/renderer-keys.d.ts +26 -0
  49. package/dist/types/renderer-keys.d.ts.map +1 -0
  50. package/package.json +4 -4
  51. package/dist/components/decorators/PollEditDecorator.d.ts +0 -13
  52. package/dist/components/decorators/PollEditDecorator.d.ts.map +0 -1
  53. package/dist/components/renderers/ChatRendererProps.d.ts +0 -19
  54. package/dist/components/renderers/ChatRendererProps.d.ts.map +0 -1
  55. package/dist/components/renderers/PollRenderer.d.ts +0 -3
  56. package/dist/components/renderers/PollRenderer.d.ts.map +0 -1
  57. package/dist/context/PollDataContext.d.ts +0 -11
  58. package/dist/context/PollDataContext.d.ts.map +0 -1
  59. package/dist/nodes/PollEditNode.d.ts +0 -14
  60. package/dist/nodes/PollEditNode.d.ts.map +0 -1
  61. package/dist/nodes/PollNode.d.ts +0 -52
  62. package/dist/nodes/PollNode.d.ts.map +0 -1
  63. package/dist/styles/poll-edit.css.d.ts +0 -43
  64. package/dist/styles/poll-edit.css.d.ts.map +0 -1
  65. package/dist/styles/poll.css.d.ts +0 -43
  66. package/dist/styles/poll.css.d.ts.map +0 -1
  67. package/dist/types/poll.d.ts +0 -36
  68. package/dist/types/poll.d.ts.map +0 -1
  69. package/dist/utils/extractPolls.d.ts +0 -4
  70. package/dist/utils/extractPolls.d.ts.map +0 -1
package/README.md CHANGED
@@ -38,7 +38,7 @@ import '@haklex/rich-editor/style.css';
38
38
  <RichEditor variant="article" initialValue={savedState} onChange={(value) => save(value)} />;
39
39
  ```
40
40
 
41
- For read-only rendering, use `@haklex/rich-static-renderer` instead.
41
+ For read-only rendering, use `@haklex/rich-compose` (exports `RichRenderer` and the modular composition API).
42
42
 
43
43
  ## Exports
44
44
 
@@ -116,9 +116,54 @@ For read-only rendering, use `@haklex/rich-static-renderer` instead.
116
116
  | `buildBlockAnchor`, `buildRangeAnchor` | Comment anchor utilities |
117
117
  | `ALL_TRANSFORMERS` | All Markdown transformers (inline + block) |
118
118
 
119
+ ### Slot Keys
120
+
121
+ `RendererConfig` keys are exposed as `as const` constants for safer call sites. Use them in `createRendererDecoration` and module override maps instead of bare string literals:
122
+
123
+ ```ts
124
+ import {
125
+ ALERT_NODE_KEY,
126
+ BANNER_NODE_KEY,
127
+ CODE_BLOCK_NODE_KEY,
128
+ FOOTNOTE_NODE_KEY,
129
+ FOOTNOTE_SECTION_NODE_KEY,
130
+ IMAGE_NODE_KEY,
131
+ KATEX_NODE_KEY,
132
+ LINK_CARD_NODE_KEY,
133
+ MENTION_NODE_KEY,
134
+ MERMAID_NODE_KEY,
135
+ RUBY_NODE_KEY,
136
+ TAG_NODE_KEY,
137
+ VIDEO_NODE_KEY,
138
+ } from '@haklex/rich-editor';
139
+ ```
140
+
141
+ Extension packages (`@haklex/rich-ext-*`) expose their own slot keys (e.g. `POLL_NODE_KEY`, `CHAT_NODE_KEY`).
142
+
143
+ ### Extending `RendererConfig`
144
+
145
+ `@haklex/rich-editor` ships only the built-in slots. Extension and downstream packages add their own slots via TypeScript module augmentation:
146
+
147
+ ```ts
148
+ import type { ComponentType } from 'react';
149
+ import type { MyChartProps } from './MyChart';
150
+ // Force the augmentation target to resolve as an external module.
151
+ import type {} from '@haklex/rich-editor';
152
+
153
+ declare module '@haklex/rich-editor' {
154
+ interface RendererConfig {
155
+ MyChart?: ComponentType<MyChartProps>;
156
+ }
157
+ }
158
+
159
+ export {};
160
+ ```
161
+
162
+ Re-export the augmentation file as a side-effect from every public entry (`/node`, `/renderer`, `/edit`, `/static`, `/index`) so consumers see the slot regardless of which sub-path they import.
163
+
119
164
  ### Types
120
165
 
121
- `RichEditorProps`, `RichEditorVariant`, `RendererConfig`, `ColorScheme`, `RendererMode`, `ImageUploadFn`, `ImageUploadResult`, `CommandItemConfig`, `SlashMenuItemConfig`, `ToolbarGroup`, `CommandPlacement`, and renderer prop types (`AlertRendererProps`, `ImageRendererProps`, `CodeBlockRendererProps`, etc.).
166
+ `RichEditorProps`, `RichEditorVariant`, `RendererConfig`, `ColorScheme`, `RendererMode`, `ImageUploadFn`, `ImageUploadResult`, `CommandItemConfig`, `SlashMenuItemConfig`, `ToolbarGroup`, `CommandPlacement`, and **built-in** renderer prop types (`AlertRendererProps`, `ImageRendererProps`, `CodeBlockRendererProps`, etc.). Extension renderer props (`PollRendererProps`, `ChatRendererProps`, `CodeFile`, `GalleryRendererProps`, …) live in their owning packages — import from `@haklex/rich-ext-<name>/node`.
122
167
 
123
168
  ### Sub-path Exports
124
169
 
@@ -126,6 +171,10 @@ For read-only rendering, use `@haklex/rich-static-renderer` instead.
126
171
  | ------------------------------- | ------------------------------------------------------------------- |
127
172
  | `@haklex/rich-editor` | Full export (components, nodes, plugins, commands, contexts, types) |
128
173
  | `@haklex/rich-editor/editor` | Editor-specific entry (RichEditor + node configs) |
174
+ | `@haklex/rich-editor/nodes` | Node classes + edit-mode node classes |
175
+ | `@haklex/rich-editor/plugins` | Built-in plugins |
176
+ | `@haklex/rich-editor/commands` | Insert / open commands + `CommandItemConfig` |
177
+ | `@haklex/rich-editor/renderers` | Built-in renderer components, prop types, and slot key constants |
129
178
  | `@haklex/rich-editor/static` | Static/SSR utilities (for renderer and extension packages) |
130
179
  | `@haklex/rich-editor/styles` | Style variables and variant class exports |
131
180
  | `@haklex/rich-editor/style.css` | Compiled editor stylesheet |
@@ -1,5 +1,5 @@
1
- import { A as AlertQuoteNode, D as $isAlertQuoteNode, E as FootnoteNode, N as AlertRenderer, _ as KaTeXInlineNode, c as SpoilerNode, i as TagNode, j as _defineProperty, m as MentionNode, t as editorTheme } from "./theme-QqiMxW5u.js";
2
- import { l as RendererWrapper } from "./KaTeXRenderer-CQQT3BMw.js";
1
+ import { A as AlertQuoteNode, D as $isAlertQuoteNode, E as FootnoteNode, N as AlertRenderer, _ as KaTeXInlineNode, c as SpoilerNode, i as TagNode, j as _defineProperty, m as MentionNode, t as editorTheme } from "./theme-DG7I1YM5.js";
2
+ import { h as ALERT_NODE_KEY, l as RendererWrapper } from "./KaTeXRenderer-CqnhvDmj.js";
3
3
  import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
4
4
  import { ListPlugin } from "@lexical/react/LexicalListPlugin";
5
5
  import { AutoLinkNode, LinkNode } from "@lexical/link";
@@ -103,7 +103,7 @@ function AlertEditDecorator({ nodeKey, alertType, contentEditor }) {
103
103
  }, [editor, nodeKey]);
104
104
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RendererWrapper, {
105
105
  defaultRenderer: AlertRenderer,
106
- rendererKey: "Alert",
106
+ rendererKey: ALERT_NODE_KEY,
107
107
  props: {
108
108
  type: alertType,
109
109
  editable,
@@ -2,6 +2,33 @@ import { l as semanticClassNames, n as katexStyles, r as clsx, t as katexClassNa
2
2
  import { createContext, createElement, use, useCallback, useEffect, useMemo, useState } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { rgbaToThumbHash, thumbHashToDataURL } from "thumbhash";
5
+ //#region src/types/renderer-keys.ts
6
+ /**
7
+ * Slot key constants for the built-in renderers in `RendererConfig`.
8
+ *
9
+ * Use these instead of string literals when wiring decorators or composing
10
+ * override modules so renames stay searchable and typos surface as compiler
11
+ * errors. Each constant is `as const` so its type is the literal key, making
12
+ * it safe for `keyof RendererConfig` indexing.
13
+ *
14
+ * Extension packages (`@haklex/rich-ext-*`) export their own slot constants
15
+ * from a sibling `slot.ts` file; downstream apps should follow the same
16
+ * pattern when adding bespoke slots via module augmentation.
17
+ */
18
+ var ALERT_NODE_KEY = "Alert";
19
+ var BANNER_NODE_KEY = "Banner";
20
+ var CODE_BLOCK_NODE_KEY = "CodeBlock";
21
+ var FOOTNOTE_NODE_KEY = "Footnote";
22
+ var FOOTNOTE_SECTION_NODE_KEY = "FootnoteSection";
23
+ var IMAGE_NODE_KEY = "Image";
24
+ var KATEX_NODE_KEY = "KaTeX";
25
+ var LINK_CARD_NODE_KEY = "LinkCard";
26
+ var MENTION_NODE_KEY = "Mention";
27
+ var MERMAID_NODE_KEY = "Mermaid";
28
+ var RUBY_NODE_KEY = "Ruby";
29
+ var TAG_NODE_KEY = "Tag";
30
+ var VIDEO_NODE_KEY = "Video";
31
+ //#endregion
5
32
  //#region src/context/RendererConfigContext.tsx
6
33
  var RendererConfigContext = createContext({
7
34
  config: void 0,
@@ -38,12 +65,19 @@ function useVariant() {
38
65
  * Wrapper component that allows overriding default renderers with custom ones.
39
66
  * Uses RendererConfig from context to determine which renderer to use.
40
67
  */
41
- function RendererWrapper({ rendererKey, defaultRenderer: DefaultRenderer, props }) {
42
- return /* @__PURE__ */ jsx(useRendererConfig()?.[rendererKey] ?? DefaultRenderer, { ...props });
68
+ function RendererWrapper({ rendererKey, defaultRenderer, props }) {
69
+ const Renderer = useRendererConfig()?.[rendererKey] ?? defaultRenderer;
70
+ if (!Renderer) return null;
71
+ return /* @__PURE__ */ jsx(Renderer, { ...props });
43
72
  }
44
73
  /**
45
74
  * Type-safe helper for creating RendererWrapper elements from .ts node files.
46
75
  * Avoids the createElement + discriminated-union typing limitation.
76
+ *
77
+ * `defaultRenderer` is optional. Pass `undefined` from extension node classes
78
+ * that should not statically import their renderer; the heavy default lives
79
+ * in a separate sub-path and is registered into RendererConfig at compose
80
+ * time, keeping the node bundle light.
47
81
  */
48
82
  function createRendererDecoration(rendererKey, defaultRenderer, props) {
49
83
  return createElement(RendererWrapper, {
@@ -212,4 +246,4 @@ function KaTeXRenderer({ equation, displayMode }) {
212
246
  });
213
247
  }
214
248
  //#endregion
215
- export { FootnoteDefinitionsProvider as a, useFootnoteDisplayNumber as c, RendererConfigProvider as d, useRendererConfig as f, FootnoteStaticRenderer as i, RendererWrapper as l, useVariant as m, computeImageMeta as n, useFootnoteContent as o, useRendererMode as p, decodeThumbHash as r, useFootnoteDefinitions as s, KaTeXRenderer as t, createRendererDecoration as u };
249
+ export { MENTION_NODE_KEY as C, VIDEO_NODE_KEY as D, TAG_NODE_KEY as E, LINK_CARD_NODE_KEY as S, RUBY_NODE_KEY as T, CODE_BLOCK_NODE_KEY as _, FootnoteDefinitionsProvider as a, IMAGE_NODE_KEY as b, useFootnoteDisplayNumber as c, RendererConfigProvider as d, useRendererConfig as f, BANNER_NODE_KEY as g, ALERT_NODE_KEY as h, FootnoteStaticRenderer as i, RendererWrapper as l, useVariant as m, computeImageMeta as n, useFootnoteContent as o, useRendererMode as p, decodeThumbHash as r, useFootnoteDefinitions as s, KaTeXRenderer as t, createRendererDecoration as u, FOOTNOTE_NODE_KEY as v, MERMAID_NODE_KEY as w, KATEX_NODE_KEY as x, FOOTNOTE_SECTION_NODE_KEY as y };
@@ -1,5 +1,5 @@
1
- import { h as $createKaTeXInlineNode, l as $createMermaidNode, v as $createKaTeXBlockNode, x as $createImageNode } from "./theme-QqiMxW5u.js";
2
- import { t as $createAlertQuoteEditNode } from "./AlertQuoteEditNode-bJolZMh7.js";
1
+ import { h as $createKaTeXInlineNode, l as $createMermaidNode, v as $createKaTeXBlockNode, x as $createImageNode } from "./theme-DG7I1YM5.js";
2
+ import { t as $createAlertQuoteEditNode } from "./AlertQuoteEditNode-DjObnJI6.js";
3
3
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
4
4
  import { useEffect } from "react";
5
5
  import { $insertNodes, COMMAND_PRIORITY_EDITOR, createCommand } from "lexical";
@@ -71,46 +71,4 @@ function usePresentDialog() {
71
71
  return use(PresentDialogContext);
72
72
  }
73
73
  //#endregion
74
- //#region src/utils/extractPolls.ts
75
- function isPollNode(node) {
76
- return node.type === "poll";
77
- }
78
- function coercePollMetadata(node) {
79
- if (typeof node.pollId !== "string" || typeof node.question !== "string") return null;
80
- if (!Array.isArray(node.options)) return null;
81
- if (node.mode !== "single" && node.mode !== "multiple") return null;
82
- const options = node.options.filter((option) => !!option && typeof option === "object" && typeof option.id === "string" && typeof option.label === "string").map((option) => ({
83
- id: option.id,
84
- label: option.label
85
- }));
86
- return {
87
- pollId: node.pollId,
88
- question: node.question,
89
- options,
90
- mode: node.mode,
91
- ...typeof node.closeAt === "string" ? { closeAt: node.closeAt } : {},
92
- ...node.showResults === "always" || node.showResults === "after-vote" || node.showResults === "after-close" ? { showResults: node.showResults } : {}
93
- };
94
- }
95
- function walk(node, out) {
96
- if (isPollNode(node)) {
97
- const meta = coercePollMetadata(node);
98
- if (meta) out.push(meta);
99
- return;
100
- }
101
- const maybe = node;
102
- if (Array.isArray(maybe.children)) for (const child of maybe.children) walk(child, out);
103
- if (maybe.content && typeof maybe.content === "object") walkSerializedState(maybe.content, out);
104
- }
105
- function walkSerializedState(state, out) {
106
- const root = state.root;
107
- if (!root || !Array.isArray(root.children)) return;
108
- for (const child of root.children) walk(child, out);
109
- }
110
- function extractPolls(state) {
111
- const out = [];
112
- walkSerializedState(state, out);
113
- return out;
114
- }
115
- //#endregion
116
- export { useExtraNodes as a, ExtraNodesProvider as i, PresentDialogProvider as n, LinkFavicon as o, usePresentDialog as r, extractPolls as t };
74
+ export { LinkFavicon as a, useExtraNodes as i, usePresentDialog as n, ExtraNodesProvider as r, PresentDialogProvider as t };
@@ -1,9 +1,9 @@
1
- import { d as setCodeBlockCursorIntent, l as $createCodeBlockEditNode, t as getResolvedEditNodes, u as $createBannerEditNode } from "./node-registry-BmeHYCtG.js";
2
- import { A as AlertQuoteNode, E as FootnoteNode, M as extractTextContent, T as $createFootnoteNode, _ as KaTeXInlineNode, b as KaTeXBlockNode, c as SpoilerNode, f as $createMentionNode, h as $createKaTeXInlineNode, m as MentionNode, o as $createSpoilerNode, v as $createKaTeXBlockNode, w as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, x as $createImageNode } from "./theme-QqiMxW5u.js";
3
- import { a as FootnoteDefinitionsProvider, n as computeImageMeta } from "./KaTeXRenderer-CQQT3BMw.js";
1
+ import { c as setCodeBlockCursorIntent, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-D9t5vPfY.js";
2
+ import { A as AlertQuoteNode, E as FootnoteNode, M as extractTextContent, T as $createFootnoteNode, _ as KaTeXInlineNode, b as KaTeXBlockNode, c as SpoilerNode, f as $createMentionNode, h as $createKaTeXInlineNode, m as MentionNode, o as $createSpoilerNode, v as $createKaTeXBlockNode, w as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, x as $createImageNode } from "./theme-DG7I1YM5.js";
3
+ import { a as FootnoteDefinitionsProvider, n as computeImageMeta } from "./KaTeXRenderer-CqnhvDmj.js";
4
4
  import "./katex.css-CIOEOXyd.js";
5
- import { A as $createCommentPlaceholderNode, D as $createDetailsNode, E as FootnoteSectionNode, M as CommentNode, O as DetailsNode, P as CodeBlockNode, S as $isGridContainerNode, T as $isFootnoteSectionNode, V as BannerNode, a as $createRubyNode, k as $createCommentNode, s as RubyNode, w as $createFootnoteSectionNode } from "./config-CTD7-xAy.js";
6
- import { t as $createAlertQuoteEditNode } from "./AlertQuoteEditNode-bJolZMh7.js";
5
+ import { S as CommentNode, _ as $createDetailsNode, a as $createRubyNode, b as $createCommentPlaceholderNode, f as $isGridContainerNode, g as FootnoteSectionNode, h as $isFootnoteSectionNode, j as BannerNode, m as $createFootnoteSectionNode, s as RubyNode, v as DetailsNode, w as CodeBlockNode, y as $createCommentNode } from "./config-EJe68p4h.js";
6
+ import { t as $createAlertQuoteEditNode } from "./AlertQuoteEditNode-DjObnJI6.js";
7
7
  import { n as getHostname, r as probeFavicon, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-B-1wmGzd.js";
8
8
  import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
9
9
  import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
@@ -21,9 +21,9 @@ import { $convertFromMarkdownString, CHECK_LIST, CODE, QUOTE, TRANSFORMERS } fro
21
21
  import { $createTableCellNode, $createTableNode, $createTableRowNode, TableCellHeaderStates } from "@lexical/table";
22
22
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
23
  import { Check, Info, Link2, Upload } from "lucide-react";
24
+ import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
24
25
  import { nanoid } from "nanoid";
25
26
  import { ActionBar, ActionButton, Dialog, DialogPopup, DialogTitle, SegmentedControl } from "@haklex/rich-editor-ui";
26
- import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
27
27
  //#region src/plugins/AutoLinkPlugin.tsx
28
28
  var DEFAULT_MATCHERS = [createLinkMatcherWithRegExp(/https?:\/\/(?:www\.)?[\w#%+.:=@~-]{1,256}\.[A-Za-z]{2}[\w#%&()+./:=?@~-]*/), createLinkMatcherWithRegExp(/(?:[\w%+.-]+@[\d.a-z-]+\.[a-z]{2,})/i, (text) => `mailto:${text}`)];
29
29
  function AutoLinkPlugin({ matchers }) {
@@ -1,5 +1,5 @@
1
- import { M as extractTextContent, o as $createSpoilerNode, s as $isSpoilerNode, w as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND } from "./theme-QqiMxW5u.js";
2
- import { i as INSERT_KATEX_INLINE_COMMAND, l as INSERT_ALERT_COMMAND, o as INSERT_IMAGE_COMMAND, r as INSERT_KATEX_BLOCK_COMMAND, t as INSERT_MERMAID_COMMAND } from "./MermaidPlugin-BRyrtUBj.js";
1
+ import { M as extractTextContent, o as $createSpoilerNode, s as $isSpoilerNode, w as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND } from "./theme-DG7I1YM5.js";
2
+ import { i as INSERT_KATEX_INLINE_COMMAND, l as INSERT_ALERT_COMMAND, o as INSERT_IMAGE_COMMAND, r as INSERT_KATEX_BLOCK_COMMAND, t as INSERT_MERMAID_COMMAND } from "./MermaidPlugin-_gPgU34D.js";
3
3
  import { $createTextNode, $getSelection, $isRangeSelection } from "lexical";
4
4
  //#region src/utils/collect-command-items.ts
5
5
  function collectCommandItems(editor) {
@@ -11,8 +11,13 @@ export type RendererWrapperProps = {
11
11
  [K in RendererKey]-?: {
12
12
  /** Name of the renderer in RendererConfig */
13
13
  rendererKey: K;
14
- /** Default renderer component */
15
- defaultRenderer: RendererComponentByKey[K];
14
+ /**
15
+ * Default renderer component. Optional — when omitted, the slot resolves
16
+ * via RendererConfig context only. If neither override nor default exists
17
+ * the wrapper renders `null`. Omit it from extension nodes that want the
18
+ * heavy default renderer to remain tree-shakable.
19
+ */
20
+ defaultRenderer?: RendererComponentByKey[K];
16
21
  /** Props to pass to the renderer */
17
22
  props: RendererPropsByKey[K];
18
23
  };
@@ -21,11 +26,16 @@ export type RendererWrapperProps = {
21
26
  * Wrapper component that allows overriding default renderers with custom ones.
22
27
  * Uses RendererConfig from context to determine which renderer to use.
23
28
  */
24
- export declare function RendererWrapper({ rendererKey, defaultRenderer: DefaultRenderer, props, }: RendererWrapperProps): import("react").JSX.Element;
29
+ export declare function RendererWrapper({ rendererKey, defaultRenderer, props }: RendererWrapperProps): import("react").JSX.Element | null;
25
30
  /**
26
31
  * Type-safe helper for creating RendererWrapper elements from .ts node files.
27
32
  * Avoids the createElement + discriminated-union typing limitation.
33
+ *
34
+ * `defaultRenderer` is optional. Pass `undefined` from extension node classes
35
+ * that should not statically import their renderer; the heavy default lives
36
+ * in a separate sub-path and is registered into RendererConfig at compose
37
+ * time, keeping the node bundle light.
28
38
  */
29
- export declare function createRendererDecoration<K extends RendererKey>(rendererKey: K, defaultRenderer: RendererComponentByKey[K], props: RendererPropsByKey[K]): ReactElement;
39
+ export declare function createRendererDecoration<K extends RendererKey>(rendererKey: K, defaultRenderer: RendererComponentByKey[K] | undefined, props: RendererPropsByKey[K]): ReactElement;
30
40
  export {};
31
41
  //# sourceMappingURL=RendererWrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RendererWrapper.d.ts","sourceRoot":"","sources":["../../src/components/RendererWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAIxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,MAAM,MAAM,WAAW,GAAG,MAAM,cAAc,CAAA;AAE9C,KAAK,kBAAkB,GAAG;KACvB,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,CACxE,MAAM,CAAC,SAAS,MAAM,CACvB,GACG,CAAC,GACD,KAAK;CACV,CAAA;AAED,KAAK,sBAAsB,GAAG;KAC3B,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG,WAAW,CAC/B,cAAc,CAAC,CAAC,CAAC,CAClB,SAAS,aAAa,CAAC,GAAG,CAAC,GACxB,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAC9B,KAAK;CACV,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG;QACpB,6CAA6C;QAC7C,WAAW,EAAE,CAAC,CAAA;QACd,iCAAiC;QACjC,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAA;QAC1C,oCAAoC;QACpC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;KAC7B;CACF,CAAC,WAAW,CAAC,CAAA;AAEd;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,eAAe,EAAE,eAAe,EAChC,KAAK,GACN,EAAE,oBAAoB,+BAKtB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,WAAW,EAC5D,WAAW,EAAE,CAAC,EACd,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAC1C,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B,YAAY,CAMd"}
1
+ {"version":3,"file":"RendererWrapper.d.ts","sourceRoot":"","sources":["../../src/components/RendererWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC;AAE/C,KAAK,kBAAkB,GAAG;KACvB,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,GAC9F,CAAC,GACD,KAAK;CACV,CAAC;AAEF,KAAK,sBAAsB,GAAG;KAC3B,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,GAC3E,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAC9B,KAAK;CACV,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG;QACpB,6CAA6C;QAC7C,WAAW,EAAE,CAAC,CAAC;QACf;;;;;WAKG;QACH,eAAe,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAC5C,oCAAoC;QACpC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;KAC9B;CACF,CAAC,WAAW,CAAC,CAAC;AAEf;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,oBAAoB,sCAO5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,WAAW,EAC5D,WAAW,EAAE,CAAC,EACd,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,SAAS,EACtD,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B,YAAY,CAMd"}
@@ -1 +1 @@
1
- {"version":3,"file":"AlertEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/AlertEditDecorator.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAe7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA0H5D,UAAU,uBAAuB;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,uBAAuB,+BA+ChG"}
1
+ {"version":3,"file":"AlertEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/AlertEditDecorator.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAe7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA2H5D,UAAU,uBAAuB;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,uBAAuB,+BA+ChG"}
@@ -1 +1 @@
1
- {"version":3,"file":"BannerEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/BannerEditDecorator.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,UAAU,wBAAwB;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,UAAU,EACV,aAAa,GACd,EAAE,wBAAwB,+BA8C1B"}
1
+ {"version":3,"file":"BannerEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/BannerEditDecorator.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMzD,UAAU,wBAAwB;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,UAAU,EACV,aAAa,GACd,EAAE,wBAAwB,+BA8C1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlockEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/CodeBlockEditDecorator.tsx"],"names":[],"mappings":"AAsBA,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,2BAA2B,+BA2K9F"}
1
+ {"version":3,"file":"CodeBlockEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/CodeBlockEditDecorator.tsx"],"names":[],"mappings":"AAuBA,UAAU,2BAA2B;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,2BAA2B,+BA2K9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"AlertStaticDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/AlertStaticDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI5D,UAAU,yBAAyB;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,yBAAyB,+BAa1F"}
1
+ {"version":3,"file":"AlertStaticDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/AlertStaticDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAK5D,UAAU,yBAAyB;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,yBAAyB,+BAa1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"BannerStaticDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/BannerStaticDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,UAAU,0BAA0B;IAClC,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED,wBAAgB,qBAAqB,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,0BAA0B,+BAa7F"}
1
+ {"version":3,"file":"BannerStaticDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/BannerStaticDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,UAAU,0BAA0B;IAClC,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED,wBAAgB,qBAAqB,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,0BAA0B,+BAa7F"}