@lobehub/editor 3.3.2 → 3.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.
Files changed (55) hide show
  1. package/es/editor-kernel/index.d.ts +1 -0
  2. package/es/editor-kernel/index.js +3 -1
  3. package/es/editor-kernel/kernel.js +1 -0
  4. package/es/editor-kernel/lexical/Lexical.dev.js +3052 -0
  5. package/es/editor-kernel/lexical/Lexical.dev.mjs +15365 -0
  6. package/es/editor-kernel/lexical/Lexical.js +7634 -0
  7. package/es/editor-kernel/lexical/Lexical.mjs +7258 -0
  8. package/es/editor-kernel/lexical/LexicalCommands.d.ts +175 -0
  9. package/es/editor-kernel/lexical/LexicalConstants.d.ts +54 -0
  10. package/es/editor-kernel/lexical/LexicalEditor.d.ts +672 -0
  11. package/es/editor-kernel/lexical/LexicalEditorState.d.ts +39 -0
  12. package/es/editor-kernel/lexical/LexicalEvents.d.ts +22 -0
  13. package/es/editor-kernel/lexical/LexicalGC.d.ts +23 -0
  14. package/es/editor-kernel/lexical/LexicalMutations.d.ts +12 -0
  15. package/es/editor-kernel/lexical/LexicalNode.d.ts +689 -0
  16. package/es/editor-kernel/lexical/LexicalNodeState.d.ts +569 -0
  17. package/es/editor-kernel/lexical/LexicalNormalization.d.ts +11 -0
  18. package/es/editor-kernel/lexical/LexicalReconciler.d.ts +28 -0
  19. package/es/editor-kernel/lexical/LexicalSelection.d.ts +368 -0
  20. package/es/editor-kernel/lexical/LexicalUpdateTags.d.ts +67 -0
  21. package/es/editor-kernel/lexical/LexicalUpdates.d.ts +72 -0
  22. package/es/editor-kernel/lexical/LexicalUtils.d.ts +492 -0
  23. package/es/editor-kernel/lexical/caret/LexicalCaret.d.ts +635 -0
  24. package/es/editor-kernel/lexical/caret/LexicalCaretUtils.d.ts +224 -0
  25. package/es/editor-kernel/lexical/extension-core/defineExtension.d.ts +126 -0
  26. package/es/editor-kernel/lexical/extension-core/index.d.ts +38 -0
  27. package/es/editor-kernel/lexical/extension-core/internal.d.ts +32 -0
  28. package/es/editor-kernel/lexical/extension-core/safeCast.d.ts +15 -0
  29. package/es/editor-kernel/lexical/extension-core/shallowMergeConfig.d.ts +20 -0
  30. package/es/editor-kernel/lexical/extension-core/types.d.ts +371 -0
  31. package/es/editor-kernel/lexical/index.d.ts +368 -0
  32. package/es/editor-kernel/lexical/nodes/ArtificialNode.d.ts +16 -0
  33. package/es/editor-kernel/lexical/nodes/LexicalDecoratorNode.d.ts +32 -0
  34. package/es/editor-kernel/lexical/nodes/LexicalElementNode.d.ts +235 -0
  35. package/es/editor-kernel/lexical/nodes/LexicalLineBreakNode.d.ts +30 -0
  36. package/es/editor-kernel/lexical/nodes/LexicalParagraphNode.d.ts +39 -0
  37. package/es/editor-kernel/lexical/nodes/LexicalRootNode.d.ts +35 -0
  38. package/es/editor-kernel/lexical/nodes/LexicalTabNode.d.ts +30 -0
  39. package/es/editor-kernel/lexical/nodes/LexicalTextNode.d.ts +311 -0
  40. package/es/plugins/common/data-source/json-data-source.js +29 -3
  41. package/es/plugins/common/react/ReactPlainText.js +9 -0
  42. package/es/plugins/common/utils/index.d.ts +2 -1
  43. package/es/plugins/common/utils/index.js +33 -0
  44. package/es/plugins/litexml/command/index.js +9 -1
  45. package/es/plugins/litexml/data-source/litexml-data-source.js +12 -2
  46. package/es/plugins/litexml/plugin/index.js +41 -3
  47. package/es/plugins/litexml/utils/index.d.ts +2 -1
  48. package/es/plugins/litexml/utils/index.js +7 -1
  49. package/es/plugins/markdown/data-source/markdown-data-source.js +6 -25
  50. package/es/plugins/markdown/data-source/markdown-writer-context.d.ts +5 -1
  51. package/es/plugins/markdown/data-source/markdown-writer-context.js +27 -2
  52. package/es/plugins/markdown/service/shortcut.d.ts +7 -0
  53. package/es/types/kernel.d.ts +4 -0
  54. package/package.json +8 -2
  55. package/scripts/patch-lexical.js +39 -0
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalCommand } from './LexicalEditor';
9
+ import type { LexicalNode } from './LexicalNode';
10
+ import type { BaseSelection } from './LexicalSelection';
11
+ import type { ElementFormatType } from './nodes/LexicalElementNode';
12
+ import type { TextFormatType } from './nodes/LexicalTextNode';
13
+
14
+ export type PasteCommandType = ClipboardEvent | InputEvent | KeyboardEvent;
15
+ /**
16
+ * Crete a command that can be used with `editor.dispatchCommand` and
17
+ * `editor.registerCommand`. Commands are used by unique reference, not by
18
+ * name.
19
+ *
20
+ * @param type A string to identify the command, very helpful for debugging
21
+ * @returns A new LexicalCommand
22
+ *
23
+ * @__NO_SIDE_EFFECTS__
24
+ */
25
+ export declare function createCommand<T>(type?: string): LexicalCommand<T>;
26
+ export declare const SELECTION_CHANGE_COMMAND: LexicalCommand<void>;
27
+ export declare const SELECTION_INSERT_CLIPBOARD_NODES_COMMAND: LexicalCommand<{
28
+ nodes: Array<LexicalNode>;
29
+ selection: BaseSelection;
30
+ }>;
31
+ export declare const CLICK_COMMAND: LexicalCommand<MouseEvent>;
32
+ export declare const BEFORE_INPUT_COMMAND: LexicalCommand<InputEvent>;
33
+ export declare const INPUT_COMMAND: LexicalCommand<InputEvent>;
34
+ export declare const COMPOSITION_START_COMMAND: LexicalCommand<CompositionEvent>;
35
+ export declare const COMPOSITION_END_COMMAND: LexicalCommand<CompositionEvent>;
36
+ /**
37
+ * Dispatched to delete a character, the payload will be `true` if the deletion
38
+ * is backwards (backspace or delete on macOS) and `false` if forwards
39
+ * (delete or Fn+Delete on macOS).
40
+ */
41
+ export declare const DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>;
42
+ /**
43
+ * Dispatched to insert a line break. With a false payload the
44
+ * cursor moves to the new line (Shift+Enter), with a true payload the cursor
45
+ * does not move (Ctrl+O on macOS).
46
+ */
47
+ export declare const INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>;
48
+ export declare const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>;
49
+ export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>;
50
+ export declare const PASTE_COMMAND: LexicalCommand<PasteCommandType>;
51
+ export declare const REMOVE_TEXT_COMMAND: LexicalCommand<InputEvent | null>;
52
+ /**
53
+ * Dispatched to delete a word, the payload will be `true` if the deletion is
54
+ * backwards (Ctrl+Backspace or Opt+Delete on macOS), and `false` if
55
+ * forwards (Ctrl+Delete or Fn+Opt+Delete on macOS).
56
+ */
57
+ export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>;
58
+ /**
59
+ * Dispatched to delete a line, the payload will be `true` if the deletion is
60
+ * backwards (Cmd+Delete on macOS), and `false` if forwards
61
+ * (Fn+Cmd+Delete on macOS).
62
+ */
63
+ export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>;
64
+ /**
65
+ * Dispatched to format the selected text.
66
+ */
67
+ export declare const FORMAT_TEXT_COMMAND: LexicalCommand<TextFormatType>;
68
+ /**
69
+ * Dispatched on undo (Cmd+Z on macOS, Ctrl+Z elsewhere).
70
+ */
71
+ export declare const UNDO_COMMAND: LexicalCommand<void>;
72
+ /**
73
+ * Dispatched on redo (Shift+Cmd+Z on macOS, Shift+Ctrl+Z or Ctrl+Y elsewhere).
74
+ */
75
+ export declare const REDO_COMMAND: LexicalCommand<void>;
76
+ /**
77
+ * Dispatched when any key is pressed.
78
+ */
79
+ export declare const KEY_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
80
+ /**
81
+ * Dispatched when the `'ArrowRight'` key is pressed.
82
+ * The shift modifier key may also be down.
83
+ */
84
+ export declare const KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>;
85
+ /**
86
+ * Dispatched when the move to end keyboard shortcut is pressed,
87
+ * (Cmd+Right on macOS; Ctrl+Right elsewhere).
88
+ */
89
+ export declare const MOVE_TO_END: LexicalCommand<KeyboardEvent>;
90
+ /**
91
+ * Dispatched when the `'ArrowLeft'` key is pressed.
92
+ * The shift modifier key may also be down.
93
+ */
94
+ export declare const KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
95
+ /**
96
+ * Dispatched when the move to start keyboard shortcut is pressed,
97
+ * (Cmd+Left on macOS; Ctrl+Left elsewhere).
98
+ */
99
+ export declare const MOVE_TO_START: LexicalCommand<KeyboardEvent>;
100
+ /**
101
+ * Dispatched when the `'ArrowUp'` key is pressed.
102
+ * The shift and/or alt (option) modifier keys may also be down.
103
+ */
104
+ export declare const KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>;
105
+ /**
106
+ * Dispatched when the `'ArrowDown'` key is pressed.
107
+ * The shift and/or alt (option) modifier keys may also be down.
108
+ */
109
+ export declare const KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
110
+ /**
111
+ * Dispatched when the enter key is pressed, may also be called with a null
112
+ * payload when the intent is to insert a newline. The shift modifier key
113
+ * must be down, any other modifier keys may also be down.
114
+ */
115
+ export declare const KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
116
+ /**
117
+ * Dispatched whenever the space (`' '`) key is pressed, any modifier
118
+ * keys may be down.
119
+ */
120
+ export declare const KEY_SPACE_COMMAND: LexicalCommand<KeyboardEvent>;
121
+ /**
122
+ * Dispatched whenever the `'Backspace'` key is pressed, the shift
123
+ * modifier key may be down.
124
+ */
125
+ export declare const KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
126
+ /**
127
+ * Dispatched whenever the `'Escape'` key is pressed, any modifier
128
+ * keys may be down.
129
+ */
130
+ export declare const KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
131
+ /**
132
+ * Dispatched whenever the `'Delete'` key is pressed (Fn+Delete on macOS).
133
+ */
134
+ export declare const KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
135
+ /**
136
+ * Dispatched whenever the `'Tab'` key is pressed. The shift modifier key
137
+ * may be down.
138
+ */
139
+ export declare const KEY_TAB_COMMAND: LexicalCommand<KeyboardEvent>;
140
+ export declare const INSERT_TAB_COMMAND: LexicalCommand<void>;
141
+ export declare const INDENT_CONTENT_COMMAND: LexicalCommand<void>;
142
+ export declare const OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
143
+ export declare const DROP_COMMAND: LexicalCommand<DragEvent>;
144
+ export declare const FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
145
+ export declare const DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
146
+ export declare const DRAGOVER_COMMAND: LexicalCommand<DragEvent>;
147
+ export declare const DRAGEND_COMMAND: LexicalCommand<DragEvent>;
148
+ /**
149
+ * Dispatched on a copy event, either via the clipboard or a KeyboardEvent
150
+ * (Cmd+C on macOS, Ctrl+C elsewhere).
151
+ */
152
+ export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>;
153
+ /**
154
+ * Dispatched on a cut event, either via the clipboard or a KeyboardEvent
155
+ * (Cmd+X on macOS, Ctrl+X elsewhere).
156
+ */
157
+ export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>;
158
+ /**
159
+ * Dispatched on the select all keyboard shortcut
160
+ * (Cmd+A on macOS, Ctrl+A elsehwere).
161
+ */
162
+ export declare const SELECT_ALL_COMMAND: LexicalCommand<KeyboardEvent>;
163
+ export declare const CLEAR_EDITOR_COMMAND: LexicalCommand<void>;
164
+ export declare const CLEAR_HISTORY_COMMAND: LexicalCommand<void>;
165
+ export declare const CAN_REDO_COMMAND: LexicalCommand<boolean>;
166
+ export declare const CAN_UNDO_COMMAND: LexicalCommand<boolean>;
167
+ export declare const FOCUS_COMMAND: LexicalCommand<FocusEvent>;
168
+ export declare const BLUR_COMMAND: LexicalCommand<FocusEvent>;
169
+ /**
170
+ * @deprecated in v0.31.0, use KEY_DOWN_COMMAND and check for modifiers
171
+ * directly.
172
+ *
173
+ * Dispatched after any KeyboardEvent when modifiers are pressed
174
+ */
175
+ export declare const KEY_MODIFIER_COMMAND: LexicalCommand<KeyboardEvent>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { ElementFormatType } from './nodes/LexicalElementNode';
9
+ import type { TextDetailType, TextFormatType, TextModeType } from './nodes/LexicalTextNode';
10
+
11
+ export declare const DOM_ELEMENT_TYPE = 1;
12
+ export declare const DOM_TEXT_TYPE = 3;
13
+ export declare const DOM_DOCUMENT_TYPE = 9;
14
+ export declare const DOM_DOCUMENT_FRAGMENT_TYPE = 11;
15
+ export declare const NO_DIRTY_NODES = 0;
16
+ export declare const HAS_DIRTY_NODES = 1;
17
+ export declare const FULL_RECONCILE = 2;
18
+ export declare const IS_NORMAL = 0;
19
+ export declare const IS_TOKEN = 1;
20
+ export declare const IS_SEGMENTED = 2;
21
+ export declare const IS_BOLD = 1;
22
+ export declare const IS_ITALIC: number;
23
+ export declare const IS_STRIKETHROUGH: number;
24
+ export declare const IS_UNDERLINE: number;
25
+ export declare const IS_CODE: number;
26
+ export declare const IS_SUBSCRIPT: number;
27
+ export declare const IS_SUPERSCRIPT: number;
28
+ export declare const IS_HIGHLIGHT: number;
29
+ export declare const IS_LOWERCASE: number;
30
+ export declare const IS_UPPERCASE: number;
31
+ export declare const IS_CAPITALIZE: number;
32
+ export declare const IS_ALL_FORMATTING: number;
33
+ export declare const IS_DIRECTIONLESS = 1;
34
+ export declare const IS_UNMERGEABLE: number;
35
+ export declare const IS_ALIGN_LEFT = 1;
36
+ export declare const IS_ALIGN_CENTER = 2;
37
+ export declare const IS_ALIGN_RIGHT = 3;
38
+ export declare const IS_ALIGN_JUSTIFY = 4;
39
+ export declare const IS_ALIGN_START = 5;
40
+ export declare const IS_ALIGN_END = 6;
41
+ export declare const NON_BREAKING_SPACE = '\u00A0';
42
+ export declare const COMPOSITION_SUFFIX: string;
43
+ export declare const DOUBLE_LINE_BREAK = '\n\n';
44
+ export declare const COMPOSITION_START_CHAR: string;
45
+ export declare const RTL_REGEX: RegExp;
46
+ export declare const LTR_REGEX: RegExp;
47
+ export declare const TEXT_TYPE_TO_FORMAT: Record<TextFormatType | string, number>;
48
+ export declare const DETAIL_TYPE_TO_DETAIL: Record<TextDetailType | string, number>;
49
+ export declare const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<ElementFormatType, ''>, number>;
50
+ export declare const ELEMENT_FORMAT_TO_TYPE: Record<number, ElementFormatType>;
51
+ export declare const TEXT_MODE_TO_TYPE: Record<TextModeType, 0 | 1 | 2>;
52
+ export declare const TEXT_TYPE_TO_MODE: Record<number, TextModeType>;
53
+ export declare const NODE_STATE_KEY = '$';
54
+ export declare const PROTOTYPE_CONFIG_METHOD = '$config';