@prosekit/core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.ts +293 -48
- package/dist/chunk-YWQGKV6X.js +863 -0
- package/dist/prosekit-core-test.d.ts +2 -0
- package/dist/prosekit-core-test.js +101 -0
- package/dist/prosekit-core.d.ts +6 -1
- package/dist/prosekit-core.js +81 -821
- package/package.json +12 -4
@@ -3,6 +3,7 @@ import { Attrs } from '@prosekit/pm/model';
|
|
3
3
|
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
4
4
|
import { Command } from '@prosekit/pm/state';
|
5
5
|
import type { ContentMatch } from '@prosekit/pm/model';
|
6
|
+
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
6
7
|
import type { DirectEditorProps } from '@prosekit/pm/view';
|
7
8
|
import type { DOMEventMap } from '@prosekit/pm/view';
|
8
9
|
import { DOMParser as DOMParser_2 } from '@prosekit/pm/model';
|
@@ -24,6 +25,7 @@ import { NodeType as NodeType_2 } from 'prosemirror-model';
|
|
24
25
|
import { NodeView } from '@prosekit/pm/view';
|
25
26
|
import { NodeViewConstructor } from '@prosekit/pm/view';
|
26
27
|
import { Options } from 'tsup';
|
28
|
+
import type { ParseOptions } from '@prosekit/pm/model';
|
27
29
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
28
30
|
import { ProseMirrorFragment } from '@prosekit/pm/model';
|
29
31
|
import { ProseMirrorNode } from '@prosekit/pm/model';
|
@@ -71,6 +73,13 @@ export { addMark as addMark_alias_1 }
|
|
71
73
|
|
72
74
|
export declare function applyAction(operator: Action): Command;
|
73
75
|
|
76
|
+
export declare const applyMarkForTest: ApplyMarkFunction;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* @internal
|
80
|
+
*/
|
81
|
+
export declare type ApplyMarkFunction = (mark: Mark, children: ProseMirrorNode[]) => ProseMirrorNode[];
|
82
|
+
|
74
83
|
/**
|
75
84
|
* @internal
|
76
85
|
*/
|
@@ -148,6 +157,8 @@ export declare function baseToggleMark(markType: MarkType, attrs?: Attrs | null,
|
|
148
157
|
removeWhenPresent: boolean;
|
149
158
|
}): Command;
|
150
159
|
|
160
|
+
export declare function buildNode(type: NodeType, args: [Attrs | NodeChild | null | undefined, ...NodeChild[]], createNode: CreateNodeFunction): ProseMirrorNode;
|
161
|
+
|
151
162
|
export declare function cache<T>(fn: () => T): () => T;
|
152
163
|
|
153
164
|
declare const canUseRegexLookbehind: () => boolean;
|
@@ -173,7 +184,14 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
|
|
173
184
|
export { clsx }
|
174
185
|
export { clsx as clsx_alias_1 }
|
175
186
|
|
176
|
-
|
187
|
+
/**
|
188
|
+
* Collects all nodes from a given content.
|
189
|
+
*
|
190
|
+
* @public
|
191
|
+
*/
|
192
|
+
declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
193
|
+
export { collectNodes }
|
194
|
+
export { collectNodes as collectNodes_alias_1 }
|
177
195
|
|
178
196
|
export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
|
179
197
|
|
@@ -208,19 +226,35 @@ declare function createEditor<E extends Extension>(options: EditorOptions<E>): E
|
|
208
226
|
export { createEditor }
|
209
227
|
export { createEditor as createEditor_alias_1 }
|
210
228
|
|
211
|
-
|
229
|
+
/**
|
230
|
+
* @internal
|
231
|
+
*/
|
232
|
+
export declare function createMarkBuilders(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkBuilder>;
|
233
|
+
|
234
|
+
/**
|
235
|
+
* @internal
|
236
|
+
*/
|
237
|
+
export declare function createNodeBuilders(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeBuilder>;
|
238
|
+
|
239
|
+
export declare const createNodeForTest: CreateNodeFunction;
|
212
240
|
|
213
|
-
|
241
|
+
/**
|
242
|
+
* @internal
|
243
|
+
*/
|
244
|
+
export declare type CreateNodeFunction = (type: NodeType, attrs: Attrs | null, children: ProseMirrorNode[]) => ProseMirrorNode;
|
245
|
+
|
246
|
+
/**
|
247
|
+
* @public
|
248
|
+
*/
|
249
|
+
declare function createTestEditor<E extends Extension>(options: EditorOptions<E>): TestEditor<E>;
|
250
|
+
export { createTestEditor }
|
251
|
+
export { createTestEditor as createTestEditor_alias_1 }
|
214
252
|
|
215
253
|
export declare function deepEquals<T>(a: T, b: T): boolean;
|
216
254
|
|
217
255
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
218
256
|
|
219
|
-
export
|
220
|
-
test: {
|
221
|
-
environment: "jsdom";
|
222
|
-
};
|
223
|
-
};
|
257
|
+
export { default_alias_1 }
|
224
258
|
|
225
259
|
/**
|
226
260
|
* @internal
|
@@ -323,7 +357,7 @@ declare function defineBaseKeymap(options?: {
|
|
323
357
|
* @default Priority.low
|
324
358
|
*/
|
325
359
|
priority?: Priority;
|
326
|
-
}): Extension<any
|
360
|
+
}): Extension<ExtensionTyping<any, any, any>>;
|
327
361
|
export { defineBaseKeymap }
|
328
362
|
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
329
363
|
|
@@ -332,7 +366,7 @@ export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
|
332
366
|
*
|
333
367
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClick}
|
334
368
|
*/
|
335
|
-
declare function defineClickHandler(handler: ClickHandler): Extension<any
|
369
|
+
declare function defineClickHandler(handler: ClickHandler): Extension<ExtensionTyping<any, any, any>>;
|
336
370
|
export { defineClickHandler }
|
337
371
|
export { defineClickHandler as defineClickHandler_alias_1 }
|
338
372
|
|
@@ -341,7 +375,7 @@ export { defineClickHandler as defineClickHandler_alias_1 }
|
|
341
375
|
*
|
342
376
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn}
|
343
377
|
*/
|
344
|
-
declare function defineClickOnHandler(handler: ClickOnHandler): Extension<any
|
378
|
+
declare function defineClickOnHandler(handler: ClickOnHandler): Extension<ExtensionTyping<any, any, any>>;
|
345
379
|
export { defineClickOnHandler }
|
346
380
|
export { defineClickOnHandler as defineClickOnHandler_alias_1 }
|
347
381
|
|
@@ -375,7 +409,7 @@ export { defineDoc as defineDoc_alias_1 }
|
|
375
409
|
*
|
376
410
|
* @public
|
377
411
|
*/
|
378
|
-
declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<any
|
412
|
+
declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<any, any, any>>;
|
379
413
|
export { defineDocChangeHandler }
|
380
414
|
export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
|
381
415
|
|
@@ -384,7 +418,7 @@ export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
|
|
384
418
|
*
|
385
419
|
* @public
|
386
420
|
*/
|
387
|
-
declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<any
|
421
|
+
declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<ExtensionTyping<any, any, any>>;
|
388
422
|
export { defineDOMEventHandler }
|
389
423
|
export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
|
390
424
|
|
@@ -393,7 +427,7 @@ export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
|
|
393
427
|
*
|
394
428
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick}
|
395
429
|
*/
|
396
|
-
declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<any
|
430
|
+
declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<ExtensionTyping<any, any, any>>;
|
397
431
|
export { defineDoubleClickHandler }
|
398
432
|
export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
|
399
433
|
|
@@ -402,7 +436,7 @@ export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
|
|
402
436
|
*
|
403
437
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn}
|
404
438
|
*/
|
405
|
-
declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<any
|
439
|
+
declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<ExtensionTyping<any, any, any>>;
|
406
440
|
export { defineDoubleClickOnHandler }
|
407
441
|
export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
|
408
442
|
|
@@ -411,7 +445,7 @@ export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
|
|
411
445
|
*
|
412
446
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop}
|
413
447
|
*/
|
414
|
-
declare function defineDropHandler(handler: DropHandler): Extension<any
|
448
|
+
declare function defineDropHandler(handler: DropHandler): Extension<ExtensionTyping<any, any, any>>;
|
415
449
|
export { defineDropHandler }
|
416
450
|
export { defineDropHandler as defineDropHandler_alias_1 }
|
417
451
|
|
@@ -454,7 +488,7 @@ export { defineFacetPayload as defineFacetPayload_alias_1 }
|
|
454
488
|
*
|
455
489
|
* @public
|
456
490
|
*/
|
457
|
-
declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<any
|
491
|
+
declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<ExtensionTyping<any, any, any>>;
|
458
492
|
export { defineFocusChangeHandler }
|
459
493
|
export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
|
460
494
|
|
@@ -462,10 +496,11 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
|
|
462
496
|
* Add undo/redo history to the editor.
|
463
497
|
*/
|
464
498
|
declare function defineHistory(): Extension< {
|
465
|
-
Nodes:
|
466
|
-
Marks:
|
499
|
+
Nodes: never;
|
500
|
+
Marks: never;
|
467
501
|
Commands: {
|
468
|
-
|
502
|
+
undo: [];
|
503
|
+
redo: [];
|
469
504
|
};
|
470
505
|
}>;
|
471
506
|
export { defineHistory }
|
@@ -476,7 +511,7 @@ export { defineHistory as defineHistory_alias_1 }
|
|
476
511
|
*
|
477
512
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
|
478
513
|
*/
|
479
|
-
declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<any
|
514
|
+
declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<any, any, any>>;
|
480
515
|
export { defineKeyDownHandler }
|
481
516
|
export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
|
482
517
|
|
@@ -492,7 +527,7 @@ export { defineKeymap as defineKeymap_alias_1 }
|
|
492
527
|
*
|
493
528
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress}
|
494
529
|
*/
|
495
|
-
declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<any
|
530
|
+
declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<ExtensionTyping<any, any, any>>;
|
496
531
|
export { defineKeyPressHandler }
|
497
532
|
export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
|
498
533
|
|
@@ -519,7 +554,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
|
|
519
554
|
*
|
520
555
|
* @public
|
521
556
|
*/
|
522
|
-
declare function defineMountHandler(handler: MountHandler): Extension<any
|
557
|
+
declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<any, any, any>>;
|
523
558
|
export { defineMountHandler }
|
524
559
|
export { defineMountHandler as defineMountHandler_alias_1 }
|
525
560
|
|
@@ -585,7 +620,7 @@ Commands: never;
|
|
585
620
|
*
|
586
621
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste}
|
587
622
|
*/
|
588
|
-
declare function definePasteHandler(handler: PasteHandler): Extension<any
|
623
|
+
declare function definePasteHandler(handler: PasteHandler): Extension<ExtensionTyping<any, any, any>>;
|
589
624
|
export { definePasteHandler }
|
590
625
|
export { definePasteHandler as definePasteHandler_alias_1 }
|
591
626
|
|
@@ -608,10 +643,70 @@ export { definePlugin as definePlugin_alias_1 }
|
|
608
643
|
*
|
609
644
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection}
|
610
645
|
*/
|
611
|
-
declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<any
|
646
|
+
declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<ExtensionTyping<any, any, any>>;
|
612
647
|
export { defineScrollToSelectionHandler }
|
613
648
|
export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_1 }
|
614
649
|
|
650
|
+
/**
|
651
|
+
* @internal
|
652
|
+
*/
|
653
|
+
export declare function defineTestExtension(): Extension< {
|
654
|
+
Nodes: "text" | "doc" | "paragraph";
|
655
|
+
Marks: "bold";
|
656
|
+
Commands: {
|
657
|
+
undo: [];
|
658
|
+
redo: [];
|
659
|
+
insertText: [{
|
660
|
+
text: string;
|
661
|
+
from?: number;
|
662
|
+
to?: number;
|
663
|
+
}];
|
664
|
+
insertNode: [options: {
|
665
|
+
node: Node_2;
|
666
|
+
pos?: number;
|
667
|
+
type?: undefined;
|
668
|
+
attrs?: undefined;
|
669
|
+
} | {
|
670
|
+
node?: undefined;
|
671
|
+
pos?: number;
|
672
|
+
type: string;
|
673
|
+
attrs?: Attrs_2;
|
674
|
+
}];
|
675
|
+
removeNode: [options: {
|
676
|
+
type: string | NodeType_2;
|
677
|
+
pos?: number;
|
678
|
+
}];
|
679
|
+
wrap: [{
|
680
|
+
nodeType: NodeType_2;
|
681
|
+
attrs?: Attrs_2 | null;
|
682
|
+
}];
|
683
|
+
setBlockType: [options: {
|
684
|
+
type: NodeType_2 | string;
|
685
|
+
attrs?: Attrs_2 | null;
|
686
|
+
from?: number;
|
687
|
+
to?: number;
|
688
|
+
}];
|
689
|
+
setNodeAttrs: [options: {
|
690
|
+
type: string | NodeType_2 | string[] | NodeType_2[];
|
691
|
+
attrs: Attrs_2;
|
692
|
+
pos?: number;
|
693
|
+
}];
|
694
|
+
selectAll: [];
|
695
|
+
addMark: [options: {
|
696
|
+
type: string | MarkType_2;
|
697
|
+
attrs?: Attrs_2 | null;
|
698
|
+
from?: number;
|
699
|
+
to?: number;
|
700
|
+
}];
|
701
|
+
removeMark: [options: {
|
702
|
+
type: string | MarkType_2;
|
703
|
+
attrs?: Attrs_2 | null;
|
704
|
+
from?: number;
|
705
|
+
to?: number;
|
706
|
+
}];
|
707
|
+
};
|
708
|
+
}>;
|
709
|
+
|
615
710
|
/**
|
616
711
|
* @public
|
617
712
|
*/
|
@@ -628,7 +723,7 @@ export { defineText as defineText_alias_1 }
|
|
628
723
|
*
|
629
724
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput}
|
630
725
|
*/
|
631
|
-
declare function defineTextInputHandler(handler: TextInputHandler): Extension<any
|
726
|
+
declare function defineTextInputHandler(handler: TextInputHandler): Extension<ExtensionTyping<any, any, any>>;
|
632
727
|
export { defineTextInputHandler }
|
633
728
|
export { defineTextInputHandler as defineTextInputHandler_alias_1 }
|
634
729
|
|
@@ -637,7 +732,7 @@ export { defineTextInputHandler as defineTextInputHandler_alias_1 }
|
|
637
732
|
*
|
638
733
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick}
|
639
734
|
*/
|
640
|
-
declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<any
|
735
|
+
declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<ExtensionTyping<any, any, any>>;
|
641
736
|
export { defineTripleClickHandler }
|
642
737
|
export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
|
643
738
|
|
@@ -646,7 +741,7 @@ export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
|
|
646
741
|
*
|
647
742
|
* See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn}
|
648
743
|
*/
|
649
|
-
declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<any
|
744
|
+
declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<ExtensionTyping<any, any, any>>;
|
650
745
|
export { defineTripleClickOnHandler }
|
651
746
|
export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
|
652
747
|
|
@@ -655,7 +750,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
|
|
655
750
|
*
|
656
751
|
* @public
|
657
752
|
*/
|
658
|
-
declare function defineUnmountHandler(handler: UnmountHandler): Extension<any
|
753
|
+
declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<any, any, any>>;
|
659
754
|
export { defineUnmountHandler }
|
660
755
|
export { defineUnmountHandler as defineUnmountHandler_alias_1 }
|
661
756
|
|
@@ -664,7 +759,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
|
|
664
759
|
*
|
665
760
|
* @public
|
666
761
|
*/
|
667
|
-
declare function defineUpdateHandler(handler: UpdateHandler): Extension<any
|
762
|
+
declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<any, any, any>>;
|
668
763
|
export { defineUpdateHandler }
|
669
764
|
export { defineUpdateHandler as defineUpdateHandler_alias_1 }
|
670
765
|
|
@@ -688,9 +783,9 @@ export declare class DOMDocumentNotFoundError extends ProseKitError {
|
|
688
783
|
}
|
689
784
|
|
690
785
|
/** @public */
|
691
|
-
declare
|
786
|
+
declare interface DOMDocumentOptions {
|
692
787
|
document?: Document;
|
693
|
-
}
|
788
|
+
}
|
694
789
|
export { DOMDocumentOptions }
|
695
790
|
export { DOMDocumentOptions as DOMDocumentOptions_alias_1 }
|
696
791
|
|
@@ -719,16 +814,16 @@ export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
|
|
719
814
|
export declare type DOMNode = InstanceType<typeof window.Node>;
|
720
815
|
|
721
816
|
/** @public */
|
722
|
-
declare
|
817
|
+
declare interface DOMParserOptions extends ParseOptions {
|
723
818
|
DOMParser?: typeof DOMParser_2;
|
724
|
-
}
|
819
|
+
}
|
725
820
|
export { DOMParserOptions }
|
726
821
|
export { DOMParserOptions as DOMParserOptions_alias_1 }
|
727
822
|
|
728
823
|
/** @public */
|
729
|
-
declare
|
824
|
+
declare interface DOMSerializerOptions {
|
730
825
|
DOMSerializer?: typeof DOMSerializer;
|
731
|
-
}
|
826
|
+
}
|
732
827
|
export { DOMSerializerOptions }
|
733
828
|
export { DOMSerializerOptions as DOMSerializerOptions_alias_1 }
|
734
829
|
|
@@ -749,8 +844,11 @@ export { DropHandler as DropHandler_alias_1 }
|
|
749
844
|
*/
|
750
845
|
declare class Editor<E extends Extension = any> {
|
751
846
|
private instance;
|
752
|
-
private constructor();
|
753
847
|
private afterMounted;
|
848
|
+
/**
|
849
|
+
* @internal
|
850
|
+
*/
|
851
|
+
constructor(instance: EditorInstance);
|
754
852
|
/**
|
755
853
|
* @internal
|
756
854
|
*/
|
@@ -767,6 +865,9 @@ declare class Editor<E extends Extension = any> {
|
|
767
865
|
* The editor schema.
|
768
866
|
*/
|
769
867
|
get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
|
868
|
+
/**
|
869
|
+
* All commands defined by the editor.
|
870
|
+
*/
|
770
871
|
get commands(): ExtractCommandAppliers<E>;
|
771
872
|
/**
|
772
873
|
* Whether the editor is focused.
|
@@ -789,14 +890,55 @@ declare class Editor<E extends Extension = any> {
|
|
789
890
|
* Blur the editor.
|
790
891
|
*/
|
791
892
|
blur(): void;
|
893
|
+
/**
|
894
|
+
* Register an extension to the editor. Return a function to unregister the
|
895
|
+
* extension.
|
896
|
+
*/
|
792
897
|
use(extension: Extension): VoidFunction;
|
898
|
+
/**
|
899
|
+
* The editor's current state.
|
900
|
+
*/
|
793
901
|
get state(): EditorState;
|
902
|
+
/**
|
903
|
+
* Update the editor's state.
|
904
|
+
*
|
905
|
+
* @remarks
|
906
|
+
*
|
907
|
+
* This is an advanced method. Use it only if you have a specific reason to
|
908
|
+
* directly manipulate the editor's state.
|
909
|
+
*/
|
910
|
+
updateState(state: EditorState): void;
|
794
911
|
get nodes(): Record<ExtractNodes<E>, NodeBuilder>;
|
795
912
|
get marks(): Record<ExtractMarks<E>, MarkBuilder>;
|
796
913
|
}
|
797
914
|
export { Editor }
|
798
915
|
export { Editor as Editor_alias_1 }
|
799
916
|
|
917
|
+
/**
|
918
|
+
* @internal
|
919
|
+
*/
|
920
|
+
export declare class EditorInstance {
|
921
|
+
view: EditorView | null;
|
922
|
+
schema: Schema;
|
923
|
+
nodeBuilders: Record<string, NodeBuilder>;
|
924
|
+
markBuilders: Record<string, MarkBuilder>;
|
925
|
+
commandAppliers: Record<string, CommandApplier>;
|
926
|
+
private tree;
|
927
|
+
private directEditorProps;
|
928
|
+
constructor(extension: Extension);
|
929
|
+
getState: () => EditorState;
|
930
|
+
updateState(state: EditorState): void;
|
931
|
+
updateExtension(extension: Extension, add: boolean): void;
|
932
|
+
mount(place: HTMLElement): void;
|
933
|
+
unmount(): void;
|
934
|
+
get mounted(): boolean;
|
935
|
+
get assertView(): EditorView;
|
936
|
+
definePlugins(plugins: readonly Plugin_2[]): void;
|
937
|
+
removePlugins(plugins: readonly Plugin_2[]): void;
|
938
|
+
defineCommand<Args extends any[] = any[]>(name: string, commandCreator: CommandCreator<Args>): void;
|
939
|
+
removeCommand(name: string): void;
|
940
|
+
}
|
941
|
+
|
800
942
|
/**
|
801
943
|
* @internal
|
802
944
|
*/
|
@@ -875,7 +1017,7 @@ export { expandMark as expandMark_alias_1 }
|
|
875
1017
|
/**
|
876
1018
|
* @public
|
877
1019
|
*/
|
878
|
-
declare interface Extension<T extends ExtensionTyping<any, any, any> = any
|
1020
|
+
declare interface Extension<T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>> {
|
879
1021
|
extension: Extension | Extension[];
|
880
1022
|
priority?: Priority;
|
881
1023
|
_type?: T;
|
@@ -933,10 +1075,12 @@ declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes'];
|
|
933
1075
|
export { ExtractNodes }
|
934
1076
|
export { ExtractNodes as ExtractNodes_alias_1 }
|
935
1077
|
|
1078
|
+
export declare function extractTags(node: TaggedProseMirrorNode): Record<string, number>;
|
1079
|
+
|
936
1080
|
/**
|
937
1081
|
* @internal
|
938
1082
|
*/
|
939
|
-
export declare type ExtractTyping<E extends Extension> = E extends Extension<infer
|
1083
|
+
export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickStringLiteral<N>, PickStringLiteral<M>, PickKnownCommandTyping<C>> : never;
|
940
1084
|
|
941
1085
|
/**
|
942
1086
|
* @internal
|
@@ -1243,9 +1387,9 @@ export { jsonFromState }
|
|
1243
1387
|
export { jsonFromState as jsonFromState_alias_1 }
|
1244
1388
|
|
1245
1389
|
/** @public */
|
1246
|
-
declare
|
1390
|
+
declare interface JSONParserOptions {
|
1247
1391
|
schema: Schema;
|
1248
|
-
}
|
1392
|
+
}
|
1249
1393
|
export { JSONParserOptions }
|
1250
1394
|
export { JSONParserOptions as JSONParserOptions_alias_1 }
|
1251
1395
|
|
@@ -1310,11 +1454,16 @@ declare interface MarkAttrOptions {
|
|
1310
1454
|
export { MarkAttrOptions }
|
1311
1455
|
export { MarkAttrOptions as MarkAttrOptions_alias_1 }
|
1312
1456
|
|
1313
|
-
|
1457
|
+
/**
|
1458
|
+
* @public
|
1459
|
+
*/
|
1460
|
+
declare interface MarkBuilder {
|
1314
1461
|
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
|
1315
1462
|
(...children: NodeChild[]): ProseMirrorNode[];
|
1316
|
-
isActive(attrs?: Attrs)
|
1463
|
+
isActive: (attrs?: Attrs) => boolean;
|
1317
1464
|
}
|
1465
|
+
export { MarkBuilder }
|
1466
|
+
export { MarkBuilder as MarkBuilder_alias_1 }
|
1318
1467
|
|
1319
1468
|
/**
|
1320
1469
|
* @public
|
@@ -1384,15 +1533,28 @@ declare interface NodeAttrOptions {
|
|
1384
1533
|
export { NodeAttrOptions }
|
1385
1534
|
export { NodeAttrOptions as NodeAttrOptions_alias_1 }
|
1386
1535
|
|
1387
|
-
|
1536
|
+
/**
|
1537
|
+
* @public
|
1538
|
+
*/
|
1539
|
+
declare interface NodeBuilder {
|
1388
1540
|
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
|
1389
1541
|
(...children: NodeChild[]): ProseMirrorNode;
|
1390
|
-
isActive(attrs?: Attrs)
|
1542
|
+
isActive: (attrs?: Attrs) => boolean;
|
1391
1543
|
}
|
1544
|
+
export { NodeBuilder }
|
1545
|
+
export { NodeBuilder as NodeBuilder_alias_1 }
|
1392
1546
|
|
1547
|
+
/**
|
1548
|
+
* @public
|
1549
|
+
*/
|
1393
1550
|
export declare type NodeChild = ProseMirrorNode | string | NodeChild[];
|
1394
1551
|
|
1395
|
-
|
1552
|
+
/**
|
1553
|
+
* @public
|
1554
|
+
*/
|
1555
|
+
declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
|
1556
|
+
export { NodeContent }
|
1557
|
+
export { NodeContent as NodeContent_alias_1 }
|
1396
1558
|
|
1397
1559
|
/**
|
1398
1560
|
* Parse a HTML element to a ProseMirror node.
|
@@ -1501,6 +1663,18 @@ export { PasteHandler as PasteHandler_alias_1 }
|
|
1501
1663
|
*/
|
1502
1664
|
export declare type Payloads<T> = Tuple5<T[]>;
|
1503
1665
|
|
1666
|
+
/**
|
1667
|
+
* @internal
|
1668
|
+
*/
|
1669
|
+
export declare type PickKnownCommandTyping<T extends CommandTyping> = [
|
1670
|
+
CommandTyping
|
1671
|
+
] extends [T] ? never : T;
|
1672
|
+
|
1673
|
+
/**
|
1674
|
+
* @internal
|
1675
|
+
*/
|
1676
|
+
export declare type PickStringLiteral<T extends string> = [string] extends [T] ? never : T;
|
1677
|
+
|
1504
1678
|
/**
|
1505
1679
|
* @internal
|
1506
1680
|
*/
|
@@ -1679,6 +1853,11 @@ export declare function setSelectionAround(tr: Transaction, pos: number): void;
|
|
1679
1853
|
*/
|
1680
1854
|
export declare type Setter<T> = (value: T) => void;
|
1681
1855
|
|
1856
|
+
/**
|
1857
|
+
* @internal
|
1858
|
+
*/
|
1859
|
+
export declare function setupEditorExtension<E extends Extension>(options: EditorOptions<E>): E;
|
1860
|
+
|
1682
1861
|
/**
|
1683
1862
|
* @internal
|
1684
1863
|
*/
|
@@ -1719,6 +1898,21 @@ export declare type StatePayload = (ctx: {
|
|
1719
1898
|
schema: Schema;
|
1720
1899
|
}) => EditorStateConfig;
|
1721
1900
|
|
1901
|
+
/**
|
1902
|
+
* A JSON representation of the prosemirror step.
|
1903
|
+
*
|
1904
|
+
* @public
|
1905
|
+
*/
|
1906
|
+
declare interface StepJSON {
|
1907
|
+
/**
|
1908
|
+
* The type of the step.
|
1909
|
+
*/
|
1910
|
+
stepType: string;
|
1911
|
+
[x: string]: unknown;
|
1912
|
+
}
|
1913
|
+
export { StepJSON }
|
1914
|
+
export { StepJSON as StepJSON_alias_1 }
|
1915
|
+
|
1722
1916
|
/**
|
1723
1917
|
* Takes two facet nodes and returns a new facet node containing inputs and
|
1724
1918
|
* children from the first node but not the second.
|
@@ -1729,6 +1923,37 @@ export declare type StatePayload = (ctx: {
|
|
1729
1923
|
*/
|
1730
1924
|
export declare function subtractFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
|
1731
1925
|
|
1926
|
+
export declare type TaggedProseMirrorNode = ProseMirrorNode & {
|
1927
|
+
tags?: Tags;
|
1928
|
+
};
|
1929
|
+
|
1930
|
+
declare type Tags = Record<string, number>;
|
1931
|
+
|
1932
|
+
/**
|
1933
|
+
* An editor for testing purposes.
|
1934
|
+
* @public
|
1935
|
+
*/
|
1936
|
+
declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
|
1937
|
+
constructor(instance: EditorInstance);
|
1938
|
+
/**
|
1939
|
+
* Set the editor state to the given document. You can use special tokens
|
1940
|
+
* `<a>` and `<b>` to set the anchor and head positions of the selection.
|
1941
|
+
*
|
1942
|
+
* @example
|
1943
|
+
*
|
1944
|
+
* ```ts
|
1945
|
+
* const editor = createTestEditor({ extension })
|
1946
|
+
* const n = editor.nodes
|
1947
|
+
* const doc = n.doc(n.paragraph('<a>Hello<b> world!'))
|
1948
|
+
* editor.set(doc) // "Hello" is selected.
|
1949
|
+
* ```
|
1950
|
+
*/
|
1951
|
+
set(doc: ProseMirrorNode): void;
|
1952
|
+
dispatchEvent(event: Event): void;
|
1953
|
+
}
|
1954
|
+
export { TestEditor }
|
1955
|
+
export { TestEditor as TestEditor_alias_1 }
|
1956
|
+
|
1732
1957
|
declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
|
1733
1958
|
export { TextInputHandler }
|
1734
1959
|
export { TextInputHandler as TextInputHandler_alias_1 }
|
@@ -1786,16 +2011,27 @@ export declare type Tuple5<T> = [T, T, T, T, T];
|
|
1786
2011
|
*
|
1787
2012
|
* @throws If no extensions are provided.
|
1788
2013
|
*
|
2014
|
+
* @example
|
2015
|
+
*
|
2016
|
+
* ```ts
|
2017
|
+
* function defineFancyNodes() {
|
2018
|
+
* return union([
|
2019
|
+
* defineFancyParagraph(),
|
2020
|
+
* defineFancyHeading(),
|
2021
|
+
* ])
|
2022
|
+
* }
|
2023
|
+
* ```
|
2024
|
+
*
|
1789
2025
|
* @public
|
1790
2026
|
*/
|
1791
|
-
declare function union<E extends Extension | Extension[]>(extension: E): UnionExtension<E>;
|
2027
|
+
declare function union<const E extends Extension | readonly Extension[]>(extension: E): UnionExtension<E>;
|
1792
2028
|
export { union }
|
1793
2029
|
export { union as union_alias_1 }
|
1794
2030
|
|
1795
2031
|
/**
|
1796
2032
|
* @internal
|
1797
2033
|
*/
|
1798
|
-
declare type UnionExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<{
|
2034
|
+
declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
|
1799
2035
|
Nodes: ExtractNodes<E[number]>;
|
1800
2036
|
Marks: ExtractMarks<E[number]>;
|
1801
2037
|
Commands: ExtractCommands<E[number]>;
|
@@ -1857,6 +2093,15 @@ export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
|
|
1857
2093
|
export declare function voidFunction(): void;
|
1858
2094
|
|
1859
2095
|
/**
|
2096
|
+
* Return an new extension with the given priority.
|
2097
|
+
*
|
2098
|
+
* @example
|
2099
|
+
* ```ts
|
2100
|
+
* import { Priority, withPriority } from 'prosekit/core'
|
2101
|
+
*
|
2102
|
+
* const extension = withPriority(defineMyExtension(), Priority.high)
|
2103
|
+
* ```
|
2104
|
+
*
|
1860
2105
|
* @public
|
1861
2106
|
*/
|
1862
2107
|
declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
|