Comparing version 0.22.1-nightly.20250101.0 to 0.22.1-nightly.20250102.0
@@ -11,3 +11,3 @@ /** | ||
export type { EditorState, EditorStateReadOptions, SerializedEditorState, } from './LexicalEditorState'; | ||
export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, DOMExportOutputMap, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode'; | ||
export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, DOMExportOutputMap, LexicalNode, LexicalUpdateJSON, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode'; | ||
export type { BaseSelection, ElementPointType as ElementPoint, NodeSelection, Point, PointType, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection'; | ||
@@ -24,3 +24,3 @@ export type { ElementDOMSlot, ElementFormatType, SerializedElementNode, } from './nodes/LexicalElementNode'; | ||
export { $parseSerializedNode, isCurrentlyReadOnlyMode } from './LexicalUpdates'; | ||
export { $addUpdateTag, $applyNodeReplacement, $cloneWithProperties, $copyNode, $getAdjacentNode, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getRoot, $hasAncestor, $hasUpdateTag, $isInlineElementOrDecoratorNode, $isLeafNode, $isRootOrShadowRoot, $isTokenOrSegmented, $nodesOfType, $onUpdate, $selectAll, $setCompositionKey, $setSelection, $splitNode, getDOMSelection, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, isBlockDomNode, isDocumentFragment, isDOMNode, isDOMTextNode, isDOMUnmanaged, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, resetRandomKey, setDOMUnmanaged, setNodeIndentFromDOM, } from './LexicalUtils'; | ||
export { $addUpdateTag, $applyNodeReplacement, $cloneWithProperties, $copyNode, $getAdjacentNode, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getRoot, $hasAncestor, $hasUpdateTag, $isInlineElementOrDecoratorNode, $isLeafNode, $isRootOrShadowRoot, $isTokenOrSegmented, $nodesOfType, $onUpdate, $selectAll, $setCompositionKey, $setSelection, $splitNode, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, isBlockDomNode, isDocumentFragment, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, resetRandomKey, setDOMUnmanaged, setNodeIndentFromDOM, } from './LexicalUtils'; | ||
export { ArtificialNode__DO_NOT_USE } from './nodes/ArtificialNode'; | ||
@@ -27,0 +27,0 @@ export { $isDecoratorNode, DecoratorNode } from './nodes/LexicalDecoratorNode'; |
@@ -12,2 +12,4 @@ /** | ||
export declare const DOM_TEXT_TYPE = 3; | ||
export declare const DOM_DOCUMENT_TYPE = 9; | ||
export declare const DOM_DOCUMENT_FRAGMENT_TYPE = 11; | ||
export declare const NO_DIRTY_NODES = 0; | ||
@@ -14,0 +16,0 @@ export declare const HAS_DIRTY_NODES = 1; |
@@ -13,6 +13,15 @@ /** | ||
export type NodeMap = Map<NodeKey, LexicalNode>; | ||
/** | ||
* The base type for all serialized nodes | ||
*/ | ||
export type SerializedLexicalNode = { | ||
/** The type string used by the Node class */ | ||
type: string; | ||
/** A numeric version for this schema, defaulting to 1, but not generally recommended for use */ | ||
version: number; | ||
}; | ||
/** | ||
* Omit the children, type, and version properties from the given SerializedLexicalNode definition. | ||
*/ | ||
export type LexicalUpdateJSON<T extends SerializedLexicalNode> = Omit<T, 'children' | 'type' | 'version'>; | ||
/** @internal */ | ||
@@ -321,2 +330,31 @@ export interface LexicalPrivateDOM { | ||
/** | ||
* Update this LexicalNode instance from serialized JSON. It's recommended | ||
* to implement as much logic as possible in this method instead of the | ||
* static importJSON method, so that the functionality can be inherited in subclasses. | ||
* | ||
* The LexicalUpdateJSON utility type should be used to ignore any type, version, | ||
* or children properties in the JSON so that the extended JSON from subclasses | ||
* are acceptable parameters for the super call. | ||
* | ||
* If overridden, this method must call super. | ||
* | ||
* @example | ||
* ```ts | ||
* class MyTextNode extends TextNode { | ||
* // ... | ||
* static importJSON(serializedNode: SerializedMyTextNode): MyTextNode { | ||
* return $createMyTextNode() | ||
* .updateFromJSON(serializedNode); | ||
* } | ||
* updateFromJSON( | ||
* serializedNode: LexicalUpdateJSON<SerializedMyTextNode>, | ||
* ): this { | ||
* return super.updateFromJSON(serializedNode) | ||
* .setMyProperty(serializedNode.myProperty); | ||
* } | ||
* } | ||
* ``` | ||
**/ | ||
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedLexicalNode>): this; | ||
/** | ||
* @experimental | ||
@@ -323,0 +361,0 @@ * |
@@ -34,3 +34,12 @@ /** | ||
export declare function $isTokenOrSegmented(node: TextNode): boolean; | ||
export declare function isDOMTextNode(node: Node): node is Text; | ||
/** | ||
* @param node - The element being tested | ||
* @returns Returns true if node is an DOM Text node, false otherwise. | ||
*/ | ||
export declare function isDOMTextNode(node: unknown): node is Text; | ||
/** | ||
* @param node - The element being tested | ||
* @returns Returns true if node is an DOM Document node, false otherwise. | ||
*/ | ||
export declare function isDOMDocumentNode(node: unknown): node is Document; | ||
export declare function getDOMTextNode(element: Node | null): Text | null; | ||
@@ -110,2 +119,3 @@ export declare function toggleTextFormatType(format: number, type: TextFormatType, alignWithFormat: null | number): number; | ||
export declare function getParentElement(node: Node): HTMLElement | null; | ||
export declare function getDOMOwnerDocument(target: EventTarget | null): Document | null; | ||
export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, selectionRect: DOMRect, rootElement: HTMLElement): void; | ||
@@ -124,3 +134,3 @@ export declare function $hasUpdateTag(tag: string): boolean; | ||
export declare function $hasAncestor(child: LexicalNode, targetNode: LexicalNode): boolean; | ||
export declare function getDefaultView(domElem: HTMLElement): Window | null; | ||
export declare function getDefaultView(domElem: EventTarget | null): Window | null; | ||
export declare function getWindow(editor: LexicalEditor): Window; | ||
@@ -155,2 +165,9 @@ export declare function $isInlineElementOrDecoratorNode(node: LexicalNode): boolean; | ||
export declare function getDOMSelection(targetWindow: null | Window): null | Selection; | ||
/** | ||
* Returns the selection for the defaultView of the ownerDocument of given EventTarget. | ||
* | ||
* @param eventTarget The node to get the selection from | ||
* @returns a Selection or null | ||
*/ | ||
export declare function getDOMSelectionFromTarget(eventTarget: null | EventTarget): null | Selection; | ||
export declare function $splitNode(node: ElementNode, offset: number): [ElementNode | null, ElementNode]; | ||
@@ -157,0 +174,0 @@ export declare function $findMatchingParent(startingNode: LexicalNode, findFn: (node: LexicalNode) => boolean): LexicalNode | null; |
@@ -9,3 +9,2 @@ /** | ||
import type { KlassConstructor, LexicalEditor } from '../LexicalEditor'; | ||
import type { NodeKey } from '../LexicalNode'; | ||
import type { ElementNode } from './LexicalElementNode'; | ||
@@ -21,3 +20,2 @@ import { EditorConfig } from 'lexical'; | ||
['constructor']: KlassConstructor<typeof DecoratorNode<T>>; | ||
constructor(key?: NodeKey); | ||
/** | ||
@@ -24,0 +22,0 @@ * The returned value is added to the LexicalEditor._decorators |
@@ -10,3 +10,3 @@ /** | ||
import type { BaseSelection, RangeSelection } from '../LexicalSelection'; | ||
import type { KlassConstructor, LexicalEditor, Spread } from 'lexical'; | ||
import type { KlassConstructor, LexicalEditor, LexicalUpdateJSON, Spread, TextFormatType } from 'lexical'; | ||
import { TextNode } from '../index'; | ||
@@ -19,2 +19,4 @@ import { LexicalNode } from '../LexicalNode'; | ||
indent: number; | ||
textFormat?: number; | ||
textStyle?: string; | ||
}, SerializedLexicalNode>; | ||
@@ -112,2 +114,6 @@ export type ElementFormatType = 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; | ||
__dir: 'ltr' | 'rtl' | null; | ||
/** @internal */ | ||
__textFormat: number; | ||
/** @internal */ | ||
__textStyle: string; | ||
constructor(key?: NodeKey); | ||
@@ -137,3 +143,12 @@ afterCloneFrom(prevNode: this): void; | ||
getDirection(): 'ltr' | 'rtl' | null; | ||
getTextFormat(): number; | ||
hasFormat(type: ElementFormatType): boolean; | ||
hasTextFormat(type: TextFormatType): boolean; | ||
/** | ||
* 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; | ||
getTextStyle(): string; | ||
select(_anchorOffset?: number, _focusOffset?: number): RangeSelection; | ||
@@ -147,2 +162,4 @@ selectStart(): RangeSelection; | ||
setStyle(style: string): this; | ||
setTextFormat(type: number): this; | ||
setTextStyle(style: string): this; | ||
setIndent(indentLevel: number): this; | ||
@@ -161,2 +178,3 @@ splice(start: number, deleteCount: number, nodesToInsert: Array<LexicalNode>): this; | ||
exportJSON(): SerializedElementNode; | ||
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedElementNode>): this; | ||
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | LexicalNode; | ||
@@ -163,0 +181,0 @@ canIndent(): boolean; |
@@ -9,7 +9,6 @@ /** | ||
import type { EditorConfig, KlassConstructor, LexicalEditor, Spread } from '../LexicalEditor'; | ||
import type { DOMConversionMap, DOMExportOutput, LexicalNode, NodeKey } from '../LexicalNode'; | ||
import type { DOMConversionMap, DOMExportOutput, LexicalNode } from '../LexicalNode'; | ||
import type { RangeSelection } from '../LexicalSelection'; | ||
import type { SerializedElementNode } from './LexicalElementNode'; | ||
import type { RangeSelection } from 'lexical'; | ||
import { ElementNode } from './LexicalElementNode'; | ||
import { TextFormatType } from './LexicalTextNode'; | ||
export type SerializedParagraphNode = Spread<{ | ||
@@ -22,20 +21,4 @@ textFormat: number; | ||
['constructor']: KlassConstructor<typeof ParagraphNode>; | ||
/** @internal */ | ||
__textFormat: number; | ||
__textStyle: string; | ||
constructor(key?: NodeKey); | ||
static getType(): string; | ||
getTextFormat(): number; | ||
setTextFormat(type: number): this; | ||
hasTextFormat(type: TextFormatType): boolean; | ||
/** | ||
* 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; | ||
getTextStyle(): string; | ||
setTextStyle(style: string): this; | ||
static clone(node: ParagraphNode): ParagraphNode; | ||
afterCloneFrom(prevNode: this): void; | ||
createDOM(config: EditorConfig): HTMLElement; | ||
@@ -42,0 +25,0 @@ updateDOM(prevNode: ParagraphNode, dom: HTMLElement, config: EditorConfig): boolean; |
@@ -17,3 +17,2 @@ /** | ||
static clone(node: TabNode): TabNode; | ||
afterCloneFrom(prevNode: this): void; | ||
constructor(key?: NodeKey); | ||
@@ -23,5 +22,5 @@ static importDOM(): DOMConversionMap | null; | ||
static importJSON(serializedTabNode: SerializedTabNode): TabNode; | ||
setTextContent(_text: string): this; | ||
setDetail(_detail: TextDetailType | number): this; | ||
setMode(_type: TextModeType): this; | ||
setTextContent(text: string): this; | ||
setDetail(detail: TextDetailType | number): this; | ||
setMode(type: TextModeType): this; | ||
canInsertTextBefore(): boolean; | ||
@@ -28,0 +27,0 @@ canInsertTextAfter(): boolean; |
@@ -9,3 +9,3 @@ /** | ||
import type { EditorConfig, KlassConstructor, LexicalEditor, Spread } from '../LexicalEditor'; | ||
import type { DOMConversionMap, DOMExportOutput, NodeKey, SerializedLexicalNode } from '../LexicalNode'; | ||
import type { DOMConversionMap, DOMExportOutput, LexicalUpdateJSON, NodeKey, SerializedLexicalNode } from '../LexicalNode'; | ||
import type { BaseSelection, RangeSelection } from '../LexicalSelection'; | ||
@@ -49,3 +49,3 @@ import type { ElementNode } from './LexicalElementNode'; | ||
afterCloneFrom(prevNode: this): void; | ||
constructor(text: string, key?: NodeKey); | ||
constructor(text?: string, key?: NodeKey); | ||
/** | ||
@@ -148,2 +148,3 @@ * Returns a 32-bit integer that represents the TextFormatTypes currently applied to the | ||
static importJSON(serializedNode: SerializedTextNode): TextNode; | ||
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedTextNode>): this; | ||
exportDOM(editor: LexicalEditor): DOMExportOutput; | ||
@@ -150,0 +151,0 @@ exportJSON(): SerializedTextNode; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.22.1-nightly.20250101.0", | ||
"version": "0.22.1-nightly.20250102.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 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
1152684
24545