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