@nexo-labs/payload-lexical-blocks-builder 1.0.2 → 1.4.1

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.
@@ -0,0 +1,2241 @@
1
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/nodes/LexicalElementNode.d.ts
2
+
3
+ type SerializedElementNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<{
4
+ children: Array<T>;
5
+ direction: 'ltr' | 'rtl' | null;
6
+ format: ElementFormatType;
7
+ indent: number;
8
+ textFormat?: number;
9
+ textStyle?: string;
10
+ }, SerializedLexicalNode>;
11
+ type ElementFormatType = 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
12
+ interface ElementNode {
13
+ getTopLevelElement(): ElementNode | null;
14
+ getTopLevelElementOrThrow(): ElementNode;
15
+ }
16
+ /**
17
+ * A utility class for managing the DOM children of an ElementNode
18
+ */
19
+ declare class ElementDOMSlot<T extends HTMLElement = HTMLElement> {
20
+ readonly element: T;
21
+ readonly before: Node | null;
22
+ readonly after: Node | null;
23
+ constructor(/** The element returned by createDOM */
24
+ element: T, /** All managed children will be inserted before this node, if defined */
25
+ before?: Node | undefined | null, /** All managed children will be inserted after this node, if defined */
26
+ after?: Node | undefined | null);
27
+ /**
28
+ * Return a new ElementDOMSlot where all managed children will be inserted before this node
29
+ */
30
+ withBefore(before: Node | undefined | null): ElementDOMSlot<T>;
31
+ /**
32
+ * Return a new ElementDOMSlot where all managed children will be inserted after this node
33
+ */
34
+ withAfter(after: Node | undefined | null): ElementDOMSlot<T>;
35
+ /**
36
+ * Return a new ElementDOMSlot with an updated root element
37
+ */
38
+ withElement<ElementType extends HTMLElement>(element: ElementType): ElementDOMSlot<ElementType>;
39
+ /**
40
+ * Insert the given child before this.before and any reconciler managed line break node,
41
+ * or append it if this.before is not defined
42
+ */
43
+ insertChild(dom: Node): this;
44
+ /**
45
+ * Remove the managed child from this container, will throw if it was not already there
46
+ */
47
+ removeChild(dom: Node): this;
48
+ /**
49
+ * Replace managed child prevDom with dom. Will throw if prevDom is not a child
50
+ *
51
+ * @param dom The new node to replace prevDom
52
+ * @param prevDom the node that will be replaced
53
+ */
54
+ replaceChild(dom: Node, prevDom: Node): this;
55
+ /**
56
+ * Returns the first managed child of this node,
57
+ * which will either be this.after.nextSibling or this.element.firstChild,
58
+ * and will never be this.before if it is defined.
59
+ */
60
+ getFirstChild(): ChildNode | null;
61
+ /**
62
+ * @internal
63
+ */
64
+ getManagedLineBreak(): Exclude<LexicalPrivateDOM['__lexicalLineBreak'], undefined>;
65
+ /** @internal */
66
+ setManagedLineBreak(lineBreakType: null | 'empty' | 'line-break' | 'decorator'): void;
67
+ /** @internal */
68
+ removeManagedLineBreak(): void;
69
+ /** @internal */
70
+ insertManagedLineBreak(webkitHack: boolean): void;
71
+ /**
72
+ * @internal
73
+ *
74
+ * Returns the offset of the first child
75
+ */
76
+ getFirstChildOffset(): number;
77
+ /**
78
+ * @internal
79
+ */
80
+ resolveChildIndex(element: ElementNode, elementDOM: HTMLElement, initialDOM: Node, initialOffset: number): [node: ElementNode, idx: number];
81
+ }
82
+ /** @noInheritDoc */
83
+ declare class ElementNode extends LexicalNode {
84
+ ['constructor']: KlassConstructor<typeof ElementNode>;
85
+ /** @internal */
86
+ __first: null | NodeKey;
87
+ /** @internal */
88
+ __last: null | NodeKey;
89
+ /** @internal */
90
+ __size: number;
91
+ /** @internal */
92
+ __format: number;
93
+ /** @internal */
94
+ __style: string;
95
+ /** @internal */
96
+ __indent: number;
97
+ /** @internal */
98
+ __dir: 'ltr' | 'rtl' | null;
99
+ /** @internal */
100
+ __textFormat: number;
101
+ /** @internal */
102
+ __textStyle: string;
103
+ constructor(key?: NodeKey);
104
+ afterCloneFrom(prevNode: this): void;
105
+ getFormat(): number;
106
+ getFormatType(): ElementFormatType;
107
+ getStyle(): string;
108
+ getIndent(): number;
109
+ getChildren<T extends LexicalNode>(): Array<T>;
110
+ getChildrenKeys(): Array<NodeKey>;
111
+ getChildrenSize(): number;
112
+ isEmpty(): boolean;
113
+ isDirty(): boolean;
114
+ isLastChild(): boolean;
115
+ getAllTextNodes(): Array<TextNode>;
116
+ getFirstDescendant<T extends LexicalNode>(): null | T;
117
+ getLastDescendant<T extends LexicalNode>(): null | T;
118
+ getDescendantByIndex<T extends LexicalNode>(index: number): null | T;
119
+ getFirstChild<T extends LexicalNode>(): null | T;
120
+ getFirstChildOrThrow<T extends LexicalNode>(): T;
121
+ getLastChild<T extends LexicalNode>(): null | T;
122
+ getLastChildOrThrow<T extends LexicalNode>(): T;
123
+ getChildAtIndex<T extends LexicalNode>(index: number): null | T;
124
+ getTextContent(): string;
125
+ getTextContentSize(): number;
126
+ getDirection(): 'ltr' | 'rtl' | null;
127
+ getTextFormat(): number;
128
+ hasFormat(type: ElementFormatType): boolean;
129
+ hasTextFormat(type: TextFormatType): boolean;
130
+ /**
131
+ * Returns the format flags applied to the node as a 32-bit integer.
132
+ *
133
+ * @returns a number representing the TextFormatTypes applied to the node.
134
+ */
135
+ getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
136
+ getTextStyle(): string;
137
+ select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
138
+ selectStart(): RangeSelection;
139
+ selectEnd(): RangeSelection;
140
+ clear(): this;
141
+ append(...nodesToAppend: LexicalNode[]): this;
142
+ setDirection(direction: 'ltr' | 'rtl' | null): this;
143
+ setFormat(type: ElementFormatType): this;
144
+ setStyle(style: string): this;
145
+ setTextFormat(type: number): this;
146
+ setTextStyle(style: string): this;
147
+ setIndent(indentLevel: number): this;
148
+ splice(start: number, deleteCount: number, nodesToInsert: Array<LexicalNode>): this;
149
+ /**
150
+ * @internal
151
+ *
152
+ * An experimental API that an ElementNode can override to control where its
153
+ * children are inserted into the DOM, this is useful to add a wrapping node
154
+ * or accessory nodes before or after the children. The root of the node returned
155
+ * by createDOM must still be exactly one HTMLElement.
156
+ */
157
+ getDOMSlot(element: HTMLElement): ElementDOMSlot<HTMLElement>;
158
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
159
+ exportJSON(): SerializedElementNode;
160
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedElementNode>): this;
161
+ insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | LexicalNode;
162
+ canIndent(): boolean;
163
+ collapseAtStart(selection: RangeSelection): boolean;
164
+ excludeFromCopy(destination?: 'clone' | 'html'): boolean;
165
+ /** @deprecated @internal */
166
+ canReplaceWith(replacement: LexicalNode): boolean;
167
+ /** @deprecated @internal */
168
+ canInsertAfter(node: LexicalNode): boolean;
169
+ canBeEmpty(): boolean;
170
+ canInsertTextBefore(): boolean;
171
+ canInsertTextAfter(): boolean;
172
+ isInline(): boolean;
173
+ isShadowRoot(): boolean;
174
+ /** @deprecated @internal */
175
+ canMergeWith(node: ElementNode): boolean;
176
+ extractWithChild(child: LexicalNode, selection: BaseSelection | null, destination: 'clone' | 'html'): boolean;
177
+ /**
178
+ * Determines whether this node, when empty, can merge with a first block
179
+ * of nodes being inserted.
180
+ *
181
+ * This method is specifically called in {@link RangeSelection.insertNodes}
182
+ * to determine merging behavior during nodes insertion.
183
+ *
184
+ * @example
185
+ * // In a ListItemNode or QuoteNode implementation:
186
+ * canMergeWhenEmpty(): true {
187
+ * return true;
188
+ * }
189
+ */
190
+ canMergeWhenEmpty(): boolean;
191
+ /** @internal */
192
+ reconcileObservedMutation(dom: HTMLElement, editor: LexicalEditor): void;
193
+ }
194
+ //#endregion
195
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/nodes/LexicalTextNode.d.ts
196
+ type SerializedTextNode = Spread<{
197
+ detail: number;
198
+ format: number;
199
+ mode: TextModeType;
200
+ style: string;
201
+ text: string;
202
+ }, SerializedLexicalNode>;
203
+ type TextDetailType = 'directionless' | 'unmergable';
204
+ type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'highlight' | 'code' | 'subscript' | 'superscript' | 'lowercase' | 'uppercase' | 'capitalize';
205
+ type TextModeType = 'normal' | 'token' | 'segmented';
206
+ interface TextNode {
207
+ getTopLevelElement(): ElementNode | null;
208
+ getTopLevelElementOrThrow(): ElementNode;
209
+ }
210
+ /** @noInheritDoc */
211
+ declare class TextNode extends LexicalNode {
212
+ ['constructor']: KlassConstructor<typeof TextNode>;
213
+ __text: string;
214
+ /** @internal */
215
+ __format: number;
216
+ /** @internal */
217
+ __style: string;
218
+ /** @internal */
219
+ __mode: 0 | 1 | 2 | 3;
220
+ /** @internal */
221
+ __detail: number;
222
+ static getType(): string;
223
+ static clone(node: TextNode): TextNode;
224
+ afterCloneFrom(prevNode: this): void;
225
+ constructor(text?: string, key?: NodeKey);
226
+ /**
227
+ * Returns a 32-bit integer that represents the TextFormatTypes currently applied to the
228
+ * TextNode. You probably don't want to use this method directly - consider using TextNode.hasFormat instead.
229
+ *
230
+ * @returns a number representing the format of the text node.
231
+ */
232
+ getFormat(): number;
233
+ /**
234
+ * Returns a 32-bit integer that represents the TextDetailTypes currently applied to the
235
+ * TextNode. You probably don't want to use this method directly - consider using TextNode.isDirectionless
236
+ * or TextNode.isUnmergeable instead.
237
+ *
238
+ * @returns a number representing the detail of the text node.
239
+ */
240
+ getDetail(): number;
241
+ /**
242
+ * Returns the mode (TextModeType) of the TextNode, which may be "normal", "token", or "segmented"
243
+ *
244
+ * @returns TextModeType.
245
+ */
246
+ getMode(): TextModeType;
247
+ /**
248
+ * Returns the styles currently applied to the node. This is analogous to CSSText in the DOM.
249
+ *
250
+ * @returns CSSText-like string of styles applied to the underlying DOM node.
251
+ */
252
+ getStyle(): string;
253
+ /**
254
+ * Returns whether or not the node is in "token" mode. TextNodes in token mode can be navigated through character-by-character
255
+ * with a RangeSelection, but are deleted as a single entity (not individually by character).
256
+ *
257
+ * @returns true if the node is in token mode, false otherwise.
258
+ */
259
+ isToken(): boolean;
260
+ /**
261
+ *
262
+ * @returns true if Lexical detects that an IME or other 3rd-party script is attempting to
263
+ * mutate the TextNode, false otherwise.
264
+ */
265
+ isComposing(): boolean;
266
+ /**
267
+ * Returns whether or not the node is in "segmented" mode. TextNodes in segmented mode can be navigated through character-by-character
268
+ * with a RangeSelection, but are deleted in space-delimited "segments".
269
+ *
270
+ * @returns true if the node is in segmented mode, false otherwise.
271
+ */
272
+ isSegmented(): boolean;
273
+ /**
274
+ * Returns whether or not the node is "directionless". Directionless nodes don't respect changes between RTL and LTR modes.
275
+ *
276
+ * @returns true if the node is directionless, false otherwise.
277
+ */
278
+ isDirectionless(): boolean;
279
+ /**
280
+ * Returns whether or not the node is unmergeable. In some scenarios, Lexical tries to merge
281
+ * adjacent TextNodes into a single TextNode. If a TextNode is unmergeable, this won't happen.
282
+ *
283
+ * @returns true if the node is unmergeable, false otherwise.
284
+ */
285
+ isUnmergeable(): boolean;
286
+ /**
287
+ * Returns whether or not the node has the provided format applied. Use this with the human-readable TextFormatType
288
+ * string values to get the format of a TextNode.
289
+ *
290
+ * @param type - the TextFormatType to check for.
291
+ *
292
+ * @returns true if the node has the provided format, false otherwise.
293
+ */
294
+ hasFormat(type: TextFormatType): boolean;
295
+ /**
296
+ * Returns whether or not the node is simple text. Simple text is defined as a TextNode that has the string type "text"
297
+ * (i.e., not a subclass) and has no mode applied to it (i.e., not segmented or token).
298
+ *
299
+ * @returns true if the node is simple text, false otherwise.
300
+ */
301
+ isSimpleText(): boolean;
302
+ /**
303
+ * Returns the text content of the node as a string.
304
+ *
305
+ * @returns a string representing the text content of the node.
306
+ */
307
+ getTextContent(): string;
308
+ /**
309
+ * Returns the format flags applied to the node as a 32-bit integer.
310
+ *
311
+ * @returns a number representing the TextFormatTypes applied to the node.
312
+ */
313
+ getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
314
+ /**
315
+ *
316
+ * @returns true if the text node supports font styling, false otherwise.
317
+ */
318
+ canHaveFormat(): boolean;
319
+ /**
320
+ * @returns true if the text node is inline, false otherwise.
321
+ */
322
+ isInline(): true;
323
+ createDOM(config: EditorConfig, editor?: LexicalEditor): HTMLElement;
324
+ updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
325
+ static importDOM(): DOMConversionMap | null;
326
+ static importJSON(serializedNode: SerializedTextNode): TextNode;
327
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedTextNode>): this;
328
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
329
+ exportJSON(): SerializedTextNode;
330
+ selectionTransform(prevSelection: null | BaseSelection, nextSelection: RangeSelection): void;
331
+ /**
332
+ * Sets the node format to the provided TextFormatType or 32-bit integer. Note that the TextFormatType
333
+ * version of the argument can only specify one format and doing so will remove all other formats that
334
+ * may be applied to the node. For toggling behavior, consider using {@link TextNode.toggleFormat}
335
+ *
336
+ * @param format - TextFormatType or 32-bit integer representing the node format.
337
+ *
338
+ * @returns this TextNode.
339
+ * // TODO 0.12 This should just be a `string`.
340
+ */
341
+ setFormat(format: TextFormatType | number): this;
342
+ /**
343
+ * Sets the node detail to the provided TextDetailType or 32-bit integer. Note that the TextDetailType
344
+ * version of the argument can only specify one detail value and doing so will remove all other detail values that
345
+ * may be applied to the node. For toggling behavior, consider using {@link TextNode.toggleDirectionless}
346
+ * or {@link TextNode.toggleUnmergeable}
347
+ *
348
+ * @param detail - TextDetailType or 32-bit integer representing the node detail.
349
+ *
350
+ * @returns this TextNode.
351
+ * // TODO 0.12 This should just be a `string`.
352
+ */
353
+ setDetail(detail: TextDetailType | number): this;
354
+ /**
355
+ * Sets the node style to the provided CSSText-like string. Set this property as you
356
+ * would an HTMLElement style attribute to apply inline styles to the underlying DOM Element.
357
+ *
358
+ * @param style - CSSText to be applied to the underlying HTMLElement.
359
+ *
360
+ * @returns this TextNode.
361
+ */
362
+ setStyle(style: string): this;
363
+ /**
364
+ * Applies the provided format to this TextNode if it's not present. Removes it if it's present.
365
+ * The subscript and superscript formats are mutually exclusive.
366
+ * Prefer using this method to turn specific formats on and off.
367
+ *
368
+ * @param type - TextFormatType to toggle.
369
+ *
370
+ * @returns this TextNode.
371
+ */
372
+ toggleFormat(type: TextFormatType): this;
373
+ /**
374
+ * Toggles the directionless detail value of the node. Prefer using this method over setDetail.
375
+ *
376
+ * @returns this TextNode.
377
+ */
378
+ toggleDirectionless(): this;
379
+ /**
380
+ * Toggles the unmergeable detail value of the node. Prefer using this method over setDetail.
381
+ *
382
+ * @returns this TextNode.
383
+ */
384
+ toggleUnmergeable(): this;
385
+ /**
386
+ * Sets the mode of the node.
387
+ *
388
+ * @returns this TextNode.
389
+ */
390
+ setMode(type: TextModeType): this;
391
+ /**
392
+ * Sets the text content of the node.
393
+ *
394
+ * @param text - the string to set as the text value of the node.
395
+ *
396
+ * @returns this TextNode.
397
+ */
398
+ setTextContent(text: string): this;
399
+ /**
400
+ * Sets the current Lexical selection to be a RangeSelection with anchor and focus on this TextNode at the provided offsets.
401
+ *
402
+ * @param _anchorOffset - the offset at which the Selection anchor will be placed.
403
+ * @param _focusOffset - the offset at which the Selection focus will be placed.
404
+ *
405
+ * @returns the new RangeSelection.
406
+ */
407
+ select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
408
+ selectStart(): RangeSelection;
409
+ selectEnd(): RangeSelection;
410
+ /**
411
+ * Inserts the provided text into this TextNode at the provided offset, deleting the number of characters
412
+ * specified. Can optionally calculate a new selection after the operation is complete.
413
+ *
414
+ * @param offset - the offset at which the splice operation should begin.
415
+ * @param delCount - the number of characters to delete, starting from the offset.
416
+ * @param newText - the text to insert into the TextNode at the offset.
417
+ * @param moveSelection - optional, whether or not to move selection to the end of the inserted substring.
418
+ *
419
+ * @returns this TextNode.
420
+ */
421
+ spliceText(offset: number, delCount: number, newText: string, moveSelection?: boolean): TextNode;
422
+ /**
423
+ * This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes
424
+ * when a user event would cause text to be inserted before them in the editor. If true, Lexical will attempt
425
+ * to insert text into this node. If false, it will insert the text in a new sibling node.
426
+ *
427
+ * @returns true if text can be inserted before the node, false otherwise.
428
+ */
429
+ canInsertTextBefore(): boolean;
430
+ /**
431
+ * This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes
432
+ * when a user event would cause text to be inserted after them in the editor. If true, Lexical will attempt
433
+ * to insert text into this node. If false, it will insert the text in a new sibling node.
434
+ *
435
+ * @returns true if text can be inserted after the node, false otherwise.
436
+ */
437
+ canInsertTextAfter(): boolean;
438
+ /**
439
+ * Splits this TextNode at the provided character offsets, forming new TextNodes from the substrings
440
+ * formed by the split, and inserting those new TextNodes into the editor, replacing the one that was split.
441
+ *
442
+ * @param splitOffsets - rest param of the text content character offsets at which this node should be split.
443
+ *
444
+ * @returns an Array containing the newly-created TextNodes.
445
+ */
446
+ splitText(...splitOffsets: Array<number>): Array<TextNode>;
447
+ /**
448
+ * Merges the target TextNode into this TextNode, removing the target node.
449
+ *
450
+ * @param target - the TextNode to merge into this one.
451
+ *
452
+ * @returns this TextNode.
453
+ */
454
+ mergeWithSibling(target: TextNode): TextNode;
455
+ /**
456
+ * This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes
457
+ * when used with the registerLexicalTextEntity function. If you're using registerLexicalTextEntity, the
458
+ * node class that you create and replace matched text with should return true from this method.
459
+ *
460
+ * @returns true if the node is to be treated as a "text entity", false otherwise.
461
+ */
462
+ isTextEntity(): boolean;
463
+ }
464
+ //#endregion
465
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalSelection.d.ts
466
+ type TextPointType = {
467
+ _selection: BaseSelection;
468
+ getNode: () => TextNode;
469
+ is: (point: PointType) => boolean;
470
+ isBefore: (point: PointType) => boolean;
471
+ key: NodeKey;
472
+ offset: number;
473
+ set: (key: NodeKey, offset: number, type: 'text' | 'element', onlyIfChanged?: boolean) => void;
474
+ type: 'text';
475
+ };
476
+ type ElementPointType = {
477
+ _selection: BaseSelection;
478
+ getNode: () => ElementNode;
479
+ is: (point: PointType) => boolean;
480
+ isBefore: (point: PointType) => boolean;
481
+ key: NodeKey;
482
+ offset: number;
483
+ set: (key: NodeKey, offset: number, type: 'text' | 'element', onlyIfChanged?: boolean) => void;
484
+ type: 'element';
485
+ };
486
+ type PointType = TextPointType | ElementPointType;
487
+ interface BaseSelection {
488
+ _cachedNodes: Array<LexicalNode> | null;
489
+ dirty: boolean;
490
+ clone(): BaseSelection;
491
+ extract(): Array<LexicalNode>;
492
+ getNodes(): Array<LexicalNode>;
493
+ getTextContent(): string;
494
+ insertText(text: string): void;
495
+ insertRawText(text: string): void;
496
+ is(selection: null | BaseSelection): boolean;
497
+ insertNodes(nodes: Array<LexicalNode>): void;
498
+ getStartEndPoints(): null | [PointType, PointType];
499
+ isCollapsed(): boolean;
500
+ isBackward(): boolean;
501
+ getCachedNodes(): LexicalNode[] | null;
502
+ setCachedNodes(nodes: LexicalNode[] | null): void;
503
+ }
504
+ declare class RangeSelection implements BaseSelection {
505
+ format: number;
506
+ style: string;
507
+ anchor: PointType;
508
+ focus: PointType;
509
+ _cachedNodes: Array<LexicalNode> | null;
510
+ dirty: boolean;
511
+ constructor(anchor: PointType, focus: PointType, format: number, style: string);
512
+ getCachedNodes(): LexicalNode[] | null;
513
+ setCachedNodes(nodes: LexicalNode[] | null): void;
514
+ /**
515
+ * Used to check if the provided selections is equal to this one by value,
516
+ * including anchor, focus, format, and style properties.
517
+ * @param selection - the Selection to compare this one to.
518
+ * @returns true if the Selections are equal, false otherwise.
519
+ */
520
+ is(selection: null | BaseSelection): boolean;
521
+ /**
522
+ * Returns whether the Selection is "collapsed", meaning the anchor and focus are
523
+ * the same node and have the same offset.
524
+ *
525
+ * @returns true if the Selection is collapsed, false otherwise.
526
+ */
527
+ isCollapsed(): boolean;
528
+ /**
529
+ * Gets all the nodes in the Selection. Uses caching to make it generally suitable
530
+ * for use in hot paths.
531
+ *
532
+ * See also the {@link CaretRange} APIs (starting with
533
+ * {@link $caretRangeFromSelection}), which are likely to provide a better
534
+ * foundation for any operation where partial selection is relevant
535
+ * (e.g. the anchor or focus are inside an ElementNode and TextNode)
536
+ *
537
+ * @returns an Array containing all the nodes in the Selection
538
+ */
539
+ getNodes(): Array<LexicalNode>;
540
+ /**
541
+ * Sets this Selection to be of type "text" at the provided anchor and focus values.
542
+ *
543
+ * @param anchorNode - the anchor node to set on the Selection
544
+ * @param anchorOffset - the offset to set on the Selection
545
+ * @param focusNode - the focus node to set on the Selection
546
+ * @param focusOffset - the focus offset to set on the Selection
547
+ */
548
+ setTextNodeRange(anchorNode: TextNode, anchorOffset: number, focusNode: TextNode, focusOffset: number): void;
549
+ /**
550
+ * Gets the (plain) text content of all the nodes in the selection.
551
+ *
552
+ * @returns a string representing the text content of all the nodes in the Selection
553
+ */
554
+ getTextContent(): string;
555
+ /**
556
+ * Attempts to map a DOM selection range onto this Lexical Selection,
557
+ * setting the anchor, focus, and type accordingly
558
+ *
559
+ * @param range a DOM Selection range conforming to the StaticRange interface.
560
+ */
561
+ applyDOMRange(range: StaticRange): void;
562
+ /**
563
+ * Creates a new RangeSelection, copying over all the property values from this one.
564
+ *
565
+ * @returns a new RangeSelection with the same property values as this one.
566
+ */
567
+ clone(): RangeSelection;
568
+ /**
569
+ * Toggles the provided format on all the TextNodes in the Selection.
570
+ *
571
+ * @param format a string TextFormatType to toggle on the TextNodes in the selection
572
+ */
573
+ toggleFormat(format: TextFormatType): void;
574
+ /**
575
+ * Sets the value of the format property on the Selection
576
+ *
577
+ * @param format - the format to set at the value of the format property.
578
+ */
579
+ setFormat(format: number): void;
580
+ /**
581
+ * Sets the value of the style property on the Selection
582
+ *
583
+ * @param style - the style to set at the value of the style property.
584
+ */
585
+ setStyle(style: string): void;
586
+ /**
587
+ * Returns whether the provided TextFormatType is present on the Selection. This will be true if any node in the Selection
588
+ * has the specified format.
589
+ *
590
+ * @param type the TextFormatType to check for.
591
+ * @returns true if the provided format is currently toggled on on the Selection, false otherwise.
592
+ */
593
+ hasFormat(type: TextFormatType): boolean;
594
+ /**
595
+ * Attempts to insert the provided text into the EditorState at the current Selection.
596
+ * converts tabs, newlines, and carriage returns into LexicalNodes.
597
+ *
598
+ * @param text the text to insert into the Selection
599
+ */
600
+ insertRawText(text: string): void;
601
+ /**
602
+ * Insert the provided text into the EditorState at the current Selection.
603
+ *
604
+ * @param text the text to insert into the Selection
605
+ */
606
+ insertText(text: string): void;
607
+ /**
608
+ * Removes the text in the Selection, adjusting the EditorState accordingly.
609
+ */
610
+ removeText(): void;
611
+ /**
612
+ * Applies the provided format to the TextNodes in the Selection, splitting or
613
+ * merging nodes as necessary.
614
+ *
615
+ * @param formatType the format type to apply to the nodes in the Selection.
616
+ * @param alignWithFormat a 32-bit integer representing formatting flags to align with.
617
+ */
618
+ formatText(formatType: TextFormatType, alignWithFormat?: number | null): void;
619
+ /**
620
+ * Attempts to "intelligently" insert an arbitrary list of Lexical nodes into the EditorState at the
621
+ * current Selection according to a set of heuristics that determine how surrounding nodes
622
+ * should be changed, replaced, or moved to accommodate the incoming ones.
623
+ *
624
+ * @param nodes - the nodes to insert
625
+ */
626
+ insertNodes(nodes: Array<LexicalNode>): void;
627
+ /**
628
+ * Inserts a new ParagraphNode into the EditorState at the current Selection
629
+ *
630
+ * @returns the newly inserted node.
631
+ */
632
+ insertParagraph(): ElementNode | null;
633
+ /**
634
+ * Inserts a logical linebreak, which may be a new LineBreakNode or a new ParagraphNode, into the EditorState at the
635
+ * current Selection.
636
+ */
637
+ insertLineBreak(selectStart?: boolean): void;
638
+ /**
639
+ * Extracts the nodes in the Selection, splitting nodes where necessary
640
+ * to get offset-level precision.
641
+ *
642
+ * @returns The nodes in the Selection
643
+ */
644
+ extract(): Array<LexicalNode>;
645
+ /**
646
+ * Modifies the Selection according to the parameters and a set of heuristics that account for
647
+ * various node types. Can be used to safely move or extend selection by one logical "unit" without
648
+ * dealing explicitly with all the possible node types.
649
+ *
650
+ * @param alter the type of modification to perform
651
+ * @param isBackward whether or not selection is backwards
652
+ * @param granularity the granularity at which to apply the modification
653
+ */
654
+ modify(alter: 'move' | 'extend', isBackward: boolean, granularity: 'character' | 'word' | 'lineboundary'): void;
655
+ /**
656
+ * Helper for handling forward character and word deletion that prevents element nodes
657
+ * like a table, columns layout being destroyed
658
+ *
659
+ * @param anchor the anchor
660
+ * @param anchorNode the anchor node in the selection
661
+ * @param isBackward whether or not selection is backwards
662
+ */
663
+ forwardDeletion(anchor: PointType, anchorNode: TextNode | ElementNode, isBackward: boolean): boolean;
664
+ /**
665
+ * Performs one logical character deletion operation on the EditorState based on the current Selection.
666
+ * Handles different node types.
667
+ *
668
+ * @param isBackward whether or not the selection is backwards.
669
+ */
670
+ deleteCharacter(isBackward: boolean): void;
671
+ /**
672
+ * Performs one logical line deletion operation on the EditorState based on the current Selection.
673
+ * Handles different node types.
674
+ *
675
+ * @param isBackward whether or not the selection is backwards.
676
+ */
677
+ deleteLine(isBackward: boolean): void;
678
+ /**
679
+ * Performs one logical word deletion operation on the EditorState based on the current Selection.
680
+ * Handles different node types.
681
+ *
682
+ * @param isBackward whether or not the selection is backwards.
683
+ */
684
+ deleteWord(isBackward: boolean): void;
685
+ /**
686
+ * Returns whether the Selection is "backwards", meaning the focus
687
+ * logically precedes the anchor in the EditorState.
688
+ * @returns true if the Selection is backwards, false otherwise.
689
+ */
690
+ isBackward(): boolean;
691
+ getStartEndPoints(): null | [PointType, PointType];
692
+ }
693
+ //#endregion
694
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/nodes/LexicalRootNode.d.ts
695
+ type SerializedRootNode<T extends SerializedLexicalNode = SerializedLexicalNode> = SerializedElementNode<T>;
696
+ //#endregion
697
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalEditorState.d.ts
698
+ interface SerializedEditorState<T extends SerializedLexicalNode = SerializedLexicalNode> {
699
+ root: SerializedRootNode<T>;
700
+ }
701
+ interface EditorStateReadOptions {
702
+ editor?: LexicalEditor | null;
703
+ }
704
+ declare class EditorState {
705
+ _nodeMap: NodeMap;
706
+ _selection: null | BaseSelection;
707
+ _flushSync: boolean;
708
+ _readOnly: boolean;
709
+ constructor(nodeMap: NodeMap, selection?: null | BaseSelection);
710
+ isEmpty(): boolean;
711
+ read<V$1>(callbackFn: () => V$1, options?: EditorStateReadOptions): V$1;
712
+ clone(selection?: null | BaseSelection): EditorState;
713
+ toJSON(): SerializedEditorState;
714
+ }
715
+ //#endregion
716
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalConstants.d.ts
717
+ declare const NODE_STATE_KEY = "$";
718
+ declare const PROTOTYPE_CONFIG_METHOD = "$config";
719
+ //#endregion
720
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalNodeState.d.ts
721
+ interface NodeStateConfig<S$1 extends AnyStateConfig> {
722
+ stateConfig: S$1;
723
+ flat?: boolean;
724
+ }
725
+ type RequiredNodeStateConfig = NodeStateConfig<AnyStateConfig> | AnyStateConfig;
726
+ type StateConfigJSON<S$1> = S$1 extends StateConfig<infer K, infer V> ? { [Key in K]?: V } : Record<never, never>;
727
+ type RequiredNodeStateConfigJSON<Config$1 extends RequiredNodeStateConfig, Flat extends boolean> = StateConfigJSON<Config$1 extends NodeStateConfig<infer S> ? Spread<Config$1, {
728
+ flat: false;
729
+ }> extends {
730
+ flat: Flat;
731
+ } ? S : never : false extends Flat ? Config$1 : never>;
732
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
733
+ type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends ((x: infer R) => any) ? R : never;
734
+ type CollectStateJSON<Tuple extends readonly RequiredNodeStateConfig[], Flat extends boolean> = UnionToIntersection<{ [K in keyof Tuple]: RequiredNodeStateConfigJSON<Tuple[K], Flat> }[number]>;
735
+ type GetStaticNodeConfig<T extends LexicalNode> = ReturnType<T[typeof PROTOTYPE_CONFIG_METHOD]> extends infer Record ? Record extends StaticNodeConfigRecord<infer Type, infer Config> ? Config & {
736
+ readonly type: Type;
737
+ } : never : never;
738
+ type GetStaticNodeConfigs<T extends LexicalNode> = GetStaticNodeConfig<T> extends infer OwnConfig ? OwnConfig extends never ? [] : OwnConfig extends {
739
+ extends: Klass<infer Parent>;
740
+ } ? GetStaticNodeConfig<Parent> extends infer ParentNodeConfig ? ParentNodeConfig extends never ? [OwnConfig] : [OwnConfig, ...GetStaticNodeConfigs<Parent>] : OwnConfig : [OwnConfig] : [];
741
+ type CollectStateConfigs<Configs> = Configs extends [infer OwnConfig, ...infer ParentConfigs] ? OwnConfig extends {
742
+ stateConfigs: infer StateConfigs;
743
+ } ? StateConfigs extends readonly RequiredNodeStateConfig[] ? [...StateConfigs, ...CollectStateConfigs<ParentConfigs>] : CollectStateConfigs<ParentConfigs> : CollectStateConfigs<ParentConfigs> : [];
744
+ type GetNodeStateConfig<T extends LexicalNode> = CollectStateConfigs<GetStaticNodeConfigs<T>>;
745
+ /**
746
+ * The NodeState JSON produced by this LexicalNode
747
+ */
748
+ type NodeStateJSON<T extends LexicalNode> = Prettify<{
749
+ [NODE_STATE_KEY]?: Prettify<CollectStateJSON<GetNodeStateConfig<T>, false>>;
750
+ } & CollectStateJSON<GetNodeStateConfig<T>, true>>;
751
+ /**
752
+ * Configure a value to be used with StateConfig.
753
+ *
754
+ * The value type should be inferred from the definition of parse.
755
+ *
756
+ * If the value type is not JSON serializable, then unparse must also be provided.
757
+ *
758
+ * Values should be treated as immutable, much like React.useState. Mutating
759
+ * stored values directly will cause unpredictable behavior, is not supported,
760
+ * and may trigger errors in the future.
761
+ *
762
+ * @example
763
+ * ```ts
764
+ * const numberOrNullState = createState('numberOrNull', {parse: (v) => typeof v === 'number' ? v : null});
765
+ * // ^? State<'numberOrNull', StateValueConfig<number | null>>
766
+ * const numberState = createState('number', {parse: (v) => typeof v === 'number' ? v : 0});
767
+ * // ^? State<'number', StateValueConfig<number>>
768
+ * ```
769
+ *
770
+ * Only the parse option is required, it is generally not useful to
771
+ * override `unparse` or `isEqual`. However, if you are using
772
+ * non-primitive types such as Array, Object, Date, or something
773
+ * more exotic then you would want to override this. In these
774
+ * cases you might want to reach for third party libraries.
775
+ *
776
+ * @example
777
+ * ```ts
778
+ * const isoDateState = createState('isoDate', {
779
+ * parse: (v): null | Date => {
780
+ * const date = typeof v === 'string' ? new Date(v) : null;
781
+ * return date && !isNaN(date.valueOf()) ? date : null;
782
+ * }
783
+ * isEqual: (a, b) => a === b || (a && b && a.valueOf() === b.valueOf()),
784
+ * unparse: (v) => v && v.toString()
785
+ * });
786
+ * ```
787
+ *
788
+ * You may find it easier to write a parse function using libraries like
789
+ * zod, valibot, ajv, Effect, TypeBox, etc. perhaps with a wrapper function.
790
+ */
791
+ interface StateValueConfig<V$1> {
792
+ /**
793
+ * This function must return a default value when called with undefined,
794
+ * otherwise it should parse the given JSON value to your type V. Note
795
+ * that it is not required to copy or clone the given value, you can
796
+ * pass it directly through if it matches the expected type.
797
+ *
798
+ * When you encounter an invalid value, it's up to you to decide
799
+ * as to whether to ignore it and return the default value,
800
+ * return some non-default error value, or throw an error.
801
+ *
802
+ * It is possible for V to include undefined, but if it does, then
803
+ * it should also be considered the default value since undefined
804
+ * can not be serialized to JSON so it is indistinguishable from the
805
+ * default.
806
+ *
807
+ * Similarly, if your V is a function, then usage of {@link $setState}
808
+ * must use an updater function because your type will be indistinguishable
809
+ * from an updater function.
810
+ */
811
+ parse: (jsonValue: unknown) => V$1;
812
+ /**
813
+ * This is optional and for advanced use cases only.
814
+ *
815
+ * You may specify a function that converts V back to JSON.
816
+ * This is mandatory when V is not a JSON serializable type.
817
+ */
818
+ unparse?: (parsed: V$1) => unknown;
819
+ /**
820
+ * This is optional and for advanced use cases only.
821
+ *
822
+ * Used to define the equality function so you can use an Array or Object
823
+ * as V and still omit default values from the exported JSON.
824
+ *
825
+ * The default is `Object.is`, but something like `fast-deep-equal` might be
826
+ * more appropriate for your use case.
827
+ */
828
+ isEqual?: (a: V$1, b: V$1) => boolean;
829
+ }
830
+ /**
831
+ * The return value of {@link createState}, for use with
832
+ * {@link $getState} and {@link $setState}.
833
+ */
834
+ declare class StateConfig<K$1 extends string, V$1> {
835
+ /** The string key used when serializing this state to JSON */
836
+ readonly key: K$1;
837
+ /** The parse function from the StateValueConfig passed to createState */
838
+ readonly parse: (value?: unknown) => V$1;
839
+ /**
840
+ * The unparse function from the StateValueConfig passed to createState,
841
+ * with a default that is simply a pass-through that assumes the value is
842
+ * JSON serializable.
843
+ */
844
+ readonly unparse: (value: V$1) => unknown;
845
+ /**
846
+ * An equality function from the StateValueConfig, with a default of
847
+ * Object.is.
848
+ */
849
+ readonly isEqual: (a: V$1, b: V$1) => boolean;
850
+ /**
851
+ * The result of `stateValueConfig.parse(undefined)`, which is computed only
852
+ * once and used as the default value. When the current value `isEqual` to
853
+ * the `defaultValue`, it will not be serialized to JSON.
854
+ */
855
+ readonly defaultValue: V$1;
856
+ constructor(key: K$1, stateValueConfig: StateValueConfig<V$1>);
857
+ }
858
+ /**
859
+ * For advanced use cases, using this type is not recommended unless
860
+ * it is required (due to TypeScript's lack of features like
861
+ * higher-kinded types).
862
+ *
863
+ * A {@link StateConfig} type with any key and any value that can be
864
+ * used in situations where the key and value type can not be known,
865
+ * such as in a generic constraint when working with a collection of
866
+ * StateConfig.
867
+ *
868
+ * {@link StateConfigKey} and {@link StateConfigValue} will be
869
+ * useful when this is used as a generic constraint.
870
+ */
871
+ type AnyStateConfig = StateConfig<any, any>;
872
+ /**
873
+ * @internal
874
+ *
875
+ * Opaque state to be stored on the editor's RegisterNode for use by NodeState
876
+ */
877
+ type SharedNodeState = {
878
+ sharedConfigMap: SharedConfigMap;
879
+ flatKeys: Set<string>;
880
+ };
881
+ type KnownStateMap = Map<AnyStateConfig, unknown>;
882
+ type UnknownStateRecord = Record<string, unknown>;
883
+ /**
884
+ * @internal
885
+ *
886
+ * A Map of string keys to state configurations to be shared across nodes
887
+ * and/or node versions.
888
+ */
889
+ type SharedConfigMap = Map<string, AnyStateConfig>;
890
+ /**
891
+ * @internal
892
+ */
893
+ declare class NodeState<T extends LexicalNode> {
894
+ /**
895
+ * @internal
896
+ *
897
+ * Track the (versioned) node that this NodeState was created for, to
898
+ * facilitate copy-on-write for NodeState. When a LexicalNode is cloned,
899
+ * it will *reference* the NodeState from its prevNode. From the nextNode
900
+ * you can continue to read state without copying, but the first $setState
901
+ * will trigger a copy of the prevNode's NodeState with the node property
902
+ * updated.
903
+ */
904
+ readonly node: LexicalNode;
905
+ /**
906
+ * @internal
907
+ *
908
+ * State that has already been parsed in a get state, so it is safe. (can be returned with
909
+ * just a cast since the proof was given before).
910
+ *
911
+ * Note that it uses StateConfig, so in addition to (1) the CURRENT VALUE, it has access to
912
+ * (2) the State key (3) the DEFAULT VALUE and (4) the PARSE FUNCTION
913
+ */
914
+ readonly knownState: KnownStateMap;
915
+ /**
916
+ * @internal
917
+ *
918
+ * A copy of serializedNode[NODE_STATE_KEY] that is made when JSON is
919
+ * imported but has not been parsed yet.
920
+ *
921
+ * It stays here until a get state requires us to parse it, and since we
922
+ * then know the value is safe we move it to knownState.
923
+ *
924
+ * Note that since only string keys are used here, we can only allow this
925
+ * state to pass-through on export or on the next version since there is
926
+ * no known value configuration. This pass-through is to support scenarios
927
+ * where multiple versions of the editor code are working in parallel so
928
+ * an old version of your code doesnt erase metadata that was
929
+ * set by a newer version of your code.
930
+ */
931
+ unknownState: undefined | UnknownStateRecord;
932
+ /**
933
+ * @internal
934
+ *
935
+ * This sharedNodeState is preserved across all instances of a given
936
+ * node type in an editor and remains writable. It is how keys are resolved
937
+ * to configuration.
938
+ */
939
+ readonly sharedNodeState: SharedNodeState;
940
+ /**
941
+ * @internal
942
+ *
943
+ * The count of known or unknown keys in this state, ignoring the
944
+ * intersection between the two sets.
945
+ */
946
+ size: number;
947
+ /**
948
+ * @internal
949
+ */
950
+ constructor(node: T, sharedNodeState: SharedNodeState, unknownState?: undefined | UnknownStateRecord, knownState?: KnownStateMap, size?: number | undefined);
951
+ /**
952
+ * @internal
953
+ *
954
+ * Get the value from knownState, or parse it from unknownState
955
+ * if it contains the given key.
956
+ *
957
+ * Updates the sharedConfigMap when no known state is found.
958
+ * Updates unknownState and knownState when an unknownState is parsed.
959
+ */
960
+ getValue<K$1 extends string, V$1>(stateConfig: StateConfig<K$1, V$1>): V$1;
961
+ /**
962
+ * @internal
963
+ *
964
+ * Used only for advanced use cases, such as collab. The intent here is to
965
+ * allow you to diff states with a more stable interface than the properties
966
+ * of this class.
967
+ */
968
+ getInternalState(): [{ readonly [k in string]: unknown } | undefined, ReadonlyMap<AnyStateConfig, unknown>];
969
+ /**
970
+ * Encode this NodeState to JSON in the format that its node expects.
971
+ * This returns `{[NODE_STATE_KEY]?: UnknownStateRecord}` rather than
972
+ * `UnknownStateRecord | undefined` so that we can support flattening
973
+ * specific entries in the future when nodes can declare what
974
+ * their required StateConfigs are.
975
+ */
976
+ toJSON(): NodeStateJSON<T>;
977
+ /**
978
+ * @internal
979
+ *
980
+ * A NodeState is writable when the node to update matches
981
+ * the node associated with the NodeState. This basically
982
+ * mirrors how the EditorState NodeMap works, but in a
983
+ * bottom-up organization rather than a top-down organization.
984
+ *
985
+ * This allows us to implement the same "copy on write"
986
+ * pattern for state, without having the state version
987
+ * update every time the node version changes (e.g. when
988
+ * its parent or siblings change).
989
+ *
990
+ * @param node The node to associate with the state
991
+ * @returns The next writable state
992
+ */
993
+ getWritable(node: T): NodeState<T>;
994
+ /** @internal */
995
+ updateFromKnown<K$1 extends string, V$1>(stateConfig: StateConfig<K$1, V$1>, value: V$1): void;
996
+ /**
997
+ * @internal
998
+ *
999
+ * This is intended for advanced use cases only, such
1000
+ * as collab or dev tools.
1001
+ *
1002
+ * Update a single key value pair from unknown state,
1003
+ * parsing it if the key is known to this node. This is
1004
+ * basically like updateFromJSON, but the effect is
1005
+ * isolated to a single entry.
1006
+ *
1007
+ * @param k The string key from an UnknownStateRecord
1008
+ * @param v The unknown value from an UnknownStateRecord
1009
+ */
1010
+ updateFromUnknown(k: string, v: unknown): void;
1011
+ /**
1012
+ * @internal
1013
+ *
1014
+ * Reset all existing state to default or empty values,
1015
+ * and perform any updates from the given unknownState.
1016
+ *
1017
+ * This is used when initializing a node's state from JSON,
1018
+ * or when resetting a node's state from JSON.
1019
+ *
1020
+ * @param unknownState The new state in serialized form
1021
+ */
1022
+ updateFromJSON(unknownState: undefined | UnknownStateRecord): void;
1023
+ }
1024
+ //#endregion
1025
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalUpdateTags.d.ts
1026
+ /**
1027
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1028
+ *
1029
+ * This source code is licensed under the MIT license found in the
1030
+ * LICENSE file in the root directory of this source tree.
1031
+ *
1032
+ */
1033
+ /**
1034
+ * Common update tags used in Lexical. These tags can be used with editor.update() or $addUpdateTag()
1035
+ * to indicate the type/purpose of an update. Multiple tags can be used in a single update.
1036
+ */
1037
+ /**
1038
+ * Indicates that the update is related to history operations (undo/redo)
1039
+ */
1040
+ declare const HISTORIC_TAG = "historic";
1041
+ /**
1042
+ * Indicates that a new history entry should be pushed to the history stack
1043
+ */
1044
+ declare const HISTORY_PUSH_TAG = "history-push";
1045
+ /**
1046
+ * Indicates that the current update should be merged with the previous history entry
1047
+ */
1048
+ declare const HISTORY_MERGE_TAG = "history-merge";
1049
+ /**
1050
+ * Indicates that the update is related to a paste operation
1051
+ */
1052
+ declare const PASTE_TAG = "paste";
1053
+ /**
1054
+ * Indicates that the update is related to collaborative editing
1055
+ */
1056
+ declare const COLLABORATION_TAG = "collaboration";
1057
+ /**
1058
+ * Indicates that the update should skip collaborative sync
1059
+ */
1060
+ declare const SKIP_COLLAB_TAG = "skip-collab";
1061
+ /**
1062
+ * Indicates that the update should skip scrolling the selection into view
1063
+ */
1064
+ declare const SKIP_SCROLL_INTO_VIEW_TAG = "skip-scroll-into-view";
1065
+ /**
1066
+ * Indicates that the update should skip updating the DOM selection
1067
+ * This is useful when you want to make updates without changing the selection or focus
1068
+ */
1069
+ declare const SKIP_DOM_SELECTION_TAG = "skip-dom-selection";
1070
+ /**
1071
+ * The update was triggered by editor.focus()
1072
+ */
1073
+ declare const FOCUS_TAG = "focus";
1074
+ /**
1075
+ * The set of known update tags to help with TypeScript suggestions.
1076
+ */
1077
+ type UpdateTag = typeof COLLABORATION_TAG | typeof FOCUS_TAG | typeof HISTORIC_TAG | typeof HISTORY_MERGE_TAG | typeof HISTORY_PUSH_TAG | typeof PASTE_TAG | typeof SKIP_COLLAB_TAG | typeof SKIP_DOM_SELECTION_TAG | typeof SKIP_SCROLL_INTO_VIEW_TAG | (string & {});
1078
+ //#endregion
1079
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalEditor.d.ts
1080
+ type Spread<T1, T2> = Omit<T2, keyof T1> & T1;
1081
+ type KlassConstructor<Cls extends GenericConstructor<any>> = GenericConstructor<InstanceType<Cls>> & { [k in keyof Cls]: Cls[k] };
1082
+ type GenericConstructor<T> = new (...args: any[]) => T;
1083
+ type Klass<T extends LexicalNode> = InstanceType<T['constructor']> extends T ? T['constructor'] : GenericConstructor<T> & T['constructor'];
1084
+ type EditorThemeClassName = string;
1085
+ type TextNodeThemeClasses = {
1086
+ base?: EditorThemeClassName;
1087
+ bold?: EditorThemeClassName;
1088
+ code?: EditorThemeClassName;
1089
+ highlight?: EditorThemeClassName;
1090
+ italic?: EditorThemeClassName;
1091
+ lowercase?: EditorThemeClassName;
1092
+ uppercase?: EditorThemeClassName;
1093
+ capitalize?: EditorThemeClassName;
1094
+ strikethrough?: EditorThemeClassName;
1095
+ subscript?: EditorThemeClassName;
1096
+ superscript?: EditorThemeClassName;
1097
+ underline?: EditorThemeClassName;
1098
+ underlineStrikethrough?: EditorThemeClassName;
1099
+ [key: string]: EditorThemeClassName | undefined;
1100
+ };
1101
+ type EditorUpdateOptions = {
1102
+ /**
1103
+ * A function to run once the update is complete. See also {@link $onUpdate}.
1104
+ */
1105
+ onUpdate?: () => void;
1106
+ /**
1107
+ * Setting this to true will suppress all node
1108
+ * transforms for this update cycle.
1109
+ * Useful for synchronizing updates in some cases.
1110
+ */
1111
+ skipTransforms?: true;
1112
+ /**
1113
+ * A tag to identify this update, in an update listener, for instance.
1114
+ * See also {@link $addUpdateTag}.
1115
+ */
1116
+ tag?: UpdateTag | UpdateTag[];
1117
+ /**
1118
+ * If true, prevents this update from being batched, forcing it to
1119
+ * run synchronously.
1120
+ */
1121
+ discrete?: true;
1122
+ /** @internal */
1123
+ event?: undefined | UIEvent | Event | null;
1124
+ };
1125
+ type EditorSetOptions = {
1126
+ tag?: string;
1127
+ };
1128
+ interface EditorFocusOptions {
1129
+ /**
1130
+ * Where to move selection when the editor is
1131
+ * focused. Can be rootStart, rootEnd, or undefined. Defaults to rootEnd.
1132
+ */
1133
+ defaultSelection?: 'rootStart' | 'rootEnd';
1134
+ }
1135
+ type EditorThemeClasses = {
1136
+ blockCursor?: EditorThemeClassName;
1137
+ characterLimit?: EditorThemeClassName;
1138
+ code?: EditorThemeClassName;
1139
+ codeHighlight?: Record<string, EditorThemeClassName>;
1140
+ hashtag?: EditorThemeClassName;
1141
+ specialText?: EditorThemeClassName;
1142
+ heading?: {
1143
+ h1?: EditorThemeClassName;
1144
+ h2?: EditorThemeClassName;
1145
+ h3?: EditorThemeClassName;
1146
+ h4?: EditorThemeClassName;
1147
+ h5?: EditorThemeClassName;
1148
+ h6?: EditorThemeClassName;
1149
+ };
1150
+ hr?: EditorThemeClassName;
1151
+ hrSelected?: EditorThemeClassName;
1152
+ image?: EditorThemeClassName;
1153
+ link?: EditorThemeClassName;
1154
+ list?: {
1155
+ ul?: EditorThemeClassName;
1156
+ ulDepth?: Array<EditorThemeClassName>;
1157
+ ol?: EditorThemeClassName;
1158
+ olDepth?: Array<EditorThemeClassName>;
1159
+ checklist?: EditorThemeClassName;
1160
+ listitem?: EditorThemeClassName;
1161
+ listitemChecked?: EditorThemeClassName;
1162
+ listitemUnchecked?: EditorThemeClassName;
1163
+ nested?: {
1164
+ list?: EditorThemeClassName;
1165
+ listitem?: EditorThemeClassName;
1166
+ };
1167
+ };
1168
+ ltr?: EditorThemeClassName;
1169
+ mark?: EditorThemeClassName;
1170
+ markOverlap?: EditorThemeClassName;
1171
+ paragraph?: EditorThemeClassName;
1172
+ quote?: EditorThemeClassName;
1173
+ root?: EditorThemeClassName;
1174
+ rtl?: EditorThemeClassName;
1175
+ tab?: EditorThemeClassName;
1176
+ table?: EditorThemeClassName;
1177
+ tableAddColumns?: EditorThemeClassName;
1178
+ tableAddRows?: EditorThemeClassName;
1179
+ tableCellActionButton?: EditorThemeClassName;
1180
+ tableCellActionButtonContainer?: EditorThemeClassName;
1181
+ tableCellSelected?: EditorThemeClassName;
1182
+ tableCell?: EditorThemeClassName;
1183
+ tableCellHeader?: EditorThemeClassName;
1184
+ tableCellResizer?: EditorThemeClassName;
1185
+ tableRow?: EditorThemeClassName;
1186
+ tableScrollableWrapper?: EditorThemeClassName;
1187
+ tableSelected?: EditorThemeClassName;
1188
+ tableSelection?: EditorThemeClassName;
1189
+ text?: TextNodeThemeClasses;
1190
+ embedBlock?: {
1191
+ base?: EditorThemeClassName;
1192
+ focus?: EditorThemeClassName;
1193
+ };
1194
+ indent?: EditorThemeClassName;
1195
+ [key: string]: any;
1196
+ };
1197
+ type EditorConfig = {
1198
+ disableEvents?: boolean;
1199
+ namespace: string;
1200
+ theme: EditorThemeClasses;
1201
+ };
1202
+ type LexicalNodeReplacement = {
1203
+ replace: Klass<LexicalNode>;
1204
+ with: <T extends {
1205
+ new (...args: any): any;
1206
+ }>(node: InstanceType<T>) => LexicalNode;
1207
+ withKlass?: Klass<LexicalNode>;
1208
+ };
1209
+ type HTMLConfig = {
1210
+ export?: DOMExportOutputMap;
1211
+ import?: DOMConversionMap;
1212
+ };
1213
+ /**
1214
+ * A LexicalNode class or LexicalNodeReplacement configuration
1215
+ */
1216
+ type LexicalNodeConfig = Klass<LexicalNode> | LexicalNodeReplacement;
1217
+ type CreateEditorArgs = {
1218
+ disableEvents?: boolean;
1219
+ editorState?: EditorState;
1220
+ namespace?: string;
1221
+ nodes?: ReadonlyArray<LexicalNodeConfig>;
1222
+ onError?: ErrorHandler;
1223
+ parentEditor?: LexicalEditor;
1224
+ editable?: boolean;
1225
+ theme?: EditorThemeClasses;
1226
+ html?: HTMLConfig;
1227
+ };
1228
+ type RegisteredNodes = Map<string, RegisteredNode>;
1229
+ type RegisteredNode = {
1230
+ klass: Klass<LexicalNode>;
1231
+ transforms: Set<Transform<LexicalNode>>;
1232
+ replace: null | ((node: LexicalNode) => LexicalNode);
1233
+ replaceWithKlass: null | Klass<LexicalNode>;
1234
+ exportDOM?: (editor: LexicalEditor, targetNode: LexicalNode) => DOMExportOutput;
1235
+ sharedNodeState: SharedNodeState;
1236
+ };
1237
+ type Transform<T extends LexicalNode> = (node: T) => void;
1238
+ type ErrorHandler = (error: Error) => void;
1239
+ type MutationListeners = Map<MutationListener, Set<Klass<LexicalNode>>>;
1240
+ type MutatedNodes = Map<Klass<LexicalNode>, Map<NodeKey, NodeMutation>>;
1241
+ type NodeMutation = 'created' | 'updated' | 'destroyed';
1242
+ interface MutationListenerOptions {
1243
+ /**
1244
+ * Skip the initial call of the listener with pre-existing DOM nodes.
1245
+ *
1246
+ * The default was previously true for backwards compatibility with <= 0.16.1
1247
+ * but this default has been changed to false as of 0.21.0.
1248
+ */
1249
+ skipInitialization?: boolean;
1250
+ }
1251
+ /**
1252
+ * The payload passed to an UpdateListener
1253
+ */
1254
+ interface UpdateListenerPayload {
1255
+ /**
1256
+ * A Map of NodeKeys of ElementNodes to a boolean that is true
1257
+ * if the node was intentionally mutated ('unintentional' mutations
1258
+ * are triggered when an indirect descendant is marked dirty)
1259
+ */
1260
+ dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>;
1261
+ /**
1262
+ * A Set of NodeKeys of all nodes that were marked dirty that
1263
+ * do not inherit from ElementNode.
1264
+ */
1265
+ dirtyLeaves: Set<NodeKey>;
1266
+ /**
1267
+ * The new EditorState after all updates have been processed,
1268
+ * equivalent to `editor.getEditorState()`
1269
+ */
1270
+ editorState: EditorState;
1271
+ /**
1272
+ * The Map of LexicalNode constructors to a `Map<NodeKey, NodeMutation>`,
1273
+ * this is useful when you have a mutation listener type use cases that
1274
+ * should apply to all or most nodes. Will be null if no DOM was mutated,
1275
+ * such as when only the selection changed. Note that this will be empty
1276
+ * unless at least one MutationListener is explicitly registered
1277
+ * (any MutationListener is sufficient to compute the mutatedNodes Map
1278
+ * for all nodes).
1279
+ *
1280
+ * Added in v0.28.0
1281
+ */
1282
+ mutatedNodes: null | MutatedNodes;
1283
+ /**
1284
+ * For advanced use cases only.
1285
+ *
1286
+ * Tracks the keys of TextNode descendants that have been merged
1287
+ * with their siblings by normalization. Note that these keys may
1288
+ * not exist in either editorState or prevEditorState and generally
1289
+ * this is only used for conflict resolution edge cases in collab.
1290
+ */
1291
+ normalizedNodes: Set<NodeKey>;
1292
+ /**
1293
+ * The previous EditorState that is being discarded
1294
+ */
1295
+ prevEditorState: EditorState;
1296
+ /**
1297
+ * The set of tags added with update options or {@link $addUpdateTag},
1298
+ * node that this includes all tags that were processed in this
1299
+ * reconciliation which may have been added by separate updates.
1300
+ */
1301
+ tags: Set<string>;
1302
+ }
1303
+ /**
1304
+ * A listener that gets called after the editor is updated
1305
+ */
1306
+ type UpdateListener = (payload: UpdateListenerPayload) => void;
1307
+ type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void;
1308
+ type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void;
1309
+ type TextContentListener = (text: string) => void;
1310
+ type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: {
1311
+ updateTags: Set<string>;
1312
+ dirtyLeaves: Set<string>;
1313
+ prevEditorState: EditorState;
1314
+ }) => void;
1315
+ type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
1316
+ type EditableListener = (editable: boolean) => void;
1317
+ type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
1318
+ type LexicalCommand<TPayload$1> = {
1319
+ type?: string;
1320
+ };
1321
+ /**
1322
+ * Type helper for extracting the payload type from a command.
1323
+ *
1324
+ * @example
1325
+ * ```ts
1326
+ * const MY_COMMAND = createCommand<SomeType>();
1327
+ *
1328
+ * // ...
1329
+ *
1330
+ * editor.registerCommand(MY_COMMAND, payload => {
1331
+ * // Type of `payload` is inferred here. But lets say we want to extract a function to delegate to
1332
+ * $handleMyCommand(editor, payload);
1333
+ * return true;
1334
+ * });
1335
+ *
1336
+ * function $handleMyCommand(editor: LexicalEditor, payload: CommandPayloadType<typeof MY_COMMAND>) {
1337
+ * // `payload` is of type `SomeType`, extracted from the command.
1338
+ * }
1339
+ * ```
1340
+ */
1341
+ type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never;
1342
+ type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>;
1343
+ interface Listeners {
1344
+ decorator: Set<DecoratorListener<any>>;
1345
+ mutation: MutationListeners;
1346
+ editable: Set<EditableListener>;
1347
+ root: Set<RootListener>;
1348
+ textcontent: Set<TextContentListener>;
1349
+ update: Set<UpdateListener>;
1350
+ }
1351
+ type IntentionallyMarkedAsDirtyElement = boolean;
1352
+ type DOMConversionCache = Map<string, Array<(node: Node) => DOMConversion | null>>;
1353
+ type SerializedEditor = {
1354
+ editorState: SerializedEditorState;
1355
+ };
1356
+ declare class LexicalEditor {
1357
+ ['constructor']: KlassConstructor<typeof LexicalEditor>;
1358
+ /** The version with build identifiers for this editor (since 0.17.1) */
1359
+ static version: string | undefined;
1360
+ /** @internal */
1361
+ _headless: boolean;
1362
+ /** @internal */
1363
+ _parentEditor: null | LexicalEditor;
1364
+ /** @internal */
1365
+ _rootElement: null | HTMLElement;
1366
+ /** @internal */
1367
+ _editorState: EditorState;
1368
+ /** @internal */
1369
+ _pendingEditorState: null | EditorState;
1370
+ /** @internal */
1371
+ _compositionKey: null | NodeKey;
1372
+ /** @internal */
1373
+ _deferred: Array<() => void>;
1374
+ /** @internal */
1375
+ _keyToDOMMap: Map<NodeKey, HTMLElement>;
1376
+ /** @internal */
1377
+ _updates: Array<[() => void, EditorUpdateOptions | undefined]>;
1378
+ /** @internal */
1379
+ _updating: boolean;
1380
+ /** @internal */
1381
+ _listeners: Listeners;
1382
+ /** @internal */
1383
+ _commands: Commands;
1384
+ /** @internal */
1385
+ _nodes: RegisteredNodes;
1386
+ /** @internal */
1387
+ _decorators: Record<NodeKey, unknown>;
1388
+ /** @internal */
1389
+ _pendingDecorators: null | Record<NodeKey, unknown>;
1390
+ /** @internal */
1391
+ _config: EditorConfig;
1392
+ /** @internal */
1393
+ _dirtyType: 0 | 1 | 2;
1394
+ /** @internal */
1395
+ _cloneNotNeeded: Set<NodeKey>;
1396
+ /** @internal */
1397
+ _dirtyLeaves: Set<NodeKey>;
1398
+ /** @internal */
1399
+ _dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>;
1400
+ /** @internal */
1401
+ _normalizedNodes: Set<NodeKey>;
1402
+ /** @internal */
1403
+ _updateTags: Set<UpdateTag>;
1404
+ /** @internal */
1405
+ _observer: null | MutationObserver;
1406
+ /** @internal */
1407
+ _key: string;
1408
+ /** @internal */
1409
+ _onError: ErrorHandler;
1410
+ /** @internal */
1411
+ _htmlConversions: DOMConversionCache;
1412
+ /** @internal */
1413
+ _window: null | Window;
1414
+ /** @internal */
1415
+ _editable: boolean;
1416
+ /** @internal */
1417
+ _blockCursorElement: null | HTMLDivElement;
1418
+ /** @internal */
1419
+ _createEditorArgs?: undefined | CreateEditorArgs;
1420
+ /** @internal */
1421
+ constructor(editorState: EditorState, parentEditor: null | LexicalEditor, nodes: RegisteredNodes, config: EditorConfig, onError: ErrorHandler, htmlConversions: DOMConversionCache, editable: boolean, createEditorArgs?: CreateEditorArgs);
1422
+ /**
1423
+ *
1424
+ * @returns true if the editor is currently in "composition" mode due to receiving input
1425
+ * through an IME, or 3P extension, for example. Returns false otherwise.
1426
+ */
1427
+ isComposing(): boolean;
1428
+ /**
1429
+ * Registers a listener for Editor update event. Will trigger the provided callback
1430
+ * each time the editor goes through an update (via {@link LexicalEditor.update}) until the
1431
+ * teardown function is called.
1432
+ *
1433
+ * @returns a teardown function that can be used to cleanup the listener.
1434
+ */
1435
+ registerUpdateListener(listener: UpdateListener): () => void;
1436
+ /**
1437
+ * Registers a listener for for when the editor changes between editable and non-editable states.
1438
+ * Will trigger the provided callback each time the editor transitions between these states until the
1439
+ * teardown function is called.
1440
+ *
1441
+ * @returns a teardown function that can be used to cleanup the listener.
1442
+ */
1443
+ registerEditableListener(listener: EditableListener): () => void;
1444
+ /**
1445
+ * Registers a listener for when the editor's decorator object changes. The decorator object contains
1446
+ * all DecoratorNode keys -> their decorated value. This is primarily used with external UI frameworks.
1447
+ *
1448
+ * Will trigger the provided callback each time the editor transitions between these states until the
1449
+ * teardown function is called.
1450
+ *
1451
+ * @returns a teardown function that can be used to cleanup the listener.
1452
+ */
1453
+ registerDecoratorListener<T>(listener: DecoratorListener<T>): () => void;
1454
+ /**
1455
+ * Registers a listener for when Lexical commits an update to the DOM and the text content of
1456
+ * the editor changes from the previous state of the editor. If the text content is the
1457
+ * same between updates, no notifications to the listeners will happen.
1458
+ *
1459
+ * Will trigger the provided callback each time the editor transitions between these states until the
1460
+ * teardown function is called.
1461
+ *
1462
+ * @returns a teardown function that can be used to cleanup the listener.
1463
+ */
1464
+ registerTextContentListener(listener: TextContentListener): () => void;
1465
+ /**
1466
+ * Registers a listener for when the editor's root DOM element (the content editable
1467
+ * Lexical attaches to) changes. This is primarily used to attach event listeners to the root
1468
+ * element. The root listener function is executed directly upon registration and then on
1469
+ * any subsequent update.
1470
+ *
1471
+ * Will trigger the provided callback each time the editor transitions between these states until the
1472
+ * teardown function is called.
1473
+ *
1474
+ * @returns a teardown function that can be used to cleanup the listener.
1475
+ */
1476
+ registerRootListener(listener: RootListener): () => void;
1477
+ /**
1478
+ * Registers a listener that will trigger anytime the provided command
1479
+ * is dispatched with {@link LexicalEditor.dispatch}, subject to priority.
1480
+ * Listeners that run at a higher priority can "intercept" commands and
1481
+ * prevent them from propagating to other handlers by returning true.
1482
+ *
1483
+ * Listeners are always invoked in an {@link LexicalEditor.update} and can
1484
+ * call dollar functions.
1485
+ *
1486
+ * Listeners registered at the same priority level will run
1487
+ * deterministically in the order of registration.
1488
+ *
1489
+ * @param command - the command that will trigger the callback.
1490
+ * @param listener - the function that will execute when the command is dispatched.
1491
+ * @param priority - the relative priority of the listener. 0 | 1 | 2 | 3 | 4
1492
+ * (or {@link COMMAND_PRIORITY_EDITOR} |
1493
+ * {@link COMMAND_PRIORITY_LOW} |
1494
+ * {@link COMMAND_PRIORITY_NORMAL} |
1495
+ * {@link COMMAND_PRIORITY_HIGH} |
1496
+ * {@link COMMAND_PRIORITY_CRITICAL})
1497
+ * @returns a teardown function that can be used to cleanup the listener.
1498
+ */
1499
+ registerCommand<P>(command: LexicalCommand<P>, listener: CommandListener<P>, priority: CommandListenerPriority): () => void;
1500
+ /**
1501
+ * Registers a listener that will run when a Lexical node of the provided class is
1502
+ * mutated. The listener will receive a list of nodes along with the type of mutation
1503
+ * that was performed on each: created, destroyed, or updated.
1504
+ *
1505
+ * One common use case for this is to attach DOM event listeners to the underlying DOM nodes as Lexical nodes are created.
1506
+ * {@link LexicalEditor.getElementByKey} can be used for this.
1507
+ *
1508
+ * If any existing nodes are in the DOM, and skipInitialization is not true, the listener
1509
+ * will be called immediately with an updateTag of 'registerMutationListener' where all
1510
+ * nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option
1511
+ * (whose default was previously true for backwards compatibility with &lt;=0.16.1 but has been changed to false as of 0.21.0).
1512
+ *
1513
+ * @param klass - The class of the node that you want to listen to mutations on.
1514
+ * @param listener - The logic you want to run when the node is mutated.
1515
+ * @param options - see {@link MutationListenerOptions}
1516
+ * @returns a teardown function that can be used to cleanup the listener.
1517
+ */
1518
+ registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener, options?: MutationListenerOptions): () => void;
1519
+ /** @internal */
1520
+ getRegisteredNode(klass: Klass<LexicalNode>): RegisteredNode;
1521
+ /** @internal */
1522
+ resolveRegisteredNodeAfterReplacements(registeredNode: RegisteredNode): RegisteredNode;
1523
+ /** @internal */
1524
+ private initializeMutationListener;
1525
+ /** @internal */
1526
+ private registerNodeTransformToKlass;
1527
+ /**
1528
+ * Registers a listener that will run when a Lexical node of the provided class is
1529
+ * marked dirty during an update. The listener will continue to run as long as the node
1530
+ * is marked dirty. There are no guarantees around the order of transform execution!
1531
+ *
1532
+ * Watch out for infinite loops. See [Node Transforms](https://lexical.dev/docs/concepts/transforms)
1533
+ * @param klass - The class of the node that you want to run transforms on.
1534
+ * @param listener - The logic you want to run when the node is updated.
1535
+ * @returns a teardown function that can be used to cleanup the listener.
1536
+ */
1537
+ registerNodeTransform<T extends LexicalNode>(klass: Klass<T>, listener: Transform<T>): () => void;
1538
+ /**
1539
+ * Used to assert that a certain node is registered, usually by plugins to ensure nodes that they
1540
+ * depend on have been registered.
1541
+ * @returns True if the editor has registered the provided node type, false otherwise.
1542
+ */
1543
+ hasNode<T extends Klass<LexicalNode>>(node: T): boolean;
1544
+ /**
1545
+ * Used to assert that certain nodes are registered, usually by plugins to ensure nodes that they
1546
+ * depend on have been registered.
1547
+ * @returns True if the editor has registered all of the provided node types, false otherwise.
1548
+ */
1549
+ hasNodes<T extends Klass<LexicalNode>>(nodes: Array<T>): boolean;
1550
+ /**
1551
+ * Dispatches a command of the specified type with the specified payload.
1552
+ * This triggers all command listeners (set by {@link LexicalEditor.registerCommand})
1553
+ * for this type, passing them the provided payload. The command listeners
1554
+ * will be triggered in an implicit {@link LexicalEditor.update}, unless
1555
+ * this was invoked from inside an update in which case that update context
1556
+ * will be re-used (as if this was a dollar function itself).
1557
+ * @param type - the type of command listeners to trigger.
1558
+ * @param payload - the data to pass as an argument to the command listeners.
1559
+ */
1560
+ dispatchCommand<TCommand extends LexicalCommand<unknown>>(type: TCommand, payload: CommandPayloadType<TCommand>): boolean;
1561
+ /**
1562
+ * Gets a map of all decorators in the editor.
1563
+ * @returns A mapping of call decorator keys to their decorated content
1564
+ */
1565
+ getDecorators<T>(): Record<NodeKey, T>;
1566
+ /**
1567
+ *
1568
+ * @returns the current root element of the editor. If you want to register
1569
+ * an event listener, do it via {@link LexicalEditor.registerRootListener}, since
1570
+ * this reference may not be stable.
1571
+ */
1572
+ getRootElement(): null | HTMLElement;
1573
+ /**
1574
+ * Gets the key of the editor
1575
+ * @returns The editor key
1576
+ */
1577
+ getKey(): string;
1578
+ /**
1579
+ * Imperatively set the root contenteditable element that Lexical listens
1580
+ * for events on.
1581
+ */
1582
+ setRootElement(nextRootElement: null | HTMLElement): void;
1583
+ /**
1584
+ * Gets the underlying HTMLElement associated with the LexicalNode for the given key.
1585
+ * @returns the HTMLElement rendered by the LexicalNode associated with the key.
1586
+ * @param key - the key of the LexicalNode.
1587
+ */
1588
+ getElementByKey(key: NodeKey): HTMLElement | null;
1589
+ /**
1590
+ * Gets the active editor state.
1591
+ * @returns The editor state
1592
+ */
1593
+ getEditorState(): EditorState;
1594
+ /**
1595
+ * Imperatively set the EditorState. Triggers reconciliation like an update.
1596
+ * @param editorState - the state to set the editor
1597
+ * @param options - options for the update.
1598
+ */
1599
+ setEditorState(editorState: EditorState, options?: EditorSetOptions): void;
1600
+ /**
1601
+ * Parses a SerializedEditorState (usually produced by {@link EditorState.toJSON}) and returns
1602
+ * and EditorState object that can be, for example, passed to {@link LexicalEditor.setEditorState}. Typically,
1603
+ * deserialization from JSON stored in a database uses this method.
1604
+ * @param maybeStringifiedEditorState
1605
+ * @param updateFn
1606
+ * @returns
1607
+ */
1608
+ parseEditorState(maybeStringifiedEditorState: string | SerializedEditorState, updateFn?: () => void): EditorState;
1609
+ /**
1610
+ * Executes a read of the editor's state, with the
1611
+ * editor context available (useful for exporting and read-only DOM
1612
+ * operations). Much like update, but prevents any mutation of the
1613
+ * editor's state. Any pending updates will be flushed immediately before
1614
+ * the read.
1615
+ * @param callbackFn - A function that has access to read-only editor state.
1616
+ */
1617
+ read<T>(callbackFn: () => T): T;
1618
+ /**
1619
+ * Executes an update to the editor state. The updateFn callback is the ONLY place
1620
+ * where Lexical editor state can be safely mutated.
1621
+ * @param updateFn - A function that has access to writable editor state.
1622
+ * @param options - A bag of options to control the behavior of the update.
1623
+ */
1624
+ update(updateFn: () => void, options?: EditorUpdateOptions): void;
1625
+ /**
1626
+ * Focuses the editor by marking the existing selection as dirty, or by
1627
+ * creating a new selection at `defaultSelection` if one does not already
1628
+ * exist. If you want to force a specific selection, you should call
1629
+ * `root.selectStart()` or `root.selectEnd()` in an update.
1630
+ *
1631
+ * @param callbackFn - A function to run after the editor is focused.
1632
+ * @param options - A bag of options
1633
+ */
1634
+ focus(callbackFn?: () => void, options?: EditorFocusOptions): void;
1635
+ /**
1636
+ * Removes focus from the editor.
1637
+ */
1638
+ blur(): void;
1639
+ /**
1640
+ * Returns true if the editor is editable, false otherwise.
1641
+ * @returns True if the editor is editable, false otherwise.
1642
+ */
1643
+ isEditable(): boolean;
1644
+ /**
1645
+ * Sets the editable property of the editor. When false, the
1646
+ * editor will not listen for user events on the underling contenteditable.
1647
+ * @param editable - the value to set the editable mode to.
1648
+ */
1649
+ setEditable(editable: boolean): void;
1650
+ /**
1651
+ * Returns a JSON-serializable javascript object NOT a JSON string.
1652
+ * You still must call JSON.stringify (or something else) to turn the
1653
+ * state into a string you can transfer over the wire and store in a database.
1654
+ *
1655
+ * See {@link LexicalNode.exportJSON}
1656
+ *
1657
+ * @returns A JSON-serializable javascript object
1658
+ */
1659
+ toJSON(): SerializedEditor;
1660
+ }
1661
+ //#endregion
1662
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/LexicalNode.d.ts
1663
+ type NodeMap = Map<NodeKey, LexicalNode>;
1664
+ /**
1665
+ * The base type for all serialized nodes
1666
+ */
1667
+ type SerializedLexicalNode = {
1668
+ /** The type string used by the Node class */
1669
+ type: string;
1670
+ /** A numeric version for this schema, defaulting to 1, but not generally recommended for use */
1671
+ version: number;
1672
+ /**
1673
+ * Any state persisted with the NodeState API that is not
1674
+ * configured for flat storage
1675
+ */
1676
+ [NODE_STATE_KEY]?: Record<string, unknown>;
1677
+ };
1678
+ /**
1679
+ * EXPERIMENTAL
1680
+ * The configuration of a node returned by LexicalNode.$config()
1681
+ *
1682
+ * @example
1683
+ * ```ts
1684
+ * class CustomText extends TextNode {
1685
+ * $config() {
1686
+ * return this.config('custom-text', {extends: TextNode}};
1687
+ * }
1688
+ * }
1689
+ * ```
1690
+ */
1691
+ interface StaticNodeConfigValue<T extends LexicalNode, Type$1 extends string> {
1692
+ /**
1693
+ * The exact type of T.getType(), e.g. 'text' - the method itself must
1694
+ * have a more generic 'string' type to be compatible wtih subclassing.
1695
+ */
1696
+ readonly type?: Type$1;
1697
+ /**
1698
+ * An alternative to the internal static transform() method
1699
+ * that provides better type inference.
1700
+ */
1701
+ readonly $transform?: (node: T) => void;
1702
+ /**
1703
+ * An alternative to the static importJSON() method
1704
+ * that provides better type inference.
1705
+ */
1706
+ readonly $importJSON?: (serializedNode: SerializedLexicalNode) => T;
1707
+ /**
1708
+ * An alternative to the static importDOM() method
1709
+ */
1710
+ readonly importDOM?: DOMConversionMap;
1711
+ /**
1712
+ * EXPERIMENTAL
1713
+ *
1714
+ * An array of RequiredNodeStateConfig to initialize your node with
1715
+ * its state requirements. This may be used to configure serialization of
1716
+ * that state.
1717
+ *
1718
+ * This function will be called (at most) once per editor initialization,
1719
+ * directly on your node's prototype. It must not depend on any state
1720
+ * initialized in the constructor.
1721
+ *
1722
+ * @example
1723
+ * ```ts
1724
+ * const flatState = createState("flat", {parse: parseNumber});
1725
+ * const nestedState = createState("nested", {parse: parseNumber});
1726
+ * class MyNode extends TextNode {
1727
+ * $config() {
1728
+ * return this.config(
1729
+ * 'my-node',
1730
+ * {
1731
+ * extends: TextNode,
1732
+ * stateConfigs: [
1733
+ * { stateConfig: flatState, flat: true},
1734
+ * nestedState,
1735
+ * ]
1736
+ * },
1737
+ * );
1738
+ * }
1739
+ * }
1740
+ * ```
1741
+ */
1742
+ readonly stateConfigs?: readonly RequiredNodeStateConfig[];
1743
+ /**
1744
+ * If specified, this must be the exact superclass of the node. It is not
1745
+ * checked at compile time and it is provided automatically at runtime.
1746
+ *
1747
+ * You would want to specify this when you are extending a node that
1748
+ * has non-trivial configuration in its $config such
1749
+ * as required state. If you do not specify this, the inferred
1750
+ * types for your node class might be missing some of that.
1751
+ */
1752
+ readonly extends?: Klass<LexicalNode>;
1753
+ }
1754
+ /**
1755
+ * This is the type of LexicalNode.$config() that can be
1756
+ * overridden by subclasses.
1757
+ */
1758
+ type BaseStaticNodeConfig = { readonly [K in string]?: StaticNodeConfigValue<LexicalNode, string> };
1759
+ /**
1760
+ * Any StaticNodeConfigValue (for generics and collections)
1761
+ */
1762
+ type AnyStaticNodeConfigValue = StaticNodeConfigValue<any, any>;
1763
+ /**
1764
+ * @internal
1765
+ *
1766
+ * This is the more specific type than BaseStaticNodeConfig that a subclass
1767
+ * should return from $config()
1768
+ */
1769
+ type StaticNodeConfigRecord<Type$1 extends string, Config$1 extends AnyStaticNodeConfigValue> = BaseStaticNodeConfig & { readonly [K in Type$1]?: Config$1 };
1770
+ /**
1771
+ * Omit the children, type, and version properties from the given SerializedLexicalNode definition.
1772
+ */
1773
+ type LexicalUpdateJSON<T extends SerializedLexicalNode> = Omit<T, 'children' | 'type' | 'version'>;
1774
+ /** @internal */
1775
+ interface LexicalPrivateDOM {
1776
+ __lexicalTextContent?: string | undefined | null;
1777
+ __lexicalLineBreak?: HTMLBRElement | HTMLImageElement | undefined | null;
1778
+ __lexicalDirTextContent?: string | undefined | null;
1779
+ __lexicalDir?: 'ltr' | 'rtl' | null | undefined;
1780
+ __lexicalUnmanaged?: boolean | undefined;
1781
+ }
1782
+ type DOMConversionProp<T extends HTMLElement> = (node: T) => DOMConversion<T> | null;
1783
+ type DOMConversion<T extends HTMLElement = HTMLElement> = {
1784
+ conversion: DOMConversionFn<T>;
1785
+ priority?: 0 | 1 | 2 | 3 | 4;
1786
+ };
1787
+ type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T) => DOMConversionOutput | null;
1788
+ type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined;
1789
+ type DOMConversionMap<T extends HTMLElement = HTMLElement> = Record<NodeName, DOMConversionProp<T>>;
1790
+ type NodeName = string;
1791
+ type DOMConversionOutput = {
1792
+ after?: (childLexicalNodes: Array<LexicalNode>) => Array<LexicalNode>;
1793
+ forChild?: DOMChildConversion;
1794
+ node: null | LexicalNode | Array<LexicalNode>;
1795
+ };
1796
+ type DOMExportOutputMap = Map<Klass<LexicalNode>, (editor: LexicalEditor, target: LexicalNode) => DOMExportOutput>;
1797
+ type DOMExportOutput = {
1798
+ after?: (generatedElement: HTMLElement | DocumentFragment | Text | null | undefined) => HTMLElement | DocumentFragment | Text | null | undefined;
1799
+ element: HTMLElement | DocumentFragment | Text | null;
1800
+ };
1801
+ type NodeKey = string;
1802
+ declare class LexicalNode {
1803
+ ['constructor']: KlassConstructor<typeof LexicalNode>;
1804
+ /** @internal */
1805
+ __type: string;
1806
+ /** @internal */
1807
+ __key: string;
1808
+ /** @internal */
1809
+ __parent: null | NodeKey;
1810
+ /** @internal */
1811
+ __prev: null | NodeKey;
1812
+ /** @internal */
1813
+ __next: null | NodeKey;
1814
+ /** @internal */
1815
+ __state?: NodeState<this>;
1816
+ /**
1817
+ * Returns the string type of this node. Every node must
1818
+ * implement this and it MUST BE UNIQUE amongst nodes registered
1819
+ * on the editor.
1820
+ *
1821
+ */
1822
+ static getType(): string;
1823
+ /**
1824
+ * Clones this node, creating a new node with a different key
1825
+ * and adding it to the EditorState (but not attaching it anywhere!). All nodes must
1826
+ * implement this method.
1827
+ *
1828
+ */
1829
+ static clone(_data: unknown): LexicalNode;
1830
+ /**
1831
+ * Override this to implement the new static node configuration protocol,
1832
+ * this method is called directly on the prototype and must not depend
1833
+ * on anything initialized in the constructor. Generally it should be
1834
+ * a trivial implementation.
1835
+ *
1836
+ * @example
1837
+ * ```ts
1838
+ * class MyNode extends TextNode {
1839
+ * $config() {
1840
+ * return this.config('my-node', {extends: TextNode});
1841
+ * }
1842
+ * }
1843
+ * ```
1844
+ */
1845
+ $config(): BaseStaticNodeConfig;
1846
+ /**
1847
+ * This is a convenience method for $config that
1848
+ * aids in type inference. See {@link LexicalNode.$config}
1849
+ * for example usage.
1850
+ */
1851
+ config<Type$1 extends string, Config$1 extends StaticNodeConfigValue<this, Type$1>>(type: Type$1, config: Config$1): StaticNodeConfigRecord<Type$1, Config$1>;
1852
+ /**
1853
+ * Perform any state updates on the clone of prevNode that are not already
1854
+ * handled by the constructor call in the static clone method. If you have
1855
+ * state to update in your clone that is not handled directly by the
1856
+ * constructor, it is advisable to override this method but it is required
1857
+ * to include a call to `super.afterCloneFrom(prevNode)` in your
1858
+ * implementation. This is only intended to be called by
1859
+ * {@link $cloneWithProperties} function or via a super call.
1860
+ *
1861
+ * @example
1862
+ * ```ts
1863
+ * class ClassesTextNode extends TextNode {
1864
+ * // Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
1865
+ * __classes = new Set<string>();
1866
+ * static clone(node: ClassesTextNode): ClassesTextNode {
1867
+ * // The inherited TextNode constructor is used here, so
1868
+ * // classes is not set by this method.
1869
+ * return new ClassesTextNode(node.__text, node.__key);
1870
+ * }
1871
+ * afterCloneFrom(node: this): void {
1872
+ * // This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
1873
+ * // for necessary state updates
1874
+ * super.afterCloneFrom(node);
1875
+ * this.__addClasses(node.__classes);
1876
+ * }
1877
+ * // This method is a private implementation detail, it is not
1878
+ * // suitable for the public API because it does not call getWritable
1879
+ * __addClasses(classNames: Iterable<string>): this {
1880
+ * for (const className of classNames) {
1881
+ * this.__classes.add(className);
1882
+ * }
1883
+ * return this;
1884
+ * }
1885
+ * addClass(...classNames: string[]): this {
1886
+ * return this.getWritable().__addClasses(classNames);
1887
+ * }
1888
+ * removeClass(...classNames: string[]): this {
1889
+ * const node = this.getWritable();
1890
+ * for (const className of classNames) {
1891
+ * this.__classes.delete(className);
1892
+ * }
1893
+ * return this;
1894
+ * }
1895
+ * getClasses(): Set<string> {
1896
+ * return this.getLatest().__classes;
1897
+ * }
1898
+ * }
1899
+ * ```
1900
+ *
1901
+ */
1902
+ afterCloneFrom(prevNode: this): void;
1903
+ static importDOM?: () => DOMConversionMap<any> | null;
1904
+ constructor(key?: NodeKey);
1905
+ /**
1906
+ * Returns the string type of this node.
1907
+ */
1908
+ getType(): string;
1909
+ isInline(): boolean;
1910
+ /**
1911
+ * Returns true if there is a path between this node and the RootNode, false otherwise.
1912
+ * This is a way of determining if the node is "attached" EditorState. Unattached nodes
1913
+ * won't be reconciled and will ultimately be cleaned up by the Lexical GC.
1914
+ */
1915
+ isAttached(): boolean;
1916
+ /**
1917
+ * Returns true if this node is contained within the provided Selection., false otherwise.
1918
+ * Relies on the algorithms implemented in {@link BaseSelection.getNodes} to determine
1919
+ * what's included.
1920
+ *
1921
+ * @param selection - The selection that we want to determine if the node is in.
1922
+ */
1923
+ isSelected(selection?: null | BaseSelection): boolean;
1924
+ /**
1925
+ * Returns this nodes key.
1926
+ */
1927
+ getKey(): NodeKey;
1928
+ /**
1929
+ * Returns the zero-based index of this node within the parent.
1930
+ */
1931
+ getIndexWithinParent(): number;
1932
+ /**
1933
+ * Returns the parent of this node, or null if none is found.
1934
+ */
1935
+ getParent<T extends ElementNode>(): T | null;
1936
+ /**
1937
+ * Returns the parent of this node, or throws if none is found.
1938
+ */
1939
+ getParentOrThrow<T extends ElementNode>(): T;
1940
+ /**
1941
+ * Returns the highest (in the EditorState tree)
1942
+ * non-root ancestor of this node, or null if none is found. See {@link lexical!$isRootOrShadowRoot}
1943
+ * for more information on which Elements comprise "roots".
1944
+ */
1945
+ getTopLevelElement(): ElementNode | DecoratorNode<unknown> | null;
1946
+ /**
1947
+ * Returns the highest (in the EditorState tree)
1948
+ * non-root ancestor of this node, or throws if none is found. See {@link lexical!$isRootOrShadowRoot}
1949
+ * for more information on which Elements comprise "roots".
1950
+ */
1951
+ getTopLevelElementOrThrow(): ElementNode | DecoratorNode<unknown>;
1952
+ /**
1953
+ * Returns a list of the every ancestor of this node,
1954
+ * all the way up to the RootNode.
1955
+ *
1956
+ */
1957
+ getParents(): Array<ElementNode>;
1958
+ /**
1959
+ * Returns a list of the keys of every ancestor of this node,
1960
+ * all the way up to the RootNode.
1961
+ *
1962
+ */
1963
+ getParentKeys(): Array<NodeKey>;
1964
+ /**
1965
+ * Returns the "previous" siblings - that is, the node that comes
1966
+ * before this one in the same parent.
1967
+ *
1968
+ */
1969
+ getPreviousSibling<T extends LexicalNode>(): T | null;
1970
+ /**
1971
+ * Returns the "previous" siblings - that is, the nodes that come between
1972
+ * this one and the first child of it's parent, inclusive.
1973
+ *
1974
+ */
1975
+ getPreviousSiblings<T extends LexicalNode>(): Array<T>;
1976
+ /**
1977
+ * Returns the "next" siblings - that is, the node that comes
1978
+ * after this one in the same parent
1979
+ *
1980
+ */
1981
+ getNextSibling<T extends LexicalNode>(): T | null;
1982
+ /**
1983
+ * Returns all "next" siblings - that is, the nodes that come between this
1984
+ * one and the last child of it's parent, inclusive.
1985
+ *
1986
+ */
1987
+ getNextSiblings<T extends LexicalNode>(): Array<T>;
1988
+ /**
1989
+ * @deprecated use {@link $getCommonAncestor}
1990
+ *
1991
+ * Returns the closest common ancestor of this node and the provided one or null
1992
+ * if one cannot be found.
1993
+ *
1994
+ * @param node - the other node to find the common ancestor of.
1995
+ */
1996
+ getCommonAncestor<T extends ElementNode = ElementNode>(node: LexicalNode): T | null;
1997
+ /**
1998
+ * Returns true if the provided node is the exact same one as this node, from Lexical's perspective.
1999
+ * Always use this instead of referential equality.
2000
+ *
2001
+ * @param object - the node to perform the equality comparison on.
2002
+ */
2003
+ is(object: LexicalNode | null | undefined): boolean;
2004
+ /**
2005
+ * Returns true if this node logically precedes the target node in the
2006
+ * editor state, false otherwise (including if there is no common ancestor).
2007
+ *
2008
+ * Note that this notion of isBefore is based on post-order; a descendant
2009
+ * node is always before its ancestors. See also
2010
+ * {@link $getCommonAncestor} and {@link $comparePointCaretNext} for
2011
+ * more flexible ways to determine the relative positions of nodes.
2012
+ *
2013
+ * @param targetNode - the node we're testing to see if it's after this one.
2014
+ */
2015
+ isBefore(targetNode: LexicalNode): boolean;
2016
+ /**
2017
+ * Returns true if this node is an ancestor of and distinct from the target node, false otherwise.
2018
+ *
2019
+ * @param targetNode - the would-be child node.
2020
+ */
2021
+ isParentOf(targetNode: LexicalNode): boolean;
2022
+ /**
2023
+ * Returns a list of nodes that are between this node and
2024
+ * the target node in the EditorState.
2025
+ *
2026
+ * @param targetNode - the node that marks the other end of the range of nodes to be returned.
2027
+ */
2028
+ getNodesBetween(targetNode: LexicalNode): Array<LexicalNode>;
2029
+ /**
2030
+ * Returns true if this node has been marked dirty during this update cycle.
2031
+ *
2032
+ */
2033
+ isDirty(): boolean;
2034
+ /**
2035
+ * Returns the latest version of the node from the active EditorState.
2036
+ * This is used to avoid getting values from stale node references.
2037
+ *
2038
+ */
2039
+ getLatest(): this;
2040
+ /**
2041
+ * Returns a mutable version of the node using {@link $cloneWithProperties}
2042
+ * if necessary. Will throw an error if called outside of a Lexical Editor
2043
+ * {@link LexicalEditor.update} callback.
2044
+ *
2045
+ */
2046
+ getWritable(): this;
2047
+ /**
2048
+ * Returns the text content of the node. Override this for
2049
+ * custom nodes that should have a representation in plain text
2050
+ * format (for copy + paste, for example)
2051
+ *
2052
+ */
2053
+ getTextContent(): string;
2054
+ /**
2055
+ * Returns the length of the string produced by calling getTextContent on this node.
2056
+ *
2057
+ */
2058
+ getTextContentSize(): number;
2059
+ /**
2060
+ * Called during the reconciliation process to determine which nodes
2061
+ * to insert into the DOM for this Lexical Node.
2062
+ *
2063
+ * This method must return exactly one HTMLElement. Nested elements are not supported.
2064
+ *
2065
+ * Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.
2066
+ *
2067
+ * @param _config - allows access to things like the EditorTheme (to apply classes) during reconciliation.
2068
+ * @param _editor - allows access to the editor for context during reconciliation.
2069
+ *
2070
+ * */
2071
+ createDOM(_config: EditorConfig, _editor: LexicalEditor): HTMLElement;
2072
+ /**
2073
+ * Called when a node changes and should update the DOM
2074
+ * in whatever way is necessary to make it align with any changes that might
2075
+ * have happened during the update.
2076
+ *
2077
+ * Returning "true" here will cause lexical to unmount and recreate the DOM node
2078
+ * (by calling createDOM). You would need to do this if the element tag changes,
2079
+ * for instance.
2080
+ *
2081
+ * */
2082
+ updateDOM(_prevNode: unknown, _dom: HTMLElement, _config: EditorConfig): boolean;
2083
+ /**
2084
+ * Controls how the this node is serialized to HTML. This is important for
2085
+ * copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces,
2086
+ * in which case the primary transfer format is HTML. It's also important if you're serializing
2087
+ * to HTML for any other reason via {@link @lexical/html!$generateHtmlFromNodes}. You could
2088
+ * also use this method to build your own HTML renderer.
2089
+ *
2090
+ * */
2091
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
2092
+ /**
2093
+ * Controls how the this node is serialized to JSON. This is important for
2094
+ * copy and paste between Lexical editors sharing the same namespace. It's also important
2095
+ * if you're serializing to JSON for persistent storage somewhere.
2096
+ * See [Serialization & Deserialization](https://lexical.dev/docs/concepts/serialization#lexical---html).
2097
+ *
2098
+ * */
2099
+ exportJSON(): SerializedLexicalNode;
2100
+ /**
2101
+ * Controls how the this node is deserialized from JSON. This is usually boilerplate,
2102
+ * but provides an abstraction between the node implementation and serialized interface that can
2103
+ * be important if you ever make breaking changes to a node schema (by adding or removing properties).
2104
+ * See [Serialization & Deserialization](https://lexical.dev/docs/concepts/serialization#lexical---html).
2105
+ *
2106
+ * */
2107
+ static importJSON(_serializedNode: SerializedLexicalNode): LexicalNode;
2108
+ /**
2109
+ * Update this LexicalNode instance from serialized JSON. It's recommended
2110
+ * to implement as much logic as possible in this method instead of the
2111
+ * static importJSON method, so that the functionality can be inherited in subclasses.
2112
+ *
2113
+ * The LexicalUpdateJSON utility type should be used to ignore any type, version,
2114
+ * or children properties in the JSON so that the extended JSON from subclasses
2115
+ * are acceptable parameters for the super call.
2116
+ *
2117
+ * If overridden, this method must call super.
2118
+ *
2119
+ * @example
2120
+ * ```ts
2121
+ * class MyTextNode extends TextNode {
2122
+ * // ...
2123
+ * static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
2124
+ * return $createMyTextNode()
2125
+ * .updateFromJSON(serializedNode);
2126
+ * }
2127
+ * updateFromJSON(
2128
+ * serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
2129
+ * ): this {
2130
+ * return super.updateFromJSON(serializedNode)
2131
+ * .setMyProperty(serializedNode.myProperty);
2132
+ * }
2133
+ * }
2134
+ * ```
2135
+ **/
2136
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedLexicalNode>): this;
2137
+ /**
2138
+ * @experimental
2139
+ *
2140
+ * Registers the returned function as a transform on the node during
2141
+ * Editor initialization. Most such use cases should be addressed via
2142
+ * the {@link LexicalEditor.registerNodeTransform} API.
2143
+ *
2144
+ * Experimental - use at your own risk.
2145
+ */
2146
+ static transform(): ((node: LexicalNode) => void) | null;
2147
+ /**
2148
+ * Removes this LexicalNode from the EditorState. If the node isn't re-inserted
2149
+ * somewhere, the Lexical garbage collector will eventually clean it up.
2150
+ *
2151
+ * @param preserveEmptyParent - If falsy, the node's parent will be removed if
2152
+ * it's empty after the removal operation. This is the default behavior, subject to
2153
+ * other node heuristics such as {@link ElementNode#canBeEmpty}
2154
+ * */
2155
+ remove(preserveEmptyParent?: boolean): void;
2156
+ /**
2157
+ * Replaces this LexicalNode with the provided node, optionally transferring the children
2158
+ * of the replaced node to the replacing node.
2159
+ *
2160
+ * @param replaceWith - The node to replace this one with.
2161
+ * @param includeChildren - Whether or not to transfer the children of this node to the replacing node.
2162
+ * */
2163
+ replace<N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N;
2164
+ /**
2165
+ * Inserts a node after this LexicalNode (as the next sibling).
2166
+ *
2167
+ * @param nodeToInsert - The node to insert after this one.
2168
+ * @param restoreSelection - Whether or not to attempt to resolve the
2169
+ * selection to the appropriate place after the operation is complete.
2170
+ * */
2171
+ insertAfter(nodeToInsert: LexicalNode, restoreSelection?: boolean): LexicalNode;
2172
+ /**
2173
+ * Inserts a node before this LexicalNode (as the previous sibling).
2174
+ *
2175
+ * @param nodeToInsert - The node to insert before this one.
2176
+ * @param restoreSelection - Whether or not to attempt to resolve the
2177
+ * selection to the appropriate place after the operation is complete.
2178
+ * */
2179
+ insertBefore(nodeToInsert: LexicalNode, restoreSelection?: boolean): LexicalNode;
2180
+ /**
2181
+ * Whether or not this node has a required parent. Used during copy + paste operations
2182
+ * to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without
2183
+ * a ListNode parent or TextNodes with a ParagraphNode parent.
2184
+ *
2185
+ * */
2186
+ isParentRequired(): boolean;
2187
+ /**
2188
+ * The creation logic for any required parent. Should be implemented if {@link isParentRequired} returns true.
2189
+ *
2190
+ * */
2191
+ createParentElementNode(): ElementNode;
2192
+ selectStart(): RangeSelection;
2193
+ selectEnd(): RangeSelection;
2194
+ /**
2195
+ * Moves selection to the previous sibling of this node, at the specified offsets.
2196
+ *
2197
+ * @param anchorOffset - The anchor offset for selection.
2198
+ * @param focusOffset - The focus offset for selection
2199
+ * */
2200
+ selectPrevious(anchorOffset?: number, focusOffset?: number): RangeSelection;
2201
+ /**
2202
+ * Moves selection to the next sibling of this node, at the specified offsets.
2203
+ *
2204
+ * @param anchorOffset - The anchor offset for selection.
2205
+ * @param focusOffset - The focus offset for selection
2206
+ * */
2207
+ selectNext(anchorOffset?: number, focusOffset?: number): RangeSelection;
2208
+ /**
2209
+ * Marks a node dirty, triggering transforms and
2210
+ * forcing it to be reconciled during the update cycle.
2211
+ *
2212
+ * */
2213
+ markDirty(): void;
2214
+ /**
2215
+ * @internal
2216
+ *
2217
+ * When the reconciler detects that a node was mutated, this method
2218
+ * may be called to restore the node to a known good state.
2219
+ */
2220
+ reconcileObservedMutation(dom: HTMLElement, editor: LexicalEditor): void;
2221
+ }
2222
+ //#endregion
2223
+ //#region ../../node_modules/.pnpm/lexical@0.35.0/node_modules/lexical/nodes/LexicalDecoratorNode.d.ts
2224
+ interface DecoratorNode<T> {
2225
+ getTopLevelElement(): ElementNode | this | null;
2226
+ getTopLevelElementOrThrow(): ElementNode | this;
2227
+ }
2228
+ /** @noInheritDoc */
2229
+ declare class DecoratorNode<T> extends LexicalNode {
2230
+ ['constructor']: KlassConstructor<typeof DecoratorNode<T>>;
2231
+ /**
2232
+ * The returned value is added to the LexicalEditor._decorators
2233
+ */
2234
+ decorate(editor: LexicalEditor, config: EditorConfig): T;
2235
+ isIsolated(): boolean;
2236
+ isInline(): boolean;
2237
+ isKeyboardSelectable(): boolean;
2238
+ }
2239
+ //#endregion
2240
+ export { LexicalNodeReplacement as a, TextNode as c, Klass as i, ElementNode as l, SerializedLexicalNode as n, SerializedEditorState as o, EditorConfig as r, TextFormatType as s, LexicalNode as t };
2241
+ //# sourceMappingURL=LexicalDecoratorNode-C9hMKfgk.d.mts.map