@prosekit/core 0.8.0 → 0.8.2

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.
@@ -0,0 +1,739 @@
1
+ import { Command, EditorState, Plugin, Selection } from "@prosekit/pm/state";
2
+ import { Attrs, DOMParser, DOMSerializer, Mark, NodeType, ParseOptions, ProseMirrorNode, Schema } from "@prosekit/pm/model";
3
+ import { EditorView } from "@prosekit/pm/view";
4
+ import { Simplify, UnionToIntersection } from "type-fest";
5
+
6
+ //#region src/types/attrs.d.ts
7
+ /**
8
+ * An object holding the attributes of a node.
9
+
10
+ * @public
11
+ */
12
+ type AnyAttrs = Attrs;
13
+ /**
14
+ * @public
15
+ */
16
+ type AttrSpec<AttrType = any> = {
17
+ /**
18
+ * The default value for this attribute, to use when no explicit value is
19
+ * provided. Attributes that have no default must be provided whenever a node
20
+ * or mark of a type that has them is created.
21
+ */
22
+ default?: AttrType;
23
+ /**
24
+ * A function or type name used to validate values of this attribute. This
25
+ * will be used when deserializing the attribute from JSON, and when running
26
+ * [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check). When a
27
+ * function, it should raise an exception if the value isn't of the expected
28
+ * type or shape. When a string, it should be a `|`-separated string of
29
+ * primitive types (`"number"`, `"string"`, `"boolean"`, `"null"`, and
30
+ * `"undefined"`), and the library will raise an error when the value is not
31
+ * one of those types.
32
+ */
33
+ validate?: string | ((value: unknown) => void);
34
+ };
35
+ //#endregion
36
+ //#region src/editor/action.d.ts
37
+ /**
38
+ * Available children parameters for {@link NodeAction} and {@link MarkAction}.
39
+ *
40
+ * @public
41
+ */
42
+ type NodeChild = ProseMirrorNode | string | NodeChild[];
43
+ /**
44
+ * A function for creating a node with optional attributes and any number of
45
+ * children.
46
+ *
47
+ * It also has a `isActive` method for checking if the node is active in the
48
+ * current editor selection.
49
+ *
50
+ * @public
51
+ */
52
+ interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
53
+ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
54
+ (...children: NodeChild[]): ProseMirrorNode;
55
+ /**
56
+ * Checks if the node is active in the current editor selection. If the
57
+ * optional `attrs` parameter is provided, it will check if the node is active
58
+ * with the given attributes.
59
+ */
60
+ isActive: (attrs?: Attrs) => boolean;
61
+ }
62
+ /**
63
+ * A function for creating a mark with optional attributes and any number of
64
+ * children.
65
+ *
66
+ * It also has a `isActive` method for checking if the mark is active in the
67
+ * current editor selection.
68
+ *
69
+ * @public
70
+ */
71
+ interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
72
+ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
73
+ (...children: NodeChild[]): ProseMirrorNode[];
74
+ /**
75
+ * Checks if the mark is active in the current editor selection. If the
76
+ * optional `attrs` parameter is provided, it will check if the mark is active
77
+ * with the given attributes.
78
+ */
79
+ isActive: (attrs?: Attrs) => boolean;
80
+ }
81
+ /**
82
+ * @deprecated Use type {@link NodeAction} instead.
83
+ */
84
+ type NodeBuilder = NodeAction;
85
+ /**
86
+ * @deprecated Use type {@link MarkAction} instead.
87
+ */
88
+ type MarkBuilder = MarkAction;
89
+ /**
90
+ * @internal
91
+ */
92
+ //#endregion
93
+ //#region src/types/extension-command.d.ts
94
+ /**
95
+ * A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
96
+ *
97
+ * It also has a `canExec` method to check if the command can be applied.
98
+ *
99
+ * @public
100
+ */
101
+ interface CommandAction<Args extends any[] = any[]> {
102
+ /**
103
+ * Execute the current command. Return `true` if the command was successfully
104
+ * executed, otherwise `false`.
105
+ */
106
+ (...args: Args): boolean;
107
+ /**
108
+ * Check if the current command can be executed. Return `true` if the command
109
+ * can be executed, otherwise `false`.
110
+ */
111
+ canExec(...args: Args): boolean;
112
+ /**
113
+ * An alias for `canExec`.
114
+ *
115
+ * @deprecated Use `canExec` instead.
116
+ */
117
+ canApply(...args: Args): boolean;
118
+ }
119
+ type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
120
+ /**
121
+ * @internal
122
+ */
123
+ interface CommandTyping {
124
+ [name: string]: any[];
125
+ }
126
+ type ToCommandCreators<T extends CommandTyping> = { [K in keyof T]: CommandCreator<T[K]> };
127
+ type ToCommandAction<T extends CommandTyping> = { [K in keyof T]: CommandAction<T[K]> };
128
+ //#endregion
129
+ //#region src/types/extension-mark.d.ts
130
+ /**
131
+ * @internal
132
+ */
133
+ interface MarkTyping {
134
+ [name: string]: Record<string, any>;
135
+ }
136
+ /**
137
+ * @internal
138
+ */
139
+ type ToMarkAction<T extends MarkTyping> = { [K in keyof T]: MarkAction<T[K]> };
140
+ //#endregion
141
+ //#region src/types/extension-node.d.ts
142
+ /**
143
+ * @internal
144
+ */
145
+ interface NodeTyping {
146
+ [name: string]: Record<string, any>;
147
+ }
148
+ /**
149
+ * @internal
150
+ */
151
+ type ToNodeAction<T extends NodeTyping> = { [K in keyof T]: NodeAction<T[K]> };
152
+ //#endregion
153
+ //#region src/types/pick-sub-type.d.ts
154
+ /**
155
+ * @internal
156
+ */
157
+ type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
158
+ //#endregion
159
+ //#region src/types/pick-string-literal.d.ts
160
+ /**
161
+ * @internal
162
+ */
163
+ type PickStringLiteral<T> = PickSubType<T, string>;
164
+ //#endregion
165
+ //#region src/types/priority.d.ts
166
+ /**
167
+ * ProseKit extension priority.
168
+ *
169
+ * @public
170
+ */
171
+ declare enum Priority {
172
+ lowest = 0,
173
+ low = 1,
174
+ default = 2,
175
+ high = 3,
176
+ highest = 4,
177
+ }
178
+ //#endregion
179
+ //#region src/types/simplify-deeper.d.ts
180
+ /**
181
+ * @internal
182
+ */
183
+ type SimplifyDeeper<T> = { [KeyType in keyof T]: Simplify<T[KeyType]> };
184
+ //#endregion
185
+ //#region src/types/simplify-union.d.ts
186
+ /**
187
+ * @internal
188
+ */
189
+ type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
190
+ //#endregion
191
+ //#region src/types/extension.d.ts
192
+ /**
193
+ * @internal
194
+ */
195
+ interface ExtensionTyping<N extends NodeTyping = never, M extends MarkTyping = never, C extends CommandTyping = never> {
196
+ Nodes?: N;
197
+ Marks?: M;
198
+ Commands?: C;
199
+ }
200
+ /**
201
+ * @public
202
+ */
203
+ interface Extension<T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>> {
204
+ extension: Extension | Extension[];
205
+ priority?: Priority;
206
+ _type?: T;
207
+ /**
208
+ * @public
209
+ *
210
+ * The schema that this extension represents.
211
+ */
212
+ schema: Schema | null;
213
+ }
214
+ /**
215
+ * @internal
216
+ */
217
+ type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickSubType<N, NodeTyping>, PickSubType<M, MarkTyping>, PickSubType<C, CommandTyping>> : never;
218
+ /**
219
+ * An extension that does not define any nodes, marks, or commands.
220
+ *
221
+ * @internal
222
+ */
223
+ type PlainExtension = Extension<{
224
+ Nodes: never;
225
+ Marks: never;
226
+ Commands: never;
227
+ }>;
228
+ /**
229
+ * @public
230
+ */
231
+ type ExtractNodes<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>["Nodes"]>>;
232
+ /**
233
+ * @public
234
+ */
235
+ type ExtractNodeNames<E extends Extension> = PickStringLiteral<keyof ExtractNodes<E>>;
236
+ /**
237
+ * @public
238
+ */
239
+ type ExtractMarks<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>["Marks"]>>;
240
+ /**
241
+ * @public
242
+ */
243
+ type ExtractMarkNames<E extends Extension> = PickStringLiteral<keyof ExtractMarks<E>>;
244
+ /**
245
+ * @internal
246
+ */
247
+ type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>["Commands"]>;
248
+ /**
249
+ * @public
250
+ */
251
+ type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommands<E>>;
252
+ /**
253
+ * Extracts the {@link CommandAction}s from an extension type.
254
+ *
255
+ * @public
256
+ */
257
+ type ExtractCommandActions<E extends Extension> = ToCommandAction<ExtractCommands<E>>;
258
+ /**
259
+ * Extracts the {@link NodeAction}s from an extension type.
260
+ *
261
+ * @public
262
+ */
263
+ type ExtractNodeActions<E extends Extension> = ToNodeAction<ExtractNodes<E>>;
264
+ /**
265
+ * Extracts the {@link MarkAction}s from an extension type.
266
+ *
267
+ * @public
268
+ */
269
+ type ExtractMarkActions<E extends Extension> = ToMarkAction<ExtractMarks<E>>;
270
+ /**
271
+ * @deprecated Use `ExtractCommandActions` instead.
272
+ */
273
+ type ExtractCommandAppliers<E extends Extension> = ExtractCommandActions<E>;
274
+ /**
275
+ * @internal
276
+ */
277
+ type Union<E extends readonly Extension[]> = Extension<{
278
+ Nodes: ExtractNodes<E[number]>;
279
+ Marks: ExtractMarks<E[number]>;
280
+ Commands: ExtractCommands<E[number]>;
281
+ }>;
282
+ /**
283
+ * @deprecated Use `Union` instead.
284
+ * @internal
285
+ */
286
+ type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
287
+ Nodes: ExtractNodes<E[number]>;
288
+ Marks: ExtractMarks<E[number]>;
289
+ Commands: ExtractCommands<E[number]>;
290
+ }> : E;
291
+ //#endregion
292
+ //#region src/types/model.d.ts
293
+ /**
294
+ * A JSON representation of the prosemirror node.
295
+ *
296
+ * @public
297
+ */
298
+ interface NodeJSON {
299
+ type: string;
300
+ marks?: Array<{
301
+ type: string;
302
+ attrs?: Record<string, any>;
303
+ }>;
304
+ text?: string;
305
+ content?: NodeJSON[];
306
+ attrs?: Record<string, any>;
307
+ }
308
+ /**
309
+ * A JSON representation of the prosemirror selection.
310
+ *
311
+ * @public
312
+ */
313
+ interface SelectionJSON {
314
+ anchor: number;
315
+ head: number;
316
+ type: string;
317
+ }
318
+ /**
319
+ * A JSON representation of the prosemirror state.
320
+ *
321
+ * @public
322
+ */
323
+ interface StateJSON {
324
+ /**
325
+ * The main `ProseMirror` doc.
326
+ */
327
+ doc: NodeJSON;
328
+ /**
329
+ * The current selection.
330
+ */
331
+ selection: SelectionJSON;
332
+ }
333
+ /**
334
+ * A JSON representation of the prosemirror step.
335
+ *
336
+ * @public
337
+ */
338
+ interface StepJSON {
339
+ /**
340
+ * The type of the step.
341
+ */
342
+ stepType: string;
343
+ [x: string]: unknown;
344
+ }
345
+ //#endregion
346
+ //#region src/types/dom-node.d.ts
347
+ type DOMNode = InstanceType<typeof window.Node>;
348
+ //#endregion
349
+ //#region src/utils/parse.d.ts
350
+ /** @public */
351
+ interface DOMParserOptions extends ParseOptions {
352
+ DOMParser?: typeof DOMParser;
353
+ }
354
+ /** @public */
355
+ interface DOMSerializerOptions {
356
+ DOMSerializer?: {
357
+ fromSchema: typeof DOMSerializer.fromSchema;
358
+ };
359
+ }
360
+ /** @public */
361
+ interface DOMDocumentOptions {
362
+ /**
363
+ * The Document object to use for DOM operations. If not provided, defaults to
364
+ * the current browser's document object. Useful for server-side rendering or
365
+ * testing environments.
366
+ */
367
+ document?: Document;
368
+ }
369
+ /** @public */
370
+ interface JSONParserOptions {
371
+ /**
372
+ * The editor schema to use.
373
+ */
374
+ schema: Schema;
375
+ }
376
+ /////////////// JSON <=> State ///////////////
377
+ /**
378
+ * Return a JSON object representing this state.
379
+ *
380
+ * @public
381
+ *
382
+ * @example
383
+ *
384
+ * ```ts
385
+ * const state = editor.state
386
+ * const json = jsonFromState(state)
387
+ * ```
388
+ */
389
+ declare function jsonFromState(state: EditorState): StateJSON;
390
+ /**
391
+ * Parse a JSON object to a ProseMirror state.
392
+ *
393
+ * @public
394
+ *
395
+ * @example
396
+ *
397
+ * ```ts
398
+ * const json = { state: { type: 'doc', content: [{ type: 'paragraph' }], selection: { type: 'text', from: 1, to: 1 } } }
399
+ * const state = stateFromJSON(json, { schema: editor.schema })
400
+ * ```
401
+ */
402
+ declare function stateFromJSON(json: StateJSON, options: JSONParserOptions): EditorState;
403
+ /////////////// JSON <=> Node ///////////////
404
+ /**
405
+ * Return a JSON object representing this node.
406
+ *
407
+ * @public
408
+ *
409
+ * @example
410
+ *
411
+ * ```ts
412
+ * const node = editor.state.doc
413
+ * const json = jsonFromNode(node)
414
+ * ```
415
+ */
416
+ declare function jsonFromNode(node: ProseMirrorNode): NodeJSON;
417
+ /**
418
+ * Parse a JSON object to a ProseMirror node.
419
+ *
420
+ * @public
421
+ *
422
+ * @example
423
+ *
424
+ * ```ts
425
+ * const json = { type: 'doc', content: [{ type: 'paragraph' }] }
426
+ * const node = nodeFromJSON(json, { schema: editor.schema })
427
+ * ```
428
+ */
429
+ declare function nodeFromJSON(json: NodeJSON, options: JSONParserOptions): ProseMirrorNode;
430
+ /////////////// Node <=> Element ///////////////
431
+ /**
432
+ * Parse a HTML element to a ProseMirror node.
433
+ *
434
+ * @public
435
+ *
436
+ * @example
437
+ *
438
+ * ```ts
439
+ * const element = document.getElementById('content')
440
+ * const node = nodeFromElement(element, { schema: editor.schema })
441
+ */
442
+ declare function nodeFromElement(element: DOMNode, options: DOMParserOptions & JSONParserOptions): ProseMirrorNode;
443
+ /**
444
+ * Serialize a ProseMirror node to a HTML element.
445
+ *
446
+ * @public
447
+ *
448
+ * @example
449
+ *
450
+ * ```ts
451
+ * const node = editor.state.doc
452
+ * const element = elementFromNode(node)
453
+ * ```
454
+ */
455
+ declare function elementFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
456
+ /////////////// Element <=> HTML ///////////////
457
+ /**
458
+ * Parse a HTML string to a HTML element.
459
+ *
460
+ * @internal
461
+ */
462
+
463
+ /////////////// Node <=> HTML ///////////////
464
+ /**
465
+ * Parse a HTML string to a ProseMirror node.
466
+ *
467
+ * @public
468
+ *
469
+ * @example
470
+ *
471
+ * ```ts
472
+ * const html = '<p>Hello, world!</p>'
473
+ * const node = nodeFromHTML(html, { schema: editor.schema })
474
+ */
475
+ declare function nodeFromHTML(html: string, options: DOMParserOptions & JSONParserOptions & DOMDocumentOptions): ProseMirrorNode;
476
+ /**
477
+ * Serialize a ProseMirror node to a HTML string
478
+ *
479
+ * @public
480
+ *
481
+ * @example
482
+ *
483
+ * ```ts
484
+ * const node = document.getElementById('content')
485
+ * const html = htmlFromNode(node)
486
+ * ```
487
+ */
488
+ declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): string;
489
+ /////////////// JSON <=> Element ///////////////
490
+ /**
491
+ * Serialize a HTML element to a ProseMirror document JSON object.
492
+ *
493
+ * @public
494
+ *
495
+ * @example
496
+ *
497
+ * ```ts
498
+ * const element = document.getElementById('content')
499
+ * const json = jsonFromElement(element, { schema: editor.schema })
500
+ * ```
501
+ */
502
+
503
+ /**
504
+ * Parse a ProseMirror document JSON object to a HTML element.
505
+ *
506
+ * @public
507
+ *
508
+ * @example
509
+ *
510
+ * ```ts
511
+ * const json = { type: 'doc', content: [{ type: 'paragraph' }] }
512
+ * const element = elementFromJSON(json, { schema: editor.schema })
513
+ * ```
514
+ */
515
+ declare function elementFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
516
+ /////////////// JSON <=> HTML ///////////////
517
+ /**
518
+ * Parse a HTML string to a ProseMirror document JSON object.
519
+ *
520
+ * @public
521
+ *
522
+ * @example
523
+ *
524
+ * ```ts
525
+ * const html = '<p>Hello, world!</p>'
526
+ * const json = jsonFromHTML(html, { schema: editor.schema })
527
+ * ```
528
+ */
529
+ declare function jsonFromHTML(html: string, options: DOMDocumentOptions & DOMParserOptions & JSONParserOptions): NodeJSON;
530
+ /**
531
+ * Parse a ProseMirror document JSON object to a HTML string.
532
+ *
533
+ * @public
534
+ *
535
+ * @example
536
+ *
537
+ * ```ts
538
+ * const json = { type: 'doc', content: [{ type: 'paragraph' }] }
539
+ * const html = htmlFromJSON(json, { schema: editor.schema })
540
+ * ```
541
+ */
542
+ declare function htmlFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): string;
543
+ //#endregion
544
+ //#region src/editor/editor.d.ts
545
+ /**
546
+ * @public
547
+ */
548
+ interface EditorOptions<E extends Extension> {
549
+ /**
550
+ * The extension to use when creating the editor.
551
+ */
552
+ extension: E;
553
+ /**
554
+ * The starting document to use when creating the editor. It can be a
555
+ * ProseMirror node JSON object, a HTML string, or a HTML element instance.
556
+ */
557
+ defaultContent?: NodeJSON | string | HTMLElement;
558
+ /**
559
+ * A JSON object representing the starting document to use when creating the
560
+ * editor.
561
+ *
562
+ * @deprecated Use `defaultContent` instead.
563
+ */
564
+ defaultDoc?: NodeJSON;
565
+ /**
566
+ * A HTML element or a HTML string representing the starting document to use
567
+ * when creating the editor.
568
+ *
569
+ * @deprecated Use `defaultContent` instead.
570
+ */
571
+ defaultHTML?: string | HTMLElement;
572
+ /**
573
+ * A JSON object representing the starting selection to use when creating the
574
+ * editor. It's only used when `defaultContent` is also provided.
575
+ */
576
+ defaultSelection?: SelectionJSON;
577
+ }
578
+ /**
579
+ * @public
580
+ */
581
+ interface getDocHTMLOptions extends DOMDocumentOptions {}
582
+ /**
583
+ * @internal
584
+ */
585
+
586
+ /**
587
+ * @public
588
+ */
589
+ declare function createEditor<E extends Extension>(options: EditorOptions<E>): Editor<E>;
590
+ /**
591
+ * An internal class to make TypeScript generic type easier to use.
592
+ *
593
+ * @internal
594
+ */
595
+ declare class EditorInstance {
596
+ view: EditorView | null;
597
+ schema: Schema;
598
+ nodes: Record<string, NodeAction>;
599
+ marks: Record<string, MarkAction>;
600
+ commands: Record<string, CommandAction>;
601
+ private tree;
602
+ private directEditorProps;
603
+ private afterMounted;
604
+ constructor(extension: Extension);
605
+ getState: () => EditorState;
606
+ private getDoc;
607
+ private getProp;
608
+ updateState(state: EditorState): void;
609
+ private dispatch;
610
+ setContent(content: NodeJSON | string | HTMLElement | ProseMirrorNode, selection?: SelectionJSON | Selection | "start" | "end"): void;
611
+ /**
612
+ * Return a JSON object representing the editor's current document.
613
+ */
614
+ getDocJSON: () => NodeJSON;
615
+ /**
616
+ * Return a HTML string representing the editor's current document.
617
+ */
618
+ getDocHTML: (options?: getDocHTMLOptions) => string;
619
+ private updateExtension;
620
+ use(extension: Extension): VoidFunction;
621
+ mount(place: HTMLElement): void;
622
+ unmount(): void;
623
+ get mounted(): boolean;
624
+ get assertView(): EditorView;
625
+ definePlugins(plugins: readonly Plugin[]): void;
626
+ removePlugins(plugins: readonly Plugin[]): void;
627
+ exec(command: Command): boolean;
628
+ canExec(command: Command): boolean;
629
+ defineCommand<Args extends any[] = any[]>(name: string, commandCreator: CommandCreator<Args>): void;
630
+ removeCommand(name: string): void;
631
+ }
632
+ /**
633
+ * @public
634
+ */
635
+ declare class Editor<E extends Extension = any> {
636
+ private instance;
637
+ /**
638
+ * @internal
639
+ */
640
+ constructor(instance: EditorInstance);
641
+ /**
642
+ * Whether the editor is mounted.
643
+ */
644
+ get mounted(): boolean;
645
+ /**
646
+ * The editor view.
647
+ */
648
+ get view(): EditorView;
649
+ /**
650
+ * The editor schema.
651
+ */
652
+ get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
653
+ /**
654
+ * The editor's current state.
655
+ */
656
+ get state(): EditorState;
657
+ /**
658
+ * Whether the editor is focused.
659
+ */
660
+ get focused(): boolean;
661
+ /**
662
+ * Mount the editor to the given HTML element.
663
+ * Pass `null` or `undefined` to unmount the editor.
664
+ */
665
+ mount: (place: HTMLElement | null | undefined) => void;
666
+ /**
667
+ * Unmount the editor. This is equivalent to `mount(null)`.
668
+ */
669
+ unmount: () => void;
670
+ /**
671
+ * Focus the editor.
672
+ */
673
+ focus: () => void;
674
+ /**
675
+ * Blur the editor.
676
+ */
677
+ blur: () => void;
678
+ /**
679
+ * Register an extension to the editor. Return a function to unregister the
680
+ * extension.
681
+ */
682
+ use: (extension: Extension) => VoidFunction;
683
+ /**
684
+ * Update the editor's state.
685
+ *
686
+ * @remarks
687
+ *
688
+ * This is an advanced method. Use it only if you have a specific reason to
689
+ * directly manipulate the editor's state.
690
+ */
691
+ updateState: (state: EditorState) => void;
692
+ /**
693
+ * Update the editor's document and selection.
694
+ *
695
+ * @param content - The new document to set. It can be one of the following:
696
+ * - A ProseMirror node instance
697
+ * - A ProseMirror node JSON object
698
+ * - An HTML string
699
+ * - An HTML element instance
700
+ * @param selection - Optional. Specifies the new selection. It can be one of the following:
701
+ * - A ProseMirror selection instance
702
+ * - A ProseMirror selection JSON object
703
+ * - The string "start" (to set selection at the beginning, default value)
704
+ * - The string "end" (to set selection at the end)
705
+ */
706
+ setContent: (content: ProseMirrorNode | NodeJSON | string | HTMLElement, selection?: SelectionJSON | Selection | "start" | "end") => void;
707
+ /**
708
+ * Return a JSON object representing the editor's current document.
709
+ */
710
+ getDocJSON: () => NodeJSON;
711
+ /**
712
+ * Return a HTML string representing the editor's current document.
713
+ */
714
+ getDocHTML: (options?: getDocHTMLOptions) => string;
715
+ /**
716
+ * Execute the given command. Return `true` if the command was successfully
717
+ * executed, otherwise `false`.
718
+ */
719
+ exec: (command: Command) => boolean;
720
+ /**
721
+ * Check if the given command can be executed. Return `true` if the command
722
+ * can be executed, otherwise `false`.
723
+ */
724
+ canExec: (command: Command) => boolean;
725
+ /**
726
+ * All {@link CommandAction}s defined by the editor.
727
+ */
728
+ get commands(): ExtractCommandActions<E>;
729
+ /**
730
+ * All {@link NodeAction}s defined by the editor.
731
+ */
732
+ get nodes(): ExtractNodeActions<E>;
733
+ /**
734
+ * All {@link MarkAction}s defined by the editor.
735
+ */
736
+ get marks(): ExtractMarkActions<E>;
737
+ }
738
+ //#endregion
739
+ export { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor, EditorInstance, EditorOptions, Extension, ExtensionTyping, ExtractCommandActions, ExtractCommandAppliers, ExtractCommandCreators, ExtractMarkActions, ExtractMarks, ExtractNodeActions, ExtractNodes, JSONParserOptions, MarkAction, MarkBuilder, MarkTyping, NodeAction, NodeBuilder, NodeChild, NodeJSON, NodeTyping, PickSubType, PlainExtension, Priority, SelectionJSON, SimplifyDeeper, SimplifyUnion, StateJSON, StepJSON, ToMarkAction, ToNodeAction, Union, UnionExtension, createEditor, elementFromJSON, elementFromNode, htmlFromJSON, htmlFromNode, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, stateFromJSON };