@examind/block-types 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +40 -0
  2. package/package.json +21 -0
  3. package/types/examind/index.d.ts +12 -0
  4. package/types/examind/nodes/EssayQuestionNode.ts +16 -0
  5. package/types/examind/nodes/FillInTheBlankQuestionNode.ts +14 -0
  6. package/types/examind/nodes/FillInTheBlankSpaceNode.ts +21 -0
  7. package/types/examind/nodes/FinancialStatementQuestionNode.ts +46 -0
  8. package/types/examind/nodes/HorizontalRuleNode.ts +3 -0
  9. package/types/examind/nodes/ImageNode.ts +18 -0
  10. package/types/examind/nodes/JournalEntryQuestionNode.ts +32 -0
  11. package/types/examind/nodes/MatchingQuestionNode.ts +21 -0
  12. package/types/examind/nodes/MultipleOptionQuestionNode.ts +29 -0
  13. package/types/examind/nodes/ShortAnswerQuestionNode.ts +15 -0
  14. package/types/examind/nodes/SimulationQuestionNode.ts +15 -0
  15. package/types/examind/nodes/VariableNode.ts +24 -0
  16. package/types/index.ts +2 -0
  17. package/types/lexical/LexicalCommands.ts +159 -0
  18. package/types/lexical/LexicalConstants.ts +51 -0
  19. package/types/lexical/LexicalEditor.ts +597 -0
  20. package/types/lexical/LexicalEditorState.ts +30 -0
  21. package/types/lexical/LexicalEvents.ts +13 -0
  22. package/types/lexical/LexicalGC.ts +13 -0
  23. package/types/lexical/LexicalMutations.ts +10 -0
  24. package/types/lexical/LexicalNode.ts +460 -0
  25. package/types/lexical/LexicalNodeState.ts +379 -0
  26. package/types/lexical/LexicalNormalization.ts +9 -0
  27. package/types/lexical/LexicalReconciler.ts +13 -0
  28. package/types/lexical/LexicalSelection.ts +295 -0
  29. package/types/lexical/LexicalUpdateTags.ts +51 -0
  30. package/types/lexical/LexicalUpdates.ts +31 -0
  31. package/types/lexical/LexicalUtils.ts +304 -0
  32. package/types/lexical/index.ts +35 -0
  33. package/types/lexical/link/index.ts +125 -0
  34. package/types/lexical/list/LexicalListItemNode.ts +65 -0
  35. package/types/lexical/list/LexicalListNode.ts +56 -0
  36. package/types/lexical/list/checkList.ts +9 -0
  37. package/types/lexical/list/formatList.ts +69 -0
  38. package/types/lexical/list/index.ts +11 -0
  39. package/types/lexical/list/utils.ts +64 -0
  40. package/types/lexical/nodes/ArtificialNode.ts +12 -0
  41. package/types/lexical/nodes/LexicalDecoratorNode.ts +26 -0
  42. package/types/lexical/nodes/LexicalElementNode.ts +207 -0
  43. package/types/lexical/nodes/LexicalLineBreakNode.ts +25 -0
  44. package/types/lexical/nodes/LexicalParagraphNode.ts +31 -0
  45. package/types/lexical/nodes/LexicalRootNode.ts +30 -0
  46. package/types/lexical/nodes/LexicalTabNode.ts +28 -0
  47. package/types/lexical/nodes/LexicalTextNode.ts +288 -0
  48. package/types/lexical/rich-text/index.ts +53 -0
  49. package/types/lexical/table/LexicalTableCellNode.ts +72 -0
  50. package/types/lexical/table/LexicalTableCommands.ts +17 -0
  51. package/types/lexical/table/LexicalTableNode.ts +65 -0
  52. package/types/lexical/table/LexicalTableObserver.ts +108 -0
  53. package/types/lexical/table/LexicalTablePluginHelpers.ts +25 -0
  54. package/types/lexical/table/LexicalTableRowNode.ts +34 -0
  55. package/types/lexical/table/LexicalTableSelection.ts +74 -0
  56. package/types/lexical/table/LexicalTableSelectionHelpers.ts +40 -0
  57. package/types/lexical/table/LexicalTableUtils.ts +112 -0
  58. package/types/lexical/table/constants.ts +8 -0
  59. package/types/lexical/table/index.ts +16 -0
@@ -0,0 +1,304 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ import type { CommandPayloadType, EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes, Spread } from './LexicalEditor';
8
+ import type { EditorState } from './LexicalEditorState';
9
+ import type { LexicalNode, NodeKey, NodeMap } from './LexicalNode';
10
+ import type { BaseSelection, PointType, RangeSelection } from './LexicalSelection';
11
+ import type { RootNode } from './nodes/LexicalRootNode';
12
+ import type { TextFormatType, TextNode } from './nodes/LexicalTextNode';
13
+ import { DecoratorNode, ElementNode, LineBreakNode, UpdateTag } from '.';
14
+ import { LexicalEditor } from './LexicalEditor';
15
+ export declare const emptyFunction: () => void;
16
+ export declare function resetRandomKey(): void;
17
+ export declare function generateRandomKey(): string;
18
+ export declare function getRegisteredNodeOrThrow(editor: LexicalEditor, nodeType: string): RegisteredNode;
19
+ export declare const isArray: (arg: any) => arg is any[];
20
+ export declare const scheduleMicroTask: (fn: () => void) => void;
21
+ export declare function $isSelectionCapturedInDecorator(node: Node): boolean;
22
+ export declare function isSelectionCapturedInDecoratorInput(anchorDOM: Node): boolean;
23
+ export declare function isSelectionWithinEditor(editor: LexicalEditor, anchorDOM: null | Node, focusDOM: null | Node): boolean;
24
+ /**
25
+ * @returns true if the given argument is a LexicalEditor instance from this build of Lexical
26
+ */
27
+ export declare function isLexicalEditor(editor: unknown): editor is LexicalEditor;
28
+ export declare function getNearestEditorFromDOMNode(node: Node | null): LexicalEditor | null;
29
+ /** @internal */
30
+ export declare function getEditorPropertyFromDOMNode(node: Node | null): unknown;
31
+ export declare function getTextDirection(text: string): 'ltr' | 'rtl' | null;
32
+ /**
33
+ * Return true if the TextNode is a TabNode or is in token mode.
34
+ */
35
+ export declare function $isTokenOrTab(node: TextNode): boolean;
36
+ /**
37
+ * Return true if the TextNode is a TabNode, or is in token or segmented mode.
38
+ */
39
+ export declare function $isTokenOrSegmented(node: TextNode): boolean;
40
+ /**
41
+ * @param node - The element being tested
42
+ * @returns Returns true if node is an DOM Text node, false otherwise.
43
+ */
44
+ export declare function isDOMTextNode(node: unknown): node is Text;
45
+ /**
46
+ * @param node - The element being tested
47
+ * @returns Returns true if node is an DOM Document node, false otherwise.
48
+ */
49
+ export declare function isDOMDocumentNode(node: unknown): node is Document;
50
+ export declare function getDOMTextNode(element: Node | null): Text | null;
51
+ export declare function toggleTextFormatType(format: number, type: TextFormatType, alignWithFormat: null | number): number;
52
+ export declare function $isLeafNode(node: LexicalNode | null | undefined): node is TextNode | LineBreakNode | DecoratorNode<unknown>;
53
+ export declare function $setNodeKey(node: LexicalNode, existingKey: NodeKey | null | undefined): void;
54
+ /**
55
+ * Removes a node from its parent, updating all necessary pointers and links.
56
+ * @internal
57
+ *
58
+ * This function is for internal use of the library.
59
+ * Please do not use it as it may change in the future.
60
+ */
61
+ export declare function removeFromParent(node: LexicalNode): void;
62
+ export declare function internalMarkNodeAsDirty(node: LexicalNode): void;
63
+ export declare function internalMarkSiblingsAsDirty(node: LexicalNode): void;
64
+ export declare function $setCompositionKey(compositionKey: null | NodeKey): void;
65
+ export declare function $getCompositionKey(): null | NodeKey;
66
+ export declare function $getNodeByKey<T extends LexicalNode>(key: NodeKey, _editorState?: EditorState): T | null;
67
+ export declare function $getNodeFromDOMNode(dom: Node, editorState?: EditorState): LexicalNode | null;
68
+ export declare function setNodeKeyOnDOMNode(dom: Node, editor: LexicalEditor, key: NodeKey): void;
69
+ export declare function getNodeKeyFromDOMNode(dom: Node, editor: LexicalEditor): NodeKey | undefined;
70
+ export declare function $getNearestNodeFromDOMNode(startingDOM: Node, editorState?: EditorState): LexicalNode | null;
71
+ export declare function cloneDecorators(editor: LexicalEditor): Record<NodeKey, unknown>;
72
+ export declare function getEditorStateTextContent(editorState: EditorState): string;
73
+ export declare function markNodesWithTypesAsDirty(editor: LexicalEditor, types: string[]): void;
74
+ export declare function $getRoot(): RootNode;
75
+ export declare function internalGetRoot(editorState: EditorState): RootNode;
76
+ export declare function $setSelection(selection: null | BaseSelection): void;
77
+ export declare function $flushMutations(): void;
78
+ export declare function $getNodeFromDOM(dom: Node): null | LexicalNode;
79
+ export declare function getTextNodeOffset(node: TextNode, moveSelectionToEnd: boolean): number;
80
+ /**
81
+ * Return true if `str` contains any valid surrogate pair.
82
+ *
83
+ * See also $updateCaretSelectionForUnicodeCharacter for
84
+ * a discussion on when and why this is useful.
85
+ */
86
+ export declare function doesContainSurrogatePair(str: string): boolean;
87
+ export declare function getEditorsToPropagate(editor: LexicalEditor): Array<LexicalEditor>;
88
+ export declare function createUID(): string;
89
+ export declare function getAnchorTextFromDOM(anchorNode: Node): null | string;
90
+ export declare function $updateSelectedTextFromDOM(isCompositionEnd: boolean, editor: LexicalEditor, data?: string): void;
91
+ export declare function $updateTextNodeFromDOMContent(textNode: TextNode, textContent: string, anchorOffset: null | number, focusOffset: null | number, compositionEnd: boolean): void;
92
+ export declare function $shouldInsertTextAfterOrBeforeTextNode(selection: RangeSelection, node: TextNode): boolean;
93
+ /**
94
+ * A KeyboardEvent or structurally similar object with a string `key` as well
95
+ * as `altKey`, `ctrlKey`, `metaKey`, and `shiftKey` boolean properties.
96
+ */
97
+ export type KeyboardEventModifiers = Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey' | 'shiftKey' | 'altKey'>;
98
+ /**
99
+ * A record of keyboard modifiers that must be enabled.
100
+ * If the value is `'any'` then the modifier key's state is ignored.
101
+ * If the value is `true` then the modifier key must be pressed.
102
+ * If the value is `false` or the property is omitted then the modifier key must
103
+ * not be pressed.
104
+ */
105
+ export type KeyboardEventModifierMask = {
106
+ [K in Exclude<keyof KeyboardEventModifiers, 'key'>]?: boolean | undefined | 'any';
107
+ };
108
+ /**
109
+ * Match a KeyboardEvent with its expected modifier state
110
+ *
111
+ * @param event A KeyboardEvent, or structurally similar object
112
+ * @param mask An object specifying the expected state of the modifiers
113
+ * @returns true if the event matches
114
+ */
115
+ export declare function isModifierMatch(event: KeyboardEventModifiers, mask: KeyboardEventModifierMask): boolean;
116
+ /**
117
+ * Match a KeyboardEvent with its expected state
118
+ *
119
+ * @param event A KeyboardEvent, or structurally similar object
120
+ * @param expectedKey The string to compare with event.key (case insensitive)
121
+ * @param mask An object specifying the expected state of the modifiers
122
+ * @returns true if the event matches
123
+ */
124
+ export declare function isExactShortcutMatch(event: KeyboardEventModifiers, expectedKey: string, mask: KeyboardEventModifierMask): boolean;
125
+ export declare function isTab(event: KeyboardEventModifiers): boolean;
126
+ export declare function isBold(event: KeyboardEventModifiers): boolean;
127
+ export declare function isItalic(event: KeyboardEventModifiers): boolean;
128
+ export declare function isUnderline(event: KeyboardEventModifiers): boolean;
129
+ export declare function isParagraph(event: KeyboardEventModifiers): boolean;
130
+ export declare function isLineBreak(event: KeyboardEventModifiers): boolean;
131
+ export declare function isOpenLineBreak(event: KeyboardEventModifiers): boolean;
132
+ export declare function isDeleteWordBackward(event: KeyboardEventModifiers): boolean;
133
+ export declare function isDeleteWordForward(event: KeyboardEventModifiers): boolean;
134
+ export declare function isDeleteLineBackward(event: KeyboardEventModifiers): boolean;
135
+ export declare function isDeleteLineForward(event: KeyboardEventModifiers): boolean;
136
+ export declare function isDeleteBackward(event: KeyboardEventModifiers): boolean;
137
+ export declare function isDeleteForward(event: KeyboardEventModifiers): boolean;
138
+ export declare function isUndo(event: KeyboardEventModifiers): boolean;
139
+ export declare function isRedo(event: KeyboardEventModifiers): boolean;
140
+ export declare function isCopy(event: KeyboardEventModifiers): boolean;
141
+ export declare function isCut(event: KeyboardEventModifiers): boolean;
142
+ export declare function isMoveBackward(event: KeyboardEventModifiers): boolean;
143
+ export declare function isMoveToStart(event: KeyboardEventModifiers): boolean;
144
+ export declare function isMoveForward(event: KeyboardEventModifiers): boolean;
145
+ export declare function isMoveToEnd(event: KeyboardEventModifiers): boolean;
146
+ export declare function isMoveUp(event: KeyboardEventModifiers): boolean;
147
+ export declare function isMoveDown(event: KeyboardEventModifiers): boolean;
148
+ export declare function isModifier(event: KeyboardEventModifiers): boolean;
149
+ export declare function isSpace(event: KeyboardEventModifiers): boolean;
150
+ export declare function controlOrMeta(metaKey: boolean, ctrlKey: boolean): boolean;
151
+ export declare function isBackspace(event: KeyboardEventModifiers): boolean;
152
+ export declare function isEscape(event: KeyboardEventModifiers): boolean;
153
+ export declare function isDelete(event: KeyboardEventModifiers): boolean;
154
+ export declare function isSelectAll(event: KeyboardEventModifiers): boolean;
155
+ export declare function $selectAll(selection?: RangeSelection | null): RangeSelection;
156
+ export declare function getCachedClassNameArray(classNamesTheme: EditorThemeClasses, classNameThemeType: string): Array<string>;
157
+ export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNodes: RegisteredNodes, mutationListeners: MutationListeners, node: LexicalNode, mutation: NodeMutation): void;
158
+ /**
159
+ * @deprecated Use {@link LexicalEditor.registerMutationListener} with `skipInitialization: false` instead.
160
+ */
161
+ export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<T>;
162
+ export declare function $getAdjacentNode(focus: PointType, isBackward: boolean): null | LexicalNode;
163
+ export declare function isFirefoxClipboardEvents(editor: LexicalEditor): boolean;
164
+ export declare function dispatchCommand<TCommand extends LexicalCommand<unknown>>(editor: LexicalEditor, command: TCommand, payload: CommandPayloadType<TCommand>): boolean;
165
+ export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean;
166
+ export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement;
167
+ export declare function getParentElement(node: Node): HTMLElement | null;
168
+ export declare function getDOMOwnerDocument(target: EventTarget | null): Document | null;
169
+ export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, selectionRect: DOMRect, rootElement: HTMLElement): void;
170
+ export declare function $hasUpdateTag(tag: UpdateTag): boolean;
171
+ export declare function $addUpdateTag(tag: UpdateTag): void;
172
+ /**
173
+ * Add a function to run after the current update. This will run after any
174
+ * `onUpdate` function already supplied to `editor.update()`, as well as any
175
+ * functions added with previous calls to `$onUpdate`.
176
+ *
177
+ * @param updateFn The function to run after the current update.
178
+ */
179
+ export declare function $onUpdate(updateFn: () => void): void;
180
+ export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode): BaseSelection | null;
181
+ export declare function $hasAncestor(child: LexicalNode, targetNode: LexicalNode): boolean;
182
+ export declare function getDefaultView(domElem: EventTarget | null): Window | null;
183
+ export declare function getWindow(editor: LexicalEditor): Window;
184
+ export declare function $isInlineElementOrDecoratorNode(node: LexicalNode): boolean;
185
+ export declare function $getNearestRootOrShadowRoot(node: LexicalNode): RootNode | ElementNode;
186
+ declare const ShadowRootNodeBrand: unique symbol;
187
+ type ShadowRootNode = Spread<{
188
+ isShadowRoot(): true;
189
+ [ShadowRootNodeBrand]: never;
190
+ }, ElementNode>;
191
+ export declare function $isRootOrShadowRoot(node: null | LexicalNode): node is RootNode | ShadowRootNode;
192
+ /**
193
+ * Returns a shallow clone of node with a new key
194
+ *
195
+ * @param node - The node to be copied.
196
+ * @returns The copy of the node.
197
+ */
198
+ export declare function $copyNode<T extends LexicalNode>(node: T): T;
199
+ export declare function $applyNodeReplacement<N extends LexicalNode>(node: N): N;
200
+ export declare function errorOnInsertTextNodeOnRoot(node: LexicalNode, insertNode: LexicalNode): void;
201
+ export declare function $getNodeByKeyOrThrow<N extends LexicalNode>(key: NodeKey): N;
202
+ export declare function removeDOMBlockCursorElement(blockCursorElement: HTMLElement, editor: LexicalEditor, rootElement: HTMLElement): void;
203
+ export declare function updateDOMBlockCursorElement(editor: LexicalEditor, rootElement: HTMLElement, nextSelection: null | BaseSelection): void;
204
+ /**
205
+ * Returns the selection for the given window, or the global window if null.
206
+ * Will return null if {@link CAN_USE_DOM} is false.
207
+ *
208
+ * @param targetWindow The window to get the selection from
209
+ * @returns a Selection or null
210
+ */
211
+ export declare function getDOMSelection(targetWindow: null | Window): null | Selection;
212
+ /**
213
+ * Returns the selection for the defaultView of the ownerDocument of given EventTarget.
214
+ *
215
+ * @param eventTarget The node to get the selection from
216
+ * @returns a Selection or null
217
+ */
218
+ export declare function getDOMSelectionFromTarget(eventTarget: null | EventTarget): null | Selection;
219
+ export declare function $splitNode(node: ElementNode, offset: number): [ElementNode | null, ElementNode];
220
+ export declare function $findMatchingParent(startingNode: LexicalNode, findFn: (node: LexicalNode) => boolean): LexicalNode | null;
221
+ /**
222
+ * @param x - The element being tested
223
+ * @returns Returns true if x is an HTML anchor tag, false otherwise
224
+ */
225
+ export declare function isHTMLAnchorElement(x: unknown): x is HTMLAnchorElement;
226
+ /**
227
+ * @param x - The element being tested
228
+ * @returns Returns true if x is an HTML element, false otherwise.
229
+ */
230
+ export declare function isHTMLElement(x: unknown): x is HTMLElement;
231
+ /**
232
+ * @param x - The element being tested
233
+ * @returns Returns true if x is a DOM Node, false otherwise.
234
+ */
235
+ export declare function isDOMNode(x: unknown): x is Node;
236
+ /**
237
+ * @param x - The element being testing
238
+ * @returns Returns true if x is a document fragment, false otherwise.
239
+ */
240
+ export declare function isDocumentFragment(x: unknown): x is DocumentFragment;
241
+ /**
242
+ *
243
+ * @param node - the Dom Node to check
244
+ * @returns if the Dom Node is an inline node
245
+ */
246
+ export declare function isInlineDomNode(node: Node): boolean;
247
+ /**
248
+ *
249
+ * @param node - the Dom Node to check
250
+ * @returns if the Dom Node is a block node
251
+ */
252
+ export declare function isBlockDomNode(node: Node): boolean;
253
+ /**
254
+ * @internal
255
+ *
256
+ * This function is for internal use of the library.
257
+ * Please do not use it as it may change in the future.
258
+ *
259
+ * This function returns true for a DecoratorNode that is not inline OR
260
+ * an ElementNode that is:
261
+ * - not a root or shadow root
262
+ * - not inline
263
+ * - can't be empty
264
+ * - has no children or an inline first child
265
+ */
266
+ export declare function INTERNAL_$isBlock(node: LexicalNode): node is ElementNode | DecoratorNode<unknown>;
267
+ export declare function $getAncestor<NodeType extends LexicalNode = LexicalNode>(node: LexicalNode, predicate: (ancestor: LexicalNode) => ancestor is NodeType): NodeType | null;
268
+ /**
269
+ * Utility function for accessing current active editor instance.
270
+ * @returns Current active editor
271
+ */
272
+ export declare function $getEditor(): LexicalEditor;
273
+ /** @internal */
274
+ export type TypeToNodeMap = Map<string, NodeMap>;
275
+ export declare function getCachedTypeToNodeMap(editorState: EditorState): TypeToNodeMap;
276
+ /**
277
+ * Returns a clone of a node using `node.constructor.clone()` followed by
278
+ * `clone.afterCloneFrom(node)`. The resulting clone must have the same key,
279
+ * parent/next/prev pointers, and other properties that are not set by
280
+ * `node.constructor.clone` (format, style, etc.). This is primarily used by
281
+ * {@link LexicalNode.getWritable} to create a writable version of an
282
+ * existing node. The clone is the same logical node as the original node,
283
+ * do not try and use this function to duplicate or copy an existing node.
284
+ *
285
+ * Does not mutate the EditorState.
286
+ * @param node - The node to be cloned.
287
+ * @returns The clone of the node.
288
+ */
289
+ export declare function $cloneWithProperties<T extends LexicalNode>(latestNode: T): T;
290
+ export declare function setNodeIndentFromDOM(elementDom: HTMLElement, elementNode: ElementNode): void;
291
+ /**
292
+ * @internal
293
+ *
294
+ * Mark this node as unmanaged by lexical's mutation observer like
295
+ * decorator nodes
296
+ */
297
+ export declare function setDOMUnmanaged(elementDom: HTMLElement): void;
298
+ /**
299
+ * @internal
300
+ *
301
+ * True if this DOM node was marked with {@link setDOMUnmanaged}
302
+ */
303
+ export declare function isDOMUnmanaged(elementDom: Node): boolean;
304
+ export {};
@@ -0,0 +1,35 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ export * from './LexicalCommands';
8
+ export * from './LexicalConstants';
9
+ export * from './LexicalEditor';
10
+ export * from './LexicalEditorState';
11
+ export * from './LexicalEvents';
12
+ export * from './LexicalGC';
13
+ export * from './LexicalMutations';
14
+ export * from './LexicalNode';
15
+ export * from './LexicalNodeState';
16
+ export * from './LexicalNormalization';
17
+ export * from './LexicalReconciler';
18
+ export * from './LexicalSelection';
19
+ export * from './LexicalUpdateTags';
20
+ export * from './LexicalUpdates';
21
+ export * from './LexicalUtils';
22
+ export * from './nodes/ArtificialNode';
23
+ export * from './nodes/LexicalDecoratorNode';
24
+ export * from './nodes/LexicalElementNode';
25
+ export * from './nodes/LexicalLineBreakNode';
26
+ export * from './nodes/LexicalParagraphNode';
27
+ export * from './nodes/LexicalRootNode';
28
+ export * from './nodes/LexicalTabNode';
29
+ export * from './nodes/LexicalTextNode';
30
+
31
+ // Plugin exports
32
+ export * from './link';
33
+ export * from './list';
34
+ export * from './rich-text';
35
+ export * from './table';
@@ -0,0 +1,125 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ import type { BaseSelection, DOMConversionMap, EditorConfig, LexicalCommand, LexicalNode, LexicalUpdateJSON, NodeKey, RangeSelection, SerializedElementNode } from './../';
8
+ import { ElementNode, Spread } from './../';
9
+ export type LinkAttributes = {
10
+ rel?: null | string;
11
+ target?: null | string;
12
+ title?: null | string;
13
+ };
14
+ export type AutoLinkAttributes = Partial<Spread<LinkAttributes, {
15
+ isUnlinked?: boolean;
16
+ }>>;
17
+ export type SerializedLinkNode = Spread<{
18
+ url: string;
19
+ }, Spread<LinkAttributes, SerializedElementNode>>;
20
+ type LinkHTMLElementType = HTMLAnchorElement | HTMLSpanElement;
21
+ /** @noInheritDoc */
22
+ export declare class LinkNode extends ElementNode {
23
+ /** @internal */
24
+ __url: string;
25
+ /** @internal */
26
+ __target: null | string;
27
+ /** @internal */
28
+ __rel: null | string;
29
+ /** @internal */
30
+ __title: null | string;
31
+ static getType(): string;
32
+ static clone(node: LinkNode): LinkNode;
33
+ constructor(url?: string, attributes?: LinkAttributes, key?: NodeKey);
34
+ createDOM(config: EditorConfig): LinkHTMLElementType;
35
+ updateLinkDOM(prevNode: this | null, anchor: LinkHTMLElementType, config: EditorConfig): void;
36
+ updateDOM(prevNode: this, anchor: LinkHTMLElementType, config: EditorConfig): boolean;
37
+ static importDOM(): DOMConversionMap | null;
38
+ static importJSON(serializedNode: SerializedLinkNode): LinkNode;
39
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedLinkNode>): this;
40
+ sanitizeUrl(url: string): string;
41
+ exportJSON(): SerializedLinkNode | SerializedAutoLinkNode;
42
+ getURL(): string;
43
+ setURL(url: string): this;
44
+ getTarget(): null | string;
45
+ setTarget(target: null | string): this;
46
+ getRel(): null | string;
47
+ setRel(rel: null | string): this;
48
+ getTitle(): null | string;
49
+ setTitle(title: null | string): this;
50
+ insertNewAfter(_: RangeSelection, restoreSelection?: boolean): null | ElementNode;
51
+ canInsertTextBefore(): false;
52
+ canInsertTextAfter(): false;
53
+ canBeEmpty(): false;
54
+ isInline(): true;
55
+ extractWithChild(child: LexicalNode, selection: BaseSelection, destination: 'clone' | 'html'): boolean;
56
+ isEmailURI(): boolean;
57
+ isWebSiteURI(): boolean;
58
+ }
59
+ /**
60
+ * Takes a URL and creates a LinkNode.
61
+ * @param url - The URL the LinkNode should direct to.
62
+ * @param attributes - Optional HTML a tag attributes \\{ target, rel, title \\}
63
+ * @returns The LinkNode.
64
+ */
65
+ export declare function $createLinkNode(url?: string, attributes?: LinkAttributes): LinkNode;
66
+ /**
67
+ * Determines if node is a LinkNode.
68
+ * @param node - The node to be checked.
69
+ * @returns true if node is a LinkNode, false otherwise.
70
+ */
71
+ export declare function $isLinkNode(node: LexicalNode | null | undefined): node is LinkNode;
72
+ export type SerializedAutoLinkNode = Spread<{
73
+ isUnlinked: boolean;
74
+ }, SerializedLinkNode>;
75
+ export declare class AutoLinkNode extends LinkNode {
76
+ /** @internal */
77
+ /** Indicates whether the autolink was ever unlinked. **/
78
+ __isUnlinked: boolean;
79
+ constructor(url?: string, attributes?: AutoLinkAttributes, key?: NodeKey);
80
+ static getType(): string;
81
+ static clone(node: AutoLinkNode): AutoLinkNode;
82
+ getIsUnlinked(): boolean;
83
+ setIsUnlinked(value: boolean): this;
84
+ createDOM(config: EditorConfig): LinkHTMLElementType;
85
+ updateDOM(prevNode: this, anchor: LinkHTMLElementType, config: EditorConfig): boolean;
86
+ static importJSON(serializedNode: SerializedAutoLinkNode): AutoLinkNode;
87
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedAutoLinkNode>): this;
88
+ static importDOM(): null;
89
+ exportJSON(): SerializedAutoLinkNode;
90
+ insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | ElementNode;
91
+ }
92
+ /**
93
+ * Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated
94
+ * during typing, which is especially useful when a button to generate a LinkNode is not practical.
95
+ * @param url - The URL the LinkNode should direct to.
96
+ * @param attributes - Optional HTML a tag attributes. \\{ target, rel, title \\}
97
+ * @returns The LinkNode.
98
+ */
99
+ export declare function $createAutoLinkNode(url?: string, attributes?: AutoLinkAttributes): AutoLinkNode;
100
+ /**
101
+ * Determines if node is an AutoLinkNode.
102
+ * @param node - The node to be checked.
103
+ * @returns true if node is an AutoLinkNode, false otherwise.
104
+ */
105
+ export declare function $isAutoLinkNode(node: LexicalNode | null | undefined): node is AutoLinkNode;
106
+ export declare const TOGGLE_LINK_COMMAND: LexicalCommand<string | ({
107
+ url: string;
108
+ } & LinkAttributes) | null>;
109
+ /**
110
+ * Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null,
111
+ * but saves any children and brings them up to the parent node.
112
+ * @param url - The URL the link directs to.
113
+ * @param attributes - Optional HTML a tag attributes. \\{ target, rel, title \\}
114
+ */
115
+ export declare function $toggleLink(url: null | string, attributes?: LinkAttributes): void;
116
+ /** @deprecated renamed to {@link $toggleLink} by @lexical/eslint-plugin rules-of-lexical */
117
+ export declare const toggleLink: typeof $toggleLink;
118
+ /**
119
+ * Formats a URL string by adding appropriate protocol if missing
120
+ *
121
+ * @param url - URL to format
122
+ * @returns Formatted URL with appropriate protocol
123
+ */
124
+ export declare function formatUrl(url: string): string;
125
+ export {};
@@ -0,0 +1,65 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ import type { BaseSelection, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, LexicalUpdateJSON, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread } from './../';
8
+ import { ElementNode, LexicalEditor } from './../';
9
+ export type SerializedListItemNode = Spread<{
10
+ checked: boolean | undefined;
11
+ value: number;
12
+ }, SerializedElementNode>;
13
+ /** @noInheritDoc */
14
+ export declare class ListItemNode extends ElementNode {
15
+ /** @internal */
16
+ __value: number;
17
+ /** @internal */
18
+ __checked?: boolean;
19
+ static getType(): string;
20
+ static clone(node: ListItemNode): ListItemNode;
21
+ constructor(value?: number, checked?: boolean, key?: NodeKey);
22
+ createDOM(config: EditorConfig): HTMLElement;
23
+ updateListItemDOM(prevNode: ListItemNode | null, dom: HTMLLIElement, config: EditorConfig): void;
24
+ updateDOM(prevNode: ListItemNode, dom: HTMLElement, config: EditorConfig): boolean;
25
+ static transform(): (node: LexicalNode) => void;
26
+ static importDOM(): DOMConversionMap | null;
27
+ static importJSON(serializedNode: SerializedListItemNode): ListItemNode;
28
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedListItemNode>): this;
29
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
30
+ exportJSON(): SerializedListItemNode;
31
+ append(...nodes: LexicalNode[]): this;
32
+ replace<N extends LexicalNode>(replaceWithNode: N, includeChildren?: boolean): N;
33
+ insertAfter(node: LexicalNode, restoreSelection?: boolean): LexicalNode;
34
+ remove(preserveEmptyParent?: boolean): void;
35
+ insertNewAfter(_: RangeSelection, restoreSelection?: boolean): ListItemNode | ParagraphNode;
36
+ collapseAtStart(selection: RangeSelection): true;
37
+ getValue(): number;
38
+ setValue(value: number): this;
39
+ getChecked(): boolean | undefined;
40
+ setChecked(checked?: boolean): this;
41
+ toggleChecked(): this;
42
+ getIndent(): number;
43
+ setIndent(indent: number): this;
44
+ /** @deprecated @internal */
45
+ canInsertAfter(node: LexicalNode): boolean;
46
+ /** @deprecated @internal */
47
+ canReplaceWith(replacement: LexicalNode): boolean;
48
+ canMergeWith(node: LexicalNode): boolean;
49
+ extractWithChild(child: LexicalNode, selection: BaseSelection): boolean;
50
+ isParentRequired(): true;
51
+ createParentElementNode(): ElementNode;
52
+ canMergeWhenEmpty(): true;
53
+ }
54
+ /**
55
+ * Creates a new List Item node, passing true/false will convert it to a checkbox input.
56
+ * @param checked - Is the List Item a checkbox and, if so, is it checked? undefined/null: not a checkbox, true/false is a checkbox and checked/unchecked, respectively.
57
+ * @returns The new List Item.
58
+ */
59
+ export declare function $createListItemNode(checked?: boolean): ListItemNode;
60
+ /**
61
+ * Checks to see if the node is a ListItemNode.
62
+ * @param node - The node to be checked.
63
+ * @returns true if the node is a ListItemNode, false otherwise.
64
+ */
65
+ export declare function $isListItemNode(node: LexicalNode | null | undefined): node is ListItemNode;
@@ -0,0 +1,56 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ import { DOMConversionMap, DOMExportOutput, EditorConfig, ElementNode, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedElementNode, Spread } from './../';
8
+ export type SerializedListNode = Spread<{
9
+ listType: ListType;
10
+ start: number;
11
+ tag: ListNodeTagType;
12
+ }, SerializedElementNode>;
13
+ export type ListType = 'number' | 'bullet' | 'check';
14
+ export type ListNodeTagType = 'ul' | 'ol';
15
+ /** @noInheritDoc */
16
+ export declare class ListNode extends ElementNode {
17
+ /** @internal */
18
+ __tag: ListNodeTagType;
19
+ /** @internal */
20
+ __start: number;
21
+ /** @internal */
22
+ __listType: ListType;
23
+ static getType(): string;
24
+ static clone(node: ListNode): ListNode;
25
+ constructor(listType?: ListType, start?: number, key?: NodeKey);
26
+ getTag(): ListNodeTagType;
27
+ setListType(type: ListType): this;
28
+ getListType(): ListType;
29
+ getStart(): number;
30
+ setStart(start: number): this;
31
+ createDOM(config: EditorConfig, _editor?: LexicalEditor): HTMLElement;
32
+ updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
33
+ static transform(): (node: LexicalNode) => void;
34
+ static importDOM(): DOMConversionMap | null;
35
+ static importJSON(serializedNode: SerializedListNode): ListNode;
36
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedListNode>): this;
37
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
38
+ exportJSON(): SerializedListNode;
39
+ canBeEmpty(): false;
40
+ canIndent(): false;
41
+ splice(start: number, deleteCount: number, nodesToInsert: LexicalNode[]): this;
42
+ extractWithChild(child: LexicalNode): boolean;
43
+ }
44
+ /**
45
+ * Creates a ListNode of listType.
46
+ * @param listType - The type of list to be created. Can be 'number', 'bullet', or 'check'.
47
+ * @param start - Where an ordered list starts its count, start = 1 if left undefined.
48
+ * @returns The new ListNode
49
+ */
50
+ export declare function $createListNode(listType?: ListType, start?: number): ListNode;
51
+ /**
52
+ * Checks to see if the node is a ListNode.
53
+ * @param node - The node to be checked.
54
+ * @returns true if the node is a ListNode, false otherwise.
55
+ */
56
+ export declare function $isListNode(node: LexicalNode | null | undefined): node is ListNode;
@@ -0,0 +1,9 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ import type { LexicalCommand, LexicalEditor } from './../';
8
+ export declare const INSERT_CHECK_LIST_COMMAND: LexicalCommand<void>;
9
+ export declare function registerCheckList(editor: LexicalEditor): () => void;
@@ -0,0 +1,69 @@
1
+ // THIS FILE IS AUTO-GENERATED
2
+ // To regenerate, run: pnpm build (from the root of the project)
3
+
4
+ // Type definitions based on Lexical
5
+ // Original copyright: Meta Platforms, Inc. and affiliates.
6
+
7
+ import { ListItemNode, ListNode } from './';
8
+ import { ListType } from './LexicalListNode';
9
+ /**
10
+ * Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of
11
+ * the root/shadow root, it will replace the ListItemNode with a ListNode and the old ListItemNode.
12
+ * Otherwise it will replace its parent with a new ListNode and re-insert the ListItemNode and any previous children.
13
+ * If the selection's anchor node is not an empty ListItemNode, it will add a new ListNode or merge an existing ListNode,
14
+ * unless the the node is a leaf node, in which case it will attempt to find a ListNode up the branch and replace it with
15
+ * a new ListNode, or create a new ListNode at the nearest root/shadow root.
16
+ * @param listType - The type of list, "number" | "bullet" | "check".
17
+ */
18
+ export declare function $insertList(listType: ListType): void;
19
+ /**
20
+ * A recursive function that goes through each list and their children, including nested lists,
21
+ * appending list2 children after list1 children and updating ListItemNode values.
22
+ * @param list1 - The first list to be merged.
23
+ * @param list2 - The second list to be merged.
24
+ */
25
+ export declare function mergeLists(list1: ListNode, list2: ListNode): void;
26
+ /**
27
+ * Searches for the nearest ancestral ListNode and removes it. If selection is an empty ListItemNode
28
+ * it will remove the whole list, including the ListItemNode. For each ListItemNode in the ListNode,
29
+ * removeList will also generate new ParagraphNodes in the removed ListNode's place. Any child node
30
+ * inside a ListItemNode will be appended to the new ParagraphNodes.
31
+ */
32
+ export declare function $removeList(): void;
33
+ /**
34
+ * Takes the value of a child ListItemNode and makes it the value the ListItemNode
35
+ * should be if it isn't already. Also ensures that checked is undefined if the
36
+ * parent does not have a list type of 'check'.
37
+ * @param list - The list whose children are updated.
38
+ */
39
+ export declare function updateChildrenListItemValue(list: ListNode): void;
40
+ /**
41
+ * Merge the next sibling list if same type.
42
+ * <ul> will merge with <ul>, but NOT <ul> with <ol>.
43
+ * @param list - The list whose next sibling should be potentially merged
44
+ */
45
+ export declare function mergeNextSiblingListIfSameType(list: ListNode): void;
46
+ /**
47
+ * Adds an empty ListNode/ListItemNode chain at listItemNode, so as to
48
+ * create an indent effect. Won't indent ListItemNodes that have a ListNode as
49
+ * a child, but does merge sibling ListItemNodes if one has a nested ListNode.
50
+ * @param listItemNode - The ListItemNode to be indented.
51
+ */
52
+ export declare function $handleIndent(listItemNode: ListItemNode): void;
53
+ /**
54
+ * Removes an indent by removing an empty ListNode/ListItemNode chain. An indented ListItemNode
55
+ * has a great grandparent node of type ListNode, which is where the ListItemNode will reside
56
+ * within as a child.
57
+ * @param listItemNode - The ListItemNode to remove the indent (outdent).
58
+ */
59
+ export declare function $handleOutdent(listItemNode: ListItemNode): void;
60
+ /**
61
+ * Attempts to insert a ParagraphNode at selection and selects the new node. The selection must contain a ListItemNode
62
+ * or a node that does not already contain text. If its grandparent is the root/shadow root, it will get the ListNode
63
+ * (which should be the parent node) and insert the ParagraphNode as a sibling to the ListNode. If the ListNode is
64
+ * nested in a ListItemNode instead, it will add the ParagraphNode after the grandparent ListItemNode.
65
+ * Throws an invariant if the selection is not a child of a ListNode.
66
+ * @returns true if a ParagraphNode was inserted successfully, false if there is no selection
67
+ * or the selection does not contain a ListItemNode or the node already holds text.
68
+ */
69
+ export declare function $handleListInsertParagraph(): boolean;