lexical 0.7.9 → 0.8.1

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.
@@ -21,6 +21,7 @@ export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>;
21
21
  export declare const FORMAT_TEXT_COMMAND: LexicalCommand<TextFormatType>;
22
22
  export declare const UNDO_COMMAND: LexicalCommand<void>;
23
23
  export declare const REDO_COMMAND: LexicalCommand<void>;
24
+ export declare const KEY_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
24
25
  export declare const KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
25
26
  export declare const MOVE_TO_END: LexicalCommand<KeyboardEvent>;
26
27
  export declare const KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
@@ -93,6 +93,7 @@ export declare type EditorThemeClasses = {
93
93
  base?: EditorThemeClassName;
94
94
  focus?: EditorThemeClassName;
95
95
  };
96
+ indent?: EditorThemeClassName;
96
97
  [key: string]: any;
97
98
  };
98
99
  export declare type EditorConfig = {
@@ -100,11 +101,28 @@ export declare type EditorConfig = {
100
101
  namespace: string;
101
102
  theme: EditorThemeClasses;
102
103
  };
104
+ export declare type CreateEditorArgs = {
105
+ disableEvents?: boolean;
106
+ editorState?: EditorState;
107
+ namespace?: string;
108
+ nodes?: ReadonlyArray<Klass<LexicalNode> | {
109
+ replace: Klass<LexicalNode>;
110
+ with: <T extends {
111
+ new (...args: any): any;
112
+ }>(node: InstanceType<T>) => LexicalNode;
113
+ withKlass?: Klass<LexicalNode>;
114
+ }>;
115
+ onError?: ErrorHandler;
116
+ parentEditor?: LexicalEditor;
117
+ editable?: boolean;
118
+ theme?: EditorThemeClasses;
119
+ };
103
120
  export declare type RegisteredNodes = Map<string, RegisteredNode>;
104
121
  export declare type RegisteredNode = {
105
122
  klass: Klass<LexicalNode>;
106
123
  transforms: Set<Transform<LexicalNode>>;
107
124
  replace: null | ((node: LexicalNode) => LexicalNode);
125
+ replaceWithKlass: null | Klass<LexicalNode>;
108
126
  };
109
127
  export declare type Transform<T extends LexicalNode> = (node: T) => void;
110
128
  export declare type ErrorHandler = (error: Error) => void;
@@ -176,21 +194,7 @@ export declare type SerializedEditor = {
176
194
  editorState: SerializedEditorState;
177
195
  };
178
196
  export declare function resetEditor(editor: LexicalEditor, prevRootElement: null | HTMLElement, nextRootElement: null | HTMLElement, pendingEditorState: EditorState): void;
179
- export declare function createEditor(editorConfig?: {
180
- disableEvents?: boolean;
181
- editorState?: EditorState;
182
- namespace?: string;
183
- nodes?: ReadonlyArray<Klass<LexicalNode> | {
184
- replace: Klass<LexicalNode>;
185
- with: <T extends {
186
- new (...args: any): any;
187
- }>(node: InstanceType<T>) => LexicalNode;
188
- }>;
189
- onError?: ErrorHandler;
190
- parentEditor?: LexicalEditor;
191
- editable?: boolean;
192
- theme?: EditorThemeClasses;
193
- }): LexicalEditor;
197
+ export declare function createEditor(editorConfig?: CreateEditorArgs): LexicalEditor;
194
198
  export declare class LexicalEditor {
195
199
  _headless: boolean;
196
200
  _parentEditor: null | LexicalEditor;
@@ -230,6 +234,7 @@ export declare class LexicalEditor {
230
234
  registerRootListener(listener: RootListener): () => void;
231
235
  registerCommand<P>(command: LexicalCommand<P>, listener: CommandListener<P>, priority: CommandListenerPriority): () => void;
232
236
  registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener): () => void;
237
+ private registerNodeTransformToKlass;
233
238
  registerNodeTransform<T extends LexicalNode>(klass: Klass<T>, listener: Transform<T>): () => void;
234
239
  hasNodes<T extends Klass<LexicalNode>>(nodes: Array<T>): boolean;
235
240
  dispatchCommand<TCommand extends LexicalCommand<unknown>>(type: TCommand, payload: CommandPayloadType<TCommand>): boolean;
@@ -11,4 +11,4 @@ export declare type EventHandler = (event: Event, editor: LexicalEditor) => void
11
11
  export declare function addRootElementEvents(rootElement: HTMLElement, editor: LexicalEditor): void;
12
12
  export declare function removeRootElementEvents(rootElement: HTMLElement): void;
13
13
  export declare function markSelectionChangeFromDOMUpdate(): void;
14
- export declare function markCollapsedSelectionFormat(format: number, offset: number, key: NodeKey, timeStamp: number): void;
14
+ export declare function markCollapsedSelectionFormat(format: number, style: string, offset: number, key: NodeKey, timeStamp: number): void;
@@ -105,8 +105,9 @@ export declare class RangeSelection implements BaseSelection {
105
105
  focus: PointType;
106
106
  dirty: boolean;
107
107
  format: number;
108
+ style: string;
108
109
  _cachedNodes: null | Array<LexicalNode>;
109
- constructor(anchor: PointType, focus: PointType, format: number);
110
+ constructor(anchor: PointType, focus: PointType, format: number, style: string);
110
111
  is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean;
111
112
  isBackward(): boolean;
112
113
  isCollapsed(): boolean;
@@ -116,6 +117,7 @@ export declare class RangeSelection implements BaseSelection {
116
117
  applyDOMRange(range: StaticRange): void;
117
118
  clone(): RangeSelection;
118
119
  toggleFormat(format: TextFormatType): void;
120
+ setStyle(style: string): void;
119
121
  hasFormat(type: TextFormatType): boolean;
120
122
  insertRawText(text: string): void;
121
123
  insertText(text: string): void;
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  */
9
9
  export type { PasteCommandType } from './LexicalCommands';
10
- export type { CommandListenerPriority, CommandPayloadType, EditableListener, EditorConfig, EditorThemeClasses, Klass, LexicalCommand, LexicalEditor, MutationListener, NodeMutation, SerializedEditor, Spread, } from './LexicalEditor';
10
+ export type { CommandListenerPriority, CommandPayloadType, CreateEditorArgs, EditableListener, EditorConfig, EditorThemeClasses, Klass, LexicalCommand, LexicalEditor, MutationListener, NodeMutation, SerializedEditor, Spread, } from './LexicalEditor';
11
11
  export type { EditorState, SerializedEditorState } from './LexicalEditorState';
12
12
  export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode';
13
13
  export type { BaseSelection, ElementPointType as ElementPoint, GridSelection, GridSelectionShape, NodeSelection, Point, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection';
@@ -15,7 +15,7 @@ export type { ElementFormatType, SerializedElementNode, } from './nodes/LexicalE
15
15
  export type { SerializedGridCellNode } from './nodes/LexicalGridCellNode';
16
16
  export type { SerializedRootNode } from './nodes/LexicalRootNode';
17
17
  export type { SerializedTextNode, TextFormatType, TextModeType, } from './nodes/LexicalTextNode';
18
- export { BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, createCommand, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, MOVE_TO_END, MOVE_TO_START, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, REDO_COMMAND, REMOVE_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, } from './LexicalCommands';
18
+ export { BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, createCommand, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, MOVE_TO_END, MOVE_TO_START, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, REDO_COMMAND, REMOVE_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, } from './LexicalCommands';
19
19
  export { COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, createEditor, } from './LexicalEditor';
20
20
  export type { EventHandler } from './LexicalEvents';
21
21
  export { $normalizeSelection as $normalizeSelection__EXPERIMENTAL } from './LexicalNormalization';
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.7.9",
12
+ "version": "0.8.1",
13
13
  "main": "Lexical.js",
14
14
  "repository": {
15
15
  "type": "git",