@prosekit/core 0.8.0 → 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.
@@ -1,3063 +0,0 @@
1
- import { AllSelection } from '@prosekit/pm/state';
2
- import type { Attrs } from '@prosekit/pm/model';
3
- import { Command } from '@prosekit/pm/state';
4
- import type { ContentMatch } from '@prosekit/pm/model';
5
- import type { DirectEditorProps } from '@prosekit/pm/view';
6
- import type { DOMEventMap } from '@prosekit/pm/view';
7
- import type { DOMOutputSpec } from '@prosekit/pm/model';
8
- import { DOMParser as DOMParser_2 } from '@prosekit/pm/model';
9
- import { DOMSerializer } from '@prosekit/pm/model';
10
- import { EditorState } from '@prosekit/pm/state';
11
- import type { EditorStateConfig } from '@prosekit/pm/state';
12
- import { EditorView } from '@prosekit/pm/view';
13
- import { Fragment } from '@prosekit/pm/model';
14
- import type { IsEqual } from 'type-fest';
15
- import { Mark } from '@prosekit/pm/model';
16
- import type { MarkSpec } from '@prosekit/pm/model';
17
- import type { MarkType } from '@prosekit/pm/model';
18
- import type { MarkViewConstructor } from '@prosekit/pm/view';
19
- import type { Node as Node_2 } from '@prosekit/pm/model';
20
- import { NodeSelection } from '@prosekit/pm/state';
21
- import type { NodeSpec } from '@prosekit/pm/model';
22
- import type { NodeType } from '@prosekit/pm/model';
23
- import type { NodeView } from '@prosekit/pm/view';
24
- import type { NodeViewConstructor } from '@prosekit/pm/view';
25
- import { ParseOptions } from '@prosekit/pm/model';
26
- import { Plugin as Plugin_2 } from '@prosekit/pm/state';
27
- import { ProseMirrorFragment } from '@prosekit/pm/model';
28
- import { ProseMirrorNode } from '@prosekit/pm/model';
29
- import type { ResolvedPos } from '@prosekit/pm/model';
30
- import { Schema } from '@prosekit/pm/model';
31
- import { SchemaSpec } from '@prosekit/pm/model';
32
- import { Selection as Selection_2 } from '@prosekit/pm/state';
33
- import type { Simplify } from 'type-fest';
34
- import { Slice } from '@prosekit/pm/model';
35
- import type { TagParseRule } from '@prosekit/pm/model';
36
- import { TextSelection } from '@prosekit/pm/state';
37
- import { Transaction } from '@prosekit/pm/state';
38
- import type { UnionToIntersection } from 'type-fest';
39
-
40
- declare type Action = (options: {
41
- tr: Transaction;
42
- view?: EditorView;
43
- }) => boolean;
44
-
45
- /**
46
- * Returns a command that adds the given mark with the given attributes.
47
- *
48
- * @public
49
- */
50
- declare function addMark(options: AddMarkOptions): Command;
51
- export { addMark }
52
- export { addMark as addMark_alias_1 }
53
-
54
- /**
55
- * @public
56
- */
57
- declare interface AddMarkOptions {
58
- /**
59
- * The type of the mark to add.
60
- */
61
- type: string | MarkType;
62
- /**
63
- * The attributes of the mark to add.
64
- */
65
- attrs?: Attrs | null;
66
- /**
67
- * The start position of the document. By default it will be the start position of current selection.
68
- */
69
- from?: number;
70
- /**
71
- * The end position of the document. By default it will be the end position of current selection.
72
- */
73
- to?: number;
74
- }
75
- export { AddMarkOptions }
76
- export { AddMarkOptions as AddMarkOptions_alias_1 }
77
-
78
- /**
79
- * An object holding the attributes of a node.
80
-
81
- * @public
82
- */
83
- declare type AnyAttrs = Attrs;
84
- export { AnyAttrs }
85
- export { AnyAttrs as AnyAttrs_alias_1 }
86
-
87
- /**
88
- * @internal
89
- */
90
- declare type AnyFunction = (...args: any[]) => any;
91
- export { AnyFunction }
92
- export { AnyFunction as AnyFunction_alias_1 }
93
-
94
- export declare function applyAction(operator: Action): Command;
95
-
96
- export declare const applyMarkForTest: ApplyMarkFunction;
97
-
98
- /**
99
- * @internal
100
- */
101
- export declare type ApplyMarkFunction = (mark: Mark, children: ProseMirrorNode[]) => ProseMirrorNode[];
102
-
103
- /**
104
- * @internal
105
- */
106
- export declare function arrayRemove<T>(array: T[], item: T): void;
107
-
108
- /**
109
- * @internal
110
- */
111
- export declare function arraySubstract<T>(a: T[], b: T[]): T[];
112
-
113
- /**
114
- * @internal
115
- */
116
- declare function assert(condition: unknown, message?: string): asserts condition;
117
- export { assert }
118
- export { assert as assert_alias_1 }
119
-
120
- /**
121
- * Utility function assert that two types are equal in tests.
122
- */
123
- export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
124
-
125
- declare interface AttrOptions {
126
- attr: string;
127
- toDOM?: (value: unknown) => [key: string, value: string] | null | undefined;
128
- parseDOM?: (node: HTMLElement) => unknown;
129
- }
130
-
131
- export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
132
-
133
- /**
134
- * @public
135
- */
136
- declare type AttrSpec<AttrType = any> = {
137
- /**
138
- * The default value for this attribute, to use when no explicit value is
139
- * provided. Attributes that have no default must be provided whenever a node
140
- * or mark of a type that has them is created.
141
- */
142
- default?: AttrType;
143
- /**
144
- * A function or type name used to validate values of this attribute. This
145
- * will be used when deserializing the attribute from JSON, and when running
146
- * [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check). When a
147
- * function, it should raise an exception if the value isn't of the expected
148
- * type or shape. When a string, it should be a `|`-separated string of
149
- * primitive types (`"number"`, `"string"`, `"boolean"`, `"null"`, and
150
- * `"undefined"`), and the library will raise an error when the value is not
151
- * one of those types.
152
- */
153
- validate?: string | ((value: unknown) => void);
154
- };
155
- export { AttrSpec }
156
- export { AttrSpec as AttrSpec_alias_1 }
157
-
158
- /**
159
- * @internal
160
- */
161
- declare type BaseCommandsExtension = Extension<{
162
- Commands: {
163
- insertText: [options: InsertTextOptions];
164
- insertNode: [options: InsertNodeOptions];
165
- removeNode: [options: RemoveNodeOptions];
166
- wrap: [options: WrapOptions];
167
- toggleWrap: [options: ToggleWrapOptions];
168
- setBlockType: [options: SetBlockTypeOptions];
169
- setNodeAttrs: [options: SetNodeAttrsOptions];
170
- insertDefaultBlock: [options?: InsertDefaultBlockOptions];
171
- selectAll: [];
172
- addMark: [options: AddMarkOptions];
173
- removeMark: [options: RemoveMarkOptions];
174
- unsetBlockType: [options?: UnsetBlockTypeOptions];
175
- unsetMark: [options?: UnsetMarkOptions];
176
- };
177
- }>;
178
- export { BaseCommandsExtension }
179
- export { BaseCommandsExtension as BaseCommandsExtension_alias_1 }
180
-
181
- /**
182
- * @internal
183
- */
184
- export declare abstract class BaseExtension<T extends ExtensionTyping = ExtensionTyping> implements Extension<T> {
185
- abstract extension: Extension | Extension[];
186
- priority?: Priority;
187
- _type?: T;
188
- private trees;
189
- /**
190
- * @internal
191
- */
192
- abstract createTree(priority: Priority): FacetNode;
193
- /**
194
- * @internal
195
- */
196
- getTree(priority?: Priority): FacetNode;
197
- /**
198
- * @internal
199
- */
200
- findFacetOutput<I, O>(facet: Facet<I, O>): Tuple5<O | null> | null;
201
- get schema(): Schema | null;
202
- }
203
-
204
- /**
205
- * @internal
206
- */
207
- declare type BaseKeymapExtension = PlainExtension;
208
- export { BaseKeymapExtension }
209
- export { BaseKeymapExtension as BaseKeymapExtension_alias_1 }
210
-
211
- /**
212
- * Some basic props for custom node views.
213
- *
214
- * @deprecated - This is no longer needed. Use `CoreNodeViewUserOptions` from `@prosemirror-adapter/core` instead.
215
- *
216
- * @hidden
217
- */
218
- declare interface BaseNodeViewOptions {
219
- /**
220
- * The wrapping DOM element for the node view. Defaults to `div` for block nodes and `span` for inline nodes.
221
- */
222
- as?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
223
- /**
224
- * The wrapping DOM element for the node view's content. Defaults to `div` for block nodes and `span` for inline nodes.
225
- */
226
- contentAs?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
227
- update?: NodeView['update'];
228
- ignoreMutation?: NodeView['ignoreMutation'];
229
- selectNode?: NodeView['selectNode'];
230
- deselectNode?: NodeView['deselectNode'];
231
- setSelection?: NodeView['setSelection'];
232
- stopEvent?: NodeView['stopEvent'];
233
- destroy?: NodeView['destroy'];
234
- onUpdate?: () => void;
235
- }
236
- export { BaseNodeViewOptions }
237
- export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
238
-
239
- export declare function buildNode(type: NodeType, args: [Attrs | NodeChild | null | undefined, ...NodeChild[]], createNode: CreateNodeFunction): ProseMirrorNode;
240
-
241
- export declare function cache<T>(fn: () => T): () => T;
242
-
243
- declare const canUseRegexLookbehind: () => boolean;
244
- export { canUseRegexLookbehind }
245
- export { canUseRegexLookbehind as canUseRegexLookbehind_alias_1 }
246
-
247
- declare type ClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
248
- export { ClickHandler }
249
- export { ClickHandler as ClickHandler_alias_1 }
250
-
251
- declare type ClickOnHandler = (view: EditorView, pos: number, node: Node_2, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
252
- export { ClickOnHandler }
253
- export { ClickOnHandler as ClickOnHandler_alias_1 }
254
-
255
- /**
256
- * @internal
257
- */
258
- declare interface ClipboardSerializerOptions {
259
- serializeFragmentWrapper?: FunctionWrapper<SerializeFragmentFunction>;
260
- serializeNodeWrapper?: FunctionWrapper<SerializeNodeFunction>;
261
- nodesFromSchemaWrapper?: FunctionWrapper<NodesFromSchemaFunction>;
262
- marksFromSchemaWrapper?: FunctionWrapper<MarksFromSchemaFunction>;
263
- }
264
- export { ClipboardSerializerOptions }
265
- export { ClipboardSerializerOptions as ClipboardSerializerOptions_alias_1 }
266
-
267
- /**
268
- * A utility for constructing `className` strings conditionally.
269
- *
270
- * It is a re-export of [clsx/lite](https://www.npmjs.com/package/clsx) with stricter types.
271
- *
272
- * @public
273
- */
274
- declare const clsx: (...args: Array<string | boolean | null | undefined>) => string;
275
- export { clsx }
276
- export { clsx as clsx_alias_1 }
277
-
278
- /**
279
- * Collects all children of a node or a fragment, and returns them as an array.
280
- *
281
- * @public
282
- */
283
- declare function collectChildren(parent: ProseMirrorNode | Fragment): ProseMirrorNode[];
284
- export { collectChildren }
285
- export { collectChildren as collectChildren_alias_1 }
286
-
287
- /**
288
- * Collects all nodes from a given content.
289
- *
290
- * @deprecated Use `collectChildren` instead.
291
- *
292
- * @public
293
- */
294
- declare function collectNodes(content: NodeContent): ProseMirrorNode[];
295
- export { collectNodes }
296
- export { collectNodes as collectNodes_alias_1 }
297
-
298
- export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): [
299
- setHandlers: (eventHandlers: Handler[]) => void,
300
- combinedEventHandler: (...args: Args) => boolean
301
- ];
302
-
303
- /**
304
- * A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
305
- *
306
- * It also has a `canExec` method to check if the command can be applied.
307
- *
308
- * @public
309
- */
310
- declare interface CommandAction<Args extends any[] = any[]> {
311
- /**
312
- * Execute the current command. Return `true` if the command was successfully
313
- * executed, otherwise `false`.
314
- */
315
- (...args: Args): boolean;
316
- /**
317
- * Check if the current command can be executed. Return `true` if the command
318
- * can be executed, otherwise `false`.
319
- */
320
- canExec(...args: Args): boolean;
321
- /**
322
- * An alias for `canExec`.
323
- *
324
- * @deprecated Use `canExec` instead.
325
- */
326
- canApply(...args: Args): boolean;
327
- }
328
- export { CommandAction }
329
- export { CommandAction as CommandAction_alias_1 }
330
-
331
- export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
332
-
333
- export declare interface CommandCreators {
334
- [name: string]: CommandCreator;
335
- }
336
-
337
- export declare const commandFacet: Facet<CommandPayload, RootPayload>;
338
-
339
- export declare type CommandPayload = CommandCreators;
340
-
341
- /**
342
- * @internal
343
- */
344
- declare interface CommandTyping {
345
- [name: string]: any[];
346
- }
347
- export { CommandTyping }
348
- export { CommandTyping as CommandTyping_alias_1 }
349
-
350
- /**
351
- * @internal
352
- */
353
- declare function containsInlineNode(doc: ProseMirrorNode, from: number, to: number): boolean;
354
- export { containsInlineNode }
355
- export { containsInlineNode as containsInlineNode_alias_1 }
356
-
357
- /**
358
- * @public
359
- */
360
- declare function createEditor<E extends Extension>(options: EditorOptions<E>): Editor<E>;
361
- export { createEditor }
362
- export { createEditor as createEditor_alias_1 }
363
-
364
- /**
365
- * @internal
366
- */
367
- export declare function createMarkActions(schema: Schema, getState: GetStateFunction, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
368
-
369
- /**
370
- * @internal
371
- */
372
- export declare function createNodeActions(schema: Schema, getState: GetStateFunction, createNode?: CreateNodeFunction): Record<string, NodeAction>;
373
-
374
- export declare const createNodeForTest: CreateNodeFunction;
375
-
376
- /**
377
- * @internal
378
- */
379
- export declare type CreateNodeFunction = (type: NodeType, attrs: Attrs | null, children: ProseMirrorNode[]) => ProseMirrorNode;
380
-
381
- /**
382
- * @public
383
- */
384
- declare function createTestEditor<E extends Extension>(options: EditorOptions<E>): TestEditor<E>;
385
- export { createTestEditor }
386
- export { createTestEditor as createTestEditor_alias_1 }
387
-
388
- export declare function deepEquals<T>(a: T, b: T): boolean;
389
-
390
- /**
391
- * @internal
392
- */
393
- declare function defaultBlockAt(match: ContentMatch): NodeType | null;
394
- export { defaultBlockAt }
395
- export { defaultBlockAt as defaultBlockAt_alias_1 }
396
-
397
- /**
398
- * @public
399
- */
400
- declare interface DefaultStateOptions {
401
- /**
402
- * The starting document to use when creating the editor. It can be a
403
- * ProseMirror node JSON object, a HTML string, or a HTML element instance.
404
- */
405
- defaultContent?: NodeJSON | string | HTMLElement;
406
- /**
407
- * A JSON object representing the starting document to use when creating the
408
- * editor.
409
- *
410
- * @deprecated Use `defaultContent` instead.
411
- */
412
- defaultDoc?: NodeJSON;
413
- /**
414
- * A HTML element or a HTML string representing the starting document to use
415
- * when creating the editor.
416
- *
417
- * @deprecated Use `defaultContent` instead.
418
- */
419
- defaultHTML?: string | HTMLElement;
420
- /**
421
- * A JSON object representing the starting selection to use when creating the
422
- * editor. It's only used when `defaultContent` is also provided.
423
- */
424
- defaultSelection?: SelectionJSON;
425
- }
426
- export { DefaultStateOptions }
427
- export { DefaultStateOptions as DefaultStateOptions_alias_1 }
428
-
429
- /**
430
- * Add some base commands
431
- *
432
- * @public
433
- */
434
- declare function defineBaseCommands(): BaseCommandsExtension;
435
- export { defineBaseCommands }
436
- export { defineBaseCommands as defineBaseCommands_alias_1 }
437
-
438
- /**
439
- * Defines some basic key bindings.
440
- *
441
- * @public
442
- */
443
- declare function defineBaseKeymap(options?: {
444
- /**
445
- * The priority of the keymap.
446
- *
447
- * @default Priority.low
448
- */
449
- priority?: Priority;
450
- }): BaseKeymapExtension;
451
- export { defineBaseKeymap }
452
- export { defineBaseKeymap as defineBaseKeymap_alias_1 }
453
-
454
- /**
455
- * @public
456
- *
457
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClick}
458
- */
459
- declare function defineClickHandler(handler: ClickHandler): PlainExtension;
460
- export { defineClickHandler }
461
- export { defineClickHandler as defineClickHandler_alias_1 }
462
-
463
- /**
464
- * @public
465
- *
466
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn}
467
- */
468
- declare function defineClickOnHandler(handler: ClickOnHandler): PlainExtension;
469
- export { defineClickOnHandler }
470
- export { defineClickOnHandler as defineClickOnHandler_alias_1 }
471
-
472
- /**
473
- * @internal
474
- */
475
- declare function defineClipboardSerializer(options: ClipboardSerializerOptions): Extension;
476
- export { defineClipboardSerializer }
477
- export { defineClipboardSerializer as defineClipboardSerializer_alias_1 }
478
-
479
- declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
480
- Commands: {
481
- [K in keyof T]: Parameters<T[K]>;
482
- };
483
- }>;
484
- export { defineCommands }
485
- export { defineCommands as defineCommands_alias_1 }
486
-
487
- /**
488
- * Define a default state for the editor.
489
- *
490
- * @param options
491
- *
492
- * @public
493
- */
494
- declare function defineDefaultState({ defaultSelection, defaultContent, defaultDoc, defaultHTML, }: DefaultStateOptions): PlainExtension;
495
- export { defineDefaultState }
496
- export { defineDefaultState as defineDefaultState_alias_1 }
497
-
498
- /**
499
- * @public
500
- *
501
- * @deprecated Use the following import instead:
502
- *
503
- * ```ts
504
- * import { defineDoc } from 'prosekit/extensions/doc'
505
- * ```
506
- */
507
- declare function defineDoc(): DocExtension;
508
- export { defineDoc }
509
- export { defineDoc as defineDoc_alias_1 }
510
-
511
- /**
512
- * Registers a event handler that is called when the editor document is changed.
513
- *
514
- * @public
515
- */
516
- declare function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension;
517
- export { defineDocChangeHandler }
518
- export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
519
-
520
- /**
521
- * @internal
522
- */
523
- export declare function defineDomEventFacetPayload(...payloads: DOMEventPayload[]): PlainExtension;
524
-
525
- /**
526
- * Register a new event handler for the given event type.
527
- *
528
- * @public
529
- */
530
- declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): PlainExtension;
531
- export { defineDOMEventHandler }
532
- export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
533
-
534
- /**
535
- * @public
536
- *
537
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick}
538
- */
539
- declare function defineDoubleClickHandler(handler: DoubleClickHandler): PlainExtension;
540
- export { defineDoubleClickHandler }
541
- export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
542
-
543
- /**
544
- * @public
545
- *
546
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn}
547
- */
548
- declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): PlainExtension;
549
- export { defineDoubleClickOnHandler }
550
- export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
551
-
552
- /**
553
- * @public
554
- *
555
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop}
556
- */
557
- declare function defineDropHandler(handler: DropHandler): PlainExtension;
558
- export { defineDropHandler }
559
- export { defineDropHandler as defineDropHandler_alias_1 }
560
-
561
- /**
562
- * @internal
563
- */
564
- declare function defineFacet<Input, Output>(options: {
565
- /**
566
- * The parent facet in the tree.
567
- */
568
- parent: Facet<Output, any>;
569
- /**
570
- * Set this to true if you only want to keep one facet payload. For example,
571
- * this facet corresponds to a ProseMirror plugin with a key.
572
- */
573
- singleton?: boolean;
574
- /**
575
- * A reducer is a function that accepts an array of input and produce a single
576
- * output.
577
- */
578
- reducer?: FacetReducer<Input, Output>;
579
- /**
580
- * A callback function that returns a reducer. This is useful if you want to
581
- * store something in the closure.
582
- */
583
- reduce?: () => FacetReducer<Input, Output>;
584
- }): Facet<Input, Output>;
585
- export { defineFacet }
586
- export { defineFacet as defineFacet_alias_1 }
587
-
588
- /**
589
- * @internal
590
- */
591
- declare function defineFacetPayload<Input>(facet: Facet<Input, any>, payloads: Input[]): Extension;
592
- export { defineFacetPayload }
593
- export { defineFacetPayload as defineFacetPayload_alias_1 }
594
-
595
- /**
596
- * Registers a event handler that is called when the editor gains or loses focus.
597
- *
598
- * @public
599
- */
600
- declare function defineFocusChangeHandler(handler: FocusChangeHandler): PlainExtension;
601
- export { defineFocusChangeHandler }
602
- export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
603
-
604
- /**
605
- * Add undo/redo history to the editor.
606
- *
607
- * @param options
608
- *
609
- * @public
610
- */
611
- declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
612
- export { defineHistory }
613
- export { defineHistory as defineHistory_alias_1 }
614
-
615
- /**
616
- * @public
617
- *
618
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
619
- */
620
- declare function defineKeyDownHandler(handler: KeyDownHandler): PlainExtension;
621
- export { defineKeyDownHandler }
622
- export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
623
-
624
- /**
625
- * @public
626
- */
627
- declare function defineKeymap(keymap: Keymap): PlainExtension;
628
- export { defineKeymap }
629
- export { defineKeymap as defineKeymap_alias_1 }
630
-
631
- /**
632
- * @public
633
- *
634
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress}
635
- */
636
- declare function defineKeyPressHandler(handler: KeyPressHandler): PlainExtension;
637
- export { defineKeyPressHandler }
638
- export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
639
-
640
- /**
641
- * @public
642
- */
643
- declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
644
- Marks: {
645
- [K in MarkType]: AttrType;
646
- };
647
- }>;
648
- export { defineMarkAttr }
649
- export { defineMarkAttr as defineMarkAttr_alias_1 }
650
-
651
- /**
652
- * @public
653
- */
654
- declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = AnyAttrs>(options: MarkSpecOptions<Mark, Attrs>): Extension<{
655
- Marks: {
656
- [K in Mark]: Attrs;
657
- };
658
- }>;
659
- export { defineMarkSpec }
660
- export { defineMarkSpec as defineMarkSpec_alias_1 }
661
-
662
- declare function defineMarkView(options: MarkViewOptions): Extension;
663
- export { defineMarkView }
664
- export { defineMarkView as defineMarkView_alias_1 }
665
-
666
- /**
667
- * @internal
668
- */
669
- declare function defineMarkViewComponent<T>(options: MarkViewComponentOptions<T>): Extension;
670
- export { defineMarkViewComponent }
671
- export { defineMarkViewComponent as defineMarkViewComponent_alias_1 }
672
-
673
- /**
674
- * @internal
675
- */
676
- declare function defineMarkViewFactory<T>(options: MarkViewFactoryOptions<T>): Extension;
677
- export { defineMarkViewFactory }
678
- export { defineMarkViewFactory as defineMarkViewFactory_alias_1 }
679
-
680
- /**
681
- * Registers a event handler that is called when the editor view is mounted.
682
- *
683
- * @public
684
- */
685
- declare function defineMountHandler(handler: MountHandler): PlainExtension;
686
- export { defineMountHandler }
687
- export { defineMountHandler as defineMountHandler_alias_1 }
688
-
689
- /**
690
- * Defines an attribute for a node type.
691
- *
692
- * @public
693
- */
694
- declare function defineNodeAttr<NodeType extends string = string, AttrName extends string = string, AttrType = any>(options: NodeAttrOptions<NodeType, AttrName, AttrType>): Extension<{
695
- Nodes: {
696
- [K in NodeType]: {
697
- [K in AttrName]: AttrType;
698
- };
699
- };
700
- }>;
701
- export { defineNodeAttr }
702
- export { defineNodeAttr as defineNodeAttr_alias_1 }
703
-
704
- /**
705
- * Defines a node type.
706
- *
707
- * @public
708
- */
709
- declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = AnyAttrs>(options: NodeSpecOptions<Node, Attrs>): Extension<{
710
- Nodes: {
711
- [K in Node]: Attrs;
712
- };
713
- }>;
714
- export { defineNodeSpec }
715
- export { defineNodeSpec as defineNodeSpec_alias_1 }
716
-
717
- declare function defineNodeView(options: NodeViewOptions): Extension;
718
- export { defineNodeView }
719
- export { defineNodeView as defineNodeView_alias_1 }
720
-
721
- /**
722
- * @internal
723
- */
724
- declare function defineNodeViewComponent<T>(options: NodeViewComponentOptions<T>): Extension;
725
- export { defineNodeViewComponent }
726
- export { defineNodeViewComponent as defineNodeViewComponent_alias_1 }
727
-
728
- /**
729
- * @internal
730
- */
731
- declare function defineNodeViewFactory<T>(options: NodeViewFactoryOptions<T>): Extension;
732
- export { defineNodeViewFactory }
733
- export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
734
-
735
- /**
736
- * @public
737
- *
738
- * Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
739
- *
740
- * @deprecated Use the following import instead:
741
- *
742
- * ```ts
743
- * import { defineParagraph } from 'prosekit/extensions/paragraph'
744
- * ```
745
- */
746
- declare function defineParagraph(): ParagraphExtension;
747
- export { defineParagraph }
748
- export { defineParagraph as defineParagraph_alias_1 }
749
-
750
- /**
751
- * @public
752
- *
753
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste}
754
- */
755
- declare function definePasteHandler(handler: PasteHandler): PlainExtension;
756
- export { definePasteHandler }
757
- export { definePasteHandler as definePasteHandler_alias_1 }
758
-
759
- /**
760
- * Adds a ProseMirror plugin to the editor.
761
- *
762
- * @param plugin - The ProseMirror plugin to add, or an array of plugins, or a
763
- * function that returns one or multiple plugins.
764
- *
765
- * @public
766
- */
767
- declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
768
- schema: Schema;
769
- }) => Plugin_2 | Plugin_2[])): PlainExtension;
770
- export { definePlugin }
771
- export { definePlugin as definePlugin_alias_1 }
772
-
773
- /**
774
- * @public
775
- *
776
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection}
777
- */
778
- declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): PlainExtension;
779
- export { defineScrollToSelectionHandler }
780
- export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_1 }
781
-
782
- /**
783
- * @public
784
- *
785
- * @deprecated Use the following import instead:
786
- *
787
- * ```ts
788
- * import { defineText } from 'prosekit/extensions/text'
789
- * ```
790
- */
791
- declare function defineText(): TextExtension;
792
- export { defineText }
793
- export { defineText as defineText_alias_1 }
794
-
795
- /**
796
- * @public
797
- *
798
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput}
799
- */
800
- declare function defineTextInputHandler(handler: TextInputHandler): PlainExtension;
801
- export { defineTextInputHandler }
802
- export { defineTextInputHandler as defineTextInputHandler_alias_1 }
803
-
804
- /**
805
- * @public
806
- *
807
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick}
808
- */
809
- declare function defineTripleClickHandler(handler: TripleClickHandler): PlainExtension;
810
- export { defineTripleClickHandler }
811
- export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
812
-
813
- /**
814
- * @public
815
- *
816
- * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn}
817
- */
818
- declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): PlainExtension;
819
- export { defineTripleClickOnHandler }
820
- export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
821
-
822
- /**
823
- * Registers a event handler that is called when the editor view is unmounted.
824
- *
825
- * @public
826
- */
827
- declare function defineUnmountHandler(handler: UnmountHandler): PlainExtension;
828
- export { defineUnmountHandler }
829
- export { defineUnmountHandler as defineUnmountHandler_alias_1 }
830
-
831
- /**
832
- * Registers a event handler that is called when the editor state is updated.
833
- *
834
- * @public
835
- */
836
- declare function defineUpdateHandler(handler: UpdateHandler): PlainExtension;
837
- export { defineUpdateHandler }
838
- export { defineUpdateHandler as defineUpdateHandler_alias_1 }
839
-
840
- /**
841
- * A function that is called when the editor document is changed.
842
- *
843
- * @param view - The editor view.
844
- * @param prevState - The previous editor state.
845
- *
846
- * @public
847
- */
848
- declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => void;
849
- export { DocChangeHandler }
850
- export { DocChangeHandler as DocChangeHandler_alias_1 }
851
-
852
- /**
853
- * @internal
854
- */
855
- declare type DocExtension = Extension<{
856
- Nodes: {
857
- doc: Attrs;
858
- };
859
- }>;
860
- export { DocExtension }
861
- export { DocExtension as DocExtension_alias_1 }
862
-
863
- /**
864
- * @internal
865
- */
866
- export declare class DOMDocumentNotFoundError extends ProseKitError {
867
- constructor();
868
- }
869
-
870
- /** @public */
871
- declare interface DOMDocumentOptions {
872
- /**
873
- * The Document object to use for DOM operations. If not provided, defaults to
874
- * the current browser's document object. Useful for server-side rendering or
875
- * testing environments.
876
- */
877
- document?: Document;
878
- }
879
- export { DOMDocumentOptions }
880
- export { DOMDocumentOptions as DOMDocumentOptions_alias_1 }
881
-
882
- /**
883
- * @internal
884
- */
885
- export declare const domEventFacet: Facet<DOMEventPayload, PluginPayload>;
886
-
887
- /**
888
- * A function to handle the events fired on the editable DOM element. Returns
889
- * `true` to indicate that it handled the given event. you are responsible for
890
- * calling `preventDefault` yourself (or not, if you want to allow the default
891
- * behavior).
892
- *
893
- * @public
894
- */
895
- declare type DOMEventHandler<Event extends keyof DOMEventMap = string> = (view: EditorView, event: DOMEventMap[Event]) => boolean | void;
896
- export { DOMEventHandler }
897
- export { DOMEventHandler as DOMEventHandler_alias_1 }
898
-
899
- /**
900
- * @internal
901
- */
902
- export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
903
-
904
- export declare type DOMNode = InstanceType<typeof window.Node>;
905
-
906
- /** @public */
907
- declare interface DOMParserOptions extends ParseOptions {
908
- DOMParser?: typeof DOMParser_2;
909
- }
910
- export { DOMParserOptions }
911
- export { DOMParserOptions as DOMParserOptions_alias_1 }
912
-
913
- /** @public */
914
- declare interface DOMSerializerOptions {
915
- DOMSerializer?: {
916
- fromSchema: typeof DOMSerializer.fromSchema;
917
- };
918
- }
919
- export { DOMSerializerOptions }
920
- export { DOMSerializerOptions as DOMSerializerOptions_alias_1 }
921
-
922
- declare type DoubleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
923
- export { DoubleClickHandler }
924
- export { DoubleClickHandler as DoubleClickHandler_alias_1 }
925
-
926
- declare type DoubleClickOnHandler = (view: EditorView, pos: number, node: Node_2, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
927
- export { DoubleClickOnHandler }
928
- export { DoubleClickOnHandler as DoubleClickOnHandler_alias_1 }
929
-
930
- declare type DropHandler = (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
931
- export { DropHandler }
932
- export { DropHandler as DropHandler_alias_1 }
933
-
934
- /**
935
- * @public
936
- */
937
- declare class Editor<E extends Extension = any> {
938
- private instance;
939
- /**
940
- * @internal
941
- */
942
- constructor(instance: EditorInstance);
943
- /**
944
- * Whether the editor is mounted.
945
- */
946
- get mounted(): boolean;
947
- /**
948
- * The editor view.
949
- */
950
- get view(): EditorView;
951
- /**
952
- * The editor schema.
953
- */
954
- get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
955
- /**
956
- * The editor's current state.
957
- */
958
- get state(): EditorState;
959
- /**
960
- * Whether the editor is focused.
961
- */
962
- get focused(): boolean;
963
- /**
964
- * Mount the editor to the given HTML element.
965
- * Pass `null` or `undefined` to unmount the editor.
966
- */
967
- mount: (place: HTMLElement | null | undefined) => void;
968
- /**
969
- * Unmount the editor. This is equivalent to `mount(null)`.
970
- */
971
- unmount: () => void;
972
- /**
973
- * Focus the editor.
974
- */
975
- focus: () => void;
976
- /**
977
- * Blur the editor.
978
- */
979
- blur: () => void;
980
- /**
981
- * Register an extension to the editor. Return a function to unregister the
982
- * extension.
983
- */
984
- use: (extension: Extension) => VoidFunction;
985
- /**
986
- * Update the editor's state.
987
- *
988
- * @remarks
989
- *
990
- * This is an advanced method. Use it only if you have a specific reason to
991
- * directly manipulate the editor's state.
992
- */
993
- updateState: (state: EditorState) => void;
994
- /**
995
- * Update the editor's document and selection.
996
- *
997
- * @param content - The new document to set. It can be one of the following:
998
- * - A ProseMirror node instance
999
- * - A ProseMirror node JSON object
1000
- * - An HTML string
1001
- * - An HTML element instance
1002
- * @param selection - Optional. Specifies the new selection. It can be one of the following:
1003
- * - A ProseMirror selection instance
1004
- * - A ProseMirror selection JSON object
1005
- * - The string "start" (to set selection at the beginning, default value)
1006
- * - The string "end" (to set selection at the end)
1007
- */
1008
- setContent: (content: ProseMirrorNode | NodeJSON | string | HTMLElement, selection?: SelectionJSON | Selection_2 | "start" | "end") => void;
1009
- /**
1010
- * Return a JSON object representing the editor's current document.
1011
- */
1012
- getDocJSON: () => NodeJSON;
1013
- /**
1014
- * Return a HTML string representing the editor's current document.
1015
- */
1016
- getDocHTML: (options?: getDocHTMLOptions) => string;
1017
- /**
1018
- * Execute the given command. Return `true` if the command was successfully
1019
- * executed, otherwise `false`.
1020
- */
1021
- exec: (command: Command) => boolean;
1022
- /**
1023
- * Check if the given command can be executed. Return `true` if the command
1024
- * can be executed, otherwise `false`.
1025
- */
1026
- canExec: (command: Command) => boolean;
1027
- /**
1028
- * All {@link CommandAction}s defined by the editor.
1029
- */
1030
- get commands(): ExtractCommandActions<E>;
1031
- /**
1032
- * All {@link NodeAction}s defined by the editor.
1033
- */
1034
- get nodes(): ExtractNodeActions<E>;
1035
- /**
1036
- * All {@link MarkAction}s defined by the editor.
1037
- */
1038
- get marks(): ExtractMarkActions<E>;
1039
- }
1040
- export { Editor }
1041
- export { Editor as Editor_alias_1 }
1042
-
1043
- /**
1044
- * @internal
1045
- */
1046
- declare const editorEventFacet: Facet<EditorEventPayload, PluginPayload>;
1047
- export { editorEventFacet }
1048
- export { editorEventFacet as editorEventFacet_alias_1 }
1049
-
1050
- declare interface EditorEventMap {
1051
- keyDown: KeyDownHandler;
1052
- keyPress: KeyPressHandler;
1053
- textInput: TextInputHandler;
1054
- clickOn: ClickOnHandler;
1055
- click: ClickHandler;
1056
- doubleClickOn: DoubleClickOnHandler;
1057
- doubleClick: DoubleClickHandler;
1058
- tripleClickOn: TripleClickOnHandler;
1059
- tripleClick: TripleClickHandler;
1060
- paste: PasteHandler;
1061
- drop: DropHandler;
1062
- scrollToSelection: ScrollToSelectionHandler;
1063
- }
1064
-
1065
- /**
1066
- * @internal
1067
- */
1068
- declare type EditorEventPayload = ObjectEntries<EditorEventMap>;
1069
- export { EditorEventPayload }
1070
- export { EditorEventPayload as EditorEventPayload_alias_1 }
1071
-
1072
- /**
1073
- * An internal class to make TypeScript generic type easier to use.
1074
- *
1075
- * @internal
1076
- */
1077
- export declare class EditorInstance {
1078
- view: EditorView | null;
1079
- schema: Schema;
1080
- nodes: Record<string, NodeAction>;
1081
- marks: Record<string, MarkAction>;
1082
- commands: Record<string, CommandAction>;
1083
- private tree;
1084
- private directEditorProps;
1085
- private afterMounted;
1086
- constructor(extension: Extension);
1087
- getState: () => EditorState;
1088
- private getDoc;
1089
- private getProp;
1090
- updateState(state: EditorState): void;
1091
- private dispatch;
1092
- setContent(content: NodeJSON | string | HTMLElement | ProseMirrorNode, selection?: SelectionJSON | Selection_2 | 'start' | 'end'): void;
1093
- /**
1094
- * Return a JSON object representing the editor's current document.
1095
- */
1096
- getDocJSON: () => NodeJSON;
1097
- /**
1098
- * Return a HTML string representing the editor's current document.
1099
- */
1100
- getDocHTML: (options?: getDocHTMLOptions) => string;
1101
- private updateExtension;
1102
- use(extension: Extension): VoidFunction;
1103
- mount(place: HTMLElement): void;
1104
- unmount(): void;
1105
- get mounted(): boolean;
1106
- get assertView(): EditorView;
1107
- definePlugins(plugins: readonly Plugin_2[]): void;
1108
- removePlugins(plugins: readonly Plugin_2[]): void;
1109
- exec(command: Command): boolean;
1110
- canExec(command: Command): boolean;
1111
- defineCommand<Args extends any[] = any[]>(name: string, commandCreator: CommandCreator<Args>): void;
1112
- removeCommand(name: string): void;
1113
- }
1114
-
1115
- /**
1116
- * @internal
1117
- */
1118
- declare class EditorNotFoundError extends ProseKitError {
1119
- constructor();
1120
- }
1121
- export { EditorNotFoundError }
1122
- export { EditorNotFoundError as EditorNotFoundError_alias_1 }
1123
-
1124
- /**
1125
- * @public
1126
- */
1127
- declare interface EditorOptions<E extends Extension> {
1128
- /**
1129
- * The extension to use when creating the editor.
1130
- */
1131
- extension: E;
1132
- /**
1133
- * The starting document to use when creating the editor. It can be a
1134
- * ProseMirror node JSON object, a HTML string, or a HTML element instance.
1135
- */
1136
- defaultContent?: NodeJSON | string | HTMLElement;
1137
- /**
1138
- * A JSON object representing the starting document to use when creating the
1139
- * editor.
1140
- *
1141
- * @deprecated Use `defaultContent` instead.
1142
- */
1143
- defaultDoc?: NodeJSON;
1144
- /**
1145
- * A HTML element or a HTML string representing the starting document to use
1146
- * when creating the editor.
1147
- *
1148
- * @deprecated Use `defaultContent` instead.
1149
- */
1150
- defaultHTML?: string | HTMLElement;
1151
- /**
1152
- * A JSON object representing the starting selection to use when creating the
1153
- * editor. It's only used when `defaultContent` is also provided.
1154
- */
1155
- defaultSelection?: SelectionJSON;
1156
- }
1157
- export { EditorOptions }
1158
- export { EditorOptions as EditorOptions_alias_1 }
1159
-
1160
- /**
1161
- * Parse a HTML string to a HTML element.
1162
- *
1163
- * @internal
1164
- */
1165
- export declare function elementFromHTML(html: string, options?: DOMDocumentOptions): HTMLElement;
1166
-
1167
- /**
1168
- * Parse a ProseMirror document JSON object to a HTML element.
1169
- *
1170
- * @public
1171
- *
1172
- * @example
1173
- *
1174
- * ```ts
1175
- * const json = { type: 'doc', content: [{ type: 'paragraph' }] }
1176
- * const element = elementFromJSON(json, { schema: editor.schema })
1177
- * ```
1178
- */
1179
- declare function elementFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
1180
- export { elementFromJSON }
1181
- export { elementFromJSON as elementFromJSON_alias_1 }
1182
-
1183
- /**
1184
- * Serialize a ProseMirror node to a HTML element.
1185
- *
1186
- * @public
1187
- *
1188
- * @example
1189
- *
1190
- * ```ts
1191
- * const node = editor.state.doc
1192
- * const element = elementFromNode(node)
1193
- * ```
1194
- */
1195
- declare function elementFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): HTMLElement;
1196
- export { elementFromNode }
1197
- export { elementFromNode as elementFromNode_alias_1 }
1198
-
1199
- /**
1200
- * Expands the selection to include the entire mark at the current position.
1201
- *
1202
- * @public
1203
- */
1204
- declare function expandMark(options: ExpandMarkOptions): Command;
1205
- export { expandMark }
1206
- export { expandMark as expandMark_alias_1 }
1207
-
1208
- /**
1209
- * @public
1210
- */
1211
- declare interface ExpandMarkOptions {
1212
- /**
1213
- * The type of the mark to expand.
1214
- */
1215
- type: string | MarkType;
1216
- }
1217
- export { ExpandMarkOptions }
1218
- export { ExpandMarkOptions as ExpandMarkOptions_alias_1 }
1219
-
1220
- /**
1221
- * @public
1222
- */
1223
- declare interface Extension<T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>> {
1224
- extension: Extension | Extension[];
1225
- priority?: Priority;
1226
- _type?: T;
1227
- /**
1228
- * @public
1229
- *
1230
- * The schema that this extension represents.
1231
- */
1232
- schema: Schema | null;
1233
- }
1234
- export { Extension }
1235
- export { Extension as Extension_alias_1 }
1236
-
1237
- /**
1238
- * @internal
1239
- */
1240
- declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
1241
- Nodes?: N;
1242
- Marks?: M;
1243
- Commands?: C;
1244
- }
1245
- export { ExtensionTyping }
1246
- export { ExtensionTyping as ExtensionTyping_alias_1 }
1247
-
1248
- /**
1249
- * Extracts the {@link CommandAction}s from an extension type.
1250
- *
1251
- * @public
1252
- */
1253
- declare type ExtractCommandActions<E extends Extension> = ToCommandAction<ExtractCommands<E>>;
1254
- export { ExtractCommandActions }
1255
- export { ExtractCommandActions as ExtractCommandActions_alias_1 }
1256
-
1257
- /**
1258
- * @deprecated Use `ExtractCommandActions` instead.
1259
- */
1260
- declare type ExtractCommandAppliers<E extends Extension> = ExtractCommandActions<E>;
1261
- export { ExtractCommandAppliers }
1262
- export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
1263
-
1264
- /**
1265
- * @public
1266
- */
1267
- declare type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommands<E>>;
1268
- export { ExtractCommandCreators }
1269
- export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
1270
-
1271
- /**
1272
- * @internal
1273
- */
1274
- export declare type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>['Commands']>;
1275
-
1276
- /**
1277
- * Extracts the {@link MarkAction}s from an extension type.
1278
- *
1279
- * @public
1280
- */
1281
- declare type ExtractMarkActions<E extends Extension> = ToMarkAction<ExtractMarks<E>>;
1282
- export { ExtractMarkActions }
1283
- export { ExtractMarkActions as ExtractMarkActions_alias_1 }
1284
-
1285
- /**
1286
- * @public
1287
- */
1288
- export declare type ExtractMarkNames<E extends Extension> = PickStringLiteral<keyof ExtractMarks<E>>;
1289
-
1290
- /**
1291
- * @public
1292
- */
1293
- declare type ExtractMarks<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Marks']>>;
1294
- export { ExtractMarks }
1295
- export { ExtractMarks as ExtractMarks_alias_1 }
1296
-
1297
- /**
1298
- * Extracts the {@link NodeAction}s from an extension type.
1299
- *
1300
- * @public
1301
- */
1302
- declare type ExtractNodeActions<E extends Extension> = ToNodeAction<ExtractNodes<E>>;
1303
- export { ExtractNodeActions }
1304
- export { ExtractNodeActions as ExtractNodeActions_alias_1 }
1305
-
1306
- /**
1307
- * @public
1308
- */
1309
- export declare type ExtractNodeNames<E extends Extension> = PickStringLiteral<keyof ExtractNodes<E>>;
1310
-
1311
- /**
1312
- * @public
1313
- */
1314
- declare type ExtractNodes<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Nodes']>>;
1315
- export { ExtractNodes }
1316
- export { ExtractNodes as ExtractNodes_alias_1 }
1317
-
1318
- export declare function extractTags(node: TaggedProseMirrorNode): Record<string, number>;
1319
-
1320
- /**
1321
- * @internal
1322
- */
1323
- export declare 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;
1324
-
1325
- /**
1326
- * @internal
1327
- */
1328
- declare class Facet<Input, Output> {
1329
- private _reducer?;
1330
- private _reduce?;
1331
- /**
1332
- * @internal
1333
- */
1334
- readonly index: number;
1335
- /**
1336
- * @internal
1337
- */
1338
- readonly parent: Facet<Output, any> | null;
1339
- /**
1340
- * @internal
1341
- */
1342
- readonly singleton: boolean;
1343
- /**
1344
- * A index path to retrieve the current facet in a tree from the root.
1345
- *
1346
- * @internal
1347
- */
1348
- readonly path: number[];
1349
- /**
1350
- * @internal
1351
- */
1352
- constructor(parent: Facet<Output, any> | null, singleton: boolean, _reducer?: FacetReducer<Input, Output> | undefined, _reduce?: (() => FacetReducer<Input, Output>) | undefined);
1353
- get reducer(): FacetReducer<Input, Output>;
1354
- }
1355
- export { Facet }
1356
- export { Facet as Facet_alias_1 }
1357
-
1358
- /**
1359
- * @internal
1360
- */
1361
- export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
1362
- readonly facet: Facet<Input, Output>;
1363
- readonly payloads: Input[];
1364
- extension: Extension;
1365
- /**
1366
- * @internal
1367
- */
1368
- constructor(facet: Facet<Input, Output>, payloads: Input[]);
1369
- /**
1370
- * @internal
1371
- */
1372
- createTree(priority: Priority): FacetNode;
1373
- }
1374
-
1375
- export declare class FacetNode<I = any, O = any> {
1376
- readonly facet: Facet<I, O>;
1377
- readonly inputs: Tuple5<I[] | null>;
1378
- readonly children: Map<number, FacetNode>;
1379
- readonly reducers: Tuple5<FacetReducer<I, O> | null>;
1380
- output: Tuple5<O | null> | null;
1381
- constructor(facet: Facet<I, O>, inputs?: Tuple5<I[] | null>, children?: Map<number, FacetNode>, reducers?: Tuple5<FacetReducer<I, O> | null>);
1382
- private calcOutput;
1383
- getOutput(): Tuple5<O | null>;
1384
- getSingletonOutput(): O | null;
1385
- getRootOutput(): RootOutput;
1386
- isRoot(): boolean;
1387
- }
1388
-
1389
- /**
1390
- * @internal
1391
- */
1392
- export declare type FacetReducer<Input, Output> = (input: Input[]) => Output;
1393
-
1394
- export declare function findBrowserDocument(options?: {
1395
- document?: Document;
1396
- }): Document | undefined;
1397
-
1398
- export declare function findBrowserWindow(options?: {
1399
- document?: Document;
1400
- }): (Window & typeof globalThis) | undefined;
1401
-
1402
- /**
1403
- * Find the closest parent node that satisfies the predicate.
1404
- *
1405
- * @public
1406
- */
1407
- declare function findParentNode(
1408
- /**
1409
- * The predicate to test the parent node.
1410
- */
1411
- predicate: (node: ProseMirrorNode) => boolean,
1412
- /**
1413
- * The position to start searching from.
1414
- */
1415
- $pos: ResolvedPos): FindParentNodeResult | undefined;
1416
- export { findParentNode }
1417
- export { findParentNode as findParentNode_alias_1 }
1418
-
1419
- /**
1420
- * Finds the closest parent node that matches the given node type.
1421
- *
1422
- * @public
1423
- */
1424
- declare function findParentNodeOfType(
1425
- /**
1426
- * The type of the node to find.
1427
- */
1428
- type: NodeType | string,
1429
- /**
1430
- * The position to start searching from.
1431
- */
1432
- $pos: ResolvedPos): FindParentNodeResult | undefined;
1433
- export { findParentNodeOfType }
1434
- export { findParentNodeOfType as findParentNodeOfType_alias_1 }
1435
-
1436
- /**
1437
- * @public
1438
- */
1439
- declare interface FindParentNodeResult {
1440
- /**
1441
- * The closest parent node that satisfies the predicate.
1442
- */
1443
- node: ProseMirrorNode;
1444
- /**
1445
- * The position directly before the node.
1446
- */
1447
- pos: number;
1448
- /**
1449
- * The position at the start of the node.
1450
- */
1451
- start: number;
1452
- /**
1453
- * The depth of the node.
1454
- */
1455
- depth: number;
1456
- }
1457
- export { FindParentNodeResult }
1458
- export { FindParentNodeResult as FindParentNodeResult_alias_1 }
1459
-
1460
- /**
1461
- * A function that is called when the editor gains or loses focus.
1462
- *
1463
- * @param hasFocus - Whether the editor has focus.
1464
- *
1465
- * @public
1466
- */
1467
- declare type FocusChangeHandler = (hasFocus: boolean) => void;
1468
- export { FocusChangeHandler }
1469
- export { FocusChangeHandler as FocusChangeHandler_alias_1 }
1470
-
1471
- declare type FunctionWrapper<T extends AnyFunction> = (fn: T) => T;
1472
-
1473
- export declare function getBrowserDocument(options?: {
1474
- document?: Document;
1475
- }): Document;
1476
-
1477
- export declare function getBrowserWindow(options?: {
1478
- document?: Document;
1479
- }): Window & typeof globalThis;
1480
-
1481
- export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_2;
1482
-
1483
- /**
1484
- * @public
1485
- */
1486
- export declare interface getDocHTMLOptions extends DOMDocumentOptions {
1487
- }
1488
-
1489
- export declare function getEditorContentDoc(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
1490
-
1491
- export declare function getEditorContentJSON(schema: Schema, content: NodeJSON | string | HTMLElement): NodeJSON;
1492
-
1493
- export declare function getEditorContentNode(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
1494
-
1495
- export declare function getEditorSelection(doc: ProseMirrorNode, selection: SelectionJSON | Selection_2 | 'start' | 'end'): Selection_2;
1496
-
1497
- /**
1498
- * Returns a unique id in the current process that can be used in various places.
1499
- *
1500
- * @internal
1501
- */
1502
- declare function getId(): string;
1503
- export { getId as _getId }
1504
- export { getId }
1505
-
1506
- /**
1507
- * @internal
1508
- */
1509
- declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;
1510
- export { getMarkType }
1511
- export { getMarkType as getMarkType_alias_1 }
1512
-
1513
- /**
1514
- * @internal
1515
- */
1516
- declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
1517
- export { getNodeType }
1518
- export { getNodeType as getNodeType_alias_1 }
1519
-
1520
- /**
1521
- * @internal
1522
- */
1523
- export declare function getNodeTypes(schema: Schema, types: string | NodeType | string[] | NodeType[]): NodeType[];
1524
-
1525
- declare type GetStateFunction = () => EditorState | null | undefined;
1526
-
1527
- export declare function groupBy<K extends PropertyKey, T>(items: Iterable<T>, keySelector: (item: T) => K): Partial<Record<K, T[]>>;
1528
-
1529
- export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): {
1530
- [K in keyof T]?: T[K][];
1531
- };
1532
-
1533
- /**
1534
- * @internal
1535
- */
1536
- declare type HistoryExtension = Extension<{
1537
- Commands: {
1538
- undo: [];
1539
- redo: [];
1540
- };
1541
- }>;
1542
- export { HistoryExtension }
1543
- export { HistoryExtension as HistoryExtension_alias_1 }
1544
-
1545
- /**
1546
- * Options for {@link defineHistory}.
1547
- *
1548
- * @public
1549
- */
1550
- declare interface HistoryOptions {
1551
- /**
1552
- * The amount of history events that are collected before the oldest events
1553
- * are discarded.
1554
- *
1555
- * @default 200
1556
- */
1557
- depth?: number;
1558
- /**
1559
- * The delay in milliseconds between changes after which a new group should be
1560
- * started.
1561
- *
1562
- * @default 250
1563
- */
1564
- newGroupDelay?: number;
1565
- }
1566
- export { HistoryOptions }
1567
- export { HistoryOptions as HistoryOptions_alias_1 }
1568
-
1569
- /**
1570
- * @internal
1571
- */
1572
- export declare function htmlFromElement(element: HTMLElement): string;
1573
-
1574
- /**
1575
- * Parse a ProseMirror document JSON object to a HTML string.
1576
- *
1577
- * @public
1578
- *
1579
- * @example
1580
- *
1581
- * ```ts
1582
- * const json = { type: 'doc', content: [{ type: 'paragraph' }] }
1583
- * const html = htmlFromJSON(json, { schema: editor.schema })
1584
- * ```
1585
- */
1586
- declare function htmlFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): string;
1587
- export { htmlFromJSON }
1588
- export { htmlFromJSON as htmlFromJSON_alias_1 }
1589
-
1590
- /**
1591
- * Serialize a ProseMirror node to a HTML string
1592
- *
1593
- * @public
1594
- *
1595
- * @example
1596
- *
1597
- * ```ts
1598
- * const node = document.getElementById('content')
1599
- * const html = htmlFromNode(node)
1600
- * ```
1601
- */
1602
- declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOptions & DOMDocumentOptions): string;
1603
- export { htmlFromNode }
1604
- export { htmlFromNode as htmlFromNode_alias_1 }
1605
-
1606
- export declare function includesMark(marks: readonly Mark[], markType: MarkType, attrs?: Attrs | null): boolean;
1607
-
1608
- /**
1609
- * Returns a command that inserts a default block after current selection or at
1610
- * the given position.
1611
- *
1612
- * @public
1613
- */
1614
- declare function insertDefaultBlock(options?: InsertDefaultBlockOptions): Command;
1615
- export { insertDefaultBlock }
1616
- export { insertDefaultBlock as insertDefaultBlock_alias_1 }
1617
-
1618
- /**
1619
- * @public
1620
- */
1621
- declare interface InsertDefaultBlockOptions {
1622
- /**
1623
- * The position to insert the node at. By default it will insert after the
1624
- * current selection.
1625
- */
1626
- pos?: number;
1627
- }
1628
- export { InsertDefaultBlockOptions }
1629
- export { InsertDefaultBlockOptions as InsertDefaultBlockOptions_alias_1 }
1630
-
1631
- /**
1632
- * Returns a command that inserts the given node at the current selection or at
1633
- * the given position.
1634
- *
1635
- * @public
1636
- */
1637
- declare function insertNode(options: InsertNodeOptions): Command;
1638
- export { insertNode }
1639
- export { insertNode as insertNode_alias_1 }
1640
-
1641
- export declare function insertNodeAction({ node, pos, }: {
1642
- node: ProseMirrorNode;
1643
- pos?: number;
1644
- }): Action;
1645
-
1646
- /**
1647
- * @public
1648
- */
1649
- declare interface InsertNodeOptions {
1650
- /**
1651
- * The node to insert. Either this or `type` must be provided.
1652
- */
1653
- node?: ProseMirrorNode;
1654
- /**
1655
- * The type of the node to insert. Either this or `node` must be provided.
1656
- */
1657
- type?: string | NodeType;
1658
- /**
1659
- * When `type` is provided, the attributes of the node to insert.
1660
- */
1661
- attrs?: Attrs;
1662
- /**
1663
- * The position to insert the node at. By default it will be the anchor
1664
- * position of current selection.
1665
- */
1666
- pos?: number;
1667
- }
1668
- export { InsertNodeOptions }
1669
- export { InsertNodeOptions as InsertNodeOptions_alias_1 }
1670
-
1671
- export declare function insertOutputSpecAttrs(dom: DOMOutputSpec, attrs: Array<[key: string, value: string]>): DOMOutputSpec;
1672
-
1673
- /**
1674
- * Returns a command that inserts the given text.
1675
- *
1676
- * @public
1677
- */
1678
- export declare function insertText({ text, from, to }: InsertTextOptions): Command;
1679
-
1680
- /**
1681
- * @public
1682
- */
1683
- export declare type InsertTextOptions = {
1684
- text: string;
1685
- from?: number;
1686
- to?: number;
1687
- };
1688
-
1689
- /**
1690
- * Checks if the given object is a `AllSelection` instance.
1691
- *
1692
- * @public
1693
- */
1694
- declare function isAllSelection(sel: Selection_2): sel is AllSelection;
1695
- export { isAllSelection }
1696
- export { isAllSelection as isAllSelection_alias_1 }
1697
-
1698
- /**
1699
- * @private
1700
- */
1701
- declare const isApple: boolean;
1702
- export { isApple }
1703
- export { isApple as isApple_alias_1 }
1704
-
1705
- /**
1706
- * Whether the selection is an empty text selection at the start of a block.
1707
- *
1708
- * @internal
1709
- */
1710
- declare function isAtBlockStart(state: EditorState, view?: EditorView): ResolvedPos | null;
1711
- export { isAtBlockStart }
1712
- export { isAtBlockStart as isAtBlockStart_alias_1 }
1713
-
1714
- /**
1715
- * @internal
1716
- */
1717
- declare function isElement(el: unknown): el is Element;
1718
- export { isElement }
1719
- export { isElement as isElement_alias_1 }
1720
-
1721
- /**
1722
- * Checks if the given object is a `Fragment` instance.
1723
- *
1724
- * @public
1725
- */
1726
- declare function isFragment(fragment: unknown): fragment is Fragment;
1727
- export { isFragment }
1728
- export { isFragment as isFragment_alias_1 }
1729
-
1730
- /**
1731
- * Check if the selection is in a code block.
1732
- *
1733
- * @internal
1734
- */
1735
- declare function isInCodeBlock(selection: Selection_2): boolean;
1736
- export { isInCodeBlock }
1737
- export { isInCodeBlock as isInCodeBlock_alias_1 }
1738
-
1739
- /**
1740
- * Checks if the given object is a `Mark` instance.
1741
- *
1742
- * @public
1743
- */
1744
- declare function isMark(mark: unknown): mark is Mark;
1745
- export { isMark }
1746
- export { isMark as isMark_alias_1 }
1747
-
1748
- /**
1749
- * Returns true if the given mark is missing in some part of the range.
1750
- * Returns false if the entire range has the given mark.
1751
- * Returns true if the mark is not allowed in the range.
1752
- *
1753
- * @internal
1754
- */
1755
- declare function isMarkAbsent(node: ProseMirrorNode, from: number, to: number, markType: MarkType, attrs?: Attrs | null): boolean;
1756
- export { isMarkAbsent }
1757
- export { isMarkAbsent as isMarkAbsent_alias_1 }
1758
-
1759
- /**
1760
- * @internal
1761
- */
1762
- declare function isMarkActive(state: EditorState, type: string | MarkType, attrs?: Attrs | null): boolean;
1763
- export { isMarkActive }
1764
- export { isMarkActive as isMarkActive_alias_1 }
1765
-
1766
- export declare function isNodeActive(state: EditorState, type: string | NodeType, attrs?: Attrs | null): boolean;
1767
-
1768
- /**
1769
- * Checks if the given object is a `NodeSelection` instance.
1770
- *
1771
- * @public
1772
- */
1773
- declare function isNodeSelection(sel: Selection_2): sel is NodeSelection;
1774
- export { isNodeSelection }
1775
- export { isNodeSelection as isNodeSelection_alias_1 }
1776
-
1777
- /**
1778
- * @internal
1779
- */
1780
- export declare function isNotNullish<T>(value: T | null | undefined | void): value is T;
1781
-
1782
- export declare function isObject(v: unknown): v is Record<string, unknown>;
1783
-
1784
- /**
1785
- * Checks if the given object is a `ProseMirrorNode` instance.
1786
- */
1787
- declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
1788
- export { isProseMirrorNode }
1789
- export { isProseMirrorNode as isProseMirrorNode_alias_1 }
1790
-
1791
- /**
1792
- * Checks if the given object is a `Selection` instance.
1793
- *
1794
- * @public
1795
- */
1796
- declare function isSelection(sel: unknown): sel is Selection_2;
1797
- export { isSelection }
1798
- export { isSelection as isSelection_alias_1 }
1799
-
1800
- /**
1801
- * Checks if the given object is a `Slice` instance.
1802
- *
1803
- * @public
1804
- */
1805
- declare function isSlice(slice: unknown): slice is Slice;
1806
- export { isSlice }
1807
- export { isSlice as isSlice_alias_1 }
1808
-
1809
- /**
1810
- * Check if `subset` is a subset of `superset`.
1811
- *
1812
- * @internal
1813
- */
1814
- export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
1815
-
1816
- /**
1817
- * Checks if the given object is a `TextSelection` instance.
1818
- *
1819
- * @public
1820
- */
1821
- declare function isTextSelection(sel: Selection_2): sel is TextSelection;
1822
- export { isTextSelection }
1823
- export { isTextSelection as isTextSelection_alias_1 }
1824
-
1825
- /**
1826
- * Serialize a HTML element to a ProseMirror document JSON object.
1827
- *
1828
- * @public
1829
- *
1830
- * @example
1831
- *
1832
- * ```ts
1833
- * const element = document.getElementById('content')
1834
- * const json = jsonFromElement(element, { schema: editor.schema })
1835
- * ```
1836
- */
1837
- export declare function jsonFromElement(element: DOMNode, options: DOMParserOptions & JSONParserOptions): NodeJSON;
1838
-
1839
- /**
1840
- * Parse a HTML string to a ProseMirror document JSON object.
1841
- *
1842
- * @public
1843
- *
1844
- * @example
1845
- *
1846
- * ```ts
1847
- * const html = '<p>Hello, world!</p>'
1848
- * const json = jsonFromHTML(html, { schema: editor.schema })
1849
- * ```
1850
- */
1851
- declare function jsonFromHTML(html: string, options: DOMDocumentOptions & DOMParserOptions & JSONParserOptions): NodeJSON;
1852
- export { jsonFromHTML }
1853
- export { jsonFromHTML as jsonFromHTML_alias_1 }
1854
-
1855
- /**
1856
- * Return a JSON object representing this node.
1857
- *
1858
- * @public
1859
- *
1860
- * @example
1861
- *
1862
- * ```ts
1863
- * const node = editor.state.doc
1864
- * const json = jsonFromNode(node)
1865
- * ```
1866
- */
1867
- declare function jsonFromNode(node: ProseMirrorNode): NodeJSON;
1868
- export { jsonFromNode }
1869
- export { jsonFromNode as jsonFromNode_alias_1 }
1870
-
1871
- /**
1872
- * Return a JSON object representing this state.
1873
- *
1874
- * @public
1875
- *
1876
- * @example
1877
- *
1878
- * ```ts
1879
- * const state = editor.state
1880
- * const json = jsonFromState(state)
1881
- * ```
1882
- */
1883
- declare function jsonFromState(state: EditorState): StateJSON;
1884
- export { jsonFromState }
1885
- export { jsonFromState as jsonFromState_alias_1 }
1886
-
1887
- /** @public */
1888
- declare interface JSONParserOptions {
1889
- /**
1890
- * The editor schema to use.
1891
- */
1892
- schema: Schema;
1893
- }
1894
- export { JSONParserOptions }
1895
- export { JSONParserOptions as JSONParserOptions_alias_1 }
1896
-
1897
- declare type KeyDownHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
1898
- export { KeyDownHandler }
1899
- export { KeyDownHandler as KeyDownHandler_alias_1 }
1900
-
1901
- /**
1902
- * @public
1903
- */
1904
- declare interface Keymap {
1905
- [key: string]: Command;
1906
- }
1907
- export { Keymap }
1908
- export { Keymap as Keymap_alias_1 }
1909
-
1910
- /**
1911
- * @internal
1912
- */
1913
- declare const keymapFacet: Facet<KeymapPayload, PluginPayload>;
1914
- export { keymapFacet }
1915
- export { keymapFacet as keymapFacet_alias_1 }
1916
-
1917
- /**
1918
- * @internal
1919
- */
1920
- declare type KeymapPayload = Keymap;
1921
- export { KeymapPayload }
1922
- export { KeymapPayload as KeymapPayload_alias_1 }
1923
-
1924
- declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boolean | void;
1925
- export { KeyPressHandler }
1926
- export { KeyPressHandler as KeyPressHandler_alias_1 }
1927
-
1928
- /**
1929
- * A function for creating a mark with optional attributes and any number of
1930
- * children.
1931
- *
1932
- * It also has a `isActive` method for checking if the mark is active in the
1933
- * current editor selection.
1934
- *
1935
- * @public
1936
- */
1937
- declare interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
1938
- (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
1939
- (...children: NodeChild[]): ProseMirrorNode[];
1940
- /**
1941
- * Checks if the mark is active in the current editor selection. If the
1942
- * optional `attrs` parameter is provided, it will check if the mark is active
1943
- * with the given attributes.
1944
- */
1945
- isActive: (attrs?: Attrs) => boolean;
1946
- }
1947
- export { MarkAction }
1948
- export { MarkAction as MarkAction_alias_1 }
1949
-
1950
- /**
1951
- * @public
1952
- */
1953
- declare interface MarkAttrOptions<MarkName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
1954
- /**
1955
- * The name of the mark type.
1956
- */
1957
- type: MarkName;
1958
- /**
1959
- * The name of the attribute.
1960
- */
1961
- attr: AttrName;
1962
- /**
1963
- * Returns the attribute key and value to be set on the HTML element.
1964
- *
1965
- * If the returned `key` is `"style"`, the value is a string of CSS properties and will
1966
- * be prepended to the existing `style` attribute on the DOM node.
1967
- *
1968
- * @param value - The value of the attribute of current ProseMirror node.
1969
- */
1970
- toDOM?: (value: AttrType) => [key: string, value: string] | null | undefined;
1971
- /**
1972
- * Parses the attribute value from the DOM.
1973
- */
1974
- parseDOM?: (node: HTMLElement) => AttrType;
1975
- }
1976
- export { MarkAttrOptions }
1977
- export { MarkAttrOptions as MarkAttrOptions_alias_1 }
1978
-
1979
- /**
1980
- * @deprecated Use type {@link MarkAction} instead.
1981
- */
1982
- declare type MarkBuilder = MarkAction;
1983
- export { MarkBuilder }
1984
- export { MarkBuilder as MarkBuilder_alias_1 }
1985
-
1986
- declare type MarksFromSchemaFunction = typeof DOMSerializer.marksFromSchema;
1987
-
1988
- /**
1989
- * @public
1990
- */
1991
- declare interface MarkSpecOptions<MarkName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends MarkSpec {
1992
- /**
1993
- * The name of the mark type.
1994
- */
1995
- name: MarkName;
1996
- /**
1997
- * The attributes that marks of this type get.
1998
- */
1999
- attrs?: {
2000
- [K in keyof Attrs]: AttrSpec<Attrs[K]>;
2001
- };
2002
- }
2003
- export { MarkSpecOptions }
2004
- export { MarkSpecOptions as MarkSpecOptions_alias_1 }
2005
-
2006
- /**
2007
- * @internal
2008
- */
2009
- declare interface MarkTyping {
2010
- [name: string]: Record<string, any>;
2011
- }
2012
- export { MarkTyping }
2013
- export { MarkTyping as MarkTyping_alias_1 }
2014
-
2015
- /**
2016
- * @internal
2017
- */
2018
- declare type MarkViewComponentOptions<T> = {
2019
- group: string;
2020
- name: string;
2021
- args: T;
2022
- };
2023
- export { MarkViewComponentOptions }
2024
- export { MarkViewComponentOptions as MarkViewComponentOptions_alias_1 }
2025
-
2026
- /**
2027
- * @internal
2028
- */
2029
- declare type MarkViewFactoryOptions<T> = {
2030
- group: string;
2031
- factory: (args: T) => MarkViewConstructor;
2032
- };
2033
- export { MarkViewFactoryOptions }
2034
- export { MarkViewFactoryOptions as MarkViewFactoryOptions_alias_1 }
2035
-
2036
- declare interface MarkViewOptions {
2037
- name: string;
2038
- constructor: MarkViewConstructor;
2039
- }
2040
- export { MarkViewOptions }
2041
- export { MarkViewOptions as MarkViewOptions_alias_1 }
2042
-
2043
- /**
2044
- * @internal
2045
- */
2046
- declare function maybeRun<MaybeFn, Result = MaybeFn extends (...args: any[]) => void ? ReturnType<MaybeFn> : MaybeFn>(value: MaybeFn, ...args: MaybeFn extends (...args: any[]) => void ? Parameters<MaybeFn> : never): Result;
2047
- export { maybeRun }
2048
- export { maybeRun as maybeRun_alias_1 }
2049
-
2050
- export declare function mergeObjects<T extends object>(...objects: Array<Partial<T> | null | undefined>): Partial<T>;
2051
-
2052
- export declare function mergeSpecs(a: NodeSpec, b: NodeSpec): NodeSpec;
2053
-
2054
- export declare function mergeSpecs(a: MarkSpec, b: MarkSpec): MarkSpec;
2055
-
2056
- /**
2057
- * A function that is called when the editor view is mounted.
2058
- *
2059
- * @param view - The editor view.
2060
- *
2061
- * @public
2062
- */
2063
- declare type MountHandler = (view: EditorView) => void;
2064
- export { MountHandler }
2065
- export { MountHandler as MountHandler_alias_1 }
2066
-
2067
- /**
2068
- * A function for creating a node with optional attributes and any number of
2069
- * children.
2070
- *
2071
- * It also has a `isActive` method for checking if the node is active in the
2072
- * current editor selection.
2073
- *
2074
- * @public
2075
- */
2076
- declare interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
2077
- (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
2078
- (...children: NodeChild[]): ProseMirrorNode;
2079
- /**
2080
- * Checks if the node is active in the current editor selection. If the
2081
- * optional `attrs` parameter is provided, it will check if the node is active
2082
- * with the given attributes.
2083
- */
2084
- isActive: (attrs?: Attrs) => boolean;
2085
- }
2086
- export { NodeAction }
2087
- export { NodeAction as NodeAction_alias_1 }
2088
-
2089
- /**
2090
- * @public
2091
- */
2092
- declare interface NodeAttrOptions<NodeName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
2093
- /**
2094
- * The name of the node type.
2095
- */
2096
- type: NodeName;
2097
- /**
2098
- * The name of the attribute.
2099
- */
2100
- attr: AttrName;
2101
- /**
2102
- * Whether the attribute should be kept when the node is split. Set it to
2103
- * `true` if you want to inherit the attribute from the previous node when
2104
- * splitting the node by pressing `Enter`.
2105
- *
2106
- * @default undefined
2107
- */
2108
- splittable?: boolean;
2109
- /**
2110
- * Returns the attribute key and value to be set on the HTML element.
2111
- *
2112
- * If the returned `key` is `"style"`, the value is a string of CSS properties and will
2113
- * be prepended to the existing `style` attribute on the DOM node.
2114
- *
2115
- * @param value - The value of the attribute of current ProseMirror node.
2116
- */
2117
- toDOM?: (value: AttrType) => [key: string, value: string] | null | undefined;
2118
- /**
2119
- * Parses the attribute value from the DOM.
2120
- */
2121
- parseDOM?: (node: HTMLElement) => AttrType;
2122
- }
2123
- export { NodeAttrOptions }
2124
- export { NodeAttrOptions as NodeAttrOptions_alias_1 }
2125
-
2126
- /**
2127
- * @deprecated Use type {@link NodeAction} instead.
2128
- */
2129
- declare type NodeBuilder = NodeAction;
2130
- export { NodeBuilder }
2131
- export { NodeBuilder as NodeBuilder_alias_1 }
2132
-
2133
- /**
2134
- * Available children parameters for {@link NodeAction} and {@link MarkAction}.
2135
- *
2136
- * @public
2137
- */
2138
- declare type NodeChild = ProseMirrorNode | string | NodeChild[];
2139
- export { NodeChild }
2140
- export { NodeChild as NodeChild_alias_1 }
2141
-
2142
- /**
2143
- * @public
2144
- *
2145
- * @deprecated
2146
- */
2147
- declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
2148
- export { NodeContent }
2149
- export { NodeContent as NodeContent_alias_1 }
2150
-
2151
- /**
2152
- * Parse a HTML element to a ProseMirror node.
2153
- *
2154
- * @public
2155
- *
2156
- * @example
2157
- *
2158
- * ```ts
2159
- * const element = document.getElementById('content')
2160
- * const node = nodeFromElement(element, { schema: editor.schema })
2161
- */
2162
- declare function nodeFromElement(element: DOMNode, options: DOMParserOptions & JSONParserOptions): ProseMirrorNode;
2163
- export { nodeFromElement }
2164
- export { nodeFromElement as nodeFromElement_alias_1 }
2165
-
2166
- /**
2167
- * Parse a HTML string to a ProseMirror node.
2168
- *
2169
- * @public
2170
- *
2171
- * @example
2172
- *
2173
- * ```ts
2174
- * const html = '<p>Hello, world!</p>'
2175
- * const node = nodeFromHTML(html, { schema: editor.schema })
2176
- */
2177
- declare function nodeFromHTML(html: string, options: DOMParserOptions & JSONParserOptions & DOMDocumentOptions): ProseMirrorNode;
2178
- export { nodeFromHTML }
2179
- export { nodeFromHTML as nodeFromHTML_alias_1 }
2180
-
2181
- /**
2182
- * Parse a JSON object to a ProseMirror node.
2183
- *
2184
- * @public
2185
- *
2186
- * @example
2187
- *
2188
- * ```ts
2189
- * const json = { type: 'doc', content: [{ type: 'paragraph' }] }
2190
- * const node = nodeFromJSON(json, { schema: editor.schema })
2191
- * ```
2192
- */
2193
- declare function nodeFromJSON(json: NodeJSON, options: JSONParserOptions): ProseMirrorNode;
2194
- export { nodeFromJSON }
2195
- export { nodeFromJSON as nodeFromJSON_alias_1 }
2196
-
2197
- /**
2198
- * A JSON representation of the prosemirror node.
2199
- *
2200
- * @public
2201
- */
2202
- declare interface NodeJSON {
2203
- type: string;
2204
- marks?: Array<{
2205
- type: string;
2206
- attrs?: Record<string, any>;
2207
- }>;
2208
- text?: string;
2209
- content?: NodeJSON[];
2210
- attrs?: Record<string, any>;
2211
- }
2212
- export { NodeJSON }
2213
- export { NodeJSON as NodeJSON_alias_1 }
2214
-
2215
- declare type NodesFromSchemaFunction = typeof DOMSerializer.nodesFromSchema;
2216
-
2217
- /**
2218
- * @public
2219
- */
2220
- declare interface NodeSpecOptions<NodeName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends NodeSpec {
2221
- /**
2222
- * The name of the node type.
2223
- */
2224
- name: NodeName;
2225
- /**
2226
- * Whether this is the top-level node type. Only one node type can be the
2227
- * top-level node type in a schema.
2228
- */
2229
- topNode?: boolean;
2230
- /**
2231
- * The attributes that nodes of this type get.
2232
- */
2233
- attrs?: {
2234
- [key in keyof Attrs]: AttrSpec<Attrs[key]>;
2235
- };
2236
- }
2237
- export { NodeSpecOptions }
2238
- export { NodeSpecOptions as NodeSpecOptions_alias_1 }
2239
-
2240
- /**
2241
- * @internal
2242
- */
2243
- declare interface NodeTyping {
2244
- [name: string]: Record<string, any>;
2245
- }
2246
- export { NodeTyping }
2247
- export { NodeTyping as NodeTyping_alias_1 }
2248
-
2249
- /**
2250
- * @internal
2251
- */
2252
- declare type NodeViewComponentOptions<T> = {
2253
- group: string;
2254
- name: string;
2255
- args: T;
2256
- };
2257
- export { NodeViewComponentOptions }
2258
- export { NodeViewComponentOptions as NodeViewComponentOptions_alias_1 }
2259
-
2260
- /**
2261
- * @internal
2262
- */
2263
- declare type NodeViewFactoryOptions<T> = {
2264
- group: string;
2265
- factory: (args: T) => NodeViewConstructor;
2266
- };
2267
- export { NodeViewFactoryOptions }
2268
- export { NodeViewFactoryOptions as NodeViewFactoryOptions_alias_1 }
2269
-
2270
- declare interface NodeViewOptions {
2271
- name: string;
2272
- constructor: NodeViewConstructor;
2273
- }
2274
- export { NodeViewOptions }
2275
- export { NodeViewOptions as NodeViewOptions_alias_1 }
2276
-
2277
- /**
2278
- * @internal
2279
- */
2280
- declare const OBJECT_REPLACEMENT_CHARACTER = "\uFFFC";
2281
- export { OBJECT_REPLACEMENT_CHARACTER }
2282
- export { OBJECT_REPLACEMENT_CHARACTER as OBJECT_REPLACEMENT_CHARACTER_alias_1 }
2283
-
2284
- /**
2285
- * @internal
2286
- *
2287
- * @example
2288
- *
2289
- * ```
2290
- * type MyObject = { a: 1; b: 'B' }
2291
- * type MyEntries = ObjectEntries<MyObject>
2292
- * // ^ ["a", 1] | ["b", "B"]
2293
- */
2294
- export declare type ObjectEntries<T extends Record<string, any>> = {
2295
- [K in keyof T]: [K, T[K]];
2296
- }[keyof T];
2297
-
2298
- export declare function objectEqual<T>(a: T, b: T): boolean;
2299
-
2300
- /**
2301
- * @internal
2302
- *
2303
- * @deprecated Use the following import instead:
2304
- *
2305
- * ```ts
2306
- * import type { ParagraphExtension } from 'prosekit/extensions/paragraph'
2307
- * ```
2308
- */
2309
- declare type ParagraphExtension = ParagraphSpecExtension;
2310
- export { ParagraphExtension }
2311
- export { ParagraphExtension as ParagraphExtension_alias_1 }
2312
-
2313
- /**
2314
- * @internal
2315
- */
2316
- declare type ParagraphSpecExtension = Extension<{
2317
- Nodes: {
2318
- paragraph: Attrs;
2319
- };
2320
- }>;
2321
-
2322
- declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
2323
- export { PasteHandler }
2324
- export { PasteHandler as PasteHandler_alias_1 }
2325
-
2326
- /**
2327
- * @internal
2328
- */
2329
- export declare type Payloads<T> = Tuple5<T[]>;
2330
-
2331
- /**
2332
- * @internal
2333
- */
2334
- export declare type PickStringLiteral<T> = PickSubType<T, string>;
2335
-
2336
- /**
2337
- * @internal
2338
- */
2339
- declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
2340
- export { PickSubType }
2341
- export { PickSubType as PickSubType_alias_1 }
2342
-
2343
- /**
2344
- * An extension that does not define any nodes, marks, or commands.
2345
- *
2346
- * @internal
2347
- */
2348
- declare type PlainExtension = Extension<{
2349
- Nodes: never;
2350
- Marks: never;
2351
- Commands: never;
2352
- }>;
2353
- export { PlainExtension }
2354
- export { PlainExtension as PlainExtension_alias_1 }
2355
-
2356
- /**
2357
- * @internal
2358
- */
2359
- declare const pluginFacet: Facet<PluginPayload, StatePayload>;
2360
- export { pluginFacet }
2361
- export { pluginFacet as pluginFacet_alias_1 }
2362
-
2363
- /**
2364
- * @internal
2365
- */
2366
- declare type PluginPayload = Plugin_2 | Plugin_2[] | ((context: {
2367
- schema: Schema;
2368
- }) => Plugin_2 | Plugin_2[]);
2369
- export { PluginPayload }
2370
- export { PluginPayload as PluginPayload_alias_1 }
2371
-
2372
- /**
2373
- * ProseKit extension priority.
2374
- *
2375
- * @public
2376
- */
2377
- declare enum Priority {
2378
- lowest = 0,
2379
- low = 1,
2380
- default = 2,
2381
- high = 3,
2382
- highest = 4
2383
- }
2384
- export { Priority }
2385
- export { Priority as Priority_alias_1 }
2386
-
2387
- /**
2388
- * Base class for all ProseKit errors.
2389
- *
2390
- * @internal
2391
- */
2392
- declare class ProseKitError extends Error {
2393
- }
2394
- export { ProseKitError }
2395
- export { ProseKitError as ProseKitError_alias_1 }
2396
-
2397
- /**
2398
- * Returns a command that removes the given mark.
2399
- *
2400
- * @public
2401
- */
2402
- declare function removeMark(options: RemoveMarkOptions): Command;
2403
- export { removeMark }
2404
- export { removeMark as removeMark_alias_1 }
2405
-
2406
- /**
2407
- * @public
2408
- */
2409
- declare interface RemoveMarkOptions {
2410
- /**
2411
- * The type of the mark to remove.
2412
- */
2413
- type: string | MarkType;
2414
- /**
2415
- * If attrs is given, remove precisely the mark with the given attrs. Otherwise, remove all marks of the given type.
2416
- */
2417
- attrs?: Attrs | null;
2418
- /**
2419
- * The start position of the document. By default it will be the start position of current selection.
2420
- */
2421
- from?: number;
2422
- /**
2423
- * The end position of the document. By default it will be the end position of current selection.
2424
- */
2425
- to?: number;
2426
- }
2427
- export { RemoveMarkOptions }
2428
- export { RemoveMarkOptions as RemoveMarkOptions_alias_1 }
2429
-
2430
- /**
2431
- * Returns a command to remove the nearest ancestor node of a specific type from the current position.
2432
- *
2433
- * @public
2434
- */
2435
- declare function removeNode(options: RemoveNodeOptions): Command;
2436
- export { removeNode }
2437
- export { removeNode as removeNode_alias_1 }
2438
-
2439
- /**
2440
- * @public
2441
- */
2442
- declare interface RemoveNodeOptions {
2443
- /**
2444
- * The type of the node to remove.
2445
- */
2446
- type: string | NodeType;
2447
- /**
2448
- * The document position to start searching node. By default it will be the
2449
- * anchor position of current selection.
2450
- */
2451
- pos?: number;
2452
- }
2453
- export { RemoveNodeOptions }
2454
- export { RemoveNodeOptions as RemoveNodeOptions_alias_1 }
2455
-
2456
- export declare function removeUndefinedValues<T extends object>(obj: T): T;
2457
-
2458
- export declare const rootFacet: Facet<RootPayload, RootOutput>;
2459
-
2460
- export declare type RootOutput = {
2461
- schema?: Schema | null;
2462
- commands?: CommandCreators;
2463
- state?: EditorStateConfig;
2464
- view?: Omit<DirectEditorProps, 'state'>;
2465
- };
2466
-
2467
- export declare type RootPayload = {
2468
- schema?: Schema | null;
2469
- commands?: CommandCreators;
2470
- state?: (ctx: {
2471
- schema: Schema;
2472
- }) => EditorStateConfig;
2473
- view?: Omit<DirectEditorProps, 'state'>;
2474
- };
2475
-
2476
- export declare const schemaFacet: Facet<SchemaSpec, RootPayload>;
2477
-
2478
- export declare const schemaSpecFacet: Facet<SchemaSpec, SchemaSpec>;
2479
-
2480
- declare type ScrollToSelectionHandler = (view: EditorView) => boolean;
2481
- export { ScrollToSelectionHandler }
2482
- export { ScrollToSelectionHandler as ScrollToSelectionHandler_alias_1 }
2483
-
2484
- /**
2485
- * Returns a command that selects the whole document.
2486
- *
2487
- * @public
2488
- */
2489
- export declare function selectAll(): Command;
2490
-
2491
- /**
2492
- * A JSON representation of the prosemirror selection.
2493
- *
2494
- * @public
2495
- */
2496
- declare interface SelectionJSON {
2497
- anchor: number;
2498
- head: number;
2499
- type: string;
2500
- }
2501
- export { SelectionJSON }
2502
- export { SelectionJSON as SelectionJSON_alias_1 }
2503
-
2504
- declare type SerializeFragmentFunction = typeof DOMSerializer.prototype.serializeFragment;
2505
-
2506
- declare type SerializeNodeFunction = typeof DOMSerializer.prototype.serializeNode;
2507
-
2508
- /**
2509
- * Returns a command that tries to set the selected textblocks to the given node
2510
- * type with the given attributes.
2511
- *
2512
- * @public
2513
- */
2514
- declare function setBlockType(options: SetBlockTypeOptions): Command;
2515
- export { setBlockType }
2516
- export { setBlockType as setBlockType_alias_1 }
2517
-
2518
- /**
2519
- * @public
2520
- */
2521
- declare interface SetBlockTypeOptions {
2522
- type: NodeType | string;
2523
- attrs?: Attrs | null;
2524
- from?: number;
2525
- to?: number;
2526
- }
2527
- export { SetBlockTypeOptions }
2528
- export { SetBlockTypeOptions as SetBlockTypeOptions_alias_1 }
2529
-
2530
- /**
2531
- * Returns a command that set the attributes of the current node.
2532
- *
2533
- * @public
2534
- */
2535
- declare function setNodeAttrs(options: SetNodeAttrsOptions): Command;
2536
- export { setNodeAttrs }
2537
- export { setNodeAttrs as setNodeAttrs_alias_1 }
2538
-
2539
- /**
2540
- * @public
2541
- */
2542
- declare interface SetNodeAttrsOptions {
2543
- /**
2544
- * The type of node to set the attributes of.
2545
- *
2546
- * If current node is not of this type, the command will do nothing.
2547
- */
2548
- type: string | NodeType | string[] | NodeType[];
2549
- /**
2550
- * The attributes to set.
2551
- */
2552
- attrs: Attrs;
2553
- /**
2554
- * The position of the node. Defaults to the position of the wrapping node
2555
- * containing the current selection.
2556
- */
2557
- pos?: number;
2558
- }
2559
- export { SetNodeAttrsOptions }
2560
- export { SetNodeAttrsOptions as SetNodeAttrsOptions_alias_1 }
2561
-
2562
- declare function setSelectionAround(tr: Transaction, pos: number): void;
2563
- export { setSelectionAround }
2564
- export { setSelectionAround as setSelectionAround_alias_1 }
2565
-
2566
- /**
2567
- * @internal
2568
- */
2569
- export declare type Setter<T> = (value: T) => void;
2570
-
2571
- /**
2572
- * @internal
2573
- */
2574
- export declare function setupEditorExtension<E extends Extension>(options: EditorOptions<E>): E;
2575
-
2576
- /**
2577
- * @internal
2578
- */
2579
- declare type SimplifyDeeper<T> = {
2580
- [KeyType in keyof T]: Simplify<T[KeyType]>;
2581
- };
2582
- export { SimplifyDeeper }
2583
- export { SimplifyDeeper as SimplifyDeeper_alias_1 }
2584
-
2585
- /**
2586
- * @internal
2587
- */
2588
- declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
2589
- export { SimplifyUnion }
2590
- export { SimplifyUnion as SimplifyUnion_alias_1 }
2591
-
2592
- export declare const stateFacet: Facet<StatePayload, RootPayload>;
2593
-
2594
- /**
2595
- * Parse a JSON object to a ProseMirror state.
2596
- *
2597
- * @public
2598
- *
2599
- * @example
2600
- *
2601
- * ```ts
2602
- * const json = { state: { type: 'doc', content: [{ type: 'paragraph' }], selection: { type: 'text', from: 1, to: 1 } } }
2603
- * const state = stateFromJSON(json, { schema: editor.schema })
2604
- * ```
2605
- */
2606
- declare function stateFromJSON(json: StateJSON, options: JSONParserOptions): EditorState;
2607
- export { stateFromJSON }
2608
- export { stateFromJSON as stateFromJSON_alias_1 }
2609
-
2610
- /**
2611
- * A JSON representation of the prosemirror state.
2612
- *
2613
- * @public
2614
- */
2615
- declare interface StateJSON {
2616
- /**
2617
- * The main `ProseMirror` doc.
2618
- */
2619
- doc: NodeJSON;
2620
- /**
2621
- * The current selection.
2622
- */
2623
- selection: SelectionJSON;
2624
- }
2625
- export { StateJSON }
2626
- export { StateJSON as StateJSON_alias_1 }
2627
-
2628
- export declare type StatePayload = (ctx: {
2629
- schema: Schema;
2630
- }) => EditorStateConfig;
2631
-
2632
- /**
2633
- * A JSON representation of the prosemirror step.
2634
- *
2635
- * @public
2636
- */
2637
- declare interface StepJSON {
2638
- /**
2639
- * The type of the step.
2640
- */
2641
- stepType: string;
2642
- [x: string]: unknown;
2643
- }
2644
- export { StepJSON }
2645
- export { StepJSON as StepJSON_alias_1 }
2646
-
2647
- /**
2648
- * Takes two facet nodes and returns a new facet node containing inputs and
2649
- * children from the first node but not the second.
2650
- *
2651
- * The reducers of the first facet node will be reused.
2652
- *
2653
- * @internal
2654
- */
2655
- export declare function subtractFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
2656
-
2657
- export declare type TaggedProseMirrorNode = ProseMirrorNode & {
2658
- tags?: Tags;
2659
- };
2660
-
2661
- declare type Tags = Record<string, number>;
2662
-
2663
- /**
2664
- * An editor for testing purposes.
2665
- * @public
2666
- */
2667
- declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
2668
- constructor(instance: EditorInstance);
2669
- /**
2670
- * Set the editor state to the given document. You can use special tokens
2671
- * `<a>` and `<b>` to set the anchor and head positions of the selection.
2672
- *
2673
- * @example
2674
- *
2675
- * ```ts
2676
- * const editor = createTestEditor({ extension })
2677
- * const n = editor.nodes
2678
- * const doc = n.doc(n.paragraph('<a>Hello<b> world!'))
2679
- * editor.set(doc) // "Hello" is selected.
2680
- * ```
2681
- */
2682
- set(doc: ProseMirrorNode): void;
2683
- dispatchEvent(event: Event): void;
2684
- }
2685
- export { TestEditor }
2686
- export { TestEditor as TestEditor_alias_1 }
2687
-
2688
- /**
2689
- * @internal
2690
- */
2691
- declare type TextExtension = Extension<{
2692
- Nodes: {
2693
- text: Attrs;
2694
- };
2695
- }>;
2696
- export { TextExtension }
2697
- export { TextExtension as TextExtension_alias_1 }
2698
-
2699
- declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
2700
- export { TextInputHandler }
2701
- export { TextInputHandler as TextInputHandler_alias_1 }
2702
-
2703
- export declare type ToCommandAction<T extends CommandTyping> = {
2704
- [K in keyof T]: CommandAction<T[K]>;
2705
- };
2706
-
2707
- export declare type ToCommandCreators<T extends CommandTyping> = {
2708
- [K in keyof T]: CommandCreator<T[K]>;
2709
- };
2710
-
2711
- /**
2712
- * Returns a command that toggles the given mark with the given attributes.
2713
- *
2714
- * @param options
2715
- *
2716
- * @public
2717
- */
2718
- declare function toggleMark({ type, attrs, removeWhenPresent, enterInlineAtoms, }: ToggleMarkOptions): Command;
2719
- export { toggleMark }
2720
- export { toggleMark as toggleMark_alias_1 }
2721
-
2722
- /**
2723
- * @public
2724
- */
2725
- declare interface ToggleMarkOptions {
2726
- /**
2727
- * The mark type to toggle.
2728
- */
2729
- type: string | MarkType;
2730
- /**
2731
- * The optional attributes to set on the mark.
2732
- */
2733
- attrs?: Attrs | null;
2734
- /**
2735
- * Controls whether, when part of the selected range has the mark
2736
- * already and part doesn't, the mark is removed (`true`) or added
2737
- * (`false`).
2738
- *
2739
- * @default false
2740
- */
2741
- removeWhenPresent?: boolean;
2742
- /**
2743
- * Whether the command should act on the content of inline nodes marked as
2744
- * [atoms](https://prosemirror.net/docs/ref/#model.NodeSpec.atom) that are
2745
- * completely covered by a selection range.
2746
- *
2747
- * @default true
2748
- */
2749
- enterInlineAtoms?: boolean;
2750
- }
2751
- export { ToggleMarkOptions }
2752
- export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
2753
-
2754
- /**
2755
- * Returns a command that set the selected textblocks to the given node type
2756
- * with the given attributes.
2757
- *
2758
- * @param options
2759
- *
2760
- * @public
2761
- */
2762
- declare function toggleNode({ type, attrs }: ToggleNodeOptions): Command;
2763
- export { toggleNode }
2764
- export { toggleNode as toggleNode_alias_1 }
2765
-
2766
- /**
2767
- * @public
2768
- */
2769
- declare interface ToggleNodeOptions {
2770
- /**
2771
- * The type of the node to toggle.
2772
- */
2773
- type: string | NodeType;
2774
- /**
2775
- * The attributes of the node to toggle.
2776
- */
2777
- attrs?: Attrs | null;
2778
- }
2779
- export { ToggleNodeOptions }
2780
- export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
2781
-
2782
- /**
2783
- * Toggle between wrapping an inactive node with the provided node type, and
2784
- * lifting it up into it's parent.
2785
- *
2786
- * @param options
2787
- *
2788
- * @public
2789
- */
2790
- declare function toggleWrap(options: ToggleWrapOptions): Command;
2791
- export { toggleWrap }
2792
- export { toggleWrap as toggleWrap_alias_1 }
2793
-
2794
- declare interface ToggleWrapOptions {
2795
- /**
2796
- * The type of the node to toggle.
2797
- */
2798
- type: string | NodeType;
2799
- /**
2800
- * The attributes of the node to toggle.
2801
- */
2802
- attrs?: Attrs | null;
2803
- }
2804
- export { ToggleWrapOptions }
2805
- export { ToggleWrapOptions as ToggleWrapOptions_alias_1 }
2806
-
2807
- /**
2808
- * @internal
2809
- */
2810
- declare type ToMarkAction<T extends MarkTyping> = {
2811
- [K in keyof T]: MarkAction<T[K]>;
2812
- };
2813
- export { ToMarkAction }
2814
- export { ToMarkAction as ToMarkAction_alias_1 }
2815
-
2816
- /**
2817
- * @internal
2818
- */
2819
- declare type ToNodeAction<T extends NodeTyping> = {
2820
- [K in keyof T]: NodeAction<T[K]>;
2821
- };
2822
- export { ToNodeAction }
2823
- export { ToNodeAction as ToNodeAction_alias_1 }
2824
-
2825
- export declare function toReversed<T>(arr: T[]): T[];
2826
-
2827
- declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
2828
- export { TripleClickHandler }
2829
- export { TripleClickHandler as TripleClickHandler_alias_1 }
2830
-
2831
- declare type TripleClickOnHandler = (view: EditorView, pos: number, node: Node_2, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
2832
- export { TripleClickOnHandler }
2833
- export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
2834
-
2835
- /**
2836
- * @internal
2837
- */
2838
- export declare type Tuple5<T> = [T, T, T, T, T];
2839
-
2840
- /**
2841
- * @internal
2842
- */
2843
- declare type Union<E extends readonly Extension[]> = Extension<{
2844
- Nodes: ExtractNodes<E[number]>;
2845
- Marks: ExtractMarks<E[number]>;
2846
- Commands: ExtractCommands<E[number]>;
2847
- }>;
2848
- export { Union }
2849
- export { Union as Union_alias_1 }
2850
-
2851
- /**
2852
- * Merges multiple extensions into one. You can pass multiple extensions as
2853
- * arguments or a single array containing multiple extensions.
2854
- *
2855
- * @throws If no extensions are provided.
2856
- *
2857
- * @example
2858
- *
2859
- * ```ts
2860
- * function defineFancyNodes() {
2861
- * return union(
2862
- * defineFancyParagraph(),
2863
- * defineFancyHeading(),
2864
- * )
2865
- * }
2866
- * ```
2867
- *
2868
- * @example
2869
- *
2870
- * ```ts
2871
- * function defineFancyNodes() {
2872
- * return union([
2873
- * defineFancyParagraph(),
2874
- * defineFancyHeading(),
2875
- * ])
2876
- * }
2877
- * ```
2878
- *
2879
- * @public
2880
- */
2881
- declare function union<const E extends readonly Extension[]>(...exts: E): Union<E>;
2882
-
2883
- declare function union<const E extends readonly Extension[]>(exts: E): Union<E>;
2884
- export { union }
2885
- export { union as union_alias_1 }
2886
-
2887
- /**
2888
- * @deprecated Use `Union` instead.
2889
- * @internal
2890
- */
2891
- declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
2892
- Nodes: ExtractNodes<E[number]>;
2893
- Marks: ExtractMarks<E[number]>;
2894
- Commands: ExtractCommands<E[number]>;
2895
- }> : E;
2896
- export { UnionExtension }
2897
- export { UnionExtension as UnionExtension_alias_1 }
2898
-
2899
- export declare class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyping> extends BaseExtension<T> implements Extension<T> {
2900
- extension: BaseExtension[];
2901
- /**
2902
- * @internal
2903
- */
2904
- constructor(extension?: BaseExtension[]);
2905
- /**
2906
- * @internal
2907
- */
2908
- createTree(priority: Priority): FacetNode;
2909
- }
2910
-
2911
- /**
2912
- * Takes two facet nodes and returns a new facet node containing inputs and
2913
- * children from both nodes.
2914
- *
2915
- * The reducers of the first facet node will be reused.
2916
- *
2917
- * @internal
2918
- */
2919
- export declare function unionFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
2920
-
2921
- export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
2922
-
2923
- export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
2924
-
2925
- /**
2926
- * A function that is called when the editor view is unmounted.
2927
- *
2928
- * @public
2929
- */
2930
- declare type UnmountHandler = () => void;
2931
- export { UnmountHandler }
2932
- export { UnmountHandler as UnmountHandler_alias_1 }
2933
-
2934
- /**
2935
- * Returns a command that set the type of all textblocks between the given range
2936
- * to the default type (usually `paragraph`).
2937
- *
2938
- * @public
2939
- */
2940
- declare function unsetBlockType(options?: UnsetBlockTypeOptions): Command;
2941
- export { unsetBlockType }
2942
- export { unsetBlockType as unsetBlockType_alias_1 }
2943
-
2944
- /**
2945
- * @public
2946
- */
2947
- declare interface UnsetBlockTypeOptions {
2948
- /**
2949
- * The start position of the document. By default it will be the start position of current selection.
2950
- */
2951
- from?: number;
2952
- /**
2953
- * The end position of the document. By default it will be the end position of current selection.
2954
- */
2955
- to?: number;
2956
- }
2957
- export { UnsetBlockTypeOptions }
2958
- export { UnsetBlockTypeOptions as UnsetBlockTypeOptions_alias_1 }
2959
-
2960
- /**
2961
- * Returns a command that removes all marks.
2962
- *
2963
- * @public
2964
- */
2965
- declare function unsetMark(options?: UnsetMarkOptions): Command;
2966
- export { unsetMark }
2967
- export { unsetMark as unsetMark_alias_1 }
2968
-
2969
- /**
2970
- * @public
2971
- */
2972
- declare interface UnsetMarkOptions {
2973
- /**
2974
- * The start position of the document. By default it will be the start position of current selection.
2975
- */
2976
- from?: number;
2977
- /**
2978
- * The end position of the document. By default it will be the end position of current selection.
2979
- */
2980
- to?: number;
2981
- }
2982
- export { UnsetMarkOptions }
2983
- export { UnsetMarkOptions as UnsetMarkOptions_alias_1 }
2984
-
2985
- /**
2986
- * A function that is called when the editor state is updated.
2987
- *
2988
- * @param view - The editor view.
2989
- * @param prevState - The previous editor state.
2990
- *
2991
- * @public
2992
- */
2993
- declare type UpdateHandler = (view: EditorView, prevState: EditorState) => void;
2994
- export { UpdateHandler }
2995
- export { UpdateHandler as UpdateHandler_alias_1 }
2996
-
2997
- export declare const viewFacet: Facet<ViewPayload, RootPayload>;
2998
-
2999
- export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
3000
-
3001
- export declare function voidFunction(): void;
3002
-
3003
- /**
3004
- * Return an new extension with the given priority.
3005
- *
3006
- * @example
3007
- * ```ts
3008
- * import { Priority, withPriority } from 'prosekit/core'
3009
- *
3010
- * const extension = withPriority(defineMyExtension(), Priority.high)
3011
- * ```
3012
- *
3013
- * @public
3014
- */
3015
- declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
3016
- export { withPriority }
3017
- export { withPriority as withPriority_alias_1 }
3018
-
3019
- /**
3020
- * @internal
3021
- */
3022
- declare function withSkipCodeBlock(command: Command): Command;
3023
- export { withSkipCodeBlock }
3024
- export { withSkipCodeBlock as withSkipCodeBlock_alias_1 }
3025
-
3026
- /**
3027
- * Returns a command that wraps the selected textblock with the given node type.
3028
- *
3029
- * @param options
3030
- *
3031
- * @public
3032
- */
3033
- declare function wrap(options: WrapOptions): Command;
3034
- export { wrap }
3035
- export { wrap as wrap_alias_1 }
3036
-
3037
- /**
3038
- * @public
3039
- */
3040
- declare interface WrapOptions {
3041
- /**
3042
- * The node type to wrap the selected textblock with.
3043
- */
3044
- type: NodeType | string;
3045
- /**
3046
- * @deprecated Use `nodeSpec` instead.
3047
- */
3048
- nodeType?: NodeType;
3049
- /**
3050
- * Optional attributes to apply to the node.
3051
- */
3052
- attrs?: Attrs | null;
3053
- }
3054
- export { WrapOptions }
3055
- export { WrapOptions as WrapOptions_alias_1 }
3056
-
3057
- export declare function wrapOutputSpecAttrs<T extends ProseMirrorNode | Mark, Args extends readonly unknown[]>(toDOM: (node: T, ...args: Args) => DOMOutputSpec, options: AttrOptions[]): (node: T, ...args: Args) => DOMOutputSpec;
3058
-
3059
- export declare function wrapTagParseRuleAttrs(rule: TagParseRule, options: AttrOptions[]): TagParseRule;
3060
-
3061
- export declare function zip<T, P>(a: T[], b: P[]): [T, P][];
3062
-
3063
- export { }