@prosekit/core 0.7.5 → 0.7.7
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 +266 -174
- package/dist/{chunk-M267LRMB.js → chunk-MDJ2B4IL.js} +238 -170
- package/dist/prosekit-core-test.js +13 -19
- package/dist/prosekit-core.d.ts +9 -0
- package/dist/prosekit-core.js +38 -45
- package/package.json +5 -4
@@ -1,6 +1,5 @@
|
|
1
1
|
import { AllSelection } from '@prosekit/pm/state';
|
2
2
|
import { Attrs } from '@prosekit/pm/model';
|
3
|
-
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
4
3
|
import { Command } from '@prosekit/pm/state';
|
5
4
|
import type { ContentMatch } from '@prosekit/pm/model';
|
6
5
|
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
@@ -148,6 +147,27 @@ declare type AttrSpec<AttrType = any> = {
|
|
148
147
|
export { AttrSpec }
|
149
148
|
export { AttrSpec as AttrSpec_alias_1 }
|
150
149
|
|
150
|
+
/**
|
151
|
+
* @internal
|
152
|
+
*/
|
153
|
+
declare type BaseCommandsExtension = Extension<{
|
154
|
+
Commands: {
|
155
|
+
insertText: [options: InsertTextOptions];
|
156
|
+
insertNode: [options: InsertNodeOptions];
|
157
|
+
removeNode: [options: RemoveNodeOptions];
|
158
|
+
wrap: [options: WrapOptions];
|
159
|
+
setBlockType: [options: SetBlockTypeOptions];
|
160
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
161
|
+
selectAll: [];
|
162
|
+
addMark: [options: AddMarkOptions];
|
163
|
+
removeMark: [options: RemoveMarkOptions];
|
164
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions];
|
165
|
+
unsetMark: [options?: UnsetMarkOptions];
|
166
|
+
};
|
167
|
+
}>;
|
168
|
+
export { BaseCommandsExtension }
|
169
|
+
export { BaseCommandsExtension as BaseCommandsExtension_alias_1 }
|
170
|
+
|
151
171
|
/**
|
152
172
|
* @internal
|
153
173
|
*/
|
@@ -171,6 +191,13 @@ export declare abstract class BaseExtension<T extends ExtensionTyping = Extensio
|
|
171
191
|
get schema(): Schema | null;
|
172
192
|
}
|
173
193
|
|
194
|
+
/**
|
195
|
+
* @internal
|
196
|
+
*/
|
197
|
+
declare type BaseKeymapExtension = PlainExtension;
|
198
|
+
export { BaseKeymapExtension }
|
199
|
+
export { BaseKeymapExtension as BaseKeymapExtension_alias_1 }
|
200
|
+
|
174
201
|
/**
|
175
202
|
* Some basic props for custom node views.
|
176
203
|
*
|
@@ -201,6 +228,12 @@ export declare function baseToggleMark(markType: MarkType, attrs?: Attrs | null,
|
|
201
228
|
removeWhenPresent: boolean;
|
202
229
|
}): Command;
|
203
230
|
|
231
|
+
declare type BoldExtension = Extension<{
|
232
|
+
Marks: {
|
233
|
+
bold: Attrs;
|
234
|
+
};
|
235
|
+
}>;
|
236
|
+
|
204
237
|
export declare function buildNode(type: NodeType, args: [Attrs | NodeChild | null | undefined, ...NodeChild[]], createNode: CreateNodeFunction): ProseMirrorNode;
|
205
238
|
|
206
239
|
export declare function cache<T>(fn: () => T): () => T;
|
@@ -228,6 +261,14 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
|
|
228
261
|
export { clsx }
|
229
262
|
export { clsx as clsx_alias_1 }
|
230
263
|
|
264
|
+
declare type CodeBlockExtension = Extension<{
|
265
|
+
Nodes: {
|
266
|
+
codeBlock: {
|
267
|
+
language: string;
|
268
|
+
};
|
269
|
+
};
|
270
|
+
}>;
|
271
|
+
|
231
272
|
/**
|
232
273
|
* Collects all nodes from a given content.
|
233
274
|
*
|
@@ -289,12 +330,12 @@ export { createEditor as createEditor_alias_1 }
|
|
289
330
|
/**
|
290
331
|
* @internal
|
291
332
|
*/
|
292
|
-
export declare function createMarkActions(schema: Schema, getState:
|
333
|
+
export declare function createMarkActions(schema: Schema, getState: GetStateFunction, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
|
293
334
|
|
294
335
|
/**
|
295
336
|
* @internal
|
296
337
|
*/
|
297
|
-
export declare function createNodeActions(schema: Schema, getState:
|
338
|
+
export declare function createNodeActions(schema: Schema, getState: GetStateFunction, createNode?: CreateNodeFunction): Record<string, NodeAction>;
|
298
339
|
|
299
340
|
export declare const createNodeForTest: CreateNodeFunction;
|
300
341
|
|
@@ -323,15 +364,27 @@ declare function defaultBlockAt(match: ContentMatch): NodeType_2 | null;
|
|
323
364
|
export { defaultBlockAt }
|
324
365
|
export { defaultBlockAt as defaultBlockAt_alias_1 }
|
325
366
|
|
367
|
+
/**
|
368
|
+
* @public
|
369
|
+
*/
|
326
370
|
declare interface DefaultStateOptions {
|
371
|
+
/**
|
372
|
+
* The starting document to use when creating the editor. It can be a
|
373
|
+
* ProseMirror node JSON object, a HTML string, or a HTML element instance.
|
374
|
+
*/
|
375
|
+
defaultContent?: NodeJSON | string | HTMLElement;
|
327
376
|
/**
|
328
377
|
* A JSON object representing the starting document to use when creating the
|
329
378
|
* editor.
|
379
|
+
*
|
380
|
+
* @deprecated Use `defaultContent` instead.
|
330
381
|
*/
|
331
382
|
defaultDoc?: NodeJSON;
|
332
383
|
/**
|
333
384
|
* A HTML element or a HTML string representing the starting document to use
|
334
385
|
* when creating the editor.
|
386
|
+
*
|
387
|
+
* @deprecated Use `defaultContent` instead.
|
335
388
|
*/
|
336
389
|
defaultHTML?: string | HTMLElement;
|
337
390
|
/**
|
@@ -348,27 +401,7 @@ export { DefaultStateOptions as DefaultStateOptions_alias_1 }
|
|
348
401
|
*
|
349
402
|
* @public
|
350
403
|
*/
|
351
|
-
declare function defineBaseCommands():
|
352
|
-
Commands: {
|
353
|
-
insertText: [{
|
354
|
-
text: string;
|
355
|
-
from?: number;
|
356
|
-
to?: number;
|
357
|
-
}];
|
358
|
-
insertNode: [options: InsertNodeOptions];
|
359
|
-
removeNode: [options: RemoveNodeOptions];
|
360
|
-
wrap: [WrapOptions];
|
361
|
-
setBlockType: [options: SetBlockTypeOptions];
|
362
|
-
setNodeAttrs: [options: SetNodeAttrsOptions];
|
363
|
-
selectAll: [];
|
364
|
-
addMark: [options: AddMarkOptions];
|
365
|
-
removeMark: [options: RemoveMarkOptions];
|
366
|
-
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
367
|
-
unsetMark: [options?: UnsetMarkOptions | undefined];
|
368
|
-
};
|
369
|
-
Nodes: never;
|
370
|
-
Marks: never;
|
371
|
-
}>;
|
404
|
+
declare function defineBaseCommands(): BaseCommandsExtension;
|
372
405
|
export { defineBaseCommands }
|
373
406
|
export { defineBaseCommands as defineBaseCommands_alias_1 }
|
374
407
|
|
@@ -384,7 +417,7 @@ declare function defineBaseKeymap(options?: {
|
|
384
417
|
* @default Priority.low
|
385
418
|
*/
|
386
419
|
priority?: Priority;
|
387
|
-
}):
|
420
|
+
}): BaseKeymapExtension;
|
388
421
|
export { defineBaseKeymap }
|
389
422
|
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
390
423
|
|
@@ -410,26 +443,23 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
|
|
410
443
|
Commands: {
|
411
444
|
[K in keyof T]: Parameters<T[K]>;
|
412
445
|
};
|
413
|
-
Nodes: never;
|
414
|
-
Marks: never;
|
415
446
|
}>;
|
416
447
|
export { defineCommands }
|
417
448
|
export { defineCommands as defineCommands_alias_1 }
|
418
449
|
|
419
|
-
|
450
|
+
/**
|
451
|
+
* Define a default state for the editor.
|
452
|
+
*
|
453
|
+
* @public
|
454
|
+
*/
|
455
|
+
declare function defineDefaultState(options: DefaultStateOptions): PlainExtension;
|
420
456
|
export { defineDefaultState }
|
421
457
|
export { defineDefaultState as defineDefaultState_alias_1 }
|
422
458
|
|
423
459
|
/**
|
424
460
|
* @public
|
425
461
|
*/
|
426
|
-
declare function defineDoc():
|
427
|
-
Nodes: {
|
428
|
-
doc: Attrs_2;
|
429
|
-
};
|
430
|
-
Marks: never;
|
431
|
-
Commands: never;
|
432
|
-
}>;
|
462
|
+
declare function defineDoc(): DocExtension;
|
433
463
|
export { defineDoc }
|
434
464
|
export { defineDoc as defineDoc_alias_1 }
|
435
465
|
|
@@ -438,7 +468,7 @@ export { defineDoc as defineDoc_alias_1 }
|
|
438
468
|
*
|
439
469
|
* @public
|
440
470
|
*/
|
441
|
-
declare function defineDocChangeHandler(handler: DocChangeHandler):
|
471
|
+
declare function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension;
|
442
472
|
export { defineDocChangeHandler }
|
443
473
|
export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
|
444
474
|
|
@@ -526,14 +556,7 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
|
|
526
556
|
*
|
527
557
|
* @public
|
528
558
|
*/
|
529
|
-
declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions):
|
530
|
-
Nodes: never;
|
531
|
-
Marks: never;
|
532
|
-
Commands: {
|
533
|
-
readonly undo: [];
|
534
|
-
readonly redo: [];
|
535
|
-
};
|
536
|
-
}>;
|
559
|
+
declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
|
537
560
|
export { defineHistory }
|
538
561
|
export { defineHistory as defineHistory_alias_1 }
|
539
562
|
|
@@ -549,7 +572,7 @@ export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
|
|
549
572
|
/**
|
550
573
|
* @public
|
551
574
|
*/
|
552
|
-
declare function defineKeymap(keymap: Keymap):
|
575
|
+
declare function defineKeymap(keymap: Keymap): PlainExtension;
|
553
576
|
export { defineKeymap }
|
554
577
|
export { defineKeymap as defineKeymap_alias_1 }
|
555
578
|
|
@@ -566,11 +589,9 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
|
|
566
589
|
* @public
|
567
590
|
*/
|
568
591
|
declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
|
569
|
-
Nodes: never;
|
570
592
|
Marks: {
|
571
593
|
[K in MarkType]: AttrType;
|
572
594
|
};
|
573
|
-
Commands: never;
|
574
595
|
}>;
|
575
596
|
export { defineMarkAttr }
|
576
597
|
export { defineMarkAttr as defineMarkAttr_alias_1 }
|
@@ -582,8 +603,6 @@ declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = An
|
|
582
603
|
Marks: {
|
583
604
|
[K in Mark]: Attrs;
|
584
605
|
};
|
585
|
-
Nodes: never;
|
586
|
-
Commands: never;
|
587
606
|
}>;
|
588
607
|
export { defineMarkSpec }
|
589
608
|
export { defineMarkSpec as defineMarkSpec_alias_1 }
|
@@ -593,7 +612,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
|
|
593
612
|
*
|
594
613
|
* @public
|
595
614
|
*/
|
596
|
-
declare function defineMountHandler(handler: MountHandler):
|
615
|
+
declare function defineMountHandler(handler: MountHandler): PlainExtension;
|
597
616
|
export { defineMountHandler }
|
598
617
|
export { defineMountHandler as defineMountHandler_alias_1 }
|
599
618
|
|
@@ -608,8 +627,6 @@ declare function defineNodeAttr<NodeType extends string = string, AttrName exten
|
|
608
627
|
[K in AttrName]: AttrType;
|
609
628
|
};
|
610
629
|
};
|
611
|
-
Marks: never;
|
612
|
-
Commands: never;
|
613
630
|
}>;
|
614
631
|
export { defineNodeAttr }
|
615
632
|
export { defineNodeAttr as defineNodeAttr_alias_1 }
|
@@ -623,8 +640,6 @@ declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = An
|
|
623
640
|
Nodes: {
|
624
641
|
[K in Node]: Attrs;
|
625
642
|
};
|
626
|
-
Marks: never;
|
627
|
-
Commands: never;
|
628
643
|
}>;
|
629
644
|
export { defineNodeSpec }
|
630
645
|
export { defineNodeSpec as defineNodeSpec_alias_1 }
|
@@ -652,13 +667,7 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
|
|
652
667
|
*
|
653
668
|
* Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
|
654
669
|
*/
|
655
|
-
declare function defineParagraph():
|
656
|
-
Nodes: {
|
657
|
-
paragraph: Attrs_2;
|
658
|
-
};
|
659
|
-
Marks: never;
|
660
|
-
Commands: never;
|
661
|
-
}>;
|
670
|
+
declare function defineParagraph(): ParagraphExtension;
|
662
671
|
export { defineParagraph }
|
663
672
|
export { defineParagraph as defineParagraph_alias_1 }
|
664
673
|
|
@@ -667,13 +676,7 @@ export { defineParagraph as defineParagraph_alias_1 }
|
|
667
676
|
*
|
668
677
|
* Defines a paragraph node spec.
|
669
678
|
*/
|
670
|
-
export declare function defineParagraphSpec():
|
671
|
-
Nodes: {
|
672
|
-
paragraph: Attrs_2;
|
673
|
-
};
|
674
|
-
Marks: never;
|
675
|
-
Commands: never;
|
676
|
-
}>;
|
679
|
+
export declare function defineParagraphSpec(): ParagraphSpecExtension;
|
677
680
|
|
678
681
|
/**
|
679
682
|
* @public
|
@@ -694,7 +697,7 @@ export { definePasteHandler as definePasteHandler_alias_1 }
|
|
694
697
|
*/
|
695
698
|
declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
|
696
699
|
schema: Schema;
|
697
|
-
}) => Plugin_2 | Plugin_2[])):
|
700
|
+
}) => Plugin_2 | Plugin_2[])): PlainExtension;
|
698
701
|
export { definePlugin }
|
699
702
|
export { definePlugin as definePlugin_alias_1 }
|
700
703
|
|
@@ -710,51 +713,16 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
|
|
710
713
|
/**
|
711
714
|
* @internal
|
712
715
|
*/
|
713
|
-
export declare function defineTestExtension(): Extension<{
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
heading: Attrs_2;
|
719
|
-
codeBlock: {
|
720
|
-
language: string;
|
721
|
-
};
|
722
|
-
}>;
|
723
|
-
Marks: SimplifyDeeper< {
|
724
|
-
bold: Attrs_2;
|
725
|
-
italic: Attrs_2;
|
726
|
-
}>;
|
727
|
-
Commands: {
|
728
|
-
insertText: [{
|
729
|
-
text: string;
|
730
|
-
from?: number;
|
731
|
-
to?: number;
|
732
|
-
}];
|
733
|
-
insertNode: [options: InsertNodeOptions];
|
734
|
-
removeNode: [options: RemoveNodeOptions];
|
735
|
-
wrap: [WrapOptions];
|
736
|
-
setBlockType: [options: SetBlockTypeOptions];
|
737
|
-
setNodeAttrs: [options: SetNodeAttrsOptions];
|
738
|
-
selectAll: [];
|
739
|
-
addMark: [options: AddMarkOptions];
|
740
|
-
removeMark: [options: RemoveMarkOptions];
|
741
|
-
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
742
|
-
unsetMark: [options?: UnsetMarkOptions | undefined];
|
743
|
-
readonly undo: [];
|
744
|
-
readonly redo: [];
|
745
|
-
};
|
746
|
-
}>;
|
716
|
+
export declare function defineTestExtension(): Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
|
717
|
+
Nodes: {
|
718
|
+
paragraph: Attrs;
|
719
|
+
};
|
720
|
+
}>, TextExtension, BoldExtension, ItalicExtension, LinkExtension, HeadingExtension, CodeBlockExtension]>;
|
747
721
|
|
748
722
|
/**
|
749
723
|
* @public
|
750
724
|
*/
|
751
|
-
declare function defineText():
|
752
|
-
Nodes: {
|
753
|
-
text: Attrs_2;
|
754
|
-
};
|
755
|
-
Marks: never;
|
756
|
-
Commands: never;
|
757
|
-
}>;
|
725
|
+
declare function defineText(): TextExtension;
|
758
726
|
export { defineText }
|
759
727
|
export { defineText as defineText_alias_1 }
|
760
728
|
|
@@ -790,7 +758,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
|
|
790
758
|
*
|
791
759
|
* @public
|
792
760
|
*/
|
793
|
-
declare function defineUnmountHandler(handler: UnmountHandler):
|
761
|
+
declare function defineUnmountHandler(handler: UnmountHandler): PlainExtension;
|
794
762
|
export { defineUnmountHandler }
|
795
763
|
export { defineUnmountHandler as defineUnmountHandler_alias_1 }
|
796
764
|
|
@@ -799,7 +767,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
|
|
799
767
|
*
|
800
768
|
* @public
|
801
769
|
*/
|
802
|
-
declare function defineUpdateHandler(handler: UpdateHandler):
|
770
|
+
declare function defineUpdateHandler(handler: UpdateHandler): PlainExtension;
|
803
771
|
export { defineUpdateHandler }
|
804
772
|
export { defineUpdateHandler as defineUpdateHandler_alias_1 }
|
805
773
|
|
@@ -815,6 +783,17 @@ declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => vo
|
|
815
783
|
export { DocChangeHandler }
|
816
784
|
export { DocChangeHandler as DocChangeHandler_alias_1 }
|
817
785
|
|
786
|
+
/**
|
787
|
+
* @internal
|
788
|
+
*/
|
789
|
+
declare type DocExtension = Extension<{
|
790
|
+
Nodes: {
|
791
|
+
doc: Attrs;
|
792
|
+
};
|
793
|
+
}>;
|
794
|
+
export { DocExtension }
|
795
|
+
export { DocExtension as DocExtension_alias_1 }
|
796
|
+
|
818
797
|
/**
|
819
798
|
* @internal
|
820
799
|
*/
|
@@ -884,15 +863,10 @@ export { DropHandler as DropHandler_alias_1 }
|
|
884
863
|
*/
|
885
864
|
declare class Editor<E extends Extension = any> {
|
886
865
|
private instance;
|
887
|
-
private afterMounted;
|
888
866
|
/**
|
889
867
|
* @internal
|
890
868
|
*/
|
891
869
|
constructor(instance: EditorInstance);
|
892
|
-
/**
|
893
|
-
* @internal
|
894
|
-
*/
|
895
|
-
static create(instance: any): Editor<any>;
|
896
870
|
/**
|
897
871
|
* Whether the editor is mounted.
|
898
872
|
*/
|
@@ -905,6 +879,10 @@ declare class Editor<E extends Extension = any> {
|
|
905
879
|
* The editor schema.
|
906
880
|
*/
|
907
881
|
get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
|
882
|
+
/**
|
883
|
+
* The editor's current state.
|
884
|
+
*/
|
885
|
+
get state(): EditorState;
|
908
886
|
/**
|
909
887
|
* Whether the editor is focused.
|
910
888
|
*/
|
@@ -913,28 +891,24 @@ declare class Editor<E extends Extension = any> {
|
|
913
891
|
* Mount the editor to the given HTML element.
|
914
892
|
* Pass `null` or `undefined` to unmount the editor.
|
915
893
|
*/
|
916
|
-
mount(place: HTMLElement | null | undefined)
|
894
|
+
mount: (place: HTMLElement | null | undefined) => void;
|
917
895
|
/**
|
918
896
|
* Unmount the editor. This is equivalent to `mount(null)`.
|
919
897
|
*/
|
920
|
-
unmount()
|
898
|
+
unmount: () => void;
|
921
899
|
/**
|
922
900
|
* Focus the editor.
|
923
901
|
*/
|
924
|
-
focus()
|
902
|
+
focus: () => void;
|
925
903
|
/**
|
926
904
|
* Blur the editor.
|
927
905
|
*/
|
928
|
-
blur()
|
906
|
+
blur: () => void;
|
929
907
|
/**
|
930
908
|
* Register an extension to the editor. Return a function to unregister the
|
931
909
|
* extension.
|
932
910
|
*/
|
933
|
-
use(extension: Extension)
|
934
|
-
/**
|
935
|
-
* The editor's current state.
|
936
|
-
*/
|
937
|
-
get state(): EditorState;
|
911
|
+
use: (extension: Extension) => VoidFunction;
|
938
912
|
/**
|
939
913
|
* Update the editor's state.
|
940
914
|
*
|
@@ -943,7 +917,22 @@ declare class Editor<E extends Extension = any> {
|
|
943
917
|
* This is an advanced method. Use it only if you have a specific reason to
|
944
918
|
* directly manipulate the editor's state.
|
945
919
|
*/
|
946
|
-
updateState(state: EditorState)
|
920
|
+
updateState: (state: EditorState) => void;
|
921
|
+
/**
|
922
|
+
* Update the editor's document and selection.
|
923
|
+
*
|
924
|
+
* @param content - The new document to set. It can be one of the following:
|
925
|
+
* - A ProseMirror node instance
|
926
|
+
* - A ProseMirror node JSON object
|
927
|
+
* - An HTML string
|
928
|
+
* - An HTML element instance
|
929
|
+
* @param selection - Optional. Specifies the new selection. It can be one of the following:
|
930
|
+
* - A ProseMirror selection instance
|
931
|
+
* - A ProseMirror selection JSON object
|
932
|
+
* - The string "start" (to set selection at the beginning, default value)
|
933
|
+
* - The string "end" (to set selection at the end)
|
934
|
+
*/
|
935
|
+
setContent: (content: ProseMirrorNode | NodeJSON | string | HTMLElement, selection?: SelectionJSON | Selection_2 | "start" | "end") => void;
|
947
936
|
/**
|
948
937
|
* All {@link CommandAction}s defined by the editor.
|
949
938
|
*/
|
@@ -961,6 +950,8 @@ export { Editor }
|
|
961
950
|
export { Editor as Editor_alias_1 }
|
962
951
|
|
963
952
|
/**
|
953
|
+
* An internal class to make TypeScript generic type easier to use.
|
954
|
+
*
|
964
955
|
* @internal
|
965
956
|
*/
|
966
957
|
export declare class EditorInstance {
|
@@ -971,10 +962,13 @@ export declare class EditorInstance {
|
|
971
962
|
commands: Record<string, CommandAction>;
|
972
963
|
private tree;
|
973
964
|
private directEditorProps;
|
965
|
+
private afterMounted;
|
974
966
|
constructor(extension: Extension);
|
975
967
|
getState: () => EditorState;
|
976
968
|
updateState(state: EditorState): void;
|
977
|
-
|
969
|
+
setContent(content: NodeJSON | string | HTMLElement | ProseMirrorNode, selection?: SelectionJSON | Selection_2 | 'start' | 'end'): void;
|
970
|
+
private updateExtension;
|
971
|
+
use(extension: Extension): VoidFunction;
|
978
972
|
mount(place: HTMLElement): void;
|
979
973
|
unmount(): void;
|
980
974
|
get mounted(): boolean;
|
@@ -1002,14 +996,23 @@ declare interface EditorOptions<E extends Extension> {
|
|
1002
996
|
* The extension to use when creating the editor.
|
1003
997
|
*/
|
1004
998
|
extension: E;
|
999
|
+
/**
|
1000
|
+
* The starting document to use when creating the editor. It can be a
|
1001
|
+
* ProseMirror node JSON object, a HTML string, or a HTML element instance.
|
1002
|
+
*/
|
1003
|
+
defaultContent?: NodeJSON | string | HTMLElement;
|
1005
1004
|
/**
|
1006
1005
|
* A JSON object representing the starting document to use when creating the
|
1007
1006
|
* editor.
|
1007
|
+
*
|
1008
|
+
* @deprecated Use `defaultContent` instead.
|
1008
1009
|
*/
|
1009
1010
|
defaultDoc?: NodeJSON;
|
1010
1011
|
/**
|
1011
1012
|
* A HTML element or a HTML string representing the starting document to use
|
1012
1013
|
* when creating the editor.
|
1014
|
+
*
|
1015
|
+
* @deprecated Use `defaultContent` instead.
|
1013
1016
|
*/
|
1014
1017
|
defaultHTML?: string | HTMLElement;
|
1015
1018
|
/**
|
@@ -1088,9 +1091,9 @@ export { Extension as Extension_alias_1 }
|
|
1088
1091
|
* @internal
|
1089
1092
|
*/
|
1090
1093
|
declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
|
1091
|
-
Nodes
|
1092
|
-
Marks
|
1093
|
-
Commands
|
1094
|
+
Nodes?: N;
|
1095
|
+
Marks?: M;
|
1096
|
+
Commands?: C;
|
1094
1097
|
}
|
1095
1098
|
export { ExtensionTyping }
|
1096
1099
|
export { ExtensionTyping as ExtensionTyping_alias_1 }
|
@@ -1219,7 +1222,7 @@ export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
|
|
1219
1222
|
/**
|
1220
1223
|
* @internal
|
1221
1224
|
*/
|
1222
|
-
createTree(priority: Priority): FacetNode
|
1225
|
+
createTree(priority: Priority): FacetNode;
|
1223
1226
|
}
|
1224
1227
|
|
1225
1228
|
export declare class FacetNode<I = any, O = any> {
|
@@ -1275,6 +1278,14 @@ export declare function getBrowserWindow(options?: {
|
|
1275
1278
|
|
1276
1279
|
export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;
|
1277
1280
|
|
1281
|
+
export declare function getEditorContentDoc(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
|
1282
|
+
|
1283
|
+
export declare function getEditorContentJSON(schema: Schema, content: NodeJSON | string | HTMLElement): NodeJSON;
|
1284
|
+
|
1285
|
+
export declare function getEditorContentNode(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
|
1286
|
+
|
1287
|
+
export declare function getEditorSelection(doc: ProseMirrorNode, selection: SelectionJSON | Selection_2 | 'start' | 'end'): Selection_2;
|
1288
|
+
|
1278
1289
|
/**
|
1279
1290
|
* Returns a unique id in the current process that can be used in various places.
|
1280
1291
|
*
|
@@ -1303,12 +1314,32 @@ export { getNodeType as getNodeType_alias_1 }
|
|
1303
1314
|
*/
|
1304
1315
|
export declare function getNodeTypes(schema: Schema, types: string | NodeType | string[] | NodeType[]): NodeType[];
|
1305
1316
|
|
1317
|
+
declare type GetStateFunction = () => EditorState | null | undefined;
|
1318
|
+
|
1306
1319
|
export declare type GroupedEntries<T extends Record<string, any>> = {
|
1307
1320
|
[K in keyof T]?: T[K][];
|
1308
1321
|
};
|
1309
1322
|
|
1310
1323
|
export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
|
1311
1324
|
|
1325
|
+
declare type HeadingExtension = Extension<{
|
1326
|
+
Nodes: {
|
1327
|
+
heading: Attrs;
|
1328
|
+
};
|
1329
|
+
}>;
|
1330
|
+
|
1331
|
+
/**
|
1332
|
+
* @internal
|
1333
|
+
*/
|
1334
|
+
declare type HistoryExtension = Extension<{
|
1335
|
+
Commands: {
|
1336
|
+
undo: [];
|
1337
|
+
redo: [];
|
1338
|
+
};
|
1339
|
+
}>;
|
1340
|
+
export { HistoryExtension }
|
1341
|
+
export { HistoryExtension as HistoryExtension_alias_1 }
|
1342
|
+
|
1312
1343
|
/**
|
1313
1344
|
* Options for {@link defineHistory}.
|
1314
1345
|
*
|
@@ -1403,11 +1434,16 @@ export { InsertNodeOptions as InsertNodeOptions_alias_1 }
|
|
1403
1434
|
*
|
1404
1435
|
* @public
|
1405
1436
|
*/
|
1406
|
-
export declare function insertText({ text, from, to
|
1437
|
+
export declare function insertText({ text, from, to }: InsertTextOptions): Command;
|
1438
|
+
|
1439
|
+
/**
|
1440
|
+
* @public
|
1441
|
+
*/
|
1442
|
+
export declare type InsertTextOptions = {
|
1407
1443
|
text: string;
|
1408
1444
|
from?: number;
|
1409
1445
|
to?: number;
|
1410
|
-
}
|
1446
|
+
};
|
1411
1447
|
|
1412
1448
|
/**
|
1413
1449
|
* @internal
|
@@ -1432,7 +1468,7 @@ declare function isAtBlockStart(state: EditorState, view?: EditorView): Resolved
|
|
1432
1468
|
export { isAtBlockStart }
|
1433
1469
|
export { isAtBlockStart as isAtBlockStart_alias_1 }
|
1434
1470
|
|
1435
|
-
export declare function isElement(
|
1471
|
+
export declare function isElement(el: unknown): el is Element;
|
1436
1472
|
|
1437
1473
|
/**
|
1438
1474
|
* Check if the selection is in a code block.
|
@@ -1479,6 +1515,8 @@ export { isNodeSelection as isNodeSelection_alias_1 }
|
|
1479
1515
|
|
1480
1516
|
export declare function isNotNull<T>(value: T | null | undefined): value is T;
|
1481
1517
|
|
1518
|
+
export declare function isObject(v: unknown): v is Record<string, unknown>;
|
1519
|
+
|
1482
1520
|
/**
|
1483
1521
|
* @internal
|
1484
1522
|
*/
|
@@ -1486,6 +1524,13 @@ declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
|
|
1486
1524
|
export { isProseMirrorNode }
|
1487
1525
|
export { isProseMirrorNode as isProseMirrorNode_alias_1 }
|
1488
1526
|
|
1527
|
+
/**
|
1528
|
+
* @internal
|
1529
|
+
*/
|
1530
|
+
declare function isSelection(sel: unknown): sel is Selection_2;
|
1531
|
+
export { isSelection }
|
1532
|
+
export { isSelection as isSelection_alias_1 }
|
1533
|
+
|
1489
1534
|
/**
|
1490
1535
|
* Check if `subset` is a subset of `superset`.
|
1491
1536
|
*
|
@@ -1500,6 +1545,12 @@ declare function isTextSelection(sel: Selection_2): sel is TextSelection;
|
|
1500
1545
|
export { isTextSelection }
|
1501
1546
|
export { isTextSelection as isTextSelection_alias_1 }
|
1502
1547
|
|
1548
|
+
declare type ItalicExtension = Extension<{
|
1549
|
+
Marks: {
|
1550
|
+
italic: Attrs;
|
1551
|
+
};
|
1552
|
+
}>;
|
1553
|
+
|
1503
1554
|
/**
|
1504
1555
|
* Serialize a HTML element to a ProseMirror document JSON object.
|
1505
1556
|
*
|
@@ -1572,6 +1623,16 @@ declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boole
|
|
1572
1623
|
export { KeyPressHandler }
|
1573
1624
|
export { KeyPressHandler as KeyPressHandler_alias_1 }
|
1574
1625
|
|
1626
|
+
declare interface LinkAttrs {
|
1627
|
+
href: string;
|
1628
|
+
}
|
1629
|
+
|
1630
|
+
declare type LinkExtension = Extension<{
|
1631
|
+
Marks: {
|
1632
|
+
link: LinkAttrs;
|
1633
|
+
};
|
1634
|
+
}>;
|
1635
|
+
|
1575
1636
|
/**
|
1576
1637
|
* A function for creating a mark with optional attributes and any number of
|
1577
1638
|
* children.
|
@@ -1784,7 +1845,10 @@ export { nodeFromJSON as nodeFromJSON_alias_1 }
|
|
1784
1845
|
*/
|
1785
1846
|
declare interface NodeJSON {
|
1786
1847
|
type: string;
|
1787
|
-
marks?: Array<
|
1848
|
+
marks?: Array<{
|
1849
|
+
type: string;
|
1850
|
+
attrs?: Record<string, any>;
|
1851
|
+
}>;
|
1788
1852
|
text?: string;
|
1789
1853
|
content?: NodeJSON[];
|
1790
1854
|
attrs?: Record<string, any>;
|
@@ -1876,6 +1940,22 @@ export declare type ObjectEntries<T extends Record<string, any>> = {
|
|
1876
1940
|
|
1877
1941
|
export declare function objectEqual<T>(a: T, b: T): boolean;
|
1878
1942
|
|
1943
|
+
/**
|
1944
|
+
* @internal
|
1945
|
+
*/
|
1946
|
+
declare type ParagraphExtension = ParagraphSpecExtension;
|
1947
|
+
export { ParagraphExtension }
|
1948
|
+
export { ParagraphExtension as ParagraphExtension_alias_1 }
|
1949
|
+
|
1950
|
+
/**
|
1951
|
+
* @internal
|
1952
|
+
*/
|
1953
|
+
declare type ParagraphSpecExtension = Extension<{
|
1954
|
+
Nodes: {
|
1955
|
+
paragraph: Attrs;
|
1956
|
+
};
|
1957
|
+
}>;
|
1958
|
+
|
1879
1959
|
declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
|
1880
1960
|
export { PasteHandler }
|
1881
1961
|
export { PasteHandler as PasteHandler_alias_1 }
|
@@ -1897,6 +1977,19 @@ declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentTy
|
|
1897
1977
|
export { PickSubType }
|
1898
1978
|
export { PickSubType as PickSubType_alias_1 }
|
1899
1979
|
|
1980
|
+
/**
|
1981
|
+
* An extension that does not define any nodes, marks, or commands.
|
1982
|
+
*
|
1983
|
+
* @internal
|
1984
|
+
*/
|
1985
|
+
declare type PlainExtension = Extension<{
|
1986
|
+
Nodes: never;
|
1987
|
+
Marks: never;
|
1988
|
+
Commands: never;
|
1989
|
+
}>;
|
1990
|
+
export { PlainExtension }
|
1991
|
+
export { PlainExtension as PlainExtension_alias_1 }
|
1992
|
+
|
1900
1993
|
/**
|
1901
1994
|
* @internal
|
1902
1995
|
*/
|
@@ -2112,40 +2205,11 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
|
|
2112
2205
|
* @internal
|
2113
2206
|
*/
|
2114
2207
|
export declare function setupTest(): {
|
2115
|
-
editor: TestEditor<Extension<{
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
heading: Attrs_2;
|
2121
|
-
codeBlock: {
|
2122
|
-
language: string;
|
2123
|
-
};
|
2124
|
-
}>;
|
2125
|
-
Marks: SimplifyDeeper< {
|
2126
|
-
bold: Attrs_2;
|
2127
|
-
italic: Attrs_2;
|
2128
|
-
}>;
|
2129
|
-
Commands: {
|
2130
|
-
insertText: [{
|
2131
|
-
text: string;
|
2132
|
-
from?: number;
|
2133
|
-
to?: number;
|
2134
|
-
}];
|
2135
|
-
insertNode: [options: InsertNodeOptions];
|
2136
|
-
removeNode: [options: RemoveNodeOptions];
|
2137
|
-
wrap: [WrapOptions];
|
2138
|
-
setBlockType: [options: SetBlockTypeOptions];
|
2139
|
-
setNodeAttrs: [options: SetNodeAttrsOptions];
|
2140
|
-
selectAll: [];
|
2141
|
-
addMark: [options: AddMarkOptions];
|
2142
|
-
removeMark: [options: RemoveMarkOptions];
|
2143
|
-
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
2144
|
-
unsetMark: [options?: UnsetMarkOptions | undefined];
|
2145
|
-
readonly undo: [];
|
2146
|
-
readonly redo: [];
|
2147
|
-
};
|
2148
|
-
}>>;
|
2208
|
+
editor: TestEditor<Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
|
2209
|
+
Nodes: {
|
2210
|
+
paragraph: Attrs;
|
2211
|
+
};
|
2212
|
+
}>, TextExtension, BoldExtension, ItalicExtension, LinkExtension, HeadingExtension, CodeBlockExtension]>>;
|
2149
2213
|
m: ToMarkAction<SimplifyDeeper< {
|
2150
2214
|
bold: {
|
2151
2215
|
readonly [x: string]: any;
|
@@ -2153,15 +2217,18 @@ export declare function setupTest(): {
|
|
2153
2217
|
italic: {
|
2154
2218
|
readonly [x: string]: any;
|
2155
2219
|
};
|
2220
|
+
link: {
|
2221
|
+
href: string;
|
2222
|
+
};
|
2156
2223
|
}>>;
|
2157
2224
|
n: {
|
2158
2225
|
p: NodeAction< {
|
2159
2226
|
readonly [x: string]: any;
|
2160
2227
|
}>;
|
2161
|
-
|
2228
|
+
doc: NodeAction< {
|
2162
2229
|
readonly [x: string]: any;
|
2163
2230
|
}>;
|
2164
|
-
|
2231
|
+
paragraph: NodeAction< {
|
2165
2232
|
readonly [x: string]: any;
|
2166
2233
|
}>;
|
2167
2234
|
text: NodeAction< {
|
@@ -2197,7 +2264,7 @@ export { SimplifyDeeper as SimplifyDeeper_alias_1 }
|
|
2197
2264
|
/**
|
2198
2265
|
* @internal
|
2199
2266
|
*/
|
2200
|
-
declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
|
2267
|
+
declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
|
2201
2268
|
export { SimplifyUnion }
|
2202
2269
|
export { SimplifyUnion as SimplifyUnion_alias_1 }
|
2203
2270
|
|
@@ -2290,6 +2357,17 @@ declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
|
|
2290
2357
|
export { TestEditor }
|
2291
2358
|
export { TestEditor as TestEditor_alias_1 }
|
2292
2359
|
|
2360
|
+
/**
|
2361
|
+
* @internal
|
2362
|
+
*/
|
2363
|
+
declare type TextExtension = Extension<{
|
2364
|
+
Nodes: {
|
2365
|
+
text: Attrs;
|
2366
|
+
};
|
2367
|
+
}>;
|
2368
|
+
export { TextExtension }
|
2369
|
+
export { TextExtension as TextExtension_alias_1 }
|
2370
|
+
|
2293
2371
|
declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
|
2294
2372
|
export { TextInputHandler }
|
2295
2373
|
export { TextInputHandler as TextInputHandler_alias_1 }
|
@@ -2380,6 +2458,17 @@ export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
|
|
2380
2458
|
*/
|
2381
2459
|
export declare type Tuple5<T> = [T, T, T, T, T];
|
2382
2460
|
|
2461
|
+
/**
|
2462
|
+
* @internal
|
2463
|
+
*/
|
2464
|
+
declare type Union<E extends readonly Extension[]> = Extension<{
|
2465
|
+
Nodes: ExtractNodes<E[number]>;
|
2466
|
+
Marks: ExtractMarks<E[number]>;
|
2467
|
+
Commands: ExtractCommands<E[number]>;
|
2468
|
+
}>;
|
2469
|
+
export { Union }
|
2470
|
+
export { Union as Union_alias_1 }
|
2471
|
+
|
2383
2472
|
/**
|
2384
2473
|
* Merge multiple extensions into one.
|
2385
2474
|
*
|
@@ -2398,11 +2487,14 @@ export declare type Tuple5<T> = [T, T, T, T, T];
|
|
2398
2487
|
*
|
2399
2488
|
* @public
|
2400
2489
|
*/
|
2401
|
-
declare function union<const E extends
|
2490
|
+
declare function union<const E extends readonly Extension[]>(...exts: E): Union<E>;
|
2491
|
+
|
2492
|
+
declare function union<const E extends readonly Extension[]>(exts: E): Union<E>;
|
2402
2493
|
export { union }
|
2403
2494
|
export { union as union_alias_1 }
|
2404
2495
|
|
2405
2496
|
/**
|
2497
|
+
* @deprecated Use `Union` instead.
|
2406
2498
|
* @internal
|
2407
2499
|
*/
|
2408
2500
|
declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
|