Comparing version 0.16.2-nightly.20240712.0 to 0.16.2-nightly.20240715.0
@@ -10,3 +10,3 @@ /** | ||
export type { CommandListener, CommandListenerPriority, CommandPayloadType, CreateEditorArgs, EditableListener, EditorConfig, EditorSetOptions, EditorThemeClasses, EditorThemeClassName, EditorUpdateOptions, HTMLConfig, Klass, KlassConstructor, LexicalCommand, LexicalEditor, LexicalNodeReplacement, MutationListener, NodeMutation, SerializedEditor, Spread, Transform, } from './LexicalEditor'; | ||
export type { EditorState, SerializedEditorState } from './LexicalEditorState'; | ||
export type { EditorState, EditorStateReadOptions, SerializedEditorState, } from './LexicalEditorState'; | ||
export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode'; | ||
@@ -13,0 +13,0 @@ export type { BaseSelection, ElementPointType as ElementPoint, NodeSelection, Point, PointType, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection'; |
@@ -144,2 +144,11 @@ /** | ||
export type NodeMutation = 'created' | 'updated' | 'destroyed'; | ||
export interface MutationListenerOptions { | ||
/** | ||
* Skip the initial call of the listener with pre-existing DOM nodes. | ||
* | ||
* The default is currently true for backwards compatibility with <= 0.16.1 | ||
* but this default is expected to change to false in 0.17.0. | ||
*/ | ||
skipInitialization?: boolean; | ||
} | ||
export type UpdateListener = (arg0: { | ||
@@ -357,8 +366,20 @@ dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>; | ||
* | ||
* If any existing nodes are in the DOM, and skipInitialization is not true, the listener | ||
* will be called immediately with an updateTag of 'registerMutationListener' where all | ||
* nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option | ||
* (default is currently true for backwards compatibility in 0.16.x but will change to false in 0.17.0). | ||
* | ||
* @param klass - The class of the node that you want to listen to mutations on. | ||
* @param listener - The logic you want to run when the node is mutated. | ||
* @param options - see {@link MutationListenerOptions} | ||
* @returns a teardown function that can be used to cleanup the listener. | ||
*/ | ||
registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener): () => void; | ||
registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener, options?: MutationListenerOptions): () => void; | ||
/** @internal */ | ||
private getRegisteredNode; | ||
/** @internal */ | ||
private resolveRegisteredNodeAfterReplacements; | ||
/** @internal */ | ||
private initializeMutationListener; | ||
/** @internal */ | ||
private registerNodeTransformToKlass; | ||
@@ -438,3 +459,3 @@ /** | ||
* and EditorState object that can be, for example, passed to {@link LexicalEditor.setEditorState}. Typically, | ||
* deserliazation from JSON stored in a database uses this method. | ||
* deserialization from JSON stored in a database uses this method. | ||
* @param maybeStringifiedEditorState | ||
@@ -446,2 +467,11 @@ * @param updateFn | ||
/** | ||
* Executes a read of the editor's state, with the | ||
* editor context available (useful for exporting and read-only DOM | ||
* operations). Much like update, but prevents any mutation of the | ||
* editor's state. Any pending updates will be flushed immediately before | ||
* the read. | ||
* @param callbackFn - A function that has access to read-only editor state. | ||
*/ | ||
read<T>(callbackFn: () => T): T; | ||
/** | ||
* Executes an update to the editor state. The updateFn callback is the ONLY place | ||
@@ -448,0 +478,0 @@ * where Lexical editor state can be safely mutated. |
@@ -18,2 +18,5 @@ /** | ||
export declare function createEmptyEditorState(): EditorState; | ||
export interface EditorStateReadOptions { | ||
editor?: LexicalEditor | null; | ||
} | ||
export declare class EditorState { | ||
@@ -26,5 +29,5 @@ _nodeMap: NodeMap; | ||
isEmpty(): boolean; | ||
read<V>(callbackFn: () => V): V; | ||
read<V>(callbackFn: () => V, options?: EditorStateReadOptions): V; | ||
clone(selection?: null | BaseSelection): EditorState; | ||
toJSON(): SerializedEditorState; | ||
} |
@@ -22,3 +22,3 @@ /** | ||
export declare function parseEditorState(serializedEditorState: SerializedEditorState, editor: LexicalEditor, updateFn: void | (() => void)): EditorState; | ||
export declare function readEditorState<V>(editorState: EditorState, callbackFn: () => V): V; | ||
export declare function readEditorState<V>(editor: LexicalEditor | null, editorState: EditorState, callbackFn: () => V): V; | ||
export declare function $commitPendingUpdates(editor: LexicalEditor, recoveryEditorState?: EditorState): void; | ||
@@ -25,0 +25,0 @@ export declare function triggerListeners(type: 'update' | 'root' | 'decorator' | 'textcontent' | 'editable', editor: LexicalEditor, isCurrentlyEnqueuingUpdates: boolean, ...payload: unknown[]): void; |
@@ -10,3 +10,3 @@ /** | ||
import type { EditorState } from './LexicalEditorState'; | ||
import type { LexicalNode, NodeKey } from './LexicalNode'; | ||
import type { LexicalNode, NodeKey, NodeMap } from './LexicalNode'; | ||
import type { BaseSelection, PointType, RangeSelection } from './LexicalSelection'; | ||
@@ -155,2 +155,5 @@ import type { RootNode } from './nodes/LexicalRootNode'; | ||
export declare function $getEditor(): LexicalEditor; | ||
/** @internal */ | ||
export type TypeToNodeMap = Map<string, NodeMap>; | ||
export declare function getCachedTypeToNodeMap(editorState: EditorState): TypeToNodeMap; | ||
export {}; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.16.2-nightly.20240712.0", | ||
"version": "0.16.2-nightly.20240715.0", | ||
"main": "Lexical.js", | ||
@@ -15,0 +15,0 @@ "types": "index.d.ts", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1052226
22460