Comparing version 0.11.1 to 0.11.2
@@ -9,3 +9,3 @@ /** | ||
import type { ElementFormatType, LexicalCommand, TextFormatType } from 'lexical'; | ||
export declare type PasteCommandType = ClipboardEvent | InputEvent | KeyboardEvent; | ||
export type PasteCommandType = ClipboardEvent | InputEvent | KeyboardEvent; | ||
export declare function createCommand<T>(type?: string): LexicalCommand<T>; | ||
@@ -19,3 +19,3 @@ export declare const SELECTION_CHANGE_COMMAND: LexicalCommand<void>; | ||
export declare const PASTE_COMMAND: LexicalCommand<PasteCommandType>; | ||
export declare const REMOVE_TEXT_COMMAND: LexicalCommand<void>; | ||
export declare const REMOVE_TEXT_COMMAND: LexicalCommand<InputEvent | null>; | ||
export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>; | ||
@@ -47,4 +47,4 @@ export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>; | ||
export declare const DRAGEND_COMMAND: LexicalCommand<DragEvent>; | ||
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>; | ||
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>; | ||
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>; | ||
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>; | ||
export declare const CLEAR_EDITOR_COMMAND: LexicalCommand<void>; | ||
@@ -51,0 +51,0 @@ export declare const CLEAR_HISTORY_COMMAND: LexicalCommand<void>; |
@@ -11,8 +11,8 @@ /** | ||
import { LexicalNode } from './LexicalNode'; | ||
export declare type Spread<T1, T2> = Omit<T2, keyof T1> & T1; | ||
export declare type Klass<T extends LexicalNode> = { | ||
export type Spread<T1, T2> = Omit<T2, keyof T1> & T1; | ||
export type Klass<T extends LexicalNode> = { | ||
new (...args: any[]): T; | ||
} & Omit<LexicalNode, 'constructor'>; | ||
export declare type EditorThemeClassName = string; | ||
export declare type TextNodeThemeClasses = { | ||
export type EditorThemeClassName = string; | ||
export type TextNodeThemeClasses = { | ||
base?: EditorThemeClassName; | ||
@@ -29,3 +29,3 @@ bold?: EditorThemeClassName; | ||
}; | ||
export declare type EditorUpdateOptions = { | ||
export type EditorUpdateOptions = { | ||
onUpdate?: () => void; | ||
@@ -36,9 +36,9 @@ skipTransforms?: true; | ||
}; | ||
export declare type EditorSetOptions = { | ||
export type EditorSetOptions = { | ||
tag?: string; | ||
}; | ||
export declare type EditorFocusOptions = { | ||
export type EditorFocusOptions = { | ||
defaultSelection?: 'rootStart' | 'rootEnd'; | ||
}; | ||
export declare type EditorThemeClasses = { | ||
export type EditorThemeClasses = { | ||
blockCursor?: EditorThemeClassName; | ||
@@ -102,3 +102,3 @@ characterLimit?: EditorThemeClassName; | ||
}; | ||
export declare type EditorConfig = { | ||
export type EditorConfig = { | ||
disableEvents?: boolean; | ||
@@ -108,3 +108,3 @@ namespace: string; | ||
}; | ||
export declare type CreateEditorArgs = { | ||
export type CreateEditorArgs = { | ||
disableEvents?: boolean; | ||
@@ -125,4 +125,4 @@ editorState?: EditorState; | ||
}; | ||
export declare type RegisteredNodes = Map<string, RegisteredNode>; | ||
export declare type RegisteredNode = { | ||
export type RegisteredNodes = Map<string, RegisteredNode>; | ||
export type RegisteredNode = { | ||
klass: Klass<LexicalNode>; | ||
@@ -133,8 +133,8 @@ transforms: Set<Transform<LexicalNode>>; | ||
}; | ||
export declare type Transform<T extends LexicalNode> = (node: T) => void; | ||
export declare type ErrorHandler = (error: Error) => void; | ||
export declare type MutationListeners = Map<MutationListener, Klass<LexicalNode>>; | ||
export declare type MutatedNodes = Map<Klass<LexicalNode>, Map<NodeKey, NodeMutation>>; | ||
export declare type NodeMutation = 'created' | 'updated' | 'destroyed'; | ||
export declare type UpdateListener = (arg0: { | ||
export type Transform<T extends LexicalNode> = (node: T) => void; | ||
export type ErrorHandler = (error: Error) => void; | ||
export type MutationListeners = Map<MutationListener, Klass<LexicalNode>>; | ||
export type MutatedNodes = Map<Klass<LexicalNode>, Map<NodeKey, NodeMutation>>; | ||
export type NodeMutation = 'created' | 'updated' | 'destroyed'; | ||
export type UpdateListener = (arg0: { | ||
dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>; | ||
@@ -147,12 +147,12 @@ dirtyLeaves: Set<NodeKey>; | ||
}) => void; | ||
export declare type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void; | ||
export declare type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void; | ||
export declare type TextContentListener = (text: string) => void; | ||
export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: { | ||
export type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void; | ||
export type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void; | ||
export type TextContentListener = (text: string) => void; | ||
export type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: { | ||
updateTags: Set<string>; | ||
dirtyLeaves: Set<string>; | ||
}) => void; | ||
export declare type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean; | ||
export declare type EditableListener = (editable: boolean) => void; | ||
export declare type CommandListenerPriority = 0 | 1 | 2 | 3 | 4; | ||
export type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean; | ||
export type EditableListener = (editable: boolean) => void; | ||
export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4; | ||
export declare const COMMAND_PRIORITY_EDITOR = 0; | ||
@@ -163,3 +163,3 @@ export declare const COMMAND_PRIORITY_LOW = 1; | ||
export declare const COMMAND_PRIORITY_CRITICAL = 4; | ||
export declare type LexicalCommand<TPayload> = { | ||
export type LexicalCommand<TPayload> = { | ||
type?: string; | ||
@@ -187,5 +187,5 @@ }; | ||
*/ | ||
export declare type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never; | ||
declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>; | ||
declare type Listeners = { | ||
export type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never; | ||
type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>; | ||
type Listeners = { | ||
decorator: Set<DecoratorListener>; | ||
@@ -198,8 +198,8 @@ mutation: MutationListeners; | ||
}; | ||
export declare type Listener = DecoratorListener | EditableListener | MutationListener | RootListener | TextContentListener | UpdateListener; | ||
export declare type ListenerType = 'update' | 'root' | 'decorator' | 'textcontent' | 'mutation' | 'editable'; | ||
export declare type TransformerType = 'text' | 'decorator' | 'element' | 'root'; | ||
declare type IntentionallyMarkedAsDirtyElement = boolean; | ||
declare type DOMConversionCache = Map<string, Array<(node: Node) => DOMConversion | null>>; | ||
export declare type SerializedEditor = { | ||
export type Listener = DecoratorListener | EditableListener | MutationListener | RootListener | TextContentListener | UpdateListener; | ||
export type ListenerType = 'update' | 'root' | 'decorator' | 'textcontent' | 'mutation' | 'editable'; | ||
export type TransformerType = 'text' | 'decorator' | 'element' | 'root'; | ||
type IntentionallyMarkedAsDirtyElement = boolean; | ||
type DOMConversionCache = Map<string, Array<(node: Node) => DOMConversion | null>>; | ||
export type SerializedEditor = { | ||
editorState: SerializedEditorState; | ||
@@ -372,2 +372,8 @@ }; | ||
/** | ||
* Used to assert that a certain node is registered, usually by plugins to ensure nodes that they | ||
* depend on have been registered. | ||
* @returns True if the editor has registered the provided node type, false otherwise. | ||
*/ | ||
hasNode<T extends Klass<LexicalNode>>(node: T): boolean; | ||
/** | ||
* Used to assert that certain nodes are registered, usually by plugins to ensure nodes that they | ||
@@ -374,0 +380,0 @@ * depend on have been registered. |
@@ -10,3 +10,3 @@ /** | ||
import type { NodeKey } from './LexicalNode'; | ||
export declare type EventHandler = (event: Event, editor: LexicalEditor) => void; | ||
export type EventHandler = (event: Event, editor: LexicalEditor) => void; | ||
export declare function addRootElementEvents(rootElement: HTMLElement, editor: LexicalEditor): void; | ||
@@ -13,0 +13,0 @@ export declare function removeRootElementEvents(rootElement: HTMLElement): void; |
@@ -12,4 +12,4 @@ /** | ||
export declare function $garbageCollectDetachedDecorators(editor: LexicalEditor, pendingEditorState: EditorState): void; | ||
declare type IntentionallyMarkedAsDirtyElement = boolean; | ||
type IntentionallyMarkedAsDirtyElement = boolean; | ||
export declare function $garbageCollectDetachedNodes(prevEditorState: EditorState, editorState: EditorState, dirtyLeaves: Set<NodeKey>, dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>): void; | ||
export {}; |
@@ -11,4 +11,4 @@ /** | ||
import { ElementNode } from '.'; | ||
export declare type NodeMap = Map<NodeKey, LexicalNode>; | ||
export declare type SerializedLexicalNode = { | ||
export type NodeMap = Map<NodeKey, LexicalNode>; | ||
export type SerializedLexicalNode = { | ||
type: string; | ||
@@ -18,11 +18,11 @@ version: number; | ||
export declare function removeNode(nodeToRemove: LexicalNode, restoreSelection: boolean, preserveEmptyParent?: boolean): void; | ||
export declare type DOMConversion<T extends HTMLElement = HTMLElement> = { | ||
export type DOMConversion<T extends HTMLElement = HTMLElement> = { | ||
conversion: DOMConversionFn<T>; | ||
priority: 0 | 1 | 2 | 3 | 4; | ||
}; | ||
export declare type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T) => DOMConversionOutput | null; | ||
export declare type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined; | ||
export declare type DOMConversionMap<T extends HTMLElement = HTMLElement> = Record<NodeName, (node: T) => DOMConversion<T> | null>; | ||
declare type NodeName = string; | ||
export declare type DOMConversionOutput = { | ||
export type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T) => DOMConversionOutput | null; | ||
export type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined; | ||
export type DOMConversionMap<T extends HTMLElement = HTMLElement> = Record<NodeName, (node: T) => DOMConversion<T> | null>; | ||
type NodeName = string; | ||
export type DOMConversionOutput = { | ||
after?: (childLexicalNodes: Array<LexicalNode>) => Array<LexicalNode>; | ||
@@ -32,7 +32,7 @@ forChild?: DOMChildConversion; | ||
}; | ||
export declare type DOMExportOutput = { | ||
export type DOMExportOutput = { | ||
after?: (generatedElement: HTMLElement | null | undefined) => HTMLElement | null | undefined; | ||
element: HTMLElement | null; | ||
}; | ||
export declare type NodeKey = string; | ||
export type NodeKey = string; | ||
export declare class LexicalNode { | ||
@@ -39,0 +39,0 @@ [x: string]: any; |
@@ -11,5 +11,5 @@ /** | ||
import { EditorState } from './LexicalEditorState'; | ||
declare type IntentionallyMarkedAsDirtyElement = boolean; | ||
type IntentionallyMarkedAsDirtyElement = boolean; | ||
export declare function reconcileRoot(prevEditorState: EditorState, nextEditorState: EditorState, editor: LexicalEditor, dirtyType: 0 | 1 | 2, dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>, dirtyLeaves: Set<NodeKey>): MutatedNodes; | ||
export declare function storeDOMWithKey(key: NodeKey, dom: HTMLElement, editor: LexicalEditor): void; | ||
export {}; |
@@ -15,3 +15,3 @@ /** | ||
import { LexicalNode } from './LexicalNode'; | ||
export declare type TextPointType = { | ||
export type TextPointType = { | ||
_selection: RangeSelection | GridSelection; | ||
@@ -26,3 +26,3 @@ getNode: () => TextNode; | ||
}; | ||
export declare type ElementPointType = { | ||
export type ElementPointType = { | ||
_selection: RangeSelection | GridSelection; | ||
@@ -37,4 +37,4 @@ getNode: () => ElementNode; | ||
}; | ||
export declare type PointType = TextPointType | ElementPointType; | ||
export declare type GridMapValueType = { | ||
export type PointType = TextPointType | ElementPointType; | ||
export type GridMapValueType = { | ||
cell: DEPRECATED_GridCellNode; | ||
@@ -44,3 +44,3 @@ startRow: number; | ||
}; | ||
export declare type GridMapType = Array<Array<GridMapValueType>>; | ||
export type GridMapType = Array<Array<GridMapValueType>>; | ||
export declare class Point { | ||
@@ -86,3 +86,3 @@ key: NodeKey; | ||
export declare function $isRangeSelection(x: unknown): x is RangeSelection; | ||
export declare type GridSelectionShape = { | ||
export type GridSelectionShape = { | ||
fromX: number; | ||
@@ -123,25 +123,167 @@ fromY: number; | ||
constructor(anchor: PointType, focus: PointType, format: number, style: string); | ||
/** | ||
* Used to check if the provided selections is equal to this one by value, | ||
* inluding anchor, focus, format, and style properties. | ||
* @param selection - the Selection to compare this one to. | ||
* @returns true if the Selections are equal, false otherwise. | ||
*/ | ||
is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean; | ||
/** | ||
* Returns whether the Selection is "backwards", meaning the focus | ||
* logically precedes the anchor in the EditorState. | ||
* @returns true if the Selection is backwards, false otherwise. | ||
*/ | ||
isBackward(): boolean; | ||
/** | ||
* Returns whether the Selection is "collapsed", meaning the anchor and focus are | ||
* the same node and have the same offset. | ||
* | ||
* @returns true if the Selection is collapsed, false otherwise. | ||
*/ | ||
isCollapsed(): boolean; | ||
/** | ||
* Gets all the nodes in the Selection. Uses caching to make it generally suitable | ||
* for use in hot paths. | ||
* | ||
* @returns an Array containing all the nodes in the Selection | ||
*/ | ||
getNodes(): Array<LexicalNode>; | ||
/** | ||
* Sets this Selection to be of type "text" at the provided anchor and focus values. | ||
* | ||
* @param anchorNode - the anchor node to set on the Selection | ||
* @param anchorOffset - the offset to set on the Selection | ||
* @param focusNode - the focus node to set on the Selection | ||
* @param focusOffset - the focus offset to set on the Selection | ||
*/ | ||
setTextNodeRange(anchorNode: TextNode, anchorOffset: number, focusNode: TextNode, focusOffset: number): void; | ||
/** | ||
* Gets the (plain) text content of all the nodes in the selection. | ||
* | ||
* @returns a string representing the text content of all the nodes in the Selection | ||
*/ | ||
getTextContent(): string; | ||
/** | ||
* Attempts to map a DOM selection range onto this Lexical Selection, | ||
* setting the anchor, focus, and type accordingly | ||
* | ||
* @param range a DOM Selection range conforming to the StaticRange interface. | ||
*/ | ||
applyDOMRange(range: StaticRange): void; | ||
/** | ||
* Creates a new RangeSelection, copying over all the property values from this one. | ||
* | ||
* @returns a new RangeSelection with the same property values as this one. | ||
*/ | ||
clone(): RangeSelection; | ||
/** | ||
* Toggles the provided format on all the TextNodes in the Selection. | ||
* | ||
* @param format a string TextFormatType to toggle on the TextNodes in the selection | ||
*/ | ||
toggleFormat(format: TextFormatType): void; | ||
/** | ||
* Sets the value of the style property on the Selection | ||
* | ||
* @param style - the style to set at the value of the style property. | ||
*/ | ||
setStyle(style: string): void; | ||
/** | ||
* Returns whether the provided TextFormatType is present on the Selection. This will be true if any node in the Selection | ||
* has the specified format. | ||
* | ||
* @param type the TextFormatType to check for. | ||
* @returns true if the provided format is currently toggled on on the Selection, false otherwise. | ||
*/ | ||
hasFormat(type: TextFormatType): boolean; | ||
/** | ||
* Attempts to insert the provided text into the EditorState at the current Selection. | ||
* converts tabs, newlines, and carriage returns into LexicalNodes. | ||
* | ||
* @param text the text to insert into the Selection | ||
*/ | ||
insertRawText(text: string): void; | ||
/** | ||
* Attempts to insert the provided text into the EditorState at the current Selection as a new | ||
* Lexical TextNode, according to a series of insertion heuristics based on the selection type and position. | ||
* | ||
* @param text the text to insert into the Selection | ||
*/ | ||
insertText(text: string): void; | ||
/** | ||
* Removes the text in the Selection, adjusting the EditorState accordingly. | ||
*/ | ||
removeText(): void; | ||
/** | ||
* Applies the provided format to the TextNodes in the Selection, splitting or | ||
* merging nodes as necessary. | ||
* | ||
* @param formatType the format type to apply to the nodes in the Selection. | ||
*/ | ||
formatText(formatType: TextFormatType): void; | ||
/** | ||
* Attempts to "intelligently" insert an arbitrary list of Lexical nodes into the EditorState at the | ||
* current Selection according to a set of heuristics that determine how surrounding nodes | ||
* should be changed, replaced, or moved to accomodate the incoming ones. | ||
* | ||
* @param nodes - the nodes to insert | ||
* @param selectStart - whether or not to select the start after the insertion. | ||
* @returns true if the nodes were inserted successfully, false otherwise. | ||
*/ | ||
insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean; | ||
/** | ||
* Inserts a new ParagraphNode into the EditorState at the current Selection | ||
*/ | ||
insertParagraph(): void; | ||
/** | ||
* Inserts a logical linebreak, which may be a new LineBreakNode or a new ParagraphNode, into the EditorState at the | ||
* current Selection. | ||
* | ||
* @param selectStart whether or not to select the start of the insertion range after the operation completes. | ||
*/ | ||
insertLineBreak(selectStart?: boolean): void; | ||
/** | ||
* Returns the character-based offsets of the Selection, accounting for non-text Points | ||
* by using the children size or text content. | ||
* | ||
* @returns the character offsets for the Selection | ||
*/ | ||
getCharacterOffsets(): [number, number]; | ||
/** | ||
* Extracts the nodes in the Selection, splitting nodes where necessary | ||
* to get offset-level precision. | ||
* | ||
* @returns The nodes in the Selection | ||
*/ | ||
extract(): Array<LexicalNode>; | ||
/** | ||
* Modifies the Selection according to the parameters and a set of heuristics that account for | ||
* various node types. Can be used to safely move or extend selection by one logical "unit" without | ||
* dealing explicitly with all the possible node types. | ||
* | ||
* @param alter the type of modification to perform | ||
* @param isBackward whether or not selection is backwards | ||
* @param granularity the granularity at which to apply the modification | ||
*/ | ||
modify(alter: 'move' | 'extend', isBackward: boolean, granularity: 'character' | 'word' | 'lineboundary'): void; | ||
/** | ||
* Performs one logical character deletion operation on the EditorState based on the current Selection. | ||
* Handles different node types. | ||
* | ||
* @param isBackward whether or not the selection is backwards. | ||
*/ | ||
deleteCharacter(isBackward: boolean): void; | ||
/** | ||
* Performs one logical line deletion operation on the EditorState based on the current Selection. | ||
* Handles different node types. | ||
* | ||
* @param isBackward whether or not the selection is backwards. | ||
*/ | ||
deleteLine(isBackward: boolean): void; | ||
/** | ||
* Performs one logical word deletion operation on the EditorState based on the current Selection. | ||
* Handles different node types. | ||
* | ||
* @param isBackward whether or not the selection is backwards. | ||
*/ | ||
deleteWord(isBackward: boolean): void; | ||
@@ -148,0 +290,0 @@ } |
@@ -22,5 +22,5 @@ /** | ||
export declare function readEditorState<V>(editorState: EditorState, callbackFn: () => V): V; | ||
export declare function commitPendingUpdates(editor: LexicalEditor): void; | ||
export declare function commitPendingUpdates(editor: LexicalEditor, recoveryEditorState?: EditorState): void; | ||
export declare function triggerListeners(type: 'update' | 'root' | 'decorator' | 'textcontent' | 'editable', editor: LexicalEditor, isCurrentlyEnqueuingUpdates: boolean, ...payload: unknown[]): void; | ||
export declare function triggerCommandListeners<TCommand extends LexicalCommand<unknown>>(editor: LexicalEditor, type: TCommand, payload: CommandPayloadType<TCommand>): boolean; | ||
export declare function updateEditor(editor: LexicalEditor, updateFn: () => void, options?: EditorUpdateOptions): void; |
@@ -87,2 +87,3 @@ /** | ||
export declare function isSelectAll(keyCode: number, metaKey: boolean, ctrlKey: boolean): boolean; | ||
export declare function $selectAll(): void; | ||
export declare function getCachedClassNameArray(classNamesTheme: EditorThemeClasses, classNameThemeType: string): Array<string>; | ||
@@ -100,3 +101,3 @@ export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNodes: RegisteredNodes, mutationListeners: MutationListeners, node: LexicalNode, mutation: NodeMutation): void; | ||
export declare function $addUpdateTag(tag: string): void; | ||
export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode, offset?: number): RangeSelection | NodeSelection | GridSelection | null; | ||
export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode): RangeSelection | NodeSelection | GridSelection | null; | ||
export declare function $hasAncestor(child: LexicalNode, targetNode: LexicalNode): boolean; | ||
@@ -103,0 +104,0 @@ export declare function getDefaultView(domElem: HTMLElement): Window | null; |
@@ -13,3 +13,3 @@ /** | ||
import { LexicalNode } from '../LexicalNode'; | ||
export declare type SerializedElementNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<{ | ||
export type SerializedElementNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<{ | ||
children: Array<T>; | ||
@@ -20,3 +20,3 @@ direction: 'ltr' | 'rtl' | null; | ||
}, SerializedLexicalNode>; | ||
export declare type ElementFormatType = 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; | ||
export type ElementFormatType = 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; | ||
/** @noInheritDoc */ | ||
@@ -23,0 +23,0 @@ export declare class ElementNode extends LexicalNode { |
@@ -10,3 +10,3 @@ /** | ||
import { ElementNode } from './LexicalElementNode'; | ||
export declare type SerializedGridCellNode = Spread<{ | ||
export type SerializedGridCellNode = Spread<{ | ||
colSpan?: number; | ||
@@ -13,0 +13,0 @@ rowSpan?: number; |
@@ -10,3 +10,3 @@ /** | ||
import { LexicalNode } from '../LexicalNode'; | ||
export declare type SerializedLineBreakNode = SerializedLexicalNode; | ||
export type SerializedLineBreakNode = SerializedLexicalNode; | ||
/** @noInheritDoc */ | ||
@@ -13,0 +13,0 @@ export declare class LineBreakNode extends LexicalNode { |
@@ -13,3 +13,3 @@ /** | ||
import { ElementNode } from './LexicalElementNode'; | ||
export declare type SerializedParagraphNode = SerializedElementNode; | ||
export type SerializedParagraphNode = SerializedElementNode; | ||
/** @noInheritDoc */ | ||
@@ -16,0 +16,0 @@ export declare class ParagraphNode extends ElementNode { |
@@ -11,3 +11,3 @@ /** | ||
import { ElementNode } from './LexicalElementNode'; | ||
export declare type SerializedRootNode<T extends SerializedLexicalNode = SerializedLexicalNode> = SerializedElementNode<T>; | ||
export type SerializedRootNode<T extends SerializedLexicalNode = SerializedLexicalNode> = SerializedElementNode<T>; | ||
/** @noInheritDoc */ | ||
@@ -14,0 +14,0 @@ export declare class RootNode extends ElementNode { |
@@ -11,3 +11,3 @@ /** | ||
import { SerializedTextNode, TextDetailType, TextModeType, TextNode } from './LexicalTextNode'; | ||
export declare type SerializedTabNode = SerializedTextNode; | ||
export type SerializedTabNode = SerializedTextNode; | ||
/** @noInheritDoc */ | ||
@@ -14,0 +14,0 @@ export declare class TabNode extends TextNode { |
@@ -12,3 +12,3 @@ /** | ||
import { LexicalNode } from '../LexicalNode'; | ||
export declare type SerializedTextNode = Spread<{ | ||
export type SerializedTextNode = Spread<{ | ||
detail: number; | ||
@@ -20,6 +20,6 @@ format: number; | ||
}, SerializedLexicalNode>; | ||
export declare type TextDetailType = 'directionless' | 'unmergable'; | ||
export declare type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'highlight' | 'code' | 'subscript' | 'superscript'; | ||
export declare type TextModeType = 'normal' | 'token' | 'segmented'; | ||
export declare type TextMark = { | ||
export type TextDetailType = 'directionless' | 'unmergable'; | ||
export type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'highlight' | 'code' | 'subscript' | 'superscript'; | ||
export type TextModeType = 'normal' | 'token' | 'segmented'; | ||
export type TextMark = { | ||
end: null | number; | ||
@@ -29,3 +29,3 @@ id: string; | ||
}; | ||
export declare type TextMarks = Array<TextMark>; | ||
export type TextMarks = Array<TextMark>; | ||
/** @noInheritDoc */ | ||
@@ -45,14 +45,89 @@ export declare class TextNode extends LexicalNode { | ||
constructor(text: string, key?: NodeKey); | ||
/** | ||
* Returns a 32-bit integer that represents the TextFormatTypes currently applied to the | ||
* TextNode. You probably don't want to use this method directly - consider using TextNode.hasFormat instead. | ||
* | ||
* @returns a number representing the format of the text node. | ||
*/ | ||
getFormat(): number; | ||
/** | ||
* Returns a 32-bit integer that represents the TextDetailTypes currently applied to the | ||
* TextNode. You probably don't want to use this method directly - consider using TextNode.isDirectionless | ||
* or TextNode.isUnmergeable instead. | ||
* | ||
* @returns a number representing the detail of the text node. | ||
*/ | ||
getDetail(): number; | ||
/** | ||
* Returns the mode (TextModeType) of the TextNode, which may be "normal", "token", or "segmented" | ||
* | ||
* @returns TextModeType. | ||
*/ | ||
getMode(): TextModeType; | ||
/** | ||
* Returns the styles currently applied to the node. This is analogous to CSSText in the DOM. | ||
* | ||
* @returns CSSText-like string of styles applied to the underlying DOM node. | ||
*/ | ||
getStyle(): string; | ||
/** | ||
* Returns whether or not the node is in "token" mode. TextNodes in token mode can be navigated through character-by-character | ||
* with a RangeSelection, but are deleted as a single entity (not invdividually by character). | ||
* | ||
* @returns true if the node is in token mode, false otherwise. | ||
*/ | ||
isToken(): boolean; | ||
/** | ||
* | ||
* @returns true if Lexical detects that an IME or other 3rd-party script is attempting to | ||
* mutate the TextNode, false otherwise. | ||
*/ | ||
isComposing(): boolean; | ||
/** | ||
* Returns whether or not the node is in "segemented" mode. TextNodes in segemented mode can be navigated through character-by-character | ||
* with a RangeSelection, but are deleted in space-delimited "segments". | ||
* | ||
* @returns true if the node is in segmented mode, false otherwise. | ||
*/ | ||
isSegmented(): boolean; | ||
/** | ||
* Returns whether or not the node is "directionless". Directionless nodes don't respect changes between RTL and LTR modes. | ||
* | ||
* @returns true if the node is directionless, false otherwise. | ||
*/ | ||
isDirectionless(): boolean; | ||
/** | ||
* Returns whether or not the node is unmergeable. In some scenarios, Lexical tries to merge | ||
* adjacent TextNodes into a single TextNode. If a TextNode is unmergeable, this won't happen. | ||
* | ||
* @returns true if the node is unmergeable, false otherwise. | ||
*/ | ||
isUnmergeable(): boolean; | ||
/** | ||
* Returns whether or not the node has the provided format applied. Use this with the human-readable TextFormatType | ||
* string values to get the format of a TextNode. | ||
* | ||
* @param type - the TextFormatType to check for. | ||
* | ||
* @returns true if the node has the provided format, false otherwise. | ||
*/ | ||
hasFormat(type: TextFormatType): boolean; | ||
/** | ||
* Returns whether or not the node is simple text. Simple text is defined as a TextNode that has the string type "text" | ||
* (i.e., not a subclass) and has no mode applied to it (i.e., not segmented or token). | ||
* | ||
* @returns true if the node is simple text, false otherwise. | ||
*/ | ||
isSimpleText(): boolean; | ||
/** | ||
* Returns the text content of the node as a string. | ||
* | ||
* @returns a string representing the text content of the node. | ||
*/ | ||
getTextContent(): string; | ||
/** | ||
* Returns the format flags applied to the node as a 32-bit integer. | ||
* | ||
* @returns a number representing the TextFormatTypes applied to the node. | ||
*/ | ||
getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number; | ||
@@ -66,16 +141,130 @@ createDOM(config: EditorConfig): HTMLElement; | ||
selectionTransform(prevSelection: null | RangeSelection | NodeSelection | GridSelection, nextSelection: RangeSelection): void; | ||
/** | ||
* Sets the node format to the provided TextFormatType or 32-bit integer. Note that the TextFormatType | ||
* version of the argument can only specify one format and doing so will remove all other formats that | ||
* may be applied to the node. For toggling behavior, consider using {@link TextNode.toggleFormat} | ||
* | ||
* @param format - TextFormatType or 32-bit integer representing the node format. | ||
* | ||
* @returns this TextNode. | ||
* // TODO 0.12 This should just be a `string`. | ||
*/ | ||
setFormat(format: TextFormatType | number): this; | ||
/** | ||
* Sets the node detail to the provided TextDetailType or 32-bit integer. Note that the TextDetailType | ||
* version of the argument can only specify one detail value and doing so will remove all other detail values that | ||
* may be applied to the node. For toggling behavior, consider using {@link TextNode.toggleDirectionless} | ||
* or {@link TextNode.togglerUnmergeable} | ||
* | ||
* @param detail - TextDetailType or 32-bit integer representing the node detail. | ||
* | ||
* @returns this TextNode. | ||
* // TODO 0.12 This should just be a `string`. | ||
*/ | ||
setDetail(detail: TextDetailType | number): this; | ||
/** | ||
* Sets the node style to the provided CSSText-like string. Set this property as you | ||
* would an HTMLElement style attribute to apply inline styles to the underlying DOM Element. | ||
* | ||
* @param style - CSSText to be applied to the underlying HTMLElement. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
setStyle(style: string): this; | ||
/** | ||
* Applies the provided format to this TextNode if it's not present. Removes it if it is present. | ||
* Prefer using this method to turn specific formats on and off. | ||
* | ||
* @param type - TextFormatType to toggle. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
toggleFormat(type: TextFormatType): this; | ||
/** | ||
* Toggles the directionless detail value of the node. Prefer using this method over setDetail. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
toggleDirectionless(): this; | ||
/** | ||
* Toggles the unmergeable detail value of the node. Prefer using this method over setDetail. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
toggleUnmergeable(): this; | ||
/** | ||
* Sets the mode of the node. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
setMode(type: TextModeType): this; | ||
/** | ||
* Sets the text content of the node. | ||
* | ||
* @param text - the string to set as the text value of the node. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
setTextContent(text: string): this; | ||
/** | ||
* Sets the current Lexical selection to be a RangeSelection with anchor and focus on this TextNode at the provided offsets. | ||
* | ||
* @param _anchorOffset - the offset at which the Selection anchor will be placed. | ||
* @param _focusOffset - the offset at which the Selection focus will be placed. | ||
* | ||
* @returns the new RangeSelection. | ||
*/ | ||
select(_anchorOffset?: number, _focusOffset?: number): RangeSelection; | ||
/** | ||
* Inserts the provided text into this TextNode at the provided offset, deleting the number of characters | ||
* specified. Can optionally calculate a new selection after the operation is complete. | ||
* | ||
* @param offset - the offset at which the splice operation should begin. | ||
* @param delCount - the number of characters to delete, starting from the offset. | ||
* @param newText - the text to insert into the TextNode at the offset. | ||
* @param moveSelection - optional, whether or not to move selection to the end of the inserted substring. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
spliceText(offset: number, delCount: number, newText: string, moveSelection?: boolean): TextNode; | ||
/** | ||
* This method is meant to be overriden by TextNode subclasses to control the behavior of those nodes | ||
* when a user event would cause text to be inserted before them in the editor. If true, Lexical will attempt | ||
* to insert text into this node. If false, it will insert the text in a new sibling node. | ||
* | ||
* @returns true if text can be inserted before the node, false otherwise. | ||
*/ | ||
canInsertTextBefore(): boolean; | ||
/** | ||
* This method is meant to be overriden by TextNode subclasses to control the behavior of those nodes | ||
* when a user event would cause text to be inserted after them in the editor. If true, Lexical will attempt | ||
* to insert text into this node. If false, it will insert the text in a new sibling node. | ||
* | ||
* @returns true if text can be inserted after the node, false otherwise. | ||
*/ | ||
canInsertTextAfter(): boolean; | ||
/** | ||
* Splits this TextNode at the provided character offsets, forming new TextNodes from the substrings | ||
* formed by the split, and inserting those new TextNodes into the editor, replacing the one that was split. | ||
* | ||
* @param splitOffsets - rest param of the text content character offsets at which this node should be split. | ||
* | ||
* @returns an Array containing the newly-created TextNodes. | ||
*/ | ||
splitText(...splitOffsets: Array<number>): Array<TextNode>; | ||
/** | ||
* Merges the target TextNode into this TextNode, removing the target node. | ||
* | ||
* @param target - the TextNode to merge into this one. | ||
* | ||
* @returns this TextNode. | ||
*/ | ||
mergeWithSibling(target: TextNode): TextNode; | ||
/** | ||
* This method is meant to be overriden by TextNode subclasses to control the behavior of those nodes | ||
* when used with the registerLexicalTextEntity function. If you're using registerLexicalTextEntity, the | ||
* node class that you create and replace matched text with should return true from this method. | ||
* | ||
* @returns true if the node is to be treated as a "text entity", false otherwise. | ||
*/ | ||
isTextEntity(): boolean; | ||
@@ -82,0 +271,0 @@ } |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"main": "Lexical.js", | ||
@@ -15,0 +15,0 @@ "repository": { |
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 too big to display
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
588481
11980