lexical 0.3.11 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,7 +111,7 @@ export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation>, paylo
111
111
  dirtyLeaves: Set<string>;
112
112
  }) => void;
113
113
  export declare type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
114
- export declare type ReadOnlyListener = (readOnly: boolean) => void;
114
+ export declare type EditableListener = (editable: boolean) => void;
115
115
  export declare type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
116
116
  export declare const COMMAND_PRIORITY_EDITOR = 0;
117
117
  export declare const COMMAND_PRIORITY_LOW = 1;
@@ -144,13 +144,13 @@ declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<u
144
144
  declare type Listeners = {
145
145
  decorator: Set<DecoratorListener>;
146
146
  mutation: MutationListeners;
147
- readonly: Set<ReadOnlyListener>;
147
+ editable: Set<EditableListener>;
148
148
  root: Set<RootListener>;
149
149
  textcontent: Set<TextContentListener>;
150
150
  update: Set<UpdateListener>;
151
151
  };
152
- export declare type Listener = DecoratorListener | ReadOnlyListener | MutationListener | RootListener | TextContentListener | UpdateListener;
153
- export declare type ListenerType = 'update' | 'root' | 'decorator' | 'textcontent' | 'mutation' | 'readonly';
152
+ export declare type Listener = DecoratorListener | EditableListener | MutationListener | RootListener | TextContentListener | UpdateListener;
153
+ export declare type ListenerType = 'update' | 'root' | 'decorator' | 'textcontent' | 'mutation' | 'editable';
154
154
  export declare type TransformerType = 'text' | 'decorator' | 'element' | 'root';
155
155
  export declare type IntentionallyMarkedAsDirtyElement = boolean;
156
156
  declare type DOMConversionCache = Map<string, Array<(node: Node) => DOMConversion | null>>;
@@ -165,7 +165,7 @@ export declare function createEditor(editorConfig?: {
165
165
  nodes?: ReadonlyArray<Klass<LexicalNode>>;
166
166
  onError?: ErrorHandler;
167
167
  parentEditor?: LexicalEditor;
168
- readOnly?: boolean;
168
+ editable?: boolean;
169
169
  theme?: EditorThemeClasses;
170
170
  }): LexicalEditor;
171
171
  export declare class LexicalEditor {
@@ -195,11 +195,12 @@ export declare class LexicalEditor {
195
195
  _key: string;
196
196
  _onError: ErrorHandler;
197
197
  _htmlConversions: DOMConversionCache;
198
- _readOnly: boolean;
199
- constructor(editorState: EditorState, parentEditor: null | LexicalEditor, nodes: RegisteredNodes, config: EditorConfig, onError: ErrorHandler, htmlConversions: DOMConversionCache, readOnly: boolean);
198
+ _window: null | Window;
199
+ _editable: boolean;
200
+ constructor(editorState: EditorState, parentEditor: null | LexicalEditor, nodes: RegisteredNodes, config: EditorConfig, onError: ErrorHandler, htmlConversions: DOMConversionCache, editable: boolean);
200
201
  isComposing(): boolean;
201
202
  registerUpdateListener(listener: UpdateListener): () => void;
202
- registerReadOnlyListener(listener: ReadOnlyListener): () => void;
203
+ registerEditableListener(listener: EditableListener): () => void;
203
204
  registerDecoratorListener<T>(listener: DecoratorListener<T>): () => void;
204
205
  registerTextContentListener(listener: TextContentListener): () => void;
205
206
  registerRootListener(listener: RootListener): () => void;
@@ -219,8 +220,8 @@ export declare class LexicalEditor {
219
220
  update(updateFn: () => void, options?: EditorUpdateOptions): void;
220
221
  focus(callbackFn?: () => void, options?: EditorFocusOptions): void;
221
222
  blur(): void;
222
- isReadOnly(): boolean;
223
- setReadOnly(readOnly: boolean): void;
223
+ isEditable(): boolean;
224
+ setEditable(editable: boolean): void;
224
225
  toJSON(): SerializedEditor;
225
226
  }
226
227
  export {};
package/LexicalNode.d.ts CHANGED
@@ -35,8 +35,11 @@ export declare type DOMExportOutput = {
35
35
  export declare type NodeKey = string;
36
36
  export declare class LexicalNode {
37
37
  [x: string]: any;
38
+ /** @internal */
38
39
  __type: string;
40
+ /** @internal */
39
41
  __key: string;
42
+ /** @internal */
40
43
  __parent: null | NodeKey;
41
44
  static getType(): string;
42
45
  static clone(_data: unknown): LexicalNode;
@@ -19,7 +19,7 @@ export declare function $parseSerializedNode(serializedNode: SerializedLexicalNo
19
19
  export declare function parseEditorState(serializedEditorState: SerializedEditorState, editor: LexicalEditor, updateFn: void | (() => void)): EditorState;
20
20
  export declare function readEditorState<V>(editorState: EditorState, callbackFn: () => V): V;
21
21
  export declare function commitPendingUpdates(editor: LexicalEditor): void;
22
- export declare function triggerListeners(type: 'update' | 'root' | 'decorator' | 'textcontent' | 'readonly', editor: LexicalEditor, isCurrentlyEnqueuingUpdates: boolean, ...payload: unknown[]): void;
22
+ export declare function triggerListeners(type: 'update' | 'root' | 'decorator' | 'textcontent' | 'editable', editor: LexicalEditor, isCurrentlyEnqueuingUpdates: boolean, ...payload: unknown[]): void;
23
23
  export declare function triggerCommandListeners<P>(editor: LexicalEditor, type: LexicalCommand<P>, payload: P): boolean;
24
24
  export declare function updateEditor(editor: LexicalEditor, updateFn: () => void, options?: EditorUpdateOptions): void;
25
25
  export declare function internalGetActiveEditor(): null | LexicalEditor;
package/LexicalUtils.d.ts CHANGED
@@ -19,6 +19,8 @@ export declare function generateRandomKey(): string;
19
19
  export declare function getRegisteredNodeOrThrow(editor: LexicalEditor, nodeType: string): RegisteredNode;
20
20
  export declare const isArray: (arg: any) => arg is any[];
21
21
  export declare const scheduleMicroTask: (fn: () => void) => void;
22
+ export declare function $isSelectionCapturedInDecorator(node: Node): boolean;
23
+ export declare function isSelectionCapturedInDecoratorInput(anchorDOM: Node): boolean;
22
24
  export declare function isSelectionWithinEditor(editor: LexicalEditor, anchorDOM: null | Node, focusDOM: null | Node): boolean;
23
25
  export declare function getNearestEditorFromDOMNode(node: Node | null): LexicalEditor | null;
24
26
  export declare function getTextDirection(text: string): 'ltr' | 'rtl' | null;
@@ -85,7 +87,7 @@ export declare function getCachedClassNameArray(classNamesTheme: EditorThemeClas
85
87
  export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNodes: RegisteredNodes, mutationListeners: MutationListeners, node: LexicalNode, mutation: NodeMutation): void;
86
88
  export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<LexicalNode>;
87
89
  export declare function $getDecoratorNode(focus: PointType, isBackward: boolean): null | LexicalNode;
88
- export declare function isFirefoxClipboardEvents(): boolean;
90
+ export declare function isFirefoxClipboardEvents(editor: LexicalEditor): boolean;
89
91
  export declare function dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(editor: LexicalEditor, type: TCommand, payload: TPayload): boolean;
90
92
  export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean;
91
93
  export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement;
@@ -93,3 +95,5 @@ export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, anchor: Po
93
95
  export declare function $hasUpdateTag(tag: string): boolean;
94
96
  export declare function $addUpdateTag(tag: string): void;
95
97
  export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode, offset?: number): RangeSelection | NodeSelection | GridSelection | null;
98
+ export declare function getDefaultView(domElem: HTMLElement): Window | null;
99
+ export declare function getWindow(editor: LexicalEditor): Window;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare const VERSION = "0.3.11";
8
+ export declare const VERSION = "0.4.0";
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /** @module lexical */
1
2
  /**
2
3
  * Copyright (c) Meta Platforms, Inc. and affiliates.
3
4
  *
@@ -5,7 +6,7 @@
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  *
7
8
  */
8
- export type { CommandListenerPriority, CommandPayloadType, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, MutationListener, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
9
+ export type { CommandListenerPriority, CommandPayloadType, EditableListener, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, MutationListener, NodeMutation, SerializedEditor, Spread, } from './LexicalEditor';
9
10
  export type { EditorState, SerializedEditorState } from './LexicalEditorState';
10
11
  export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode';
11
12
  export type { BaseSelection, ElementPointType as ElementPoint, GridSelection, GridSelectionShape, NodeSelection, Point, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection';
@@ -25,7 +26,9 @@ export { $isElementNode, ElementNode } from './nodes/LexicalElementNode';
25
26
  export { $isGridCellNode, GridCellNode } from './nodes/LexicalGridCellNode';
26
27
  export { $isGridNode, GridNode } from './nodes/LexicalGridNode';
27
28
  export { $isGridRowNode, GridRowNode } from './nodes/LexicalGridRowNode';
29
+ export type { SerializedLineBreakNode } from './nodes/LexicalLineBreakNode';
28
30
  export { $createLineBreakNode, $isLineBreakNode, LineBreakNode, } from './nodes/LexicalLineBreakNode';
31
+ export type { SerializedParagraphNode } from './nodes/LexicalParagraphNode';
29
32
  export { $createParagraphNode, $isParagraphNode, ParagraphNode, } from './nodes/LexicalParagraphNode';
30
33
  export { $isRootNode, RootNode } from './nodes/LexicalRootNode';
31
34
  export { $createTextNode, $isTextNode, TextNode } from './nodes/LexicalTextNode';
@@ -9,6 +9,7 @@ import type { LexicalEditor } from '../LexicalEditor';
9
9
  import type { NodeKey } from '../LexicalNode';
10
10
  import { EditorConfig } from 'lexical';
11
11
  import { LexicalNode } from '../LexicalNode';
12
+ /** @noInheritDoc */
12
13
  export declare class DecoratorNode<T> extends LexicalNode {
13
14
  constructor(key?: NodeKey);
14
15
  decorate(editor: LexicalEditor, config: EditorConfig): T;
@@ -17,10 +17,15 @@ export declare type SerializedElementNode = Spread<{
17
17
  indent: number;
18
18
  }, SerializedLexicalNode>;
19
19
  export declare type ElementFormatType = 'left' | 'center' | 'right' | 'justify' | '';
20
+ /** @noInheritDoc */
20
21
  export declare class ElementNode extends LexicalNode {
22
+ /** @internal */
21
23
  __children: Array<NodeKey>;
24
+ /** @internal */
22
25
  __format: number;
26
+ /** @internal */
23
27
  __indent: number;
28
+ /** @internal */
24
29
  __dir: 'ltr' | 'rtl' | null;
25
30
  constructor(key?: NodeKey);
26
31
  getFormat(): number;
@@ -10,7 +10,9 @@ import { ElementNode } from './LexicalElementNode';
10
10
  export declare type SerializedGridCellNode = Spread<{
11
11
  colSpan: number;
12
12
  }, SerializedElementNode>;
13
+ /** @noInheritDoc */
13
14
  export declare class GridCellNode extends ElementNode {
15
+ /** @internal */
14
16
  __colSpan: number;
15
17
  constructor(colSpan: number, key?: NodeKey);
16
18
  exportJSON(): SerializedGridCellNode;
@@ -11,6 +11,7 @@ import { LexicalNode } from '../LexicalNode';
11
11
  export declare type SerializedLineBreakNode = Spread<{
12
12
  type: 'linebreak';
13
13
  }, SerializedLexicalNode>;
14
+ /** @noInheritDoc */
14
15
  export declare class LineBreakNode extends LexicalNode {
15
16
  static getType(): string;
16
17
  static clone(node: LineBreakNode): LineBreakNode;
@@ -14,6 +14,7 @@ export declare type SerializedParagraphNode = Spread<{
14
14
  type: 'paragraph';
15
15
  version: 1;
16
16
  }, SerializedElementNode>;
17
+ /** @noInheritDoc */
17
18
  export declare class ParagraphNode extends ElementNode {
18
19
  static getType(): string;
19
20
  static clone(node: ParagraphNode): ParagraphNode;
@@ -9,7 +9,9 @@ import type { LexicalNode } from '../LexicalNode';
9
9
  import type { SerializedElementNode } from './LexicalElementNode';
10
10
  import { ElementNode } from './LexicalElementNode';
11
11
  export declare type SerializedRootNode = SerializedElementNode;
12
+ /** @noInheritDoc */
12
13
  export declare class RootNode extends ElementNode {
14
+ /** @internal */
13
15
  __cachedText: null | string;
14
16
  static getType(): string;
15
17
  static clone(): RootNode;
@@ -26,6 +26,7 @@ export declare type TextMark = {
26
26
  start: null | number;
27
27
  };
28
28
  export declare type TextMarks = Array<TextMark>;
29
+ /** @noInheritDoc */
29
30
  export declare class TextNode extends LexicalNode {
30
31
  __text: string;
31
32
  __format: number;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.3.11",
12
+ "version": "0.4.0",
13
13
  "main": "Lexical.js",
14
14
  "repository": {
15
15
  "type": "git",