@haklex/rich-headless 0.1.1 → 0.3.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.
package/dist/index.mjs CHANGED
@@ -1,480 +1,480 @@
1
- import { CodeNode, CodeHighlightNode } from "@lexical/code-core";
1
+ import { $toMarkdown, allHeadlessTransformers } from "./transformers.mjs";
2
+ import { CodeHighlightNode, CodeNode } from "@lexical/code-core";
2
3
  import { HorizontalRuleNode } from "@lexical/extension";
3
- import { LinkNode, AutoLinkNode } from "@lexical/link";
4
- import { ListNode, ListItemNode } from "@lexical/list";
4
+ import { AutoLinkNode, LinkNode } from "@lexical/link";
5
+ import { ListItemNode, ListNode } from "@lexical/list";
5
6
  import { HeadingNode, QuoteNode } from "@lexical/rich-text";
6
- import { TableNode, TableCellNode, TableRowNode } from "@lexical/table";
7
+ import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
7
8
  import { DecoratorNode, ElementNode } from "lexical";
8
- import { $toMarkdown, allHeadlessTransformers } from "./transformers.mjs";
9
- const builtinNodes = [
10
- HeadingNode,
11
- QuoteNode,
12
- ListNode,
13
- ListItemNode,
14
- LinkNode,
15
- AutoLinkNode,
16
- HorizontalRuleNode,
17
- TableNode,
18
- TableCellNode,
19
- TableRowNode,
20
- CodeNode,
21
- CodeHighlightNode
9
+ //#region src/index.ts
10
+ /**
11
+ * @haklex/rich-headless
12
+ *
13
+ * Headless-compatible Lexical node registry for server-side parsing.
14
+ * Zero React dependency — only lexical + standard @lexical/* packages.
15
+ *
16
+ * Usage with @lexical/headless:
17
+ * import { createHeadlessEditor } from '@lexical/headless'
18
+ * import { allHeadlessNodes } from '@haklex/rich-headless'
19
+ * const editor = createHeadlessEditor({ nodes: allHeadlessNodes })
20
+ */
21
+ var builtinNodes = [
22
+ HeadingNode,
23
+ QuoteNode,
24
+ ListNode,
25
+ ListItemNode,
26
+ LinkNode,
27
+ AutoLinkNode,
28
+ HorizontalRuleNode,
29
+ TableNode,
30
+ TableCellNode,
31
+ TableRowNode,
32
+ CodeNode,
33
+ CodeHighlightNode
22
34
  ];
23
35
  function stubDOM() {
24
- return document.createElement("span");
36
+ return document.createElement("span");
25
37
  }
26
38
  function extractText(state) {
27
- if (!state || typeof state !== "object") return "";
28
- const root = state.root;
29
- if (!root) return "";
30
- return walkChildren(root);
39
+ if (!state || typeof state !== "object") return "";
40
+ const root = state.root;
41
+ if (!root) return "";
42
+ return walkChildren(root);
31
43
  }
32
44
  function walkChildren(node) {
33
- const children = node.children;
34
- if (!children) return node.text ?? "";
35
- return children.map(walkChildren).join("\n");
36
- }
37
- class SpoilerNode extends ElementNode {
38
- static getType() {
39
- return "spoiler";
40
- }
41
- static clone(node) {
42
- return new SpoilerNode(node.__key);
43
- }
44
- constructor(key) {
45
- super(key);
46
- }
47
- static importJSON(_json) {
48
- return new SpoilerNode();
49
- }
50
- exportJSON() {
51
- return { ...super.exportJSON(), type: "spoiler", version: 1 };
52
- }
53
- createDOM() {
54
- return stubDOM();
55
- }
56
- updateDOM() {
57
- return false;
58
- }
59
- isInline() {
60
- return true;
61
- }
62
- }
63
- class RubyNode extends ElementNode {
64
- constructor(key) {
65
- super(key);
66
- this.__reading = "";
67
- }
68
- static getType() {
69
- return "ruby";
70
- }
71
- static clone(node) {
72
- const n = new RubyNode(node.__key);
73
- n.__reading = node.__reading;
74
- return n;
75
- }
76
- static importJSON(json) {
77
- const node = new RubyNode();
78
- node.__reading = json.reading ?? "";
79
- return node;
80
- }
81
- exportJSON() {
82
- return {
83
- ...super.exportJSON(),
84
- type: "ruby",
85
- reading: this.__reading,
86
- version: 1
87
- };
88
- }
89
- createDOM() {
90
- return stubDOM();
91
- }
92
- updateDOM() {
93
- return false;
94
- }
95
- isInline() {
96
- return true;
97
- }
98
- }
99
- class DetailsNode extends ElementNode {
100
- constructor(key) {
101
- super(key);
102
- this.__summary = "";
103
- this.__open = false;
104
- }
105
- static getType() {
106
- return "details";
107
- }
108
- static clone(node) {
109
- const n = new DetailsNode(node.__key);
110
- n.__summary = node.__summary;
111
- n.__open = node.__open;
112
- return n;
113
- }
114
- static importJSON(json) {
115
- const node = new DetailsNode();
116
- node.__summary = json.summary ?? "";
117
- node.__open = json.open ?? false;
118
- return node;
119
- }
120
- exportJSON() {
121
- return {
122
- ...super.exportJSON(),
123
- type: "details",
124
- summary: this.__summary,
125
- open: this.__open
126
- };
127
- }
128
- createDOM() {
129
- return stubDOM();
130
- }
131
- updateDOM() {
132
- return false;
133
- }
45
+ const children = node.children;
46
+ if (!children) return node.text ?? "";
47
+ return children.map(walkChildren).join("\n");
134
48
  }
49
+ var SpoilerNode = class SpoilerNode extends ElementNode {
50
+ static getType() {
51
+ return "spoiler";
52
+ }
53
+ static clone(node) {
54
+ return new SpoilerNode(node.__key);
55
+ }
56
+ constructor(key) {
57
+ super(key);
58
+ }
59
+ static importJSON(_json) {
60
+ return new SpoilerNode();
61
+ }
62
+ exportJSON() {
63
+ return {
64
+ ...super.exportJSON(),
65
+ type: "spoiler",
66
+ version: 1
67
+ };
68
+ }
69
+ createDOM() {
70
+ return stubDOM();
71
+ }
72
+ updateDOM() {
73
+ return false;
74
+ }
75
+ isInline() {
76
+ return true;
77
+ }
78
+ };
79
+ var RubyNode = class RubyNode extends ElementNode {
80
+ static getType() {
81
+ return "ruby";
82
+ }
83
+ static clone(node) {
84
+ const n = new RubyNode(node.__key);
85
+ n.__reading = node.__reading;
86
+ return n;
87
+ }
88
+ constructor(key) {
89
+ super(key);
90
+ this.__reading = "";
91
+ }
92
+ static importJSON(json) {
93
+ const node = new RubyNode();
94
+ node.__reading = json.reading ?? "";
95
+ return node;
96
+ }
97
+ exportJSON() {
98
+ return {
99
+ ...super.exportJSON(),
100
+ type: "ruby",
101
+ reading: this.__reading,
102
+ version: 1
103
+ };
104
+ }
105
+ createDOM() {
106
+ return stubDOM();
107
+ }
108
+ updateDOM() {
109
+ return false;
110
+ }
111
+ isInline() {
112
+ return true;
113
+ }
114
+ };
115
+ var DetailsNode = class DetailsNode extends ElementNode {
116
+ static getType() {
117
+ return "details";
118
+ }
119
+ static clone(node) {
120
+ const n = new DetailsNode(node.__key);
121
+ n.__summary = node.__summary;
122
+ n.__open = node.__open;
123
+ return n;
124
+ }
125
+ constructor(key) {
126
+ super(key);
127
+ this.__summary = "";
128
+ this.__open = false;
129
+ }
130
+ static importJSON(json) {
131
+ const node = new DetailsNode();
132
+ node.__summary = json.summary ?? "";
133
+ node.__open = json.open ?? false;
134
+ return node;
135
+ }
136
+ exportJSON() {
137
+ return {
138
+ ...super.exportJSON(),
139
+ type: "details",
140
+ summary: this.__summary,
141
+ open: this.__open
142
+ };
143
+ }
144
+ createDOM() {
145
+ return stubDOM();
146
+ }
147
+ updateDOM() {
148
+ return false;
149
+ }
150
+ };
135
151
  function headlessDecorator(type, propKeys, defaults, inline = false) {
136
- class Node extends DecoratorNode {
137
- constructor(key) {
138
- super(key);
139
- for (const k of propKeys) {
140
- this[`__${k}`] = defaults[k];
141
- }
142
- }
143
- static getType() {
144
- return type;
145
- }
146
- static clone(node) {
147
- const n = new Node(node.__key);
148
- for (const k of propKeys) {
149
- n[`__${k}`] = node[`__${k}`];
150
- }
151
- return n;
152
- }
153
- static importJSON(json) {
154
- const node = new Node();
155
- for (const k of propKeys) {
156
- node[`__${k}`] = json[k] ?? defaults[k];
157
- }
158
- return node;
159
- }
160
- exportJSON() {
161
- const out = { type, version: 1 };
162
- for (const k of propKeys) {
163
- out[k] = this[`__${k}`];
164
- }
165
- return out;
166
- }
167
- createDOM(_config) {
168
- return stubDOM();
169
- }
170
- updateDOM() {
171
- return false;
172
- }
173
- decorate(_editor, _config) {
174
- return null;
175
- }
176
- isInline() {
177
- return inline;
178
- }
179
- }
180
- return Node;
152
+ class Node extends DecoratorNode {
153
+ constructor(key) {
154
+ super(key);
155
+ for (const k of propKeys) this[`__${k}`] = defaults[k];
156
+ }
157
+ static getType() {
158
+ return type;
159
+ }
160
+ static clone(node) {
161
+ const n = new Node(node.__key);
162
+ for (const k of propKeys) n[`__${k}`] = node[`__${k}`];
163
+ return n;
164
+ }
165
+ static importJSON(json) {
166
+ const node = new Node();
167
+ for (const k of propKeys) node[`__${k}`] = json[k] ?? defaults[k];
168
+ return node;
169
+ }
170
+ exportJSON() {
171
+ const out = {
172
+ type,
173
+ version: 1
174
+ };
175
+ for (const k of propKeys) out[k] = this[`__${k}`];
176
+ return out;
177
+ }
178
+ createDOM(_config) {
179
+ return stubDOM();
180
+ }
181
+ updateDOM() {
182
+ return false;
183
+ }
184
+ decorate(_editor, _config) {
185
+ return null;
186
+ }
187
+ isInline() {
188
+ return inline;
189
+ }
190
+ }
191
+ return Node;
181
192
  }
182
- const ImageNode = headlessDecorator(
183
- "image",
184
- ["src", "altText", "width", "height", "caption", "thumbhash", "accent"],
185
- {
186
- src: "",
187
- altText: "",
188
- width: void 0,
189
- height: void 0,
190
- caption: void 0,
191
- thumbhash: void 0,
192
- accent: void 0
193
- }
194
- );
195
- const VideoNode = headlessDecorator("video", ["src", "poster", "width", "height"], {
196
- src: "",
197
- poster: void 0,
198
- width: void 0,
199
- height: void 0
200
- });
201
- const LinkCardNode = headlessDecorator(
202
- "link-card",
203
- ["url", "source", "id", "title", "description", "favicon", "image"],
204
- {
205
- url: "",
206
- source: void 0,
207
- id: void 0,
208
- title: void 0,
209
- description: void 0,
210
- favicon: void 0,
211
- image: void 0
212
- }
213
- );
214
- const KaTeXInlineNode = headlessDecorator(
215
- "katex-inline",
216
- ["equation"],
217
- { equation: "" },
218
- true
219
- );
220
- const KaTeXBlockNode = headlessDecorator("katex-block", ["equation"], {
221
- equation: ""
222
- });
223
- const MermaidNode = headlessDecorator("mermaid", ["diagram"], {
224
- diagram: ""
193
+ var ImageNode = headlessDecorator("image", [
194
+ "src",
195
+ "altText",
196
+ "width",
197
+ "height",
198
+ "caption",
199
+ "thumbhash",
200
+ "accent"
201
+ ], {
202
+ src: "",
203
+ altText: "",
204
+ width: void 0,
205
+ height: void 0,
206
+ caption: void 0,
207
+ thumbhash: void 0,
208
+ accent: void 0
225
209
  });
226
- const MentionNode = headlessDecorator(
227
- "mention",
228
- ["platform", "handle", "displayName"],
229
- { platform: "", handle: "", displayName: void 0 },
230
- true
231
- );
232
- const CodeBlockNode = headlessDecorator("code-block", ["code", "language"], {
233
- code: "",
234
- language: ""
210
+ var VideoNode = headlessDecorator("video", [
211
+ "src",
212
+ "poster",
213
+ "width",
214
+ "height"
215
+ ], {
216
+ src: "",
217
+ poster: void 0,
218
+ width: void 0,
219
+ height: void 0
235
220
  });
236
- const FootnoteNode = headlessDecorator("footnote", ["identifier"], { identifier: "" }, true);
237
- const FootnoteSectionNode = headlessDecorator("footnote-section", ["definitions"], {
238
- definitions: {}
221
+ var LinkCardNode = headlessDecorator("link-card", [
222
+ "url",
223
+ "source",
224
+ "id",
225
+ "title",
226
+ "description",
227
+ "favicon",
228
+ "image"
229
+ ], {
230
+ url: "",
231
+ source: void 0,
232
+ id: void 0,
233
+ title: void 0,
234
+ description: void 0,
235
+ favicon: void 0,
236
+ image: void 0
239
237
  });
240
- const EmbedNode = headlessDecorator("embed", ["url", "source"], {
241
- url: "",
242
- source: null
238
+ var KaTeXInlineNode = headlessDecorator("katex-inline", ["equation"], { equation: "" }, true);
239
+ var KaTeXBlockNode = headlessDecorator("katex-block", ["equation"], { equation: "" });
240
+ var MermaidNode = headlessDecorator("mermaid", ["diagram"], { diagram: "" });
241
+ var MentionNode = headlessDecorator("mention", [
242
+ "platform",
243
+ "handle",
244
+ "displayName"
245
+ ], {
246
+ platform: "",
247
+ handle: "",
248
+ displayName: void 0
249
+ }, true);
250
+ var CodeBlockNode = headlessDecorator("code-block", ["code", "language"], {
251
+ code: "",
252
+ language: ""
243
253
  });
244
- const CodeSnippetNode = headlessDecorator("code-snippet", ["files"], {
245
- files: []
254
+ var FootnoteNode = headlessDecorator("footnote", ["identifier"], { identifier: "" }, true);
255
+ var FootnoteSectionNode = headlessDecorator("footnote-section", ["definitions"], { definitions: {} });
256
+ var EmbedNode = headlessDecorator("embed", ["url", "source"], {
257
+ url: "",
258
+ source: null
246
259
  });
247
- const GalleryNode = headlessDecorator("gallery", ["images", "layout"], {
248
- images: [],
249
- layout: "grid"
260
+ var CodeSnippetNode = headlessDecorator("code-snippet", ["files"], { files: [] });
261
+ var GalleryNode = headlessDecorator("gallery", ["images", "layout"], {
262
+ images: [],
263
+ layout: "grid"
250
264
  });
251
- const ExcalidrawNode = headlessDecorator("excalidraw", ["snapshot"], {
252
- snapshot: ""
265
+ var ExcalidrawNode = headlessDecorator("excalidraw", ["snapshot"], { snapshot: "" });
266
+ var TagNode = headlessDecorator("tag", ["text"], { text: "" }, true);
267
+ var CommentNode = headlessDecorator("comment", ["text"], { text: "" }, true);
268
+ var PollNode = headlessDecorator("poll", [
269
+ "pollId",
270
+ "question",
271
+ "options",
272
+ "mode",
273
+ "closeAt",
274
+ "showResults"
275
+ ], {
276
+ pollId: "",
277
+ question: "",
278
+ options: [],
279
+ mode: "single",
280
+ closeAt: void 0,
281
+ showResults: void 0
253
282
  });
254
- const TagNode = headlessDecorator("tag", ["text"], { text: "" }, true);
255
- const CommentNode = headlessDecorator("comment", ["text"], { text: "" }, true);
256
- class BannerNode extends DecoratorNode {
257
- constructor(key) {
258
- super(key);
259
- this.__bannerType = "note";
260
- this.__contentState = null;
261
- }
262
- static getType() {
263
- return "banner";
264
- }
265
- static clone(node) {
266
- const n = new BannerNode(node.__key);
267
- n.__bannerType = node.__bannerType;
268
- n.__contentState = node.__contentState;
269
- return n;
270
- }
271
- static importJSON(json) {
272
- const node = new BannerNode();
273
- node.__bannerType = json.bannerType ?? "note";
274
- node.__contentState = json.content ?? null;
275
- return node;
276
- }
277
- exportJSON() {
278
- return {
279
- type: "banner",
280
- version: 1,
281
- bannerType: this.__bannerType,
282
- content: this.__contentState
283
- };
284
- }
285
- createDOM() {
286
- return stubDOM();
287
- }
288
- updateDOM() {
289
- return false;
290
- }
291
- decorate() {
292
- return null;
293
- }
294
- getTextContent() {
295
- return extractText(this.__contentState);
296
- }
297
- }
298
- class AlertQuoteNode extends DecoratorNode {
299
- constructor(key) {
300
- super(key);
301
- this.__alertType = "note";
302
- this.__contentState = null;
303
- }
304
- static getType() {
305
- return "alert-quote";
306
- }
307
- static clone(node) {
308
- const n = new AlertQuoteNode(node.__key);
309
- n.__alertType = node.__alertType;
310
- n.__contentState = node.__contentState;
311
- return n;
312
- }
313
- static importJSON(json) {
314
- const node = new AlertQuoteNode();
315
- node.__alertType = json.alertType ?? "note";
316
- node.__contentState = json.content ?? null;
317
- return node;
318
- }
319
- exportJSON() {
320
- return {
321
- type: "alert-quote",
322
- version: 1,
323
- alertType: this.__alertType,
324
- content: this.__contentState
325
- };
326
- }
327
- createDOM() {
328
- return stubDOM();
329
- }
330
- updateDOM() {
331
- return false;
332
- }
333
- decorate() {
334
- return null;
335
- }
336
- getTextContent() {
337
- return extractText(this.__contentState);
338
- }
339
- }
340
- class NestedDocNode extends DecoratorNode {
341
- constructor(key) {
342
- super(key);
343
- this.__contentState = null;
344
- }
345
- static getType() {
346
- return "nested-doc";
347
- }
348
- static clone(node) {
349
- const n = new NestedDocNode(node.__key);
350
- n.__contentState = node.__contentState;
351
- return n;
352
- }
353
- static importJSON(json) {
354
- const node = new NestedDocNode();
355
- node.__contentState = json.content ?? null;
356
- return node;
357
- }
358
- exportJSON() {
359
- return {
360
- type: "nested-doc",
361
- version: 1,
362
- content: this.__contentState
363
- };
364
- }
365
- createDOM() {
366
- return stubDOM();
367
- }
368
- updateDOM() {
369
- return false;
370
- }
371
- decorate() {
372
- return null;
373
- }
374
- getTextContent() {
375
- return extractText(this.__contentState);
376
- }
377
- }
378
- class GridContainerNode extends DecoratorNode {
379
- constructor(key) {
380
- super(key);
381
- this.__cols = 2;
382
- this.__gap = "16px";
383
- this.__cells = [];
384
- }
385
- static getType() {
386
- return "grid-container";
387
- }
388
- static clone(node) {
389
- const n = new GridContainerNode(node.__key);
390
- n.__cols = node.__cols;
391
- n.__gap = node.__gap;
392
- n.__cells = node.__cells;
393
- return n;
394
- }
395
- static importJSON(json) {
396
- const node = new GridContainerNode();
397
- node.__cols = json.cols ?? 2;
398
- const rawGap = json.gap;
399
- node.__gap = typeof rawGap === "number" ? `${rawGap}px` : rawGap ?? "16px";
400
- node.__cells = json.cells ?? [];
401
- return node;
402
- }
403
- exportJSON() {
404
- return {
405
- type: "grid-container",
406
- version: 1,
407
- cols: this.__cols,
408
- gap: this.__gap,
409
- cells: this.__cells
410
- };
411
- }
412
- createDOM() {
413
- return stubDOM();
414
- }
415
- updateDOM() {
416
- return false;
417
- }
418
- decorate() {
419
- return null;
420
- }
421
- getTextContent() {
422
- return this.__cells.map((cell) => extractText(cell)).join("\n");
423
- }
424
- }
425
- const customHeadlessNodes = [
426
- SpoilerNode,
427
- RubyNode,
428
- DetailsNode,
429
- ImageNode,
430
- VideoNode,
431
- LinkCardNode,
432
- KaTeXInlineNode,
433
- KaTeXBlockNode,
434
- MermaidNode,
435
- MentionNode,
436
- CodeBlockNode,
437
- FootnoteNode,
438
- FootnoteSectionNode,
439
- EmbedNode,
440
- CodeSnippetNode,
441
- GalleryNode,
442
- ExcalidrawNode,
443
- TagNode,
444
- CommentNode,
445
- BannerNode,
446
- AlertQuoteNode,
447
- NestedDocNode,
448
- GridContainerNode
449
- ];
450
- const allHeadlessNodes = [...builtinNodes, ...customHeadlessNodes];
451
- export {
452
- $toMarkdown,
453
- AlertQuoteNode,
454
- BannerNode,
455
- CodeBlockNode,
456
- CodeSnippetNode,
457
- CommentNode,
458
- DetailsNode,
459
- EmbedNode,
460
- ExcalidrawNode,
461
- FootnoteNode,
462
- FootnoteSectionNode,
463
- GalleryNode,
464
- GridContainerNode,
465
- ImageNode,
466
- KaTeXBlockNode,
467
- KaTeXInlineNode,
468
- LinkCardNode,
469
- MentionNode,
470
- MermaidNode,
471
- NestedDocNode,
472
- RubyNode,
473
- SpoilerNode,
474
- TagNode,
475
- VideoNode,
476
- allHeadlessNodes,
477
- allHeadlessTransformers,
478
- builtinNodes,
479
- customHeadlessNodes
283
+ var BannerNode = class BannerNode extends DecoratorNode {
284
+ static getType() {
285
+ return "banner";
286
+ }
287
+ constructor(key) {
288
+ super(key);
289
+ this.__bannerType = "note";
290
+ this.__contentState = null;
291
+ }
292
+ static clone(node) {
293
+ const n = new BannerNode(node.__key);
294
+ n.__bannerType = node.__bannerType;
295
+ n.__contentState = node.__contentState;
296
+ return n;
297
+ }
298
+ static importJSON(json) {
299
+ const node = new BannerNode();
300
+ node.__bannerType = json.bannerType ?? "note";
301
+ node.__contentState = json.content ?? null;
302
+ return node;
303
+ }
304
+ exportJSON() {
305
+ return {
306
+ type: "banner",
307
+ version: 1,
308
+ bannerType: this.__bannerType,
309
+ content: this.__contentState
310
+ };
311
+ }
312
+ createDOM() {
313
+ return stubDOM();
314
+ }
315
+ updateDOM() {
316
+ return false;
317
+ }
318
+ decorate() {
319
+ return null;
320
+ }
321
+ getTextContent() {
322
+ return extractText(this.__contentState);
323
+ }
480
324
  };
325
+ var AlertQuoteNode = class AlertQuoteNode extends DecoratorNode {
326
+ static getType() {
327
+ return "alert-quote";
328
+ }
329
+ constructor(key) {
330
+ super(key);
331
+ this.__alertType = "note";
332
+ this.__contentState = null;
333
+ }
334
+ static clone(node) {
335
+ const n = new AlertQuoteNode(node.__key);
336
+ n.__alertType = node.__alertType;
337
+ n.__contentState = node.__contentState;
338
+ return n;
339
+ }
340
+ static importJSON(json) {
341
+ const node = new AlertQuoteNode();
342
+ node.__alertType = json.alertType ?? "note";
343
+ node.__contentState = json.content ?? null;
344
+ return node;
345
+ }
346
+ exportJSON() {
347
+ return {
348
+ type: "alert-quote",
349
+ version: 1,
350
+ alertType: this.__alertType,
351
+ content: this.__contentState
352
+ };
353
+ }
354
+ createDOM() {
355
+ return stubDOM();
356
+ }
357
+ updateDOM() {
358
+ return false;
359
+ }
360
+ decorate() {
361
+ return null;
362
+ }
363
+ getTextContent() {
364
+ return extractText(this.__contentState);
365
+ }
366
+ };
367
+ var NestedDocNode = class NestedDocNode extends DecoratorNode {
368
+ static getType() {
369
+ return "nested-doc";
370
+ }
371
+ constructor(key) {
372
+ super(key);
373
+ this.__contentState = null;
374
+ }
375
+ static clone(node) {
376
+ const n = new NestedDocNode(node.__key);
377
+ n.__contentState = node.__contentState;
378
+ return n;
379
+ }
380
+ static importJSON(json) {
381
+ const node = new NestedDocNode();
382
+ node.__contentState = json.content ?? null;
383
+ return node;
384
+ }
385
+ exportJSON() {
386
+ return {
387
+ type: "nested-doc",
388
+ version: 1,
389
+ content: this.__contentState
390
+ };
391
+ }
392
+ createDOM() {
393
+ return stubDOM();
394
+ }
395
+ updateDOM() {
396
+ return false;
397
+ }
398
+ decorate() {
399
+ return null;
400
+ }
401
+ getTextContent() {
402
+ return extractText(this.__contentState);
403
+ }
404
+ };
405
+ var GridContainerNode = class GridContainerNode extends DecoratorNode {
406
+ static getType() {
407
+ return "grid-container";
408
+ }
409
+ constructor(key) {
410
+ super(key);
411
+ this.__cols = 2;
412
+ this.__gap = "16px";
413
+ this.__cells = [];
414
+ }
415
+ static clone(node) {
416
+ const n = new GridContainerNode(node.__key);
417
+ n.__cols = node.__cols;
418
+ n.__gap = node.__gap;
419
+ n.__cells = node.__cells;
420
+ return n;
421
+ }
422
+ static importJSON(json) {
423
+ const node = new GridContainerNode();
424
+ node.__cols = json.cols ?? 2;
425
+ const rawGap = json.gap;
426
+ node.__gap = typeof rawGap === "number" ? `${rawGap}px` : rawGap ?? "16px";
427
+ node.__cells = json.cells ?? [];
428
+ return node;
429
+ }
430
+ exportJSON() {
431
+ return {
432
+ type: "grid-container",
433
+ version: 1,
434
+ cols: this.__cols,
435
+ gap: this.__gap,
436
+ cells: this.__cells
437
+ };
438
+ }
439
+ createDOM() {
440
+ return stubDOM();
441
+ }
442
+ updateDOM() {
443
+ return false;
444
+ }
445
+ decorate() {
446
+ return null;
447
+ }
448
+ getTextContent() {
449
+ return this.__cells.map((cell) => extractText(cell)).join("\n");
450
+ }
451
+ };
452
+ var customHeadlessNodes = [
453
+ SpoilerNode,
454
+ RubyNode,
455
+ DetailsNode,
456
+ ImageNode,
457
+ VideoNode,
458
+ LinkCardNode,
459
+ KaTeXInlineNode,
460
+ KaTeXBlockNode,
461
+ MermaidNode,
462
+ MentionNode,
463
+ CodeBlockNode,
464
+ FootnoteNode,
465
+ FootnoteSectionNode,
466
+ EmbedNode,
467
+ CodeSnippetNode,
468
+ GalleryNode,
469
+ ExcalidrawNode,
470
+ TagNode,
471
+ CommentNode,
472
+ BannerNode,
473
+ AlertQuoteNode,
474
+ NestedDocNode,
475
+ GridContainerNode,
476
+ PollNode
477
+ ];
478
+ var allHeadlessNodes = [...builtinNodes, ...customHeadlessNodes];
479
+ //#endregion
480
+ export { $toMarkdown, AlertQuoteNode, BannerNode, CodeBlockNode, CodeSnippetNode, CommentNode, DetailsNode, EmbedNode, ExcalidrawNode, FootnoteNode, FootnoteSectionNode, GalleryNode, GridContainerNode, ImageNode, KaTeXBlockNode, KaTeXInlineNode, LinkCardNode, MentionNode, MermaidNode, NestedDocNode, PollNode, RubyNode, SpoilerNode, TagNode, VideoNode, allHeadlessNodes, allHeadlessTransformers, builtinNodes, customHeadlessNodes };