@tiptap/extension-drag-handle-vue-2 2.24.2 → 3.0.0-beta.10

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,2566 @@
1
+ import * as vue_types_vue from 'vue/types/vue';
2
+ import * as Vue from 'vue';
3
+ import Vue__default from 'vue';
4
+ import { Node as Node$3 } from 'prosemirror-model';
5
+ import { PluginKey as PluginKey$1 } from 'prosemirror-state';
6
+ import { Plugin, PluginKey, Transaction, EditorState } from '@tiptap/pm/state';
7
+ import { NodeType as NodeType$1, MarkType as MarkType$1, Node as Node$2, Fragment, ParseOptions, Schema, Slice, Mark as Mark$1, ResolvedPos, MarkSpec, DOMOutputSpec, NodeSpec } from '@tiptap/pm/model';
8
+ import { EditorView, EditorProps, NodeViewConstructor, MarkViewConstructor, NodeView, MarkView } from '@tiptap/pm/view';
9
+ import { Transform } from '@tiptap/pm/transform';
10
+ import { DragHandlePluginProps } from '@tiptap/extension-drag-handle';
11
+
12
+ type StringKeyOf<T> = Extract<keyof T, string>;
13
+ type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
14
+ type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
15
+ declare class EventEmitter<T extends Record<string, any>> {
16
+ private callbacks;
17
+ on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
18
+ emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
19
+ off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
20
+ once<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
21
+ removeAllListeners(): void;
22
+ }
23
+
24
+ type InputRuleMatch = {
25
+ index: number;
26
+ text: string;
27
+ replaceWith?: string;
28
+ match?: RegExpMatchArray;
29
+ data?: Record<string, any>;
30
+ };
31
+ type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
32
+ declare class InputRule {
33
+ find: InputRuleFinder;
34
+ handler: (props: {
35
+ state: EditorState;
36
+ range: Range;
37
+ match: ExtendedRegExpMatchArray;
38
+ commands: SingleCommands;
39
+ chain: () => ChainedCommands;
40
+ can: () => CanCommands;
41
+ }) => void | null;
42
+ constructor(config: {
43
+ find: InputRuleFinder;
44
+ handler: (props: {
45
+ state: EditorState;
46
+ range: Range;
47
+ match: ExtendedRegExpMatchArray;
48
+ commands: SingleCommands;
49
+ chain: () => ChainedCommands;
50
+ can: () => CanCommands;
51
+ }) => void | null;
52
+ });
53
+ }
54
+
55
+ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, MarkConfig<Options, Storage>, MarkType$1> {
56
+ /**
57
+ * Mark View
58
+ */
59
+ addMarkView?: ((this: {
60
+ name: string;
61
+ options: Options;
62
+ storage: Storage;
63
+ editor: Editor;
64
+ type: MarkType$1;
65
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addMarkView'];
66
+ }) => MarkViewRenderer) | null;
67
+ /**
68
+ * Keep mark after split node
69
+ */
70
+ keepOnSplit?: boolean | (() => boolean);
71
+ /**
72
+ * Inclusive
73
+ */
74
+ inclusive?: MarkSpec['inclusive'] | ((this: {
75
+ name: string;
76
+ options: Options;
77
+ storage: Storage;
78
+ parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'];
79
+ editor?: Editor;
80
+ }) => MarkSpec['inclusive']);
81
+ /**
82
+ * Excludes
83
+ */
84
+ excludes?: MarkSpec['excludes'] | ((this: {
85
+ name: string;
86
+ options: Options;
87
+ storage: Storage;
88
+ parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'];
89
+ editor?: Editor;
90
+ }) => MarkSpec['excludes']);
91
+ /**
92
+ * Marks this Mark as exitable
93
+ */
94
+ exitable?: boolean | (() => boolean);
95
+ /**
96
+ * Group
97
+ */
98
+ group?: MarkSpec['group'] | ((this: {
99
+ name: string;
100
+ options: Options;
101
+ storage: Storage;
102
+ parent: ParentConfig<MarkConfig<Options, Storage>>['group'];
103
+ editor?: Editor;
104
+ }) => MarkSpec['group']);
105
+ /**
106
+ * Spanning
107
+ */
108
+ spanning?: MarkSpec['spanning'] | ((this: {
109
+ name: string;
110
+ options: Options;
111
+ storage: Storage;
112
+ parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'];
113
+ editor?: Editor;
114
+ }) => MarkSpec['spanning']);
115
+ /**
116
+ * Code
117
+ */
118
+ code?: boolean | ((this: {
119
+ name: string;
120
+ options: Options;
121
+ storage: Storage;
122
+ parent: ParentConfig<MarkConfig<Options, Storage>>['code'];
123
+ editor?: Editor;
124
+ }) => boolean);
125
+ /**
126
+ * Parse HTML
127
+ */
128
+ parseHTML?: (this: {
129
+ name: string;
130
+ options: Options;
131
+ storage: Storage;
132
+ parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'];
133
+ editor?: Editor;
134
+ }) => MarkSpec['parseDOM'];
135
+ /**
136
+ * Render HTML
137
+ */
138
+ renderHTML?: ((this: {
139
+ name: string;
140
+ options: Options;
141
+ storage: Storage;
142
+ parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'];
143
+ editor?: Editor;
144
+ }, props: {
145
+ mark: Mark$1;
146
+ HTMLAttributes: Record<string, any>;
147
+ }) => DOMOutputSpec) | null;
148
+ /**
149
+ * Attributes
150
+ */
151
+ addAttributes?: (this: {
152
+ name: string;
153
+ options: Options;
154
+ storage: Storage;
155
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'];
156
+ editor?: Editor;
157
+ }) => Attributes$1 | {};
158
+ }
159
+ /**
160
+ * The Mark class is used to create custom mark extensions.
161
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
162
+ */
163
+ declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
164
+ type: string;
165
+ static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
166
+ static handleExit({ editor, mark }: {
167
+ editor: Editor;
168
+ mark: Mark;
169
+ }): boolean;
170
+ configure(options?: Partial<Options>): Mark<Options, Storage>;
171
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
172
+ }
173
+
174
+ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
175
+ /**
176
+ * Node View
177
+ */
178
+ addNodeView?: ((this: {
179
+ name: string;
180
+ options: Options;
181
+ storage: Storage;
182
+ editor: Editor;
183
+ type: NodeType$1;
184
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
185
+ }) => NodeViewRenderer) | null;
186
+ /**
187
+ * Defines if this node should be a top level node (doc)
188
+ * @default false
189
+ * @example true
190
+ */
191
+ topNode?: boolean;
192
+ /**
193
+ * The content expression for this node, as described in the [schema
194
+ * guide](/docs/guide/#schema.content_expressions). When not given,
195
+ * the node does not allow any content.
196
+ *
197
+ * You can read more about it on the Prosemirror documentation here
198
+ * @see https://prosemirror.net/docs/guide/#schema.content_expressions
199
+ * @default undefined
200
+ * @example content: 'block+'
201
+ * @example content: 'headline paragraph block*'
202
+ */
203
+ content?: NodeSpec['content'] | ((this: {
204
+ name: string;
205
+ options: Options;
206
+ storage: Storage;
207
+ parent: ParentConfig<NodeConfig<Options, Storage>>['content'];
208
+ editor?: Editor;
209
+ }) => NodeSpec['content']);
210
+ /**
211
+ * The marks that are allowed inside of this node. May be a
212
+ * space-separated string referring to mark names or groups, `"_"`
213
+ * to explicitly allow all marks, or `""` to disallow marks. When
214
+ * not given, nodes with inline content default to allowing all
215
+ * marks, other nodes default to not allowing marks.
216
+ *
217
+ * @example marks: 'strong em'
218
+ */
219
+ marks?: NodeSpec['marks'] | ((this: {
220
+ name: string;
221
+ options: Options;
222
+ storage: Storage;
223
+ parent: ParentConfig<NodeConfig<Options, Storage>>['marks'];
224
+ editor?: Editor;
225
+ }) => NodeSpec['marks']);
226
+ /**
227
+ * The group or space-separated groups to which this node belongs,
228
+ * which can be referred to in the content expressions for the
229
+ * schema.
230
+ *
231
+ * By default Tiptap uses the groups 'block' and 'inline' for nodes. You
232
+ * can also use custom groups if you want to group specific nodes together
233
+ * and handle them in your schema.
234
+ * @example group: 'block'
235
+ * @example group: 'inline'
236
+ * @example group: 'customBlock' // this uses a custom group
237
+ */
238
+ group?: NodeSpec['group'] | ((this: {
239
+ name: string;
240
+ options: Options;
241
+ storage: Storage;
242
+ parent: ParentConfig<NodeConfig<Options, Storage>>['group'];
243
+ editor?: Editor;
244
+ }) => NodeSpec['group']);
245
+ /**
246
+ * Should be set to true for inline nodes. (Implied for text nodes.)
247
+ */
248
+ inline?: NodeSpec['inline'] | ((this: {
249
+ name: string;
250
+ options: Options;
251
+ storage: Storage;
252
+ parent: ParentConfig<NodeConfig<Options, Storage>>['inline'];
253
+ editor?: Editor;
254
+ }) => NodeSpec['inline']);
255
+ /**
256
+ * Can be set to true to indicate that, though this isn't a [leaf
257
+ * node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
258
+ * content and should be treated as a single unit in the view.
259
+ *
260
+ * @example atom: true
261
+ */
262
+ atom?: NodeSpec['atom'] | ((this: {
263
+ name: string;
264
+ options: Options;
265
+ storage: Storage;
266
+ parent: ParentConfig<NodeConfig<Options, Storage>>['atom'];
267
+ editor?: Editor;
268
+ }) => NodeSpec['atom']);
269
+ /**
270
+ * Controls whether nodes of this type can be selected as a [node
271
+ * selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
272
+ * nodes.
273
+ *
274
+ * @default true
275
+ * @example selectable: false
276
+ */
277
+ selectable?: NodeSpec['selectable'] | ((this: {
278
+ name: string;
279
+ options: Options;
280
+ storage: Storage;
281
+ parent: ParentConfig<NodeConfig<Options, Storage>>['selectable'];
282
+ editor?: Editor;
283
+ }) => NodeSpec['selectable']);
284
+ /**
285
+ * Determines whether nodes of this type can be dragged without
286
+ * being selected. Defaults to false.
287
+ *
288
+ * @default: false
289
+ * @example: draggable: true
290
+ */
291
+ draggable?: NodeSpec['draggable'] | ((this: {
292
+ name: string;
293
+ options: Options;
294
+ storage: Storage;
295
+ parent: ParentConfig<NodeConfig<Options, Storage>>['draggable'];
296
+ editor?: Editor;
297
+ }) => NodeSpec['draggable']);
298
+ /**
299
+ * Can be used to indicate that this node contains code, which
300
+ * causes some commands to behave differently.
301
+ */
302
+ code?: NodeSpec['code'] | ((this: {
303
+ name: string;
304
+ options: Options;
305
+ storage: Storage;
306
+ parent: ParentConfig<NodeConfig<Options, Storage>>['code'];
307
+ editor?: Editor;
308
+ }) => NodeSpec['code']);
309
+ /**
310
+ * Controls way whitespace in this a node is parsed. The default is
311
+ * `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
312
+ * collapse whitespace in normal mode, and normalize it (replacing
313
+ * newlines and such with spaces) otherwise. `"pre"` causes the
314
+ * parser to preserve spaces inside the node. When this option isn't
315
+ * given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
316
+ * will default to `"pre"`. Note that this option doesn't influence
317
+ * the way the node is rendered—that should be handled by `toDOM`
318
+ * and/or styling.
319
+ */
320
+ whitespace?: NodeSpec['whitespace'] | ((this: {
321
+ name: string;
322
+ options: Options;
323
+ storage: Storage;
324
+ parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace'];
325
+ editor?: Editor;
326
+ }) => NodeSpec['whitespace']);
327
+ /**
328
+ * Allows a **single** node to be set as linebreak equivalent (e.g. hardBreak).
329
+ * When converting between block types that have whitespace set to "pre"
330
+ * and don't support the linebreak node (e.g. codeBlock) and other block types
331
+ * that do support the linebreak node (e.g. paragraphs) - this node will be used
332
+ * as the linebreak instead of stripping the newline.
333
+ *
334
+ * See [linebreakReplacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement).
335
+ */
336
+ linebreakReplacement?: NodeSpec['linebreakReplacement'] | ((this: {
337
+ name: string;
338
+ options: Options;
339
+ storage: Storage;
340
+ parent: ParentConfig<NodeConfig<Options, Storage>>['linebreakReplacement'];
341
+ editor?: Editor;
342
+ }) => NodeSpec['linebreakReplacement']);
343
+ /**
344
+ * When enabled, enables both
345
+ * [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
346
+ * [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
347
+ *
348
+ * @default false
349
+ * @example isolating: true
350
+ */
351
+ defining?: NodeSpec['defining'] | ((this: {
352
+ name: string;
353
+ options: Options;
354
+ storage: Storage;
355
+ parent: ParentConfig<NodeConfig<Options, Storage>>['defining'];
356
+ editor?: Editor;
357
+ }) => NodeSpec['defining']);
358
+ /**
359
+ * When enabled (default is false), the sides of nodes of this type
360
+ * count as boundaries that regular editing operations, like
361
+ * backspacing or lifting, won't cross. An example of a node that
362
+ * should probably have this enabled is a table cell.
363
+ */
364
+ isolating?: NodeSpec['isolating'] | ((this: {
365
+ name: string;
366
+ options: Options;
367
+ storage: Storage;
368
+ parent: ParentConfig<NodeConfig<Options, Storage>>['isolating'];
369
+ editor?: Editor;
370
+ }) => NodeSpec['isolating']);
371
+ /**
372
+ * Associates DOM parser information with this node, which can be
373
+ * used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
374
+ * automatically derive a parser. The `node` field in the rules is
375
+ * implied (the name of this node will be filled in automatically).
376
+ * If you supply your own parser, you do not need to also specify
377
+ * parsing rules in your schema.
378
+ *
379
+ * @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]
380
+ */
381
+ parseHTML?: (this: {
382
+ name: string;
383
+ options: Options;
384
+ storage: Storage;
385
+ parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML'];
386
+ editor?: Editor;
387
+ }) => NodeSpec['parseDOM'];
388
+ /**
389
+ * A description of a DOM structure. Can be either a string, which is
390
+ * interpreted as a text node, a DOM node, which is interpreted as
391
+ * itself, a `{dom, contentDOM}` object, or an array.
392
+ *
393
+ * An array describes a DOM element. The first value in the array
394
+ * should be a string—the name of the DOM element, optionally prefixed
395
+ * by a namespace URL and a space. If the second element is plain
396
+ * object, it is interpreted as a set of attributes for the element.
397
+ * Any elements after that (including the 2nd if it's not an attribute
398
+ * object) are interpreted as children of the DOM elements, and must
399
+ * either be valid `DOMOutputSpec` values, or the number zero.
400
+ *
401
+ * The number zero (pronounced “hole”) is used to indicate the place
402
+ * where a node's child nodes should be inserted. If it occurs in an
403
+ * output spec, it should be the only child element in its parent
404
+ * node.
405
+ *
406
+ * @example toDOM: ['div[data-id="my-block"]', { class: 'my-block' }, 0]
407
+ */
408
+ renderHTML?: ((this: {
409
+ name: string;
410
+ options: Options;
411
+ storage: Storage;
412
+ parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML'];
413
+ editor?: Editor;
414
+ }, props: {
415
+ node: Node$2;
416
+ HTMLAttributes: Record<string, any>;
417
+ }) => DOMOutputSpec) | null;
418
+ /**
419
+ * renders the node as text
420
+ * @example renderText: () => 'foo
421
+ */
422
+ renderText?: ((this: {
423
+ name: string;
424
+ options: Options;
425
+ storage: Storage;
426
+ parent: ParentConfig<NodeConfig<Options, Storage>>['renderText'];
427
+ editor?: Editor;
428
+ }, props: {
429
+ node: Node$2;
430
+ pos: number;
431
+ parent: Node$2;
432
+ index: number;
433
+ }) => string) | null;
434
+ /**
435
+ * Add attributes to the node
436
+ * @example addAttributes: () => ({ class: 'foo' })
437
+ */
438
+ addAttributes?: (this: {
439
+ name: string;
440
+ options: Options;
441
+ storage: Storage;
442
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes'];
443
+ editor?: Editor;
444
+ }) => Attributes$1 | {};
445
+ }
446
+ /**
447
+ * The Node class is used to create custom node extensions.
448
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
449
+ */
450
+ declare class Node$1<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
451
+ type: string;
452
+ static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node$1<O, S>;
453
+ configure(options?: Partial<Options>): Node$1<Options, Storage>;
454
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node$1<ExtendedOptions, ExtendedStorage>;
455
+ }
456
+
457
+ type PasteRuleMatch = {
458
+ index: number;
459
+ text: string;
460
+ replaceWith?: string;
461
+ match?: RegExpMatchArray;
462
+ data?: Record<string, any>;
463
+ };
464
+ type PasteRuleFinder = RegExp | ((text: string, event?: ClipboardEvent | null) => PasteRuleMatch[] | null | undefined);
465
+ /**
466
+ * Paste rules are used to react to pasted content.
467
+ * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
468
+ */
469
+ declare class PasteRule {
470
+ find: PasteRuleFinder;
471
+ handler: (props: {
472
+ state: EditorState;
473
+ range: Range;
474
+ match: ExtendedRegExpMatchArray;
475
+ commands: SingleCommands;
476
+ chain: () => ChainedCommands;
477
+ can: () => CanCommands;
478
+ pasteEvent: ClipboardEvent | null;
479
+ dropEvent: DragEvent | null;
480
+ }) => void | null;
481
+ constructor(config: {
482
+ find: PasteRuleFinder;
483
+ handler: (props: {
484
+ can: () => CanCommands;
485
+ chain: () => ChainedCommands;
486
+ commands: SingleCommands;
487
+ dropEvent: DragEvent | null;
488
+ match: ExtendedRegExpMatchArray;
489
+ pasteEvent: ClipboardEvent | null;
490
+ range: Range;
491
+ state: EditorState;
492
+ }) => void | null;
493
+ });
494
+ }
495
+
496
+ interface ExtendableConfig<Options = any, Storage = any, Config extends ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage> | ExtendableConfig<Options, Storage> = ExtendableConfig<Options, Storage, any, any>, PMType = any> {
497
+ /**
498
+ * The extension name - this must be unique.
499
+ * It will be used to identify the extension.
500
+ *
501
+ * @example 'myExtension'
502
+ */
503
+ name: string;
504
+ /**
505
+ * The priority of your extension. The higher, the earlier it will be called
506
+ * and will take precedence over other extensions with a lower priority.
507
+ * @default 100
508
+ * @example 101
509
+ */
510
+ priority?: number;
511
+ /**
512
+ * This method will add options to this extension
513
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#settings
514
+ * @example
515
+ * addOptions() {
516
+ * return {
517
+ * myOption: 'foo',
518
+ * myOtherOption: 10,
519
+ * }
520
+ */
521
+ addOptions?: (this: {
522
+ name: string;
523
+ parent: ParentConfig<Config>['addOptions'];
524
+ }) => Options;
525
+ /**
526
+ * The default storage this extension can save data to.
527
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#storage
528
+ * @example
529
+ * defaultStorage: {
530
+ * prefetchedUsers: [],
531
+ * loading: false,
532
+ * }
533
+ */
534
+ addStorage?: (this: {
535
+ name: string;
536
+ options: Options;
537
+ parent: ParentConfig<Config>['addStorage'];
538
+ }) => Storage;
539
+ /**
540
+ * This function adds globalAttributes to specific nodes.
541
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#global-attributes
542
+ * @example
543
+ * addGlobalAttributes() {
544
+ * return [
545
+ * {
546
+ // Extend the following extensions
547
+ * types: [
548
+ * 'heading',
549
+ * 'paragraph',
550
+ * ],
551
+ * // … with those attributes
552
+ * attributes: {
553
+ * textAlign: {
554
+ * default: 'left',
555
+ * renderHTML: attributes => ({
556
+ * style: `text-align: ${attributes.textAlign}`,
557
+ * }),
558
+ * parseHTML: element => element.style.textAlign || 'left',
559
+ * },
560
+ * },
561
+ * },
562
+ * ]
563
+ * }
564
+ */
565
+ addGlobalAttributes?: (this: {
566
+ name: string;
567
+ options: Options;
568
+ storage: Storage;
569
+ extensions: (Node$1 | Mark)[];
570
+ parent: ParentConfig<Config>['addGlobalAttributes'];
571
+ }) => GlobalAttributes;
572
+ /**
573
+ * This function adds commands to the editor
574
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#commands
575
+ * @example
576
+ * addCommands() {
577
+ * return {
578
+ * myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
579
+ * }
580
+ * }
581
+ */
582
+ addCommands?: (this: {
583
+ name: string;
584
+ options: Options;
585
+ storage: Storage;
586
+ editor: Editor;
587
+ type: PMType;
588
+ parent: ParentConfig<Config>['addCommands'];
589
+ }) => Partial<RawCommands>;
590
+ /**
591
+ * This function registers keyboard shortcuts.
592
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#keyboard-shortcuts
593
+ * @example
594
+ * addKeyboardShortcuts() {
595
+ * return {
596
+ * 'Mod-l': () => this.editor.commands.toggleBulletList(),
597
+ * }
598
+ * },
599
+ */
600
+ addKeyboardShortcuts?: (this: {
601
+ name: string;
602
+ options: Options;
603
+ storage: Storage;
604
+ editor: Editor;
605
+ type: PMType;
606
+ parent: ParentConfig<Config>['addKeyboardShortcuts'];
607
+ }) => {
608
+ [key: string]: KeyboardShortcutCommand;
609
+ };
610
+ /**
611
+ * This function adds input rules to the editor.
612
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#input-rules
613
+ * @example
614
+ * addInputRules() {
615
+ * return [
616
+ * markInputRule({
617
+ * find: inputRegex,
618
+ * type: this.type,
619
+ * }),
620
+ * ]
621
+ * },
622
+ */
623
+ addInputRules?: (this: {
624
+ name: string;
625
+ options: Options;
626
+ storage: Storage;
627
+ editor: Editor;
628
+ type: PMType;
629
+ parent: ParentConfig<Config>['addInputRules'];
630
+ }) => InputRule[];
631
+ /**
632
+ * This function adds paste rules to the editor.
633
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#paste-rules
634
+ * @example
635
+ * addPasteRules() {
636
+ * return [
637
+ * markPasteRule({
638
+ * find: pasteRegex,
639
+ * type: this.type,
640
+ * }),
641
+ * ]
642
+ * },
643
+ */
644
+ addPasteRules?: (this: {
645
+ name: string;
646
+ options: Options;
647
+ storage: Storage;
648
+ editor: Editor;
649
+ type: PMType;
650
+ parent: ParentConfig<Config>['addPasteRules'];
651
+ }) => PasteRule[];
652
+ /**
653
+ * This function adds Prosemirror plugins to the editor
654
+ * @see https://tiptap.dev/docs/editor/guide/custom-extensions#prosemirror-plugins
655
+ * @example
656
+ * addProseMirrorPlugins() {
657
+ * return [
658
+ * customPlugin(),
659
+ * ]
660
+ * }
661
+ */
662
+ addProseMirrorPlugins?: (this: {
663
+ name: string;
664
+ options: Options;
665
+ storage: Storage;
666
+ editor: Editor;
667
+ type: PMType;
668
+ parent: ParentConfig<Config>['addProseMirrorPlugins'];
669
+ }) => Plugin[];
670
+ /**
671
+ * This function adds additional extensions to the editor. This is useful for
672
+ * building extension kits.
673
+ * @example
674
+ * addExtensions() {
675
+ * return [
676
+ * BulletList,
677
+ * OrderedList,
678
+ * ListItem
679
+ * ]
680
+ * }
681
+ */
682
+ addExtensions?: (this: {
683
+ name: string;
684
+ options: Options;
685
+ storage: Storage;
686
+ parent: ParentConfig<Config>['addExtensions'];
687
+ }) => Extensions;
688
+ /**
689
+ * This function extends the schema of the node.
690
+ * @example
691
+ * extendNodeSchema() {
692
+ * return {
693
+ * group: 'inline',
694
+ * selectable: false,
695
+ * }
696
+ * }
697
+ */
698
+ extendNodeSchema?: ((this: {
699
+ name: string;
700
+ options: Options;
701
+ storage: Storage;
702
+ parent: ParentConfig<Config>['extendNodeSchema'];
703
+ }, extension: Node$1) => Record<string, any>) | null;
704
+ /**
705
+ * This function extends the schema of the mark.
706
+ * @example
707
+ * extendMarkSchema() {
708
+ * return {
709
+ * group: 'inline',
710
+ * selectable: false,
711
+ * }
712
+ * }
713
+ */
714
+ extendMarkSchema?: ((this: {
715
+ name: string;
716
+ options: Options;
717
+ storage: Storage;
718
+ parent: ParentConfig<Config>['extendMarkSchema'];
719
+ }, extension: Mark) => Record<string, any>) | null;
720
+ /**
721
+ * The editor is not ready yet.
722
+ */
723
+ onBeforeCreate?: ((this: {
724
+ name: string;
725
+ options: Options;
726
+ storage: Storage;
727
+ editor: Editor;
728
+ type: PMType;
729
+ parent: ParentConfig<Config>['onBeforeCreate'];
730
+ }, event: EditorEvents['beforeCreate']) => void) | null;
731
+ /**
732
+ * The editor is ready.
733
+ */
734
+ onCreate?: ((this: {
735
+ name: string;
736
+ options: Options;
737
+ storage: Storage;
738
+ editor: Editor;
739
+ type: PMType;
740
+ parent: ParentConfig<Config>['onCreate'];
741
+ }, event: EditorEvents['create']) => void) | null;
742
+ /**
743
+ * The content has changed.
744
+ */
745
+ onUpdate?: ((this: {
746
+ name: string;
747
+ options: Options;
748
+ storage: Storage;
749
+ editor: Editor;
750
+ type: PMType;
751
+ parent: ParentConfig<Config>['onUpdate'];
752
+ }, event: EditorEvents['update']) => void) | null;
753
+ /**
754
+ * The selection has changed.
755
+ */
756
+ onSelectionUpdate?: ((this: {
757
+ name: string;
758
+ options: Options;
759
+ storage: Storage;
760
+ editor: Editor;
761
+ type: PMType;
762
+ parent: ParentConfig<Config>['onSelectionUpdate'];
763
+ }, event: EditorEvents['selectionUpdate']) => void) | null;
764
+ /**
765
+ * The editor state has changed.
766
+ */
767
+ onTransaction?: ((this: {
768
+ name: string;
769
+ options: Options;
770
+ storage: Storage;
771
+ editor: Editor;
772
+ type: PMType;
773
+ parent: ParentConfig<Config>['onTransaction'];
774
+ }, event: EditorEvents['transaction']) => void) | null;
775
+ /**
776
+ * The editor is focused.
777
+ */
778
+ onFocus?: ((this: {
779
+ name: string;
780
+ options: Options;
781
+ storage: Storage;
782
+ editor: Editor;
783
+ type: PMType;
784
+ parent: ParentConfig<Config>['onFocus'];
785
+ }, event: EditorEvents['focus']) => void) | null;
786
+ /**
787
+ * The editor isn’t focused anymore.
788
+ */
789
+ onBlur?: ((this: {
790
+ name: string;
791
+ options: Options;
792
+ storage: Storage;
793
+ editor: Editor;
794
+ type: PMType;
795
+ parent: ParentConfig<Config>['onBlur'];
796
+ }, event: EditorEvents['blur']) => void) | null;
797
+ /**
798
+ * The editor is destroyed.
799
+ */
800
+ onDestroy?: ((this: {
801
+ name: string;
802
+ options: Options;
803
+ storage: Storage;
804
+ editor: Editor;
805
+ type: PMType;
806
+ parent: ParentConfig<Config>['onDestroy'];
807
+ }, event: EditorEvents['destroy']) => void) | null;
808
+ }
809
+ declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>> {
810
+ type: string;
811
+ parent: Extendable | null;
812
+ child: Extendable | null;
813
+ name: string;
814
+ config: Config;
815
+ constructor(config?: Partial<Config>);
816
+ get options(): Options;
817
+ get storage(): Readonly<Storage>;
818
+ configure(options?: Partial<Options>): Extendable<Options, Storage, ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>>;
819
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage> | NodeConfig<ExtendedOptions, ExtendedStorage> | MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extendable<ExtendedOptions, ExtendedStorage>;
820
+ }
821
+ type AnyExtension = Extendable;
822
+ type Extensions = AnyExtension[];
823
+ type ParentConfig<T> = Partial<{
824
+ [P in keyof T]: Required<T>[P] extends (...args: any) => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P];
825
+ }>;
826
+ interface EditorEvents {
827
+ beforeCreate: {
828
+ /**
829
+ * The editor instance
830
+ */
831
+ editor: Editor;
832
+ };
833
+ create: {
834
+ /**
835
+ * The editor instance
836
+ */
837
+ editor: Editor;
838
+ };
839
+ contentError: {
840
+ /**
841
+ * The editor instance
842
+ */
843
+ editor: Editor;
844
+ /**
845
+ * The error that occurred while parsing the content
846
+ */
847
+ error: Error;
848
+ /**
849
+ * If called, will re-initialize the editor with the collaboration extension removed.
850
+ * This will prevent syncing back deletions of content not present in the current schema.
851
+ */
852
+ disableCollaboration: () => void;
853
+ };
854
+ update: {
855
+ /**
856
+ * The editor instance
857
+ */
858
+ editor: Editor;
859
+ /**
860
+ * The transaction that caused the update
861
+ */
862
+ transaction: Transaction;
863
+ /**
864
+ * Appended transactions that were added to the initial transaction by plugins
865
+ */
866
+ appendedTransactions: Transaction[];
867
+ };
868
+ selectionUpdate: {
869
+ /**
870
+ * The editor instance
871
+ */
872
+ editor: Editor;
873
+ /**
874
+ * The transaction that caused the selection update
875
+ */
876
+ transaction: Transaction;
877
+ };
878
+ beforeTransaction: {
879
+ /**
880
+ * The editor instance
881
+ */
882
+ editor: Editor;
883
+ /**
884
+ * The transaction that will be applied
885
+ */
886
+ transaction: Transaction;
887
+ /**
888
+ * The next state of the editor after the transaction is applied
889
+ */
890
+ nextState: EditorState;
891
+ };
892
+ transaction: {
893
+ /**
894
+ * The editor instance
895
+ */
896
+ editor: Editor;
897
+ /**
898
+ * The initial transaction
899
+ */
900
+ transaction: Transaction;
901
+ /**
902
+ * Appended transactions that were added to the initial transaction by plugins
903
+ */
904
+ appendedTransactions: Transaction[];
905
+ };
906
+ focus: {
907
+ /**
908
+ * The editor instance
909
+ */
910
+ editor: Editor;
911
+ /**
912
+ * The focus event
913
+ */
914
+ event: FocusEvent;
915
+ /**
916
+ * The transaction that caused the focus
917
+ */
918
+ transaction: Transaction;
919
+ };
920
+ blur: {
921
+ /**
922
+ * The editor instance
923
+ */
924
+ editor: Editor;
925
+ /**
926
+ * The focus event
927
+ */
928
+ event: FocusEvent;
929
+ /**
930
+ * The transaction that caused the blur
931
+ */
932
+ transaction: Transaction;
933
+ };
934
+ destroy: void;
935
+ paste: {
936
+ /**
937
+ * The editor instance
938
+ */
939
+ editor: Editor;
940
+ /**
941
+ * The clipboard event
942
+ */
943
+ event: ClipboardEvent;
944
+ /**
945
+ * The slice that was pasted
946
+ */
947
+ slice: Slice;
948
+ };
949
+ drop: {
950
+ /**
951
+ * The editor instance
952
+ */
953
+ editor: Editor;
954
+ /**
955
+ * The drag event
956
+ */
957
+ event: DragEvent;
958
+ /**
959
+ * The slice that was dropped
960
+ */
961
+ slice: Slice;
962
+ /**
963
+ * Whether the content was moved (true) or copied (false)
964
+ */
965
+ moved: boolean;
966
+ };
967
+ delete: {
968
+ /**
969
+ * The editor instance
970
+ */
971
+ editor: Editor;
972
+ /**
973
+ * The range of the deleted content (before the deletion)
974
+ */
975
+ deletedRange: Range;
976
+ /**
977
+ * The new range of positions of where the deleted content was in the new document (after the deletion)
978
+ */
979
+ newRange: Range;
980
+ /**
981
+ * The transaction that caused the deletion
982
+ */
983
+ transaction: Transaction;
984
+ /**
985
+ * The combined transform (including all appended transactions) that caused the deletion
986
+ */
987
+ combinedTransform: Transform;
988
+ /**
989
+ * Whether the deletion was partial (only a part of this content was deleted)
990
+ */
991
+ partial: boolean;
992
+ /**
993
+ * This is the start position of the mark in the document (before the deletion)
994
+ */
995
+ from: number;
996
+ /**
997
+ * This is the end position of the mark in the document (before the deletion)
998
+ */
999
+ to: number;
1000
+ } & ({
1001
+ /**
1002
+ * The content that was deleted
1003
+ */
1004
+ type: 'node';
1005
+ /**
1006
+ * The node which the deletion occurred in
1007
+ * @note This can be a parent node of the deleted content
1008
+ */
1009
+ node: Node$2;
1010
+ /**
1011
+ * The new start position of the node in the document (after the deletion)
1012
+ */
1013
+ newFrom: number;
1014
+ /**
1015
+ * The new end position of the node in the document (after the deletion)
1016
+ */
1017
+ newTo: number;
1018
+ } | {
1019
+ /**
1020
+ * The content that was deleted
1021
+ */
1022
+ type: 'mark';
1023
+ /**
1024
+ * The mark that was deleted
1025
+ */
1026
+ mark: Mark$1;
1027
+ });
1028
+ }
1029
+ type EnableRules = (AnyExtension | string)[] | boolean;
1030
+ interface EditorOptions {
1031
+ /**
1032
+ * The element or selector to bind the editor to
1033
+ * If `null` is passed, the editor will not be mounted automatically
1034
+ * If a function is passed, it will be called with the editor's root element
1035
+ */
1036
+ element: Element | null;
1037
+ /**
1038
+ * The content of the editor (HTML, JSON, or a JSON array)
1039
+ */
1040
+ content: Content;
1041
+ /**
1042
+ * The extensions to use
1043
+ */
1044
+ extensions: Extensions;
1045
+ /**
1046
+ * Whether to inject base CSS styles
1047
+ */
1048
+ injectCSS: boolean;
1049
+ /**
1050
+ * A nonce to use for CSP while injecting styles
1051
+ */
1052
+ injectNonce: string | undefined;
1053
+ /**
1054
+ * The editor's initial focus position
1055
+ */
1056
+ autofocus: FocusPosition;
1057
+ /**
1058
+ * Whether the editor is editable
1059
+ */
1060
+ editable: boolean;
1061
+ /**
1062
+ * The editor's props
1063
+ */
1064
+ editorProps: EditorProps;
1065
+ /**
1066
+ * The editor's content parser options
1067
+ */
1068
+ parseOptions: ParseOptions;
1069
+ /**
1070
+ * The editor's core extension options
1071
+ */
1072
+ coreExtensionOptions?: {
1073
+ clipboardTextSerializer?: {
1074
+ blockSeparator?: string;
1075
+ };
1076
+ delete?: {
1077
+ /**
1078
+ * Whether the `delete` extension should be called asynchronously to avoid blocking the editor while processing deletions
1079
+ * @default true deletion events are called asynchronously
1080
+ */
1081
+ async?: boolean;
1082
+ /**
1083
+ * Allows filtering the transactions that are processed by the `delete` extension.
1084
+ * If the function returns `true`, the transaction will be ignored.
1085
+ */
1086
+ filterTransaction?: (transaction: Transaction) => boolean;
1087
+ };
1088
+ };
1089
+ /**
1090
+ * Whether to enable input rules behavior
1091
+ */
1092
+ enableInputRules: EnableRules;
1093
+ /**
1094
+ * Whether to enable paste rules behavior
1095
+ */
1096
+ enablePasteRules: EnableRules;
1097
+ /**
1098
+ * Determines whether core extensions are enabled.
1099
+ *
1100
+ * If set to `false`, all core extensions will be disabled.
1101
+ * To disable specific core extensions, provide an object where the keys are the extension names and the values are `false`.
1102
+ * Extensions not listed in the object will remain enabled.
1103
+ *
1104
+ * @example
1105
+ * // Disable all core extensions
1106
+ * enabledCoreExtensions: false
1107
+ *
1108
+ * @example
1109
+ * // Disable only the keymap core extension
1110
+ * enabledCoreExtensions: { keymap: false }
1111
+ *
1112
+ * @default true
1113
+ */
1114
+ enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex' | 'drop' | 'paste' | 'delete', false>>;
1115
+ /**
1116
+ * If `true`, the editor will check the content for errors on initialization.
1117
+ * Emitting the `contentError` event if the content is invalid.
1118
+ * Which can be used to show a warning or error message to the user.
1119
+ * @default false
1120
+ */
1121
+ enableContentCheck: boolean;
1122
+ /**
1123
+ * If `true`, the editor will emit the `contentError` event if invalid content is
1124
+ * encountered but `enableContentCheck` is `false`. This lets you preserve the
1125
+ * invalid editor content while still showing a warning or error message to
1126
+ * the user.
1127
+ *
1128
+ * @default false
1129
+ */
1130
+ emitContentError: boolean;
1131
+ /**
1132
+ * Called before the editor is constructed.
1133
+ */
1134
+ onBeforeCreate: (props: EditorEvents['beforeCreate']) => void;
1135
+ /**
1136
+ * Called after the editor is constructed.
1137
+ */
1138
+ onCreate: (props: EditorEvents['create']) => void;
1139
+ /**
1140
+ * Called when the editor encounters an error while parsing the content.
1141
+ * Only enabled if `enableContentCheck` is `true`.
1142
+ */
1143
+ onContentError: (props: EditorEvents['contentError']) => void;
1144
+ /**
1145
+ * Called when the editor's content is updated.
1146
+ */
1147
+ onUpdate: (props: EditorEvents['update']) => void;
1148
+ /**
1149
+ * Called when the editor's selection is updated.
1150
+ */
1151
+ onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void;
1152
+ /**
1153
+ * Called after a transaction is applied to the editor.
1154
+ */
1155
+ onTransaction: (props: EditorEvents['transaction']) => void;
1156
+ /**
1157
+ * Called on focus events.
1158
+ */
1159
+ onFocus: (props: EditorEvents['focus']) => void;
1160
+ /**
1161
+ * Called on blur events.
1162
+ */
1163
+ onBlur: (props: EditorEvents['blur']) => void;
1164
+ /**
1165
+ * Called when the editor is destroyed.
1166
+ */
1167
+ onDestroy: (props: EditorEvents['destroy']) => void;
1168
+ /**
1169
+ * Called when content is pasted into the editor.
1170
+ */
1171
+ onPaste: (e: ClipboardEvent, slice: Slice) => void;
1172
+ /**
1173
+ * Called when content is dropped into the editor.
1174
+ */
1175
+ onDrop: (e: DragEvent, slice: Slice, moved: boolean) => void;
1176
+ /**
1177
+ * Called when content is deleted from the editor.
1178
+ */
1179
+ onDelete: (props: EditorEvents['delete']) => void;
1180
+ }
1181
+ /**
1182
+ * The editor's content as HTML
1183
+ */
1184
+ type HTMLContent = string;
1185
+ /**
1186
+ * Loosely describes a JSON representation of a Prosemirror document or node
1187
+ */
1188
+ type JSONContent = {
1189
+ type?: string;
1190
+ attrs?: Record<string, any>;
1191
+ content?: JSONContent[];
1192
+ marks?: {
1193
+ type: string;
1194
+ attrs?: Record<string, any>;
1195
+ [key: string]: any;
1196
+ }[];
1197
+ text?: string;
1198
+ [key: string]: any;
1199
+ };
1200
+ /**
1201
+ * A mark type is either a JSON representation of a mark or a Prosemirror mark instance
1202
+ */
1203
+ type MarkType<Type extends string | {
1204
+ name: string;
1205
+ } = any, TAttributes extends undefined | Record<string, any> = any> = {
1206
+ type: Type;
1207
+ attrs: TAttributes;
1208
+ };
1209
+ /**
1210
+ * A node type is either a JSON representation of a node or a Prosemirror node instance
1211
+ */
1212
+ type NodeType<Type extends string | {
1213
+ name: string;
1214
+ } = any, TAttributes extends undefined | Record<string, any> = any, NodeMarkType extends MarkType = any, TContent extends (NodeType | TextType)[] = any> = {
1215
+ type: Type;
1216
+ attrs: TAttributes;
1217
+ content?: TContent;
1218
+ marks?: NodeMarkType[];
1219
+ };
1220
+ /**
1221
+ * A node type is either a JSON representation of a doc node or a Prosemirror doc node instance
1222
+ */
1223
+ type DocumentType<TDocAttributes extends Record<string, any> | undefined = Record<string, any>, TContentType extends NodeType[] = NodeType[]> = Omit<NodeType<'doc', TDocAttributes, never, TContentType>, 'marks' | 'content'> & {
1224
+ content: TContentType;
1225
+ };
1226
+ /**
1227
+ * A node type is either a JSON representation of a text node or a Prosemirror text node instance
1228
+ */
1229
+ type TextType<TMarkType extends MarkType = MarkType> = {
1230
+ type: 'text';
1231
+ text: string;
1232
+ marks: TMarkType[];
1233
+ };
1234
+ type Content = HTMLContent | JSONContent | JSONContent[] | null;
1235
+ type CommandProps = {
1236
+ editor: Editor;
1237
+ tr: Transaction;
1238
+ commands: SingleCommands;
1239
+ can: () => CanCommands;
1240
+ chain: () => ChainedCommands;
1241
+ state: EditorState;
1242
+ view: EditorView;
1243
+ dispatch: ((args?: any) => any) | undefined;
1244
+ };
1245
+ type Command = (props: CommandProps) => boolean;
1246
+ type KeyboardShortcutCommand = (props: {
1247
+ editor: Editor;
1248
+ }) => boolean;
1249
+ type Attribute = {
1250
+ default?: any;
1251
+ validate?: string | ((value: any) => void);
1252
+ rendered?: boolean;
1253
+ renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null;
1254
+ parseHTML?: ((element: HTMLElement) => any | null) | null;
1255
+ keepOnSplit?: boolean;
1256
+ isRequired?: boolean;
1257
+ };
1258
+ type Attributes$1 = {
1259
+ [key: string]: Attribute;
1260
+ };
1261
+ type ExtensionAttribute = {
1262
+ type: string;
1263
+ name: string;
1264
+ attribute: Required<Omit<Attribute, 'validate'>> & Pick<Attribute, 'validate'>;
1265
+ };
1266
+ type GlobalAttributes = {
1267
+ /**
1268
+ * The node & mark types this attribute should be applied to.
1269
+ */
1270
+ types: string[];
1271
+ /**
1272
+ * The attributes to add to the node or mark types.
1273
+ */
1274
+ attributes: Record<string, Attribute | undefined>;
1275
+ }[];
1276
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
1277
+ type ValuesOf<T> = T[keyof T];
1278
+ type KeysWithTypeOf<T, Type> = {
1279
+ [P in keyof T]: T[P] extends Type ? P : never;
1280
+ }[keyof T];
1281
+ interface NodeViewRendererProps {
1282
+ /**
1283
+ * The node that is being rendered.
1284
+ */
1285
+ node: Parameters<NodeViewConstructor>[0];
1286
+ /**
1287
+ * The editor's view.
1288
+ */
1289
+ view: Parameters<NodeViewConstructor>[1];
1290
+ /**
1291
+ * A function that can be called to get the node's current position in the document.
1292
+ */
1293
+ getPos: Parameters<NodeViewConstructor>[2];
1294
+ /**
1295
+ * is an array of node or inline decorations that are active around the node.
1296
+ * They are automatically drawn in the normal way, and you will usually just want to ignore this, but they can also be used as a way to provide context information to the node view without adding it to the document itself.
1297
+ */
1298
+ decorations: Parameters<NodeViewConstructor>[3];
1299
+ /**
1300
+ * holds the decorations for the node's content. You can safely ignore this if your view has no content or a contentDOM property, since the editor will draw the decorations on the content.
1301
+ * But if you, for example, want to create a nested editor with the content, it may make sense to provide it with the inner decorations.
1302
+ */
1303
+ innerDecorations: Parameters<NodeViewConstructor>[4];
1304
+ /**
1305
+ * The editor instance.
1306
+ */
1307
+ editor: Editor;
1308
+ /**
1309
+ * The extension that is responsible for the node.
1310
+ */
1311
+ extension: Node$1;
1312
+ /**
1313
+ * The HTML attributes that should be added to the node's DOM element.
1314
+ */
1315
+ HTMLAttributes: Record<string, any>;
1316
+ }
1317
+ type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView;
1318
+ interface MarkViewRendererProps {
1319
+ /**
1320
+ * The node that is being rendered.
1321
+ */
1322
+ mark: Parameters<MarkViewConstructor>[0];
1323
+ /**
1324
+ * The editor's view.
1325
+ */
1326
+ view: Parameters<MarkViewConstructor>[1];
1327
+ /**
1328
+ * indicates whether the mark's content is inline
1329
+ */
1330
+ inline: Parameters<MarkViewConstructor>[2];
1331
+ /**
1332
+ * The editor instance.
1333
+ */
1334
+ editor: Editor;
1335
+ /**
1336
+ * The extension that is responsible for the mark.
1337
+ */
1338
+ extension: Mark;
1339
+ /**
1340
+ * The HTML attributes that should be added to the mark's DOM element.
1341
+ */
1342
+ HTMLAttributes: Record<string, any>;
1343
+ }
1344
+ type MarkViewRenderer = (props: MarkViewRendererProps) => MarkView;
1345
+ type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, object>>>>;
1346
+ type RawCommands = {
1347
+ [Item in keyof UnionCommands]: UnionCommands<Command>[Item];
1348
+ };
1349
+ type SingleCommands = {
1350
+ [Item in keyof UnionCommands]: UnionCommands<boolean>[Item];
1351
+ };
1352
+ type ChainedCommands = {
1353
+ [Item in keyof UnionCommands]: UnionCommands<ChainedCommands>[Item];
1354
+ } & {
1355
+ run: () => boolean;
1356
+ };
1357
+ type CanCommands = SingleCommands & {
1358
+ chain: () => ChainedCommands;
1359
+ };
1360
+ type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null;
1361
+ type Range = {
1362
+ from: number;
1363
+ to: number;
1364
+ };
1365
+ type TextSerializer = (props: {
1366
+ node: Node$2;
1367
+ pos: number;
1368
+ parent: Node$2;
1369
+ index: number;
1370
+ range: Range;
1371
+ }) => string;
1372
+ type ExtendedRegExpMatchArray = RegExpMatchArray & {
1373
+ data?: Record<string, any>;
1374
+ };
1375
+
1376
+ /**
1377
+ * Create a flattened array of extensions by traversing the `addExtensions` field.
1378
+ * @param extensions An array of Tiptap extensions
1379
+ * @returns A flattened array of Tiptap extensions
1380
+ */
1381
+ declare function flattenExtensions(extensions: Extensions): Extensions;
1382
+
1383
+ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
1384
+ }
1385
+
1386
+ /**
1387
+ * Returns a flattened and sorted extension list while
1388
+ * also checking for duplicated extensions and warns the user.
1389
+ * @param extensions An array of Tiptap extensions
1390
+ * @returns An flattened and sorted array of Tiptap extensions
1391
+ */
1392
+ declare function resolveExtensions(extensions: Extensions): Extensions;
1393
+
1394
+ /**
1395
+ * Sort extensions by priority.
1396
+ * @param extensions An array of Tiptap extensions
1397
+ * @returns A sorted array of Tiptap extensions by priority
1398
+ */
1399
+ declare function sortExtensions(extensions: Extensions): Extensions;
1400
+
1401
+ declare class ExtensionManager {
1402
+ editor: Editor;
1403
+ schema: Schema;
1404
+ extensions: Extensions;
1405
+ splittableMarks: string[];
1406
+ constructor(extensions: Extensions, editor: Editor);
1407
+ static resolve: typeof resolveExtensions;
1408
+ static sort: typeof sortExtensions;
1409
+ static flatten: typeof flattenExtensions;
1410
+ /**
1411
+ * Get all commands from the extensions.
1412
+ * @returns An object with all commands where the key is the command name and the value is the command function
1413
+ */
1414
+ get commands(): RawCommands;
1415
+ /**
1416
+ * Get all registered Prosemirror plugins from the extensions.
1417
+ * @returns An array of Prosemirror plugins
1418
+ */
1419
+ get plugins(): Plugin[];
1420
+ /**
1421
+ * Get all attributes from the extensions.
1422
+ * @returns An array of attributes
1423
+ */
1424
+ get attributes(): ExtensionAttribute[];
1425
+ /**
1426
+ * Get all node views from the extensions.
1427
+ * @returns An object with all node views where the key is the node name and the value is the node view function
1428
+ */
1429
+ get nodeViews(): Record<string, NodeViewConstructor>;
1430
+ get markViews(): Record<string, MarkViewConstructor>;
1431
+ /**
1432
+ * Go through all extensions, create extension storages & setup marks
1433
+ * & bind editor event listener.
1434
+ */
1435
+ private setupExtensions;
1436
+ }
1437
+
1438
+ declare class NodePos {
1439
+ private resolvedPos;
1440
+ private isBlock;
1441
+ private editor;
1442
+ private get name();
1443
+ constructor(pos: ResolvedPos, editor: Editor, isBlock?: boolean, node?: Node$2 | null);
1444
+ private currentNode;
1445
+ get node(): Node$2;
1446
+ get element(): HTMLElement;
1447
+ actualDepth: number | null;
1448
+ get depth(): number;
1449
+ get pos(): number;
1450
+ get content(): Fragment;
1451
+ set content(content: Content);
1452
+ get attributes(): {
1453
+ [key: string]: any;
1454
+ };
1455
+ get textContent(): string;
1456
+ get size(): number;
1457
+ get from(): number;
1458
+ get range(): Range;
1459
+ get to(): number;
1460
+ get parent(): NodePos | null;
1461
+ get before(): NodePos | null;
1462
+ get after(): NodePos | null;
1463
+ get children(): NodePos[];
1464
+ get firstChild(): NodePos | null;
1465
+ get lastChild(): NodePos | null;
1466
+ closest(selector: string, attributes?: {
1467
+ [key: string]: any;
1468
+ }): NodePos | null;
1469
+ querySelector(selector: string, attributes?: {
1470
+ [key: string]: any;
1471
+ }): NodePos | null;
1472
+ querySelectorAll(selector: string, attributes?: {
1473
+ [key: string]: any;
1474
+ }, firstItemOnly?: boolean): NodePos[];
1475
+ setAttribute(attributes: {
1476
+ [key: string]: any;
1477
+ }): void;
1478
+ }
1479
+
1480
+ declare module '@tiptap/core' {
1481
+ interface Commands<ReturnType> {
1482
+ blur: {
1483
+ /**
1484
+ * Removes focus from the editor.
1485
+ * @example editor.commands.blur()
1486
+ */
1487
+ blur: () => ReturnType;
1488
+ };
1489
+ }
1490
+ }
1491
+
1492
+ declare module '@tiptap/core' {
1493
+ interface Commands<ReturnType> {
1494
+ clearContent: {
1495
+ /**
1496
+ * Clear the whole document.
1497
+ * @example editor.commands.clearContent()
1498
+ */
1499
+ clearContent: (
1500
+ /**
1501
+ * Whether to emit an update event.
1502
+ * @default true
1503
+ */
1504
+ emitUpdate?: boolean) => ReturnType;
1505
+ };
1506
+ }
1507
+ }
1508
+
1509
+ declare module '@tiptap/core' {
1510
+ interface Commands<ReturnType> {
1511
+ clearNodes: {
1512
+ /**
1513
+ * Normalize nodes to a simple paragraph.
1514
+ * @example editor.commands.clearNodes()
1515
+ */
1516
+ clearNodes: () => ReturnType;
1517
+ };
1518
+ }
1519
+ }
1520
+
1521
+ declare module '@tiptap/core' {
1522
+ interface Commands<ReturnType> {
1523
+ command: {
1524
+ /**
1525
+ * Define a command inline.
1526
+ * @param fn The command function.
1527
+ * @example
1528
+ * editor.commands.command(({ tr, state }) => {
1529
+ * ...
1530
+ * return true
1531
+ * })
1532
+ */
1533
+ command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
1534
+ };
1535
+ }
1536
+ }
1537
+
1538
+ declare module '@tiptap/core' {
1539
+ interface Commands<ReturnType> {
1540
+ createParagraphNear: {
1541
+ /**
1542
+ * Create a paragraph nearby.
1543
+ * @example editor.commands.createParagraphNear()
1544
+ */
1545
+ createParagraphNear: () => ReturnType;
1546
+ };
1547
+ }
1548
+ }
1549
+
1550
+ declare module '@tiptap/core' {
1551
+ interface Commands<ReturnType> {
1552
+ cut: {
1553
+ /**
1554
+ * Cuts content from a range and inserts it at a given position.
1555
+ * @param range The range to cut.
1556
+ * @param range.from The start position of the range.
1557
+ * @param range.to The end position of the range.
1558
+ * @param targetPos The position to insert the content at.
1559
+ * @example editor.commands.cut({ from: 1, to: 3 }, 5)
1560
+ */
1561
+ cut: ({ from, to }: {
1562
+ from: number;
1563
+ to: number;
1564
+ }, targetPos: number) => ReturnType;
1565
+ };
1566
+ }
1567
+ }
1568
+
1569
+ declare module '@tiptap/core' {
1570
+ interface Commands<ReturnType> {
1571
+ deleteCurrentNode: {
1572
+ /**
1573
+ * Delete the node that currently has the selection anchor.
1574
+ * @example editor.commands.deleteCurrentNode()
1575
+ */
1576
+ deleteCurrentNode: () => ReturnType;
1577
+ };
1578
+ }
1579
+ }
1580
+
1581
+ declare module '@tiptap/core' {
1582
+ interface Commands<ReturnType> {
1583
+ deleteNode: {
1584
+ /**
1585
+ * Delete a node with a given type or name.
1586
+ * @param typeOrName The type or name of the node.
1587
+ * @example editor.commands.deleteNode('paragraph')
1588
+ */
1589
+ deleteNode: (typeOrName: string | NodeType$1) => ReturnType;
1590
+ };
1591
+ }
1592
+ }
1593
+
1594
+ declare module '@tiptap/core' {
1595
+ interface Commands<ReturnType> {
1596
+ deleteRange: {
1597
+ /**
1598
+ * Delete a given range.
1599
+ * @param range The range to delete.
1600
+ * @example editor.commands.deleteRange({ from: 1, to: 3 })
1601
+ */
1602
+ deleteRange: (range: Range) => ReturnType;
1603
+ };
1604
+ }
1605
+ }
1606
+
1607
+ declare module '@tiptap/core' {
1608
+ interface Commands<ReturnType> {
1609
+ deleteSelection: {
1610
+ /**
1611
+ * Delete the selection, if there is one.
1612
+ * @example editor.commands.deleteSelection()
1613
+ */
1614
+ deleteSelection: () => ReturnType;
1615
+ };
1616
+ }
1617
+ }
1618
+
1619
+ declare module '@tiptap/core' {
1620
+ interface Commands<ReturnType> {
1621
+ enter: {
1622
+ /**
1623
+ * Trigger enter.
1624
+ * @example editor.commands.enter()
1625
+ */
1626
+ enter: () => ReturnType;
1627
+ };
1628
+ }
1629
+ }
1630
+
1631
+ declare module '@tiptap/core' {
1632
+ interface Commands<ReturnType> {
1633
+ exitCode: {
1634
+ /**
1635
+ * Exit from a code block.
1636
+ * @example editor.commands.exitCode()
1637
+ */
1638
+ exitCode: () => ReturnType;
1639
+ };
1640
+ }
1641
+ }
1642
+
1643
+ declare module '@tiptap/core' {
1644
+ interface Commands<ReturnType> {
1645
+ extendMarkRange: {
1646
+ /**
1647
+ * Extends the text selection to the current mark by type or name.
1648
+ * @param typeOrName The type or name of the mark.
1649
+ * @param attributes The attributes of the mark.
1650
+ * @example editor.commands.extendMarkRange('bold')
1651
+ * @example editor.commands.extendMarkRange('mention', { userId: "1" })
1652
+ */
1653
+ extendMarkRange: (
1654
+ /**
1655
+ * The type or name of the mark.
1656
+ */
1657
+ typeOrName: string | MarkType$1,
1658
+ /**
1659
+ * The attributes of the mark.
1660
+ */
1661
+ attributes?: Record<string, any>) => ReturnType;
1662
+ };
1663
+ }
1664
+ }
1665
+
1666
+ declare module '@tiptap/core' {
1667
+ interface Commands<ReturnType> {
1668
+ first: {
1669
+ /**
1670
+ * Runs one command after the other and stops at the first which returns true.
1671
+ * @param commands The commands to run.
1672
+ * @example editor.commands.first([command1, command2])
1673
+ */
1674
+ first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
1675
+ };
1676
+ }
1677
+ }
1678
+
1679
+ declare module '@tiptap/core' {
1680
+ interface Commands<ReturnType> {
1681
+ focus: {
1682
+ /**
1683
+ * Focus the editor at the given position.
1684
+ * @param position The position to focus at.
1685
+ * @param options.scrollIntoView Scroll the focused position into view after focusing
1686
+ * @example editor.commands.focus()
1687
+ * @example editor.commands.focus(32, { scrollIntoView: false })
1688
+ */
1689
+ focus: (
1690
+ /**
1691
+ * The position to focus at.
1692
+ */
1693
+ position?: FocusPosition,
1694
+ /**
1695
+ * Optional options
1696
+ * @default { scrollIntoView: true }
1697
+ */
1698
+ options?: {
1699
+ scrollIntoView?: boolean;
1700
+ }) => ReturnType;
1701
+ };
1702
+ }
1703
+ }
1704
+
1705
+ declare module '@tiptap/core' {
1706
+ interface Commands<ReturnType> {
1707
+ forEach: {
1708
+ /**
1709
+ * Loop through an array of items.
1710
+ */
1711
+ forEach: <T>(items: T[], fn: (item: T, props: CommandProps & {
1712
+ index: number;
1713
+ }) => boolean) => ReturnType;
1714
+ };
1715
+ }
1716
+ }
1717
+
1718
+ declare module '@tiptap/core' {
1719
+ interface Commands<ReturnType> {
1720
+ insertContent: {
1721
+ /**
1722
+ * Insert a node or string of HTML at the current position.
1723
+ * @example editor.commands.insertContent('<h1>Example</h1>')
1724
+ * @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
1725
+ */
1726
+ insertContent: (
1727
+ /**
1728
+ * The ProseMirror content to insert.
1729
+ */
1730
+ value: Content | Node$2 | Fragment,
1731
+ /**
1732
+ * Optional options
1733
+ */
1734
+ options?: {
1735
+ /**
1736
+ * Options for parsing the content.
1737
+ */
1738
+ parseOptions?: ParseOptions;
1739
+ /**
1740
+ * Whether to update the selection after inserting the content.
1741
+ */
1742
+ updateSelection?: boolean;
1743
+ applyInputRules?: boolean;
1744
+ applyPasteRules?: boolean;
1745
+ }) => ReturnType;
1746
+ };
1747
+ }
1748
+ }
1749
+
1750
+ declare module '@tiptap/core' {
1751
+ interface Commands<ReturnType> {
1752
+ insertContentAt: {
1753
+ /**
1754
+ * Insert a node or string of HTML at a specific position.
1755
+ * @example editor.commands.insertContentAt(0, '<h1>Example</h1>')
1756
+ */
1757
+ insertContentAt: (
1758
+ /**
1759
+ * The position to insert the content at.
1760
+ */
1761
+ position: number | Range,
1762
+ /**
1763
+ * The ProseMirror content to insert.
1764
+ */
1765
+ value: Content | Node$2 | Fragment,
1766
+ /**
1767
+ * Optional options
1768
+ */
1769
+ options?: {
1770
+ /**
1771
+ * Options for parsing the content.
1772
+ */
1773
+ parseOptions?: ParseOptions;
1774
+ /**
1775
+ * Whether to update the selection after inserting the content.
1776
+ */
1777
+ updateSelection?: boolean;
1778
+ /**
1779
+ * Whether to apply input rules after inserting the content.
1780
+ */
1781
+ applyInputRules?: boolean;
1782
+ /**
1783
+ * Whether to apply paste rules after inserting the content.
1784
+ */
1785
+ applyPasteRules?: boolean;
1786
+ /**
1787
+ * Whether to throw an error if the content is invalid.
1788
+ */
1789
+ errorOnInvalidContent?: boolean;
1790
+ }) => ReturnType;
1791
+ };
1792
+ }
1793
+ }
1794
+
1795
+ declare module '@tiptap/core' {
1796
+ interface Commands<ReturnType> {
1797
+ joinUp: {
1798
+ /**
1799
+ * Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.
1800
+ * @example editor.commands.joinUp()
1801
+ */
1802
+ joinUp: () => ReturnType;
1803
+ };
1804
+ joinDown: {
1805
+ /**
1806
+ * Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
1807
+ * @example editor.commands.joinDown()
1808
+ */
1809
+ joinDown: () => ReturnType;
1810
+ };
1811
+ joinBackward: {
1812
+ /**
1813
+ * If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there's a block directly before it that can be joined, join them.
1814
+ * If not, try to move the selected block closer to the next one in the document structure by lifting it out of its
1815
+ * parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.
1816
+ * @example editor.commands.joinBackward()
1817
+ */
1818
+ joinBackward: () => ReturnType;
1819
+ };
1820
+ joinForward: {
1821
+ /**
1822
+ * If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it,
1823
+ * either by joining them or by moving the other block closer to this one in the tree structure.
1824
+ * Will use the view for accurate start-of-textblock detection if given.
1825
+ * @example editor.commands.joinForward()
1826
+ */
1827
+ joinForward: () => ReturnType;
1828
+ };
1829
+ }
1830
+ }
1831
+
1832
+ declare module '@tiptap/core' {
1833
+ interface Commands<ReturnType> {
1834
+ joinItemBackward: {
1835
+ /**
1836
+ * Join two items backward.
1837
+ * @example editor.commands.joinItemBackward()
1838
+ */
1839
+ joinItemBackward: () => ReturnType;
1840
+ };
1841
+ }
1842
+ }
1843
+
1844
+ declare module '@tiptap/core' {
1845
+ interface Commands<ReturnType> {
1846
+ joinItemForward: {
1847
+ /**
1848
+ * Join two items Forwards.
1849
+ * @example editor.commands.joinItemForward()
1850
+ */
1851
+ joinItemForward: () => ReturnType;
1852
+ };
1853
+ }
1854
+ }
1855
+
1856
+ declare module '@tiptap/core' {
1857
+ interface Commands<ReturnType> {
1858
+ joinTextblockBackward: {
1859
+ /**
1860
+ * A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.
1861
+ */
1862
+ joinTextblockBackward: () => ReturnType;
1863
+ };
1864
+ }
1865
+ }
1866
+
1867
+ declare module '@tiptap/core' {
1868
+ interface Commands<ReturnType> {
1869
+ joinTextblockForward: {
1870
+ /**
1871
+ * A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.
1872
+ */
1873
+ joinTextblockForward: () => ReturnType;
1874
+ };
1875
+ }
1876
+ }
1877
+
1878
+ declare module '@tiptap/core' {
1879
+ interface Commands<ReturnType> {
1880
+ keyboardShortcut: {
1881
+ /**
1882
+ * Trigger a keyboard shortcut.
1883
+ * @param name The name of the keyboard shortcut.
1884
+ * @example editor.commands.keyboardShortcut('Mod-b')
1885
+ */
1886
+ keyboardShortcut: (name: string) => ReturnType;
1887
+ };
1888
+ }
1889
+ }
1890
+
1891
+ declare module '@tiptap/core' {
1892
+ interface Commands<ReturnType> {
1893
+ lift: {
1894
+ /**
1895
+ * Removes an existing wrap if possible lifting the node out of it
1896
+ * @param typeOrName The type or name of the node.
1897
+ * @param attributes The attributes of the node.
1898
+ * @example editor.commands.lift('paragraph')
1899
+ * @example editor.commands.lift('heading', { level: 1 })
1900
+ */
1901
+ lift: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
1902
+ };
1903
+ }
1904
+ }
1905
+
1906
+ declare module '@tiptap/core' {
1907
+ interface Commands<ReturnType> {
1908
+ liftEmptyBlock: {
1909
+ /**
1910
+ * If the cursor is in an empty textblock that can be lifted, lift the block.
1911
+ * @example editor.commands.liftEmptyBlock()
1912
+ */
1913
+ liftEmptyBlock: () => ReturnType;
1914
+ };
1915
+ }
1916
+ }
1917
+
1918
+ declare module '@tiptap/core' {
1919
+ interface Commands<ReturnType> {
1920
+ liftListItem: {
1921
+ /**
1922
+ * Create a command to lift the list item around the selection up into a wrapping list.
1923
+ * @param typeOrName The type or name of the node.
1924
+ * @example editor.commands.liftListItem('listItem')
1925
+ */
1926
+ liftListItem: (typeOrName: string | NodeType$1) => ReturnType;
1927
+ };
1928
+ }
1929
+ }
1930
+
1931
+ declare module '@tiptap/core' {
1932
+ interface Commands<ReturnType> {
1933
+ newlineInCode: {
1934
+ /**
1935
+ * Add a newline character in code.
1936
+ * @example editor.commands.newlineInCode()
1937
+ */
1938
+ newlineInCode: () => ReturnType;
1939
+ };
1940
+ }
1941
+ }
1942
+
1943
+ declare module '@tiptap/core' {
1944
+ interface Commands<ReturnType> {
1945
+ resetAttributes: {
1946
+ /**
1947
+ * Resets some node attributes to the default value.
1948
+ * @param typeOrName The type or name of the node.
1949
+ * @param attributes The attributes of the node to reset.
1950
+ * @example editor.commands.resetAttributes('heading', 'level')
1951
+ */
1952
+ resetAttributes: (typeOrName: string | NodeType$1 | MarkType$1, attributes: string | string[]) => ReturnType;
1953
+ };
1954
+ }
1955
+ }
1956
+
1957
+ declare module '@tiptap/core' {
1958
+ interface Commands<ReturnType> {
1959
+ scrollIntoView: {
1960
+ /**
1961
+ * Scroll the selection into view.
1962
+ * @example editor.commands.scrollIntoView()
1963
+ */
1964
+ scrollIntoView: () => ReturnType;
1965
+ };
1966
+ }
1967
+ }
1968
+
1969
+ declare module '@tiptap/core' {
1970
+ interface Commands<ReturnType> {
1971
+ selectAll: {
1972
+ /**
1973
+ * Select the whole document.
1974
+ * @example editor.commands.selectAll()
1975
+ */
1976
+ selectAll: () => ReturnType;
1977
+ };
1978
+ }
1979
+ }
1980
+
1981
+ declare module '@tiptap/core' {
1982
+ interface Commands<ReturnType> {
1983
+ selectNodeBackward: {
1984
+ /**
1985
+ * Select a node backward.
1986
+ * @example editor.commands.selectNodeBackward()
1987
+ */
1988
+ selectNodeBackward: () => ReturnType;
1989
+ };
1990
+ }
1991
+ }
1992
+
1993
+ declare module '@tiptap/core' {
1994
+ interface Commands<ReturnType> {
1995
+ selectNodeForward: {
1996
+ /**
1997
+ * Select a node forward.
1998
+ * @example editor.commands.selectNodeForward()
1999
+ */
2000
+ selectNodeForward: () => ReturnType;
2001
+ };
2002
+ }
2003
+ }
2004
+
2005
+ declare module '@tiptap/core' {
2006
+ interface Commands<ReturnType> {
2007
+ selectParentNode: {
2008
+ /**
2009
+ * Select the parent node.
2010
+ * @example editor.commands.selectParentNode()
2011
+ */
2012
+ selectParentNode: () => ReturnType;
2013
+ };
2014
+ }
2015
+ }
2016
+
2017
+ declare module '@tiptap/core' {
2018
+ interface Commands<ReturnType> {
2019
+ selectTextblockEnd: {
2020
+ /**
2021
+ * Moves the cursor to the end of current text block.
2022
+ * @example editor.commands.selectTextblockEnd()
2023
+ */
2024
+ selectTextblockEnd: () => ReturnType;
2025
+ };
2026
+ }
2027
+ }
2028
+
2029
+ declare module '@tiptap/core' {
2030
+ interface Commands<ReturnType> {
2031
+ selectTextblockStart: {
2032
+ /**
2033
+ * Moves the cursor to the start of current text block.
2034
+ * @example editor.commands.selectTextblockStart()
2035
+ */
2036
+ selectTextblockStart: () => ReturnType;
2037
+ };
2038
+ }
2039
+ }
2040
+
2041
+ declare module '@tiptap/core' {
2042
+ interface Commands<ReturnType> {
2043
+ setContent: {
2044
+ /**
2045
+ * Replace the whole document with new content.
2046
+ * @param content The new content.
2047
+ * @param emitUpdate Whether to emit an update event.
2048
+ * @param parseOptions Options for parsing the content.
2049
+ * @example editor.commands.setContent('<p>Example text</p>')
2050
+ */
2051
+ setContent: (
2052
+ /**
2053
+ * The new content.
2054
+ */
2055
+ content: Content | Fragment | Node$2,
2056
+ /**
2057
+ * Options for `setContent`.
2058
+ */
2059
+ options?: {
2060
+ /**
2061
+ * Options for parsing the content.
2062
+ * @default {}
2063
+ */
2064
+ parseOptions?: ParseOptions;
2065
+ /**
2066
+ * Whether to throw an error if the content is invalid.
2067
+ */
2068
+ errorOnInvalidContent?: boolean;
2069
+ /**
2070
+ * Whether to emit an update event.
2071
+ * @default true
2072
+ */
2073
+ emitUpdate?: boolean;
2074
+ }) => ReturnType;
2075
+ };
2076
+ }
2077
+ }
2078
+
2079
+ declare module '@tiptap/core' {
2080
+ interface Commands<ReturnType> {
2081
+ setMark: {
2082
+ /**
2083
+ * Add a mark with new attributes.
2084
+ * @param typeOrName The mark type or name.
2085
+ * @example editor.commands.setMark('bold', { level: 1 })
2086
+ */
2087
+ setMark: (typeOrName: string | MarkType$1, attributes?: Record<string, any>) => ReturnType;
2088
+ };
2089
+ }
2090
+ }
2091
+
2092
+ declare module '@tiptap/core' {
2093
+ interface Commands<ReturnType> {
2094
+ setMeta: {
2095
+ /**
2096
+ * Store a metadata property in the current transaction.
2097
+ * @param key The key of the metadata property.
2098
+ * @param value The value to store.
2099
+ * @example editor.commands.setMeta('foo', 'bar')
2100
+ */
2101
+ setMeta: (key: string | Plugin | PluginKey, value: any) => ReturnType;
2102
+ };
2103
+ }
2104
+ }
2105
+
2106
+ declare module '@tiptap/core' {
2107
+ interface Commands<ReturnType> {
2108
+ setNode: {
2109
+ /**
2110
+ * Replace a given range with a node.
2111
+ * @param typeOrName The type or name of the node
2112
+ * @param attributes The attributes of the node
2113
+ * @example editor.commands.setNode('paragraph')
2114
+ */
2115
+ setNode: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2116
+ };
2117
+ }
2118
+ }
2119
+
2120
+ declare module '@tiptap/core' {
2121
+ interface Commands<ReturnType> {
2122
+ setNodeSelection: {
2123
+ /**
2124
+ * Creates a NodeSelection.
2125
+ * @param position - Position of the node.
2126
+ * @example editor.commands.setNodeSelection(10)
2127
+ */
2128
+ setNodeSelection: (position: number) => ReturnType;
2129
+ };
2130
+ }
2131
+ }
2132
+
2133
+ declare module '@tiptap/core' {
2134
+ interface Commands<ReturnType> {
2135
+ setTextSelection: {
2136
+ /**
2137
+ * Creates a TextSelection.
2138
+ * @param position The position of the selection.
2139
+ * @example editor.commands.setTextSelection(10)
2140
+ */
2141
+ setTextSelection: (position: number | Range) => ReturnType;
2142
+ };
2143
+ }
2144
+ }
2145
+
2146
+ declare module '@tiptap/core' {
2147
+ interface Commands<ReturnType> {
2148
+ sinkListItem: {
2149
+ /**
2150
+ * Sink the list item down into an inner list.
2151
+ * @param typeOrName The type or name of the node.
2152
+ * @example editor.commands.sinkListItem('listItem')
2153
+ */
2154
+ sinkListItem: (typeOrName: string | NodeType$1) => ReturnType;
2155
+ };
2156
+ }
2157
+ }
2158
+
2159
+ declare module '@tiptap/core' {
2160
+ interface Commands<ReturnType> {
2161
+ splitBlock: {
2162
+ /**
2163
+ * Forks a new node from an existing node.
2164
+ * @param options.keepMarks Keep marks from the previous node.
2165
+ * @example editor.commands.splitBlock()
2166
+ * @example editor.commands.splitBlock({ keepMarks: true })
2167
+ */
2168
+ splitBlock: (options?: {
2169
+ keepMarks?: boolean;
2170
+ }) => ReturnType;
2171
+ };
2172
+ }
2173
+ }
2174
+
2175
+ declare module '@tiptap/core' {
2176
+ interface Commands<ReturnType> {
2177
+ splitListItem: {
2178
+ /**
2179
+ * Splits one list item into two list items.
2180
+ * @param typeOrName The type or name of the node.
2181
+ * @param overrideAttrs The attributes to ensure on the new node.
2182
+ * @example editor.commands.splitListItem('listItem')
2183
+ */
2184
+ splitListItem: (typeOrName: string | NodeType$1, overrideAttrs?: Record<string, any>) => ReturnType;
2185
+ };
2186
+ }
2187
+ }
2188
+
2189
+ declare module '@tiptap/core' {
2190
+ interface Commands<ReturnType> {
2191
+ toggleList: {
2192
+ /**
2193
+ * Toggle between different list types.
2194
+ * @param listTypeOrName The type or name of the list.
2195
+ * @param itemTypeOrName The type or name of the list item.
2196
+ * @param keepMarks Keep marks when toggling.
2197
+ * @param attributes Attributes for the new list.
2198
+ * @example editor.commands.toggleList('bulletList', 'listItem')
2199
+ */
2200
+ toggleList: (listTypeOrName: string | NodeType$1, itemTypeOrName: string | NodeType$1, keepMarks?: boolean, attributes?: Record<string, any>) => ReturnType;
2201
+ };
2202
+ }
2203
+ }
2204
+
2205
+ declare module '@tiptap/core' {
2206
+ interface Commands<ReturnType> {
2207
+ toggleMark: {
2208
+ /**
2209
+ * Toggle a mark on and off.
2210
+ * @param typeOrName The mark type or name.
2211
+ * @param attributes The attributes of the mark.
2212
+ * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
2213
+ * @example editor.commands.toggleMark('bold')
2214
+ */
2215
+ toggleMark: (
2216
+ /**
2217
+ * The mark type or name.
2218
+ */
2219
+ typeOrName: string | MarkType$1,
2220
+ /**
2221
+ * The attributes of the mark.
2222
+ */
2223
+ attributes?: Record<string, any>, options?: {
2224
+ /**
2225
+ * Removes the mark even across the current selection. Defaults to `false`.
2226
+ */
2227
+ extendEmptyMarkRange?: boolean;
2228
+ }) => ReturnType;
2229
+ };
2230
+ }
2231
+ }
2232
+
2233
+ declare module '@tiptap/core' {
2234
+ interface Commands<ReturnType> {
2235
+ toggleNode: {
2236
+ /**
2237
+ * Toggle a node with another node.
2238
+ * @param typeOrName The type or name of the node.
2239
+ * @param toggleTypeOrName The type or name of the node to toggle.
2240
+ * @param attributes The attributes of the node.
2241
+ * @example editor.commands.toggleNode('heading', 'paragraph')
2242
+ */
2243
+ toggleNode: (typeOrName: string | NodeType$1, toggleTypeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2244
+ };
2245
+ }
2246
+ }
2247
+
2248
+ declare module '@tiptap/core' {
2249
+ interface Commands<ReturnType> {
2250
+ toggleWrap: {
2251
+ /**
2252
+ * Wraps nodes in another node, or removes an existing wrap.
2253
+ * @param typeOrName The type or name of the node.
2254
+ * @param attributes The attributes of the node.
2255
+ * @example editor.commands.toggleWrap('blockquote')
2256
+ */
2257
+ toggleWrap: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2258
+ };
2259
+ }
2260
+ }
2261
+
2262
+ declare module '@tiptap/core' {
2263
+ interface Commands<ReturnType> {
2264
+ undoInputRule: {
2265
+ /**
2266
+ * Undo an input rule.
2267
+ * @example editor.commands.undoInputRule()
2268
+ */
2269
+ undoInputRule: () => ReturnType;
2270
+ };
2271
+ }
2272
+ }
2273
+
2274
+ declare module '@tiptap/core' {
2275
+ interface Commands<ReturnType> {
2276
+ unsetAllMarks: {
2277
+ /**
2278
+ * Remove all marks in the current selection.
2279
+ * @example editor.commands.unsetAllMarks()
2280
+ */
2281
+ unsetAllMarks: () => ReturnType;
2282
+ };
2283
+ }
2284
+ }
2285
+
2286
+ declare module '@tiptap/core' {
2287
+ interface Commands<ReturnType> {
2288
+ unsetMark: {
2289
+ /**
2290
+ * Remove all marks in the current selection.
2291
+ * @param typeOrName The mark type or name.
2292
+ * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
2293
+ * @example editor.commands.unsetMark('bold')
2294
+ */
2295
+ unsetMark: (
2296
+ /**
2297
+ * The mark type or name.
2298
+ */
2299
+ typeOrName: string | MarkType$1, options?: {
2300
+ /**
2301
+ * Removes the mark even across the current selection. Defaults to `false`.
2302
+ */
2303
+ extendEmptyMarkRange?: boolean;
2304
+ }) => ReturnType;
2305
+ };
2306
+ }
2307
+ }
2308
+
2309
+ declare module '@tiptap/core' {
2310
+ interface Commands<ReturnType> {
2311
+ updateAttributes: {
2312
+ /**
2313
+ * Update attributes of a node or mark.
2314
+ * @param typeOrName The type or name of the node or mark.
2315
+ * @param attributes The attributes of the node or mark.
2316
+ * @example editor.commands.updateAttributes('mention', { userId: "2" })
2317
+ */
2318
+ updateAttributes: (
2319
+ /**
2320
+ * The type or name of the node or mark.
2321
+ */
2322
+ typeOrName: string | NodeType$1 | MarkType$1,
2323
+ /**
2324
+ * The attributes of the node or mark.
2325
+ */
2326
+ attributes: Record<string, any>) => ReturnType;
2327
+ };
2328
+ }
2329
+ }
2330
+
2331
+ declare module '@tiptap/core' {
2332
+ interface Commands<ReturnType> {
2333
+ wrapIn: {
2334
+ /**
2335
+ * Wraps nodes in another node.
2336
+ * @param typeOrName The type or name of the node.
2337
+ * @param attributes The attributes of the node.
2338
+ * @example editor.commands.wrapIn('blockquote')
2339
+ */
2340
+ wrapIn: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2341
+ };
2342
+ }
2343
+ }
2344
+
2345
+ declare module '@tiptap/core' {
2346
+ interface Commands<ReturnType> {
2347
+ wrapInList: {
2348
+ /**
2349
+ * Wrap a node in a list.
2350
+ * @param typeOrName The type or name of the node.
2351
+ * @param attributes The attributes of the node.
2352
+ * @example editor.commands.wrapInList('bulletList')
2353
+ */
2354
+ wrapInList: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2355
+ };
2356
+ }
2357
+ }
2358
+ declare class Editor extends EventEmitter<EditorEvents> {
2359
+ private commandManager;
2360
+ extensionManager: ExtensionManager;
2361
+ private css;
2362
+ schema: Schema;
2363
+ private editorView;
2364
+ isFocused: boolean;
2365
+ private editorState;
2366
+ /**
2367
+ * The editor is considered initialized after the `create` event has been emitted.
2368
+ */
2369
+ isInitialized: boolean;
2370
+ extensionStorage: Storage;
2371
+ /**
2372
+ * A unique ID for this editor instance.
2373
+ */
2374
+ instanceId: string;
2375
+ options: EditorOptions;
2376
+ constructor(options?: Partial<EditorOptions>);
2377
+ /**
2378
+ * Attach the editor to the DOM, creating a new editor view.
2379
+ */
2380
+ mount(el: NonNullable<EditorOptions['element']> & {}): void;
2381
+ /**
2382
+ * Remove the editor from the DOM, but still allow remounting at a different point in time
2383
+ */
2384
+ unmount(): void;
2385
+ /**
2386
+ * Returns the editor storage.
2387
+ */
2388
+ get storage(): Storage;
2389
+ /**
2390
+ * An object of all registered commands.
2391
+ */
2392
+ get commands(): SingleCommands;
2393
+ /**
2394
+ * Create a command chain to call multiple commands at once.
2395
+ */
2396
+ chain(): ChainedCommands;
2397
+ /**
2398
+ * Check if a command or a command chain can be executed. Without executing it.
2399
+ */
2400
+ can(): CanCommands;
2401
+ /**
2402
+ * Inject CSS styles.
2403
+ */
2404
+ private injectCSS;
2405
+ /**
2406
+ * Update editor options.
2407
+ *
2408
+ * @param options A list of options
2409
+ */
2410
+ setOptions(options?: Partial<EditorOptions>): void;
2411
+ /**
2412
+ * Update editable state of the editor.
2413
+ */
2414
+ setEditable(editable: boolean, emitUpdate?: boolean): void;
2415
+ /**
2416
+ * Returns whether the editor is editable.
2417
+ */
2418
+ get isEditable(): boolean;
2419
+ /**
2420
+ * Returns the editor state.
2421
+ */
2422
+ get view(): EditorView;
2423
+ /**
2424
+ * Returns the editor state.
2425
+ */
2426
+ get state(): EditorState;
2427
+ /**
2428
+ * Register a ProseMirror plugin.
2429
+ *
2430
+ * @param plugin A ProseMirror plugin
2431
+ * @param handlePlugins Control how to merge the plugin into the existing plugins.
2432
+ * @returns The new editor state
2433
+ */
2434
+ registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
2435
+ /**
2436
+ * Unregister a ProseMirror plugin.
2437
+ *
2438
+ * @param nameOrPluginKeyToRemove The plugins name
2439
+ * @returns The new editor state or undefined if the editor is destroyed
2440
+ */
2441
+ unregisterPlugin(nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]): EditorState | undefined;
2442
+ /**
2443
+ * Creates an extension manager.
2444
+ */
2445
+ private createExtensionManager;
2446
+ /**
2447
+ * Creates an command manager.
2448
+ */
2449
+ private createCommandManager;
2450
+ /**
2451
+ * Creates a ProseMirror schema.
2452
+ */
2453
+ private createSchema;
2454
+ /**
2455
+ * Creates the initial document.
2456
+ */
2457
+ private createDoc;
2458
+ /**
2459
+ * Creates a ProseMirror view.
2460
+ */
2461
+ private createView;
2462
+ /**
2463
+ * Creates all node and mark views.
2464
+ */
2465
+ createNodeViews(): void;
2466
+ /**
2467
+ * Prepend class name to element.
2468
+ */
2469
+ prependClass(): void;
2470
+ isCapturingTransaction: boolean;
2471
+ private capturedTransaction;
2472
+ captureTransaction(fn: () => void): Transaction | null;
2473
+ /**
2474
+ * The callback over which to send transactions (state updates) produced by the view.
2475
+ *
2476
+ * @param transaction An editor state transaction
2477
+ */
2478
+ private dispatchTransaction;
2479
+ /**
2480
+ * Get attributes of the currently selected node or mark.
2481
+ */
2482
+ getAttributes(nameOrType: string | NodeType$1 | MarkType$1): Record<string, any>;
2483
+ /**
2484
+ * Returns if the currently selected node or mark is active.
2485
+ *
2486
+ * @param name Name of the node or mark
2487
+ * @param attributes Attributes of the node or mark
2488
+ */
2489
+ isActive(name: string, attributes?: {}): boolean;
2490
+ isActive(attributes: {}): boolean;
2491
+ /**
2492
+ * Get the document as JSON.
2493
+ */
2494
+ getJSON(): DocumentType<Record<string, any> | undefined, NodeType<string, undefined | Record<string, any>, any, (NodeType | TextType)[]>[]>;
2495
+ /**
2496
+ * Get the document as HTML.
2497
+ */
2498
+ getHTML(): string;
2499
+ /**
2500
+ * Get the document as text.
2501
+ */
2502
+ getText(options?: {
2503
+ blockSeparator?: string;
2504
+ textSerializers?: Record<string, TextSerializer>;
2505
+ }): string;
2506
+ /**
2507
+ * Check if there is no content.
2508
+ */
2509
+ get isEmpty(): boolean;
2510
+ /**
2511
+ * Destroy the editor.
2512
+ */
2513
+ destroy(): void;
2514
+ /**
2515
+ * Check if the editor is already destroyed.
2516
+ */
2517
+ get isDestroyed(): boolean;
2518
+ $node(selector: string, attributes?: {
2519
+ [key: string]: any;
2520
+ }): NodePos | null;
2521
+ $nodes(selector: string, attributes?: {
2522
+ [key: string]: any;
2523
+ }): NodePos[] | null;
2524
+ $pos(pos: number): NodePos;
2525
+ get $doc(): NodePos;
2526
+ }
2527
+ declare global {
2528
+ namespace JSX {
2529
+ type Element = [string, ...any[]];
2530
+ interface IntrinsicElements {
2531
+ [key: string]: any;
2532
+ }
2533
+ }
2534
+ }
2535
+
2536
+ interface Commands<ReturnType = any> {
2537
+ }
2538
+ interface Storage {
2539
+ }
2540
+
2541
+ type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
2542
+ type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
2543
+ class?: string;
2544
+ onNodeChange?: (data: {
2545
+ node: Node | null;
2546
+ editor: Editor;
2547
+ pos: number;
2548
+ }) => void;
2549
+ };
2550
+ declare const DragHandle: vue_types_vue.ExtendedVue<Vue__default<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue__default>, unknown, unknown, unknown, {
2551
+ pluginKey: string | PluginKey$1<any> | undefined;
2552
+ editor: Editor;
2553
+ computePositionConfig: {} | undefined;
2554
+ onNodeChange: (((data: {
2555
+ editor: Editor;
2556
+ node: Node$3 | null;
2557
+ pos: number;
2558
+ }) => void) & ((data: {
2559
+ node: Node | null;
2560
+ editor: Editor;
2561
+ pos: number;
2562
+ }) => void)) | undefined;
2563
+ class: string | undefined;
2564
+ }, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin>;
2565
+
2566
+ export { DragHandle, type DragHandleProps, DragHandle as default };