@lobehub/editor 4.8.4 → 4.9.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.
- package/es/{ReactSlashPlugin-BZvB0g1k.js → ReactSlashPlugin-Dn5VWUzS.js} +352 -339
- package/es/headless.d.ts +531 -0
- package/es/headless.js +26178 -0
- package/es/{index-BfKEHYDe.d.ts → index-BXj6uAM3.d.ts} +4 -0
- package/es/index.d.ts +250 -185
- package/es/index.js +2077 -1849
- package/es/react.d.ts +1 -1
- package/es/react.js +5 -5
- package/es/renderer.js +66 -6
- package/es/{style-B7Vfm0cE.js → style-CcDKrOoJ.js} +143 -143
- package/es/{style-Tlcvrhqp.js → style-DAKdXzC4.js} +42 -1
- package/package.json +5 -1
package/es/headless.d.ts
ADDED
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
import { HistoryState, HistoryStateEntry } from "@lexical/history";
|
|
2
|
+
import * as _$lexical from "lexical";
|
|
3
|
+
import { CommandListener, CommandListenerPriority, CommandPayloadType, EditorState, ElementNode, LexicalCommand, LexicalEditor, LexicalNode, LexicalNodeConfig, SerializedEditorState, SerializedLexicalNode } from "lexical";
|
|
4
|
+
|
|
5
|
+
//#region src/editor-kernel/data-source.d.ts
|
|
6
|
+
interface IWriteOptions {
|
|
7
|
+
selection?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare class DataSource {
|
|
10
|
+
protected dataType: string;
|
|
11
|
+
constructor(dataType: string);
|
|
12
|
+
get type(): string;
|
|
13
|
+
read(editor: LexicalEditor, data: any, options?: Record<string, unknown>): void;
|
|
14
|
+
write(editor: LexicalEditor, options?: IWriteOptions): any;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/types/hotkey.d.ts
|
|
18
|
+
declare const HotkeyEnum: {
|
|
19
|
+
readonly Bold: "bold";
|
|
20
|
+
readonly BulletList: "bulletList";
|
|
21
|
+
readonly CodeInline: "codeInline";
|
|
22
|
+
readonly Italic: "italic";
|
|
23
|
+
readonly Link: "link";
|
|
24
|
+
readonly Mention: "mention";
|
|
25
|
+
readonly NumberList: "numberList";
|
|
26
|
+
readonly PasteAsPlainText: "pasteAsPlainText";
|
|
27
|
+
readonly Redo: "redo";
|
|
28
|
+
readonly Slash: "slash";
|
|
29
|
+
readonly Strikethrough: "strikethrough";
|
|
30
|
+
readonly Underline: "underline";
|
|
31
|
+
readonly Undo: "undo";
|
|
32
|
+
};
|
|
33
|
+
type HotkeyId = (typeof HotkeyEnum)[keyof typeof HotkeyEnum];
|
|
34
|
+
type ModifierCombination = {
|
|
35
|
+
altKey?: boolean;
|
|
36
|
+
ctrlKey?: boolean;
|
|
37
|
+
metaKey?: boolean;
|
|
38
|
+
shiftKey?: boolean;
|
|
39
|
+
} | Record<string, never>;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/utils/hotkey/registerHotkey.d.ts
|
|
42
|
+
type HotkeysEvent = {
|
|
43
|
+
key?: string;
|
|
44
|
+
keys: string;
|
|
45
|
+
modifiers: ModifierCombination;
|
|
46
|
+
scopes?: string[];
|
|
47
|
+
};
|
|
48
|
+
type HotkeyOptions = {
|
|
49
|
+
enabled?: boolean;
|
|
50
|
+
preventDefault?: boolean;
|
|
51
|
+
stopImmediatePropagation?: boolean;
|
|
52
|
+
stopPropagation?: boolean;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/locale/index.d.ts
|
|
56
|
+
declare const _default: {
|
|
57
|
+
cancel: string;
|
|
58
|
+
codemirror: {
|
|
59
|
+
copyFailed: string;
|
|
60
|
+
copySuccess: string;
|
|
61
|
+
selectLanguage: string;
|
|
62
|
+
selectTheme: string;
|
|
63
|
+
showLineNumbers: string;
|
|
64
|
+
tabSize: string;
|
|
65
|
+
theme: string;
|
|
66
|
+
useTabs: string;
|
|
67
|
+
};
|
|
68
|
+
confirm: string;
|
|
69
|
+
file: {
|
|
70
|
+
error: string;
|
|
71
|
+
uploading: string;
|
|
72
|
+
};
|
|
73
|
+
image: {
|
|
74
|
+
broken: string;
|
|
75
|
+
replace: string;
|
|
76
|
+
};
|
|
77
|
+
link: {
|
|
78
|
+
edit: string;
|
|
79
|
+
editLinkTitle: string;
|
|
80
|
+
editTextTitle: string;
|
|
81
|
+
open: string;
|
|
82
|
+
placeholder: string;
|
|
83
|
+
unlink: string;
|
|
84
|
+
};
|
|
85
|
+
markdown: {
|
|
86
|
+
autoFormatMessage: string;
|
|
87
|
+
autoFormatTitle: string;
|
|
88
|
+
cancel: string;
|
|
89
|
+
confirm: string;
|
|
90
|
+
parseMessage: string;
|
|
91
|
+
parseTitle: string;
|
|
92
|
+
};
|
|
93
|
+
math: {
|
|
94
|
+
placeholder: string;
|
|
95
|
+
};
|
|
96
|
+
modifier: {
|
|
97
|
+
accept: string;
|
|
98
|
+
acceptAll: string;
|
|
99
|
+
reject: string;
|
|
100
|
+
rejectedAll: string;
|
|
101
|
+
};
|
|
102
|
+
table: {
|
|
103
|
+
delete: string;
|
|
104
|
+
deleteColumn: string;
|
|
105
|
+
deleteRow: string;
|
|
106
|
+
insertColumnLeft: string;
|
|
107
|
+
insertColumnRight: string;
|
|
108
|
+
insertRowAbove: string;
|
|
109
|
+
insertRowBelow: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/types/locale.d.ts
|
|
114
|
+
/**
|
|
115
|
+
* Internationalization key type declaration, plugins can extend through declaration merging
|
|
116
|
+
*/
|
|
117
|
+
type LocaleType = typeof _default;
|
|
118
|
+
type FlattenKeys<T, Prefix extends string = ''> = { [K in keyof T & string]: T[K] extends string ? Prefix extends '' ? K : `${Prefix}.${K}` : T[K] extends Record<string, any> ? FlattenKeys<T[K], Prefix extends '' ? K : `${Prefix}.${K}`> : never }[keyof T & string];
|
|
119
|
+
type ILocaleKeys = Record<FlattenKeys<LocaleType>, string>;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/types/kernel.d.ts
|
|
122
|
+
type IDecoratorFunc = (_node: LexicalNode, _editor: LexicalEditor) => any;
|
|
123
|
+
type IDecorator = {
|
|
124
|
+
queryDOM: (_element: HTMLElement) => HTMLElement;
|
|
125
|
+
render: IDecoratorFunc;
|
|
126
|
+
} | IDecoratorFunc;
|
|
127
|
+
/**
|
|
128
|
+
* Service ID type
|
|
129
|
+
*/
|
|
130
|
+
type IServiceID<Service> = {
|
|
131
|
+
readonly __serviceId: string;
|
|
132
|
+
__serviceType?: Service;
|
|
133
|
+
};
|
|
134
|
+
interface ISelectionObject {
|
|
135
|
+
endNodeId: string;
|
|
136
|
+
endOffset: number;
|
|
137
|
+
startNodeId: string;
|
|
138
|
+
startOffset: number;
|
|
139
|
+
type: 'range' | 'node' | 'table';
|
|
140
|
+
}
|
|
141
|
+
interface IDocumentOptions {
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
keepHistory?: boolean;
|
|
144
|
+
/** only work for json datasource */
|
|
145
|
+
keepId?: boolean;
|
|
146
|
+
}
|
|
147
|
+
interface IKernelEventMap {
|
|
148
|
+
/**
|
|
149
|
+
* Document change event
|
|
150
|
+
*/
|
|
151
|
+
documentChange: (type: string, content: any) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Editor editable state change event
|
|
154
|
+
*/
|
|
155
|
+
editableChange: (editable: boolean) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Editor error event
|
|
158
|
+
*/
|
|
159
|
+
error: (error: Error) => void;
|
|
160
|
+
/**
|
|
161
|
+
* Initialization event
|
|
162
|
+
* @param editor Lexical editor instance
|
|
163
|
+
* @returns
|
|
164
|
+
*/
|
|
165
|
+
initialized: (editor: LexicalEditor) => void;
|
|
166
|
+
/**
|
|
167
|
+
* handle markdown parse event
|
|
168
|
+
*/
|
|
169
|
+
markdownParse: (params: {
|
|
170
|
+
cacheState: EditorState;
|
|
171
|
+
historyState: HistoryStateEntry | null;
|
|
172
|
+
markdown: string;
|
|
173
|
+
matchedPatterns: string[];
|
|
174
|
+
score: number;
|
|
175
|
+
}) => void;
|
|
176
|
+
/**
|
|
177
|
+
* handle paste event
|
|
178
|
+
*/
|
|
179
|
+
onPaste: (event: ClipboardEvent) => void;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* External API
|
|
183
|
+
*/
|
|
184
|
+
interface IEditor {
|
|
185
|
+
/**
|
|
186
|
+
* Lose focus
|
|
187
|
+
*/
|
|
188
|
+
blur(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Clean editor content (clear all content)
|
|
191
|
+
*/
|
|
192
|
+
cleanDocument(): void;
|
|
193
|
+
/**
|
|
194
|
+
* Destroy editor instance
|
|
195
|
+
*/
|
|
196
|
+
destroy(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Execute editor commands to manipulate editor content
|
|
199
|
+
* @param type
|
|
200
|
+
* @param payload
|
|
201
|
+
*/
|
|
202
|
+
dispatchCommand<TCommand extends LexicalCommand<unknown>>(type: TCommand, payload: CommandPayloadType<TCommand>): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Focus editor
|
|
205
|
+
*/
|
|
206
|
+
focus(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Get editor content of specified type
|
|
209
|
+
*/
|
|
210
|
+
getDocument(type: string): DataSource | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Lexical history state (undo stack metadata)
|
|
213
|
+
*/
|
|
214
|
+
getHistoryState(): HistoryState;
|
|
215
|
+
/**
|
|
216
|
+
* Get Lexical editor instance
|
|
217
|
+
*/
|
|
218
|
+
getLexicalEditor(): LexicalEditor | null;
|
|
219
|
+
/**
|
|
220
|
+
* Get document editor root node
|
|
221
|
+
*/
|
|
222
|
+
getRootElement(): HTMLElement | null;
|
|
223
|
+
/**
|
|
224
|
+
* Get editor selection information
|
|
225
|
+
*/
|
|
226
|
+
getSelection(): ISelectionObject | null;
|
|
227
|
+
/**
|
|
228
|
+
* Get document editor selection content of specified type
|
|
229
|
+
* @param type
|
|
230
|
+
*/
|
|
231
|
+
getSelectionDocument(type: string): unknown | null;
|
|
232
|
+
/**
|
|
233
|
+
* Get editor theme
|
|
234
|
+
*/
|
|
235
|
+
getTheme(): Record<string, string | Record<string, string>>;
|
|
236
|
+
/**
|
|
237
|
+
* Get headless editor instance
|
|
238
|
+
*/
|
|
239
|
+
initHeadlessEditor(): LexicalEditor | null;
|
|
240
|
+
/**
|
|
241
|
+
* Get node editor instance
|
|
242
|
+
*/
|
|
243
|
+
initNodeEditor(): LexicalEditor | null;
|
|
244
|
+
/**
|
|
245
|
+
* Check if editor is editable
|
|
246
|
+
*/
|
|
247
|
+
isEditable(): boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Check if editor content is empty
|
|
250
|
+
* @returns true if editor content is empty, false otherwise
|
|
251
|
+
*/
|
|
252
|
+
get isEmpty(): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Check if editor has active selection
|
|
255
|
+
* @returns true if editor has selection, false otherwise
|
|
256
|
+
*/
|
|
257
|
+
get isSelected(): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Remove editor event listener
|
|
260
|
+
* @param event
|
|
261
|
+
* @param listener
|
|
262
|
+
*/
|
|
263
|
+
off<T extends keyof IKernelEventMap>(event: T, listener: IKernelEventMap[T]): this;
|
|
264
|
+
/**
|
|
265
|
+
* Add editor event listener
|
|
266
|
+
* @param event
|
|
267
|
+
* @param listener
|
|
268
|
+
*/
|
|
269
|
+
on<T extends keyof IKernelEventMap>(event: T, listener: IKernelEventMap[T]): this;
|
|
270
|
+
/**
|
|
271
|
+
* Listen to event once, automatically remove listener after trigger
|
|
272
|
+
* @param event
|
|
273
|
+
* @param listener
|
|
274
|
+
*/
|
|
275
|
+
once<T extends keyof IKernelEventMap>(event: T, listener: IKernelEventMap[T]): this;
|
|
276
|
+
/**
|
|
277
|
+
* Extends the priority level of Lexical commands.
|
|
278
|
+
* Registers a listener that triggers when the provided command is dispatched
|
|
279
|
+
* via {@link LexicalEditor.dispatch}. The listener is triggered based on its priority.
|
|
280
|
+
* Listeners with higher priority can "intercept" commands and prevent them
|
|
281
|
+
* from propagating to other handlers by returning true.
|
|
282
|
+
*
|
|
283
|
+
* Listeners are always invoked within {@link LexicalEditor.update} and can call dollar functions.
|
|
284
|
+
*
|
|
285
|
+
* Listeners registered at the same priority level will deterministically run
|
|
286
|
+
* in the order of registration.
|
|
287
|
+
*
|
|
288
|
+
* @param command - The command that triggers the callback.
|
|
289
|
+
* @param listener - The function executed when the command is dispatched.
|
|
290
|
+
* @param priority - The relative priority of the listener. 0 | 1 | 2 | 3 | 4
|
|
291
|
+
* (or {@link COMMAND_PRIORITY_EDITOR} |
|
|
292
|
+
* {@link COMMAND_PRIORITY_LOW} |
|
|
293
|
+
* {@link COMMAND_PRIORITY_NORMAL} |
|
|
294
|
+
* {@link COMMAND_PRIORITY_HIGH} |
|
|
295
|
+
* {@link COMMAND_PRIORITY_CRITICAL})
|
|
296
|
+
* @returns A teardown function to clean up the listener.
|
|
297
|
+
*/
|
|
298
|
+
registerHighCommand<P>(command: LexicalCommand<P>, listener: CommandListener<P>, priority: CommandListenerPriority): () => void;
|
|
299
|
+
/**
|
|
300
|
+
* Register keyboard shortcut
|
|
301
|
+
* @param hotkey
|
|
302
|
+
* @param callback
|
|
303
|
+
* @param options
|
|
304
|
+
*/
|
|
305
|
+
registerHotkey(hotkey: HotkeyId, callback: (event: KeyboardEvent, handler: HotkeysEvent) => void, options?: HotkeyOptions): () => void;
|
|
306
|
+
/**
|
|
307
|
+
* Register internationalization text
|
|
308
|
+
* @param locale Internationalization text object
|
|
309
|
+
*/
|
|
310
|
+
registerLocale(locale: Partial<Record<keyof ILocaleKeys, string>>): void;
|
|
311
|
+
/**
|
|
312
|
+
* Register editor plugin
|
|
313
|
+
*/
|
|
314
|
+
registerPlugin<T>(plugin: IEditorPluginConstructor<T>, config?: T): IEditor;
|
|
315
|
+
/**
|
|
316
|
+
* Register multiple editor plugins
|
|
317
|
+
*/
|
|
318
|
+
registerPlugins(plugins: Array<IPlugin>): IEditor;
|
|
319
|
+
/**
|
|
320
|
+
* Get editor Service, usually provided by plugins to extend certain functionalities
|
|
321
|
+
* @param serviceId
|
|
322
|
+
*/
|
|
323
|
+
requireService<T>(serviceId: IServiceID<T>): T | null;
|
|
324
|
+
/**
|
|
325
|
+
* Set editor content, type is content type, content is content data
|
|
326
|
+
* @param type
|
|
327
|
+
* @param content
|
|
328
|
+
*/
|
|
329
|
+
setDocument(type: string, content: any, options?: IDocumentOptions): void;
|
|
330
|
+
/**
|
|
331
|
+
* Enable or disable editor editing capability
|
|
332
|
+
* @param editable
|
|
333
|
+
*/
|
|
334
|
+
setEditable(editable: boolean): void;
|
|
335
|
+
/**
|
|
336
|
+
* Set document editor root node
|
|
337
|
+
* @param dom
|
|
338
|
+
*/
|
|
339
|
+
setRootElement(dom: HTMLElement, editable?: boolean): LexicalEditor;
|
|
340
|
+
/**
|
|
341
|
+
* set editor selection
|
|
342
|
+
* @param selection
|
|
343
|
+
*/
|
|
344
|
+
setSelection(selection: ISelectionObject, opt?: {
|
|
345
|
+
collapseToEnd?: boolean;
|
|
346
|
+
collapseToStart?: boolean;
|
|
347
|
+
}): Promise<boolean>;
|
|
348
|
+
/**
|
|
349
|
+
* Get translation text
|
|
350
|
+
* @param key Translation key
|
|
351
|
+
* @param params Parameter replacement
|
|
352
|
+
*/
|
|
353
|
+
t<K extends keyof ILocaleKeys>(key: K, params?: Record<string, any>): string;
|
|
354
|
+
/**
|
|
355
|
+
* Update editor theme
|
|
356
|
+
* @param key
|
|
357
|
+
* @param value
|
|
358
|
+
*/
|
|
359
|
+
updateTheme(key: string, value: string | Record<string, string>): void;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* API provided to plugins
|
|
363
|
+
*/
|
|
364
|
+
interface IEditorKernel extends IEditor {
|
|
365
|
+
/**
|
|
366
|
+
* Clone the current editor kernel instance
|
|
367
|
+
*/
|
|
368
|
+
cloneNodeEditor(): IEditorKernel;
|
|
369
|
+
emit<T extends keyof IKernelEventMap>(event: T, params: Parameters<IKernelEventMap[T]>[0]): void;
|
|
370
|
+
/**
|
|
371
|
+
* Get editor Node decorator for specific Node rendering
|
|
372
|
+
* @param name
|
|
373
|
+
*/
|
|
374
|
+
getDecorator(name: string): IDecorator | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Get all registered decorator names
|
|
377
|
+
*/
|
|
378
|
+
getRegisteredDecorators(): string[];
|
|
379
|
+
/**
|
|
380
|
+
* Check if hot reload mode is enabled
|
|
381
|
+
*/
|
|
382
|
+
isHotReloadMode(): boolean;
|
|
383
|
+
/**
|
|
384
|
+
* Register data source for multi-format data conversion
|
|
385
|
+
* @param dataSource
|
|
386
|
+
*/
|
|
387
|
+
registerDataSource(dataSource: DataSource): void;
|
|
388
|
+
/**
|
|
389
|
+
* Register editor node decorator
|
|
390
|
+
* @param name
|
|
391
|
+
* @param decorator
|
|
392
|
+
*/
|
|
393
|
+
registerDecorator(name: string, decorator: IDecorator): void;
|
|
394
|
+
/**
|
|
395
|
+
* Register Lexical Node
|
|
396
|
+
* @param nodes
|
|
397
|
+
*/
|
|
398
|
+
registerNodes(nodes: Array<LexicalNodeConfig>): void;
|
|
399
|
+
/**
|
|
400
|
+
* Register service
|
|
401
|
+
* @param serviceId
|
|
402
|
+
* @param service
|
|
403
|
+
*/
|
|
404
|
+
registerService<T>(serviceId: IServiceID<T>, service: T): void;
|
|
405
|
+
/**
|
|
406
|
+
* Register service with hot reload support - allows overriding existing services
|
|
407
|
+
* @param serviceId Service identifier
|
|
408
|
+
* @param service Service instance
|
|
409
|
+
*/
|
|
410
|
+
registerServiceHotReload<T>(serviceId: IServiceID<T>, service: T): void;
|
|
411
|
+
/**
|
|
412
|
+
* Register theme
|
|
413
|
+
* @param themes
|
|
414
|
+
*/
|
|
415
|
+
registerThemes(themes: Record<string, any>): void;
|
|
416
|
+
/**
|
|
417
|
+
* Enable or disable hot reload mode
|
|
418
|
+
* @param enabled Whether to enable hot reload mode
|
|
419
|
+
*/
|
|
420
|
+
setHotReloadMode(enabled: boolean): void;
|
|
421
|
+
/**
|
|
422
|
+
* Unregister editor node decorator
|
|
423
|
+
* @param name Decorator name
|
|
424
|
+
*/
|
|
425
|
+
unregisterDecorator(name: string): boolean;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Plugin interface
|
|
429
|
+
*/
|
|
430
|
+
interface IEditorPlugin<IConfig> {
|
|
431
|
+
config?: IConfig;
|
|
432
|
+
/**
|
|
433
|
+
* Editor destruction
|
|
434
|
+
*/
|
|
435
|
+
destroy(): void;
|
|
436
|
+
/**
|
|
437
|
+
* After Lexical editor instantiation
|
|
438
|
+
* @param editor Lexical editor instance
|
|
439
|
+
*/
|
|
440
|
+
onInit?(editor: LexicalEditor): void;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Plugin class interface
|
|
444
|
+
*/
|
|
445
|
+
interface IEditorPluginConstructor<IConfig> {
|
|
446
|
+
readonly pluginName: string;
|
|
447
|
+
new (kernel: IEditorKernel, config?: IConfig): IEditorPlugin<IConfig>;
|
|
448
|
+
}
|
|
449
|
+
type IPlugin<T = any> = IEditorPluginConstructor<T> | [IEditorPluginConstructor<T>, T?];
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/plugins/litexml/command/index.d.ts
|
|
452
|
+
declare const LITEXML_MODIFY_COMMAND: _$lexical.LexicalCommand<({
|
|
453
|
+
action: "insert";
|
|
454
|
+
beforeId: string;
|
|
455
|
+
litexml: string;
|
|
456
|
+
} | {
|
|
457
|
+
action: "insert";
|
|
458
|
+
afterId: string;
|
|
459
|
+
litexml: string;
|
|
460
|
+
} | {
|
|
461
|
+
action: "remove";
|
|
462
|
+
id: string;
|
|
463
|
+
} | {
|
|
464
|
+
action: "modify";
|
|
465
|
+
litexml: string | string[];
|
|
466
|
+
})[]>;
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/headless/index.d.ts
|
|
469
|
+
type HeadlessDocumentType = 'json' | 'litexml' | 'markdown' | (string & object);
|
|
470
|
+
interface HeadlessEditorHydrationInput {
|
|
471
|
+
content: unknown;
|
|
472
|
+
options?: IDocumentOptions;
|
|
473
|
+
type: HeadlessDocumentType;
|
|
474
|
+
}
|
|
475
|
+
interface HeadlessEditorExportOptions {
|
|
476
|
+
litexml?: boolean;
|
|
477
|
+
}
|
|
478
|
+
interface HeadlessEditorExport {
|
|
479
|
+
editorData: SerializedEditorState<SerializedLexicalNode>;
|
|
480
|
+
litexml?: string;
|
|
481
|
+
markdown: string;
|
|
482
|
+
}
|
|
483
|
+
interface HeadlessEditorOptions {
|
|
484
|
+
additionalPlugins?: ReadonlyArray<IPlugin>;
|
|
485
|
+
initialValue?: HeadlessEditorHydrationInput;
|
|
486
|
+
plugins?: ReadonlyArray<IPlugin>;
|
|
487
|
+
}
|
|
488
|
+
interface HeadlessLiteXMLReplaceOperation {
|
|
489
|
+
action: 'apply' | 'replace';
|
|
490
|
+
delay?: boolean;
|
|
491
|
+
litexml: string | string[];
|
|
492
|
+
}
|
|
493
|
+
type HeadlessLiteXMLInsertOperation = {
|
|
494
|
+
action: 'insert';
|
|
495
|
+
afterId: string;
|
|
496
|
+
delay?: boolean;
|
|
497
|
+
litexml: string;
|
|
498
|
+
} | {
|
|
499
|
+
action: 'insert';
|
|
500
|
+
beforeId: string;
|
|
501
|
+
delay?: boolean;
|
|
502
|
+
litexml: string;
|
|
503
|
+
};
|
|
504
|
+
interface HeadlessLiteXMLRemoveOperation {
|
|
505
|
+
action: 'remove';
|
|
506
|
+
delay?: boolean;
|
|
507
|
+
id: string;
|
|
508
|
+
}
|
|
509
|
+
interface HeadlessLiteXMLBatchOperation {
|
|
510
|
+
action: 'batch';
|
|
511
|
+
operations: CommandPayloadType<typeof LITEXML_MODIFY_COMMAND>;
|
|
512
|
+
}
|
|
513
|
+
type HeadlessLiteXMLOperation = HeadlessLiteXMLBatchOperation | HeadlessLiteXMLInsertOperation | HeadlessLiteXMLRemoveOperation | HeadlessLiteXMLReplaceOperation;
|
|
514
|
+
declare const DEFAULT_HEADLESS_EDITOR_PLUGINS: ReadonlyArray<IPlugin>;
|
|
515
|
+
declare class HeadlessEditor {
|
|
516
|
+
readonly kernel: IEditor;
|
|
517
|
+
constructor(options?: HeadlessEditorOptions);
|
|
518
|
+
hydrate(input: HeadlessEditorHydrationInput): this;
|
|
519
|
+
hydrateEditorData(editorData: SerializedEditorState<SerializedLexicalNode> | string, options?: IDocumentOptions): this;
|
|
520
|
+
hydrateLiteXML(litexml: string, options?: IDocumentOptions): this;
|
|
521
|
+
hydrateMarkdown(markdown: string, options?: IDocumentOptions): this;
|
|
522
|
+
applyLiteXML(operation: HeadlessLiteXMLOperation | ReadonlyArray<HeadlessLiteXMLOperation>): Promise<this>;
|
|
523
|
+
applyLiteXMLBatch(operations: CommandPayloadType<typeof LITEXML_MODIFY_COMMAND>): Promise<this>;
|
|
524
|
+
export(options?: HeadlessEditorExportOptions): HeadlessEditorExport;
|
|
525
|
+
exportState(options?: HeadlessEditorExportOptions): HeadlessEditorExport;
|
|
526
|
+
destroy(): void;
|
|
527
|
+
private applyLiteXMLOperation;
|
|
528
|
+
}
|
|
529
|
+
declare function createHeadlessEditor(options?: HeadlessEditorOptions): HeadlessEditor;
|
|
530
|
+
//#endregion
|
|
531
|
+
export { DEFAULT_HEADLESS_EDITOR_PLUGINS, HeadlessDocumentType, HeadlessEditor, HeadlessEditorExport, HeadlessEditorExportOptions, HeadlessEditorHydrationInput, HeadlessEditorOptions, HeadlessLiteXMLBatchOperation, HeadlessLiteXMLInsertOperation, HeadlessLiteXMLOperation, HeadlessLiteXMLRemoveOperation, HeadlessLiteXMLReplaceOperation, createHeadlessEditor };
|