@prosekit/core 0.0.16 → 0.0.18
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 +222 -39
- package/dist/prosekit-core.d.ts +5 -1
- package/dist/prosekit-core.js +289 -151
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/index.ts +0 -53
@@ -12,6 +12,7 @@ import type { IsEqual } from 'type-fest';
|
|
12
12
|
import { Mark } from '@prosekit/pm/model';
|
13
13
|
import type { MarkSpec } from '@prosekit/pm/model';
|
14
14
|
import { MarkType } from '@prosekit/pm/model';
|
15
|
+
import { MarkType as MarkType_2 } from 'prosemirror-model';
|
15
16
|
import { Node as Node_2 } from 'prosemirror-model';
|
16
17
|
import type { NodeSpec } from '@prosekit/pm/model';
|
17
18
|
import { NodeType } from '@prosekit/pm/model';
|
@@ -34,15 +35,24 @@ declare type Action = (options: {
|
|
34
35
|
view?: EditorView;
|
35
36
|
}) => boolean;
|
36
37
|
|
38
|
+
/**
|
39
|
+
* Add the given mark to the inline content.
|
40
|
+
*/
|
37
41
|
declare function addMark(options: {
|
42
|
+
/**
|
43
|
+
* The type of the mark to add.
|
44
|
+
*/
|
38
45
|
type: string | MarkType;
|
46
|
+
/**
|
47
|
+
* The attributes of the mark to add.
|
48
|
+
*/
|
39
49
|
attrs?: Attrs | null;
|
40
50
|
/**
|
41
|
-
* The start position of the
|
51
|
+
* The start position of the document. By default it will be the start position of current selection.
|
42
52
|
*/
|
43
53
|
from?: number;
|
44
54
|
/**
|
45
|
-
* The end position of the
|
55
|
+
* The end position of the document. By default it will be the end position of current selection.
|
46
56
|
*/
|
47
57
|
to?: number;
|
48
58
|
}): Command;
|
@@ -56,6 +66,30 @@ export declare function applyAction(operator: Action): Command;
|
|
56
66
|
*/
|
57
67
|
export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
58
68
|
|
69
|
+
export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
|
70
|
+
|
71
|
+
export declare abstract class BaseExtension<T extends ExtensionTyping = ExtensionTyping> implements Extension<T> {
|
72
|
+
extension: Extension | Extension[];
|
73
|
+
priority?: Priority;
|
74
|
+
_type?: T;
|
75
|
+
/**
|
76
|
+
* @internal
|
77
|
+
*
|
78
|
+
* Whether this extension has payload that can be converted to a schema.
|
79
|
+
*
|
80
|
+
* Notice that this does not mean that the extension has a schema. For
|
81
|
+
* example, a `FacetExtension` with a `schemaFacet` will return `true` for
|
82
|
+
* this property, but will return `null` for `schema`.
|
83
|
+
*/
|
84
|
+
abstract hasSchema: boolean;
|
85
|
+
/**
|
86
|
+
* @internal
|
87
|
+
*
|
88
|
+
* The schema that this extension represents.
|
89
|
+
*/
|
90
|
+
abstract schema: Schema | null;
|
91
|
+
}
|
92
|
+
|
59
93
|
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
60
94
|
|
61
95
|
export declare interface CommandApplier<Args extends any[] = any[]> {
|
@@ -63,7 +97,9 @@ export declare interface CommandApplier<Args extends any[] = any[]> {
|
|
63
97
|
canApply(...args: Args): boolean;
|
64
98
|
}
|
65
99
|
|
66
|
-
/**
|
100
|
+
/**
|
101
|
+
* @internal
|
102
|
+
*/
|
67
103
|
declare interface CommandArgs {
|
68
104
|
[name: string]: any[];
|
69
105
|
}
|
@@ -84,8 +120,10 @@ export declare type Converters = ConverterTuple[];
|
|
84
120
|
|
85
121
|
declare type ConverterTuple = Tuple5<FacetConverter | undefined>;
|
86
122
|
|
87
|
-
/**
|
88
|
-
|
123
|
+
/**
|
124
|
+
* @public
|
125
|
+
*/
|
126
|
+
declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultHTML, defaultSelection, }: EditorOptions<E>): Editor<E>;
|
89
127
|
export { createEditor }
|
90
128
|
export { createEditor as createEditor_alias_1 }
|
91
129
|
|
@@ -99,13 +137,20 @@ export declare const default_alias_1: UserProjectConfigExport;
|
|
99
137
|
|
100
138
|
declare interface DefaultStateOptions {
|
101
139
|
/**
|
102
|
-
* A JSON
|
140
|
+
* A JSON object representing the starting document to use when creating the
|
141
|
+
* editor.
|
103
142
|
*/
|
104
|
-
|
143
|
+
defaultDoc?: NodeJson;
|
105
144
|
/**
|
106
|
-
* A
|
145
|
+
* A HTML string representing the starting document to use when creating the
|
146
|
+
* editor.
|
107
147
|
*/
|
108
|
-
|
148
|
+
defaultHTML?: string;
|
149
|
+
/**
|
150
|
+
* A JSON object representing the starting selection to use when creating the
|
151
|
+
* editor. It's only used when `defaultDoc` or `defaultHTML` is also provided.
|
152
|
+
*/
|
153
|
+
defaultSelection?: SelectionJson;
|
109
154
|
}
|
110
155
|
export { DefaultStateOptions }
|
111
156
|
export { DefaultStateOptions as DefaultStateOptions_alias_1 }
|
@@ -137,12 +182,26 @@ declare function defineBaseCommands(): Extension<{
|
|
137
182
|
to?: number | undefined;
|
138
183
|
}];
|
139
184
|
selectAll: [];
|
185
|
+
addMark: [options: {
|
186
|
+
type: string | MarkType_2;
|
187
|
+
attrs?: Attrs_2 | null | undefined;
|
188
|
+
from?: number | undefined;
|
189
|
+
to?: number | undefined;
|
190
|
+
}];
|
191
|
+
removeMark: [options: {
|
192
|
+
type: string | MarkType_2;
|
193
|
+
attrs?: Attrs_2 | null | undefined;
|
194
|
+
from?: number | undefined;
|
195
|
+
to?: number | undefined;
|
196
|
+
}];
|
140
197
|
};
|
141
198
|
}>;
|
142
199
|
export { defineBaseCommands }
|
143
200
|
export { defineBaseCommands as defineBaseCommands_alias_1 }
|
144
201
|
|
145
|
-
/**
|
202
|
+
/**
|
203
|
+
* @public
|
204
|
+
*/
|
146
205
|
declare function defineBaseKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
147
206
|
export { defineBaseKeymap }
|
148
207
|
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
@@ -155,11 +214,13 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
|
|
155
214
|
export { defineCommands }
|
156
215
|
export { defineCommands as defineCommands_alias_1 }
|
157
216
|
|
158
|
-
declare function defineDefaultState(
|
217
|
+
declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): Extension;
|
159
218
|
export { defineDefaultState }
|
160
219
|
export { defineDefaultState as defineDefaultState_alias_1 }
|
161
220
|
|
162
|
-
/**
|
221
|
+
/**
|
222
|
+
* @public
|
223
|
+
*/
|
163
224
|
declare function defineDoc(): Extension< {
|
164
225
|
NODES: "doc";
|
165
226
|
}>;
|
@@ -171,7 +232,7 @@ export { defineDoc as defineDoc_alias_1 }
|
|
171
232
|
*/
|
172
233
|
declare function defineEventHandler(options: {
|
173
234
|
update?: VoidFunction;
|
174
|
-
}):
|
235
|
+
}): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
175
236
|
export { defineEventHandler }
|
176
237
|
export { defineEventHandler as defineEventHandler_alias_1 }
|
177
238
|
|
@@ -196,7 +257,9 @@ declare function defineInputRule(rules: (context: {
|
|
196
257
|
export { defineInputRule }
|
197
258
|
export { defineInputRule as defineInputRule_alias_1 }
|
198
259
|
|
199
|
-
/**
|
260
|
+
/**
|
261
|
+
* @public
|
262
|
+
*/
|
200
263
|
declare function defineKeymap(keymap: Keymap): Extension;
|
201
264
|
export { defineKeymap }
|
202
265
|
export { defineKeymap as defineKeymap_alias_1 }
|
@@ -261,19 +324,25 @@ declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
|
|
261
324
|
export { definePlugin }
|
262
325
|
export { definePlugin as definePlugin_alias_1 }
|
263
326
|
|
264
|
-
/**
|
327
|
+
/**
|
328
|
+
* @public
|
329
|
+
*/
|
265
330
|
declare function defineText(): Extension< {
|
266
331
|
NODES: "text";
|
267
332
|
}>;
|
268
333
|
export { defineText }
|
269
334
|
export { defineText as defineText_alias_1 }
|
270
335
|
|
271
|
-
/**
|
336
|
+
/**
|
337
|
+
* @public
|
338
|
+
*/
|
272
339
|
declare class Editor<E extends Extension = any> {
|
273
340
|
private instance;
|
274
341
|
private constructor();
|
275
342
|
private afterMounted;
|
276
|
-
/**
|
343
|
+
/**
|
344
|
+
* @internal
|
345
|
+
*/
|
277
346
|
static create(instance: any): Editor<any>;
|
278
347
|
get mounted(): boolean;
|
279
348
|
get view(): EditorView;
|
@@ -296,7 +365,9 @@ declare class Editor<E extends Extension = any> {
|
|
296
365
|
export { Editor }
|
297
366
|
export { Editor as Editor_alias_1 }
|
298
367
|
|
299
|
-
/**
|
368
|
+
/**
|
369
|
+
* @public
|
370
|
+
*/
|
300
371
|
declare interface EditorOptions<E extends Extension> {
|
301
372
|
/**
|
302
373
|
* The extension to use when creating the editor.
|
@@ -307,15 +378,34 @@ declare interface EditorOptions<E extends Extension> {
|
|
307
378
|
* editor.
|
308
379
|
*/
|
309
380
|
defaultDoc?: NodeJson;
|
381
|
+
/**
|
382
|
+
* A HTML string representing the starting document to use when creating the
|
383
|
+
* editor.
|
384
|
+
*/
|
385
|
+
defaultHTML?: string;
|
310
386
|
/**
|
311
387
|
* A JSON object representing the starting selection to use when creating the
|
312
|
-
* editor. It's only used when `defaultDoc` is also provided.
|
388
|
+
* editor. It's only used when `defaultDoc` or `defaultHTML` is also provided.
|
313
389
|
*/
|
314
390
|
defaultSelection?: SelectionJson;
|
315
391
|
}
|
316
392
|
export { EditorOptions }
|
317
393
|
export { EditorOptions as EditorOptions_alias_1 }
|
318
394
|
|
395
|
+
/**
|
396
|
+
* Parse a HTML element to a ProseMirror document JSON.
|
397
|
+
*/
|
398
|
+
declare function elementToJSON(element: HTMLElement, schema: Schema): NodeJson;
|
399
|
+
export { elementToJSON }
|
400
|
+
export { elementToJSON as elementToJSON_alias_1 }
|
401
|
+
|
402
|
+
/**
|
403
|
+
* Parse a HTML element to a ProseMirror node.
|
404
|
+
*/
|
405
|
+
declare function elementToNode(element: HTMLElement, schema: Schema): ProseMirrorNode;
|
406
|
+
export { elementToNode }
|
407
|
+
export { elementToNode as elementToNode_alias_1 }
|
408
|
+
|
319
409
|
declare type EmptyValue = undefined | null | EmptyObject;
|
320
410
|
|
321
411
|
export declare type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
|
@@ -327,6 +417,12 @@ declare interface Extension<T extends ExtensionTyping = ExtensionTyping> {
|
|
327
417
|
extension: Extension | Extension[];
|
328
418
|
priority?: Priority;
|
329
419
|
_type?: T;
|
420
|
+
/**
|
421
|
+
* @public
|
422
|
+
*
|
423
|
+
* The schema that this extension represents.
|
424
|
+
*/
|
425
|
+
schema: Schema | null;
|
330
426
|
}
|
331
427
|
export { Extension }
|
332
428
|
export { Extension as Extension_alias_1 }
|
@@ -391,42 +487,64 @@ export declare type ExtractNodesFromTyping<T extends ExtensionTyping> = ExtractK
|
|
391
487
|
*/
|
392
488
|
export declare type ExtractTyping<E extends Extension> = E extends Extension<infer T> ? T : never;
|
393
489
|
|
394
|
-
/**
|
490
|
+
/**
|
491
|
+
* @public
|
492
|
+
*/
|
395
493
|
declare class Facet<Input, Output> {
|
396
|
-
/**
|
494
|
+
/**
|
495
|
+
* @internal
|
496
|
+
*/
|
397
497
|
readonly index: number;
|
398
|
-
/**
|
498
|
+
/**
|
499
|
+
* @internal
|
500
|
+
*/
|
399
501
|
readonly converter: () => FacetConverter<Input, Output>;
|
400
|
-
/**
|
502
|
+
/**
|
503
|
+
* @internal
|
504
|
+
*/
|
401
505
|
readonly next: Facet<Output, any> | null;
|
402
|
-
/**
|
506
|
+
/**
|
507
|
+
* @internal
|
508
|
+
*/
|
403
509
|
readonly singleton: boolean;
|
510
|
+
/**
|
511
|
+
* @internal
|
512
|
+
*/
|
513
|
+
isSchema: boolean;
|
404
514
|
private constructor();
|
405
|
-
static define<Input, Output>({ converter
|
406
|
-
/**
|
515
|
+
static define<Input, Output>({ converter, convert, next, singleton, }: FacetOptions<Input, Output>): Facet<Input, Output>;
|
516
|
+
/**
|
517
|
+
* @internal
|
518
|
+
*/
|
407
519
|
static defineRootFacet<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
|
408
|
-
extension(payloads: Input[]):
|
520
|
+
extension(payloads: Input[]): Extension;
|
409
521
|
}
|
410
522
|
export { Facet }
|
411
523
|
export { Facet as Facet_alias_1 }
|
412
524
|
|
413
|
-
/**
|
525
|
+
/**
|
526
|
+
* @public
|
527
|
+
*/
|
414
528
|
export declare interface FacetConverter<Input = any, Output = any> {
|
415
529
|
create: (inputs: Input[]) => Output;
|
416
530
|
update: (inputs: Input[]) => Output | null;
|
417
531
|
}
|
418
532
|
|
419
|
-
/**
|
420
|
-
|
533
|
+
/**
|
534
|
+
* @public
|
535
|
+
*/
|
536
|
+
export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
|
421
537
|
readonly facet: Facet<Input, Output>;
|
422
538
|
readonly payloads: Input[];
|
423
539
|
extension: Extension;
|
540
|
+
hasSchema: boolean;
|
541
|
+
schema: null;
|
424
542
|
constructor(facet: Facet<Input, Output>, payloads: Input[]);
|
425
543
|
}
|
426
|
-
export { FacetExtension }
|
427
|
-
export { FacetExtension as FacetExtension_alias_1 }
|
428
544
|
|
429
|
-
/**
|
545
|
+
/**
|
546
|
+
* @public
|
547
|
+
*/
|
430
548
|
declare interface FacetOptions<Input, Output> {
|
431
549
|
convert?: (payloads: Input[]) => Output;
|
432
550
|
converter?: () => FacetConverter<Input, Output>;
|
@@ -436,20 +554,42 @@ declare interface FacetOptions<Input, Output> {
|
|
436
554
|
export { FacetOptions }
|
437
555
|
export { FacetOptions as FacetOptions_alias_1 }
|
438
556
|
|
557
|
+
export declare function getBrowserDocument(): Document | undefined;
|
558
|
+
|
559
|
+
export declare function getBrowserWindow(): (Window & typeof globalThis) | null | undefined;
|
560
|
+
|
439
561
|
export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_2;
|
440
562
|
|
441
563
|
export declare function getFacetCount(): number;
|
442
564
|
|
443
|
-
/**
|
565
|
+
/**
|
566
|
+
* @internal
|
567
|
+
*/
|
444
568
|
declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;
|
445
569
|
export { getMarkType }
|
446
570
|
export { getMarkType as getMarkType_alias_1 }
|
447
571
|
|
448
|
-
/**
|
572
|
+
/**
|
573
|
+
* @internal
|
574
|
+
*/
|
449
575
|
declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
|
450
576
|
export { getNodeType }
|
451
577
|
export { getNodeType as getNodeType_alias_1 }
|
452
578
|
|
579
|
+
/**
|
580
|
+
* Parse a HTML element to a ProseMirror document JSON.
|
581
|
+
*/
|
582
|
+
declare function htmlToJSON(html: string, schema: Schema): NodeJson;
|
583
|
+
export { htmlToJSON }
|
584
|
+
export { htmlToJSON as htmlToJSON_alias_1 }
|
585
|
+
|
586
|
+
/**
|
587
|
+
* Parse a HTML string to a ProseMirror node.
|
588
|
+
*/
|
589
|
+
declare function htmlToNode(html: string, schema: Schema): ProseMirrorNode;
|
590
|
+
export { htmlToNode }
|
591
|
+
export { htmlToNode as htmlToNode_alias_1 }
|
592
|
+
|
453
593
|
declare function insertNode(options: {
|
454
594
|
node: ProseMirrorNode;
|
455
595
|
pos?: number;
|
@@ -484,7 +624,9 @@ export declare function isNodeActive(state: EditorState, type: string | NodeType
|
|
484
624
|
|
485
625
|
export declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
|
486
626
|
|
487
|
-
/**
|
627
|
+
/**
|
628
|
+
* @public
|
629
|
+
*/
|
488
630
|
declare interface Keymap {
|
489
631
|
[key: string]: Command;
|
490
632
|
}
|
@@ -560,6 +702,8 @@ declare interface NodeViewOptions {
|
|
560
702
|
export { NodeViewOptions }
|
561
703
|
export { NodeViewOptions as NodeViewOptions_alias_1 }
|
562
704
|
|
705
|
+
export declare function notNull<T>(value: T | null | undefined): value is T;
|
706
|
+
|
563
707
|
export declare function objectEqual<T>(a: T, b: T): boolean;
|
564
708
|
|
565
709
|
declare type Payload = unknown;
|
@@ -568,12 +712,16 @@ export declare type Payloads = PayloadTuple[];
|
|
568
712
|
|
569
713
|
declare type PayloadTuple = Tuple5<Payload[]>;
|
570
714
|
|
571
|
-
/**
|
715
|
+
/**
|
716
|
+
* @internal
|
717
|
+
*/
|
572
718
|
declare const pluginFacet: Facet<PluginPayload, StatePayload>;
|
573
719
|
export { pluginFacet }
|
574
720
|
export { pluginFacet as pluginFacet_alias_1 }
|
575
721
|
|
576
|
-
/**
|
722
|
+
/**
|
723
|
+
* @internal
|
724
|
+
*/
|
577
725
|
declare type PluginPayload = (context: {
|
578
726
|
schema: Schema;
|
579
727
|
}) => Plugin_2[];
|
@@ -601,6 +749,30 @@ declare class ProseKitError extends Error {
|
|
601
749
|
export { ProseKitError }
|
602
750
|
export { ProseKitError as ProseKitError_alias_1 }
|
603
751
|
|
752
|
+
/**
|
753
|
+
* Remove the given mark from the inline content.
|
754
|
+
*/
|
755
|
+
declare function removeMark(options: {
|
756
|
+
/**
|
757
|
+
* The type of the mark to remove.
|
758
|
+
*/
|
759
|
+
type: string | MarkType;
|
760
|
+
/**
|
761
|
+
* If attrs is given, remove precisely the mark with the given attrs. Otherwise, remove all marks of the given type.
|
762
|
+
*/
|
763
|
+
attrs?: Attrs | null;
|
764
|
+
/**
|
765
|
+
* The start position of the document. By default it will be the start position of current selection.
|
766
|
+
*/
|
767
|
+
from?: number;
|
768
|
+
/**
|
769
|
+
* The end position of the document. By default it will be the end position of current selection.
|
770
|
+
*/
|
771
|
+
to?: number;
|
772
|
+
}): Command;
|
773
|
+
export { removeMark }
|
774
|
+
export { removeMark as removeMark_alias_1 }
|
775
|
+
|
604
776
|
export declare const schemaFacet: Facet<SchemaPayload, SchemaPayload>;
|
605
777
|
|
606
778
|
export declare type SchemaPayload = SchemaSpec;
|
@@ -707,6 +879,15 @@ declare function union<E extends Extension | Extension[]>(extension: E): Simplif
|
|
707
879
|
export { union }
|
708
880
|
export { union as union_alias_1 }
|
709
881
|
|
882
|
+
export declare class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyping> extends BaseExtension<T> implements Extension<T> {
|
883
|
+
extension: BaseExtension[];
|
884
|
+
private _schema;
|
885
|
+
private hasSchemaCount;
|
886
|
+
constructor(extension?: BaseExtension[]);
|
887
|
+
get hasSchema(): boolean;
|
888
|
+
get schema(): Schema | null;
|
889
|
+
}
|
890
|
+
|
710
891
|
export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
|
711
892
|
|
712
893
|
export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
|
@@ -724,7 +905,9 @@ export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
|
|
724
905
|
|
725
906
|
export declare function voidFunction(): void;
|
726
907
|
|
727
|
-
/**
|
908
|
+
/**
|
909
|
+
* @public
|
910
|
+
*/
|
728
911
|
declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
|
729
912
|
export { withPriority }
|
730
913
|
export { withPriority as withPriority_alias_1 }
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
export { addMark } from './_tsup-dts-rollup';
|
2
2
|
export { insertNode } from './_tsup-dts-rollup';
|
3
|
+
export { removeMark } from './_tsup-dts-rollup';
|
3
4
|
export { setBlockType } from './_tsup-dts-rollup';
|
4
5
|
export { toggleMark } from './_tsup-dts-rollup';
|
5
6
|
export { toggleNode } from './_tsup-dts-rollup';
|
@@ -34,7 +35,6 @@ export { pluginFacet } from './_tsup-dts-rollup';
|
|
34
35
|
export { PluginPayload } from './_tsup-dts-rollup';
|
35
36
|
export { defineText } from './_tsup-dts-rollup';
|
36
37
|
export { Facet } from './_tsup-dts-rollup';
|
37
|
-
export { FacetExtension } from './_tsup-dts-rollup';
|
38
38
|
export { FacetOptions } from './_tsup-dts-rollup';
|
39
39
|
export { CommandArgs } from './_tsup-dts-rollup';
|
40
40
|
export { Extension } from './_tsup-dts-rollup';
|
@@ -51,3 +51,7 @@ export { Priority } from './_tsup-dts-rollup';
|
|
51
51
|
export { SimplifyUnion } from './_tsup-dts-rollup';
|
52
52
|
export { getMarkType } from './_tsup-dts-rollup';
|
53
53
|
export { getNodeType } from './_tsup-dts-rollup';
|
54
|
+
export { elementToJSON } from './_tsup-dts-rollup';
|
55
|
+
export { elementToNode } from './_tsup-dts-rollup';
|
56
|
+
export { htmlToJSON } from './_tsup-dts-rollup';
|
57
|
+
export { htmlToNode } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -75,6 +75,24 @@ function insertNode(options) {
|
|
75
75
|
};
|
76
76
|
}
|
77
77
|
|
78
|
+
// src/commands/remove-mark.ts
|
79
|
+
import "@prosekit/pm/model";
|
80
|
+
import "@prosekit/pm/state";
|
81
|
+
function removeMark(options) {
|
82
|
+
return (state, dispatch) => {
|
83
|
+
var _a, _b;
|
84
|
+
const markType = getMarkType(state.schema, options.type);
|
85
|
+
const mark = options.attrs ? markType.create(options.attrs) : markType;
|
86
|
+
const from = (_a = options.from) != null ? _a : state.selection.from;
|
87
|
+
const to = (_b = options.to) != null ? _b : state.selection.to;
|
88
|
+
if (from > to) {
|
89
|
+
return false;
|
90
|
+
}
|
91
|
+
dispatch == null ? void 0 : dispatch(state.tr.removeMark(from, to, mark));
|
92
|
+
return true;
|
93
|
+
};
|
94
|
+
}
|
95
|
+
|
78
96
|
// src/commands/set-block-type.ts
|
79
97
|
import "@prosekit/pm/state";
|
80
98
|
|
@@ -154,30 +172,11 @@ import { setBlockType as setBlockType2 } from "@prosekit/pm/commands";
|
|
154
172
|
import "@prosekit/pm/model";
|
155
173
|
import "@prosekit/pm/state";
|
156
174
|
|
157
|
-
// src/utils/
|
158
|
-
function
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
if (typeof a !== "object" || typeof b !== "object") {
|
163
|
-
return false;
|
164
|
-
}
|
165
|
-
if (a === null || b === null) {
|
166
|
-
return false;
|
167
|
-
}
|
168
|
-
if (Array.isArray(a) || Array.isArray(b)) {
|
169
|
-
return false;
|
170
|
-
}
|
171
|
-
const aKeys = Object.keys(a);
|
172
|
-
const bKeys = Object.keys(b);
|
173
|
-
if (aKeys.length !== bKeys.length) {
|
174
|
-
return false;
|
175
|
-
}
|
176
|
-
for (const key of aKeys) {
|
177
|
-
if (!bKeys.includes(key)) {
|
178
|
-
return false;
|
179
|
-
}
|
180
|
-
if (!objectEqual(a[key], b[key])) {
|
175
|
+
// src/utils/attrs-match.ts
|
176
|
+
function attrsMatch(nodeOrMark, attrs) {
|
177
|
+
const currentAttrs = nodeOrMark.attrs;
|
178
|
+
for (const [key, value] of Object.entries(attrs)) {
|
179
|
+
if (currentAttrs[key] !== value) {
|
181
180
|
return false;
|
182
181
|
}
|
183
182
|
}
|
@@ -190,7 +189,7 @@ function isNodeActive(state, type, attrs) {
|
|
190
189
|
const nodeType = getNodeType(state.schema, type);
|
191
190
|
for (let depth = $pos.depth; depth >= 0; depth--) {
|
192
191
|
const node = $pos.node(depth);
|
193
|
-
if (node.type === nodeType && (!attrs ||
|
192
|
+
if (node.type === nodeType && (!attrs || attrsMatch(node, attrs))) {
|
194
193
|
return true;
|
195
194
|
}
|
196
195
|
}
|
@@ -217,7 +216,7 @@ function toggleNode({
|
|
217
216
|
}
|
218
217
|
|
219
218
|
// src/editor/editor.ts
|
220
|
-
import { Schema as
|
219
|
+
import { Schema as Schema6 } from "@prosekit/pm/model";
|
221
220
|
import { EditorState } from "@prosekit/pm/state";
|
222
221
|
import { EditorView } from "@prosekit/pm/view";
|
223
222
|
|
@@ -245,6 +244,14 @@ function uniqRemove(prev, next) {
|
|
245
244
|
return result;
|
246
245
|
}
|
247
246
|
|
247
|
+
// src/facets/base-extension.ts
|
248
|
+
import "@prosekit/pm/model";
|
249
|
+
var BaseExtension = class {
|
250
|
+
constructor() {
|
251
|
+
this.extension = [];
|
252
|
+
}
|
253
|
+
};
|
254
|
+
|
248
255
|
// src/facets/facet.ts
|
249
256
|
var facetCount = 0;
|
250
257
|
function getFacetCount() {
|
@@ -252,8 +259,14 @@ function getFacetCount() {
|
|
252
259
|
}
|
253
260
|
var Facet = class _Facet {
|
254
261
|
constructor(converter, next, singleton) {
|
255
|
-
/**
|
262
|
+
/**
|
263
|
+
* @internal
|
264
|
+
*/
|
256
265
|
this.index = facetCount++;
|
266
|
+
/**
|
267
|
+
* @internal
|
268
|
+
*/
|
269
|
+
this.isSchema = false;
|
257
270
|
this.converter = converter;
|
258
271
|
this.next = next;
|
259
272
|
this.singleton = singleton;
|
@@ -273,18 +286,24 @@ var Facet = class _Facet {
|
|
273
286
|
}
|
274
287
|
return new _Facet(converterFunction, next, singleton != null ? singleton : false);
|
275
288
|
}
|
276
|
-
/**
|
289
|
+
/**
|
290
|
+
* @internal
|
291
|
+
*/
|
277
292
|
static defineRootFacet(options) {
|
278
293
|
return _Facet.define(options);
|
279
294
|
}
|
280
295
|
extension(payloads) {
|
281
|
-
return new
|
296
|
+
return new FacetExtensionImpl(this, payloads);
|
282
297
|
}
|
283
298
|
};
|
284
|
-
var
|
299
|
+
var FacetExtensionImpl = class extends BaseExtension {
|
285
300
|
constructor(facet, payloads) {
|
301
|
+
var _a;
|
302
|
+
super();
|
286
303
|
this.facet = facet;
|
287
304
|
this.payloads = payloads;
|
305
|
+
this.schema = null;
|
306
|
+
this.hasSchema = !!(facet.isSchema || ((_a = facet.next) == null ? void 0 : _a.isSchema));
|
288
307
|
}
|
289
308
|
};
|
290
309
|
|
@@ -319,118 +338,97 @@ var stateFacet = Facet.defineRootFacet({
|
|
319
338
|
}
|
320
339
|
});
|
321
340
|
|
322
|
-
// src/
|
323
|
-
|
324
|
-
return stateFacet.extension([
|
325
|
-
({ schema }) => {
|
326
|
-
const config = {};
|
327
|
-
if (options.doc) {
|
328
|
-
config.doc = schema.nodeFromJSON(options.doc);
|
329
|
-
if (options.selection) {
|
330
|
-
config.selection = Selection.fromJSON(config.doc, options.selection);
|
331
|
-
}
|
332
|
-
}
|
333
|
-
return config;
|
334
|
-
}
|
335
|
-
]);
|
336
|
-
}
|
341
|
+
// src/utils/parse.ts
|
342
|
+
import { DOMParser } from "@prosekit/pm/model";
|
337
343
|
|
338
|
-
// src/utils/
|
339
|
-
|
340
|
-
|
341
|
-
|
344
|
+
// src/utils/get-dom-api.ts
|
345
|
+
function getGlobalBrowserDocument() {
|
346
|
+
if (typeof document !== "undefined") {
|
347
|
+
return document;
|
348
|
+
}
|
349
|
+
if (typeof globalThis !== "undefined" && globalThis.document) {
|
350
|
+
return globalThis.document;
|
351
|
+
}
|
342
352
|
}
|
343
|
-
function
|
344
|
-
|
353
|
+
function getGlobalBrowserWindow() {
|
354
|
+
if (typeof window !== "undefined") {
|
355
|
+
return window;
|
356
|
+
}
|
357
|
+
if (typeof globalThis !== "undefined" && globalThis.window) {
|
358
|
+
return globalThis.window;
|
359
|
+
}
|
345
360
|
}
|
346
|
-
|
347
|
-
// src/utils/is-mark-active.ts
|
348
|
-
function isMarkActive(state, type, attrs) {
|
361
|
+
function getBrowserWindow() {
|
349
362
|
var _a;
|
350
|
-
const
|
351
|
-
|
352
|
-
|
353
|
-
return state.doc.rangeHasMark(from, to, mark) || hasMark(
|
354
|
-
[...$from.marks(), ...$to.marks(), ...(_a = state.storedMarks) != null ? _a : []],
|
355
|
-
mark
|
356
|
-
);
|
357
|
-
}
|
358
|
-
function hasMark(marks, mark) {
|
359
|
-
if (marks.length === 0) {
|
360
|
-
return false;
|
361
|
-
}
|
362
|
-
if (isMark(mark)) {
|
363
|
-
return marks.some((m) => m.eq(mark));
|
364
|
-
} else {
|
365
|
-
return marks.some((m) => m.type === mark);
|
363
|
+
const win = getGlobalBrowserWindow();
|
364
|
+
if (win) {
|
365
|
+
return win;
|
366
366
|
}
|
367
|
+
return (_a = getGlobalBrowserDocument()) == null ? void 0 : _a.defaultView;
|
367
368
|
}
|
368
369
|
|
369
|
-
// src/
|
370
|
-
|
371
|
-
|
372
|
-
const builder = (...args) => buildNode(type, args);
|
373
|
-
builder.isActive = (attrs) => {
|
374
|
-
const state = getState();
|
375
|
-
return state ? isNodeActive(state, type, attrs) : false;
|
376
|
-
};
|
377
|
-
return builder;
|
370
|
+
// src/utils/parse.ts
|
371
|
+
function elementToNode(element, schema) {
|
372
|
+
return DOMParser.fromSchema(schema).parse(element);
|
378
373
|
}
|
379
|
-
function
|
380
|
-
|
381
|
-
builder.isActive = (attrs) => {
|
382
|
-
const state = getState();
|
383
|
-
return state ? isMarkActive(state, type, attrs) : false;
|
384
|
-
};
|
385
|
-
return builder;
|
374
|
+
function elementToJSON(element, schema) {
|
375
|
+
return elementToNode(element, schema).toJSON();
|
386
376
|
}
|
387
|
-
function
|
388
|
-
|
389
|
-
return flattenChildren(type.schema, children, type.create(attrs));
|
377
|
+
function htmlToNode(html, schema) {
|
378
|
+
return elementToNode(htmlToElement(html), schema);
|
390
379
|
}
|
391
|
-
function
|
392
|
-
|
393
|
-
const node = type.createAndFill(attrs, flattenChildren(type.schema, children));
|
394
|
-
if (!node) {
|
395
|
-
throw new ProseKitError(`Couldn't create node ${type.name}`);
|
396
|
-
}
|
397
|
-
return node;
|
380
|
+
function htmlToJSON(html, schema) {
|
381
|
+
return elementToJSON(htmlToElement(html), schema);
|
398
382
|
}
|
399
|
-
function
|
400
|
-
const
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
}
|
406
|
-
} else if (Array.isArray(child)) {
|
407
|
-
nodes.push(...flattenChildren(schema, child, mark));
|
408
|
-
} else if (isProseMirrorNode(child)) {
|
409
|
-
nodes.push(mark ? child.mark(mark.addToSet(child.marks)) : child);
|
410
|
-
} else {
|
411
|
-
throw new ProseKitError(`Invalid node child: ${typeof child}`);
|
412
|
-
}
|
413
|
-
}
|
414
|
-
return nodes;
|
415
|
-
}
|
416
|
-
function normalizeArgs(args) {
|
417
|
-
const [attrs, ...children] = args;
|
418
|
-
if (isNodeChild(args)) {
|
419
|
-
children.unshift(args);
|
420
|
-
return [null, children];
|
421
|
-
} else if (typeof attrs === "object") {
|
422
|
-
return [attrs, children];
|
423
|
-
} else {
|
424
|
-
return [null, children];
|
383
|
+
function htmlToElement(html) {
|
384
|
+
const win = getBrowserWindow();
|
385
|
+
if (!win) {
|
386
|
+
throw new ProseKitError(
|
387
|
+
"No Browser Document Found. You can only parse a HTML string in the browser environment."
|
388
|
+
);
|
425
389
|
}
|
390
|
+
const parser = new win.DOMParser();
|
391
|
+
return parser.parseFromString(`<body>${html}</body>`, "text/html").body;
|
426
392
|
}
|
427
|
-
|
428
|
-
|
429
|
-
|
393
|
+
|
394
|
+
// src/extensions/default-state.ts
|
395
|
+
function defineDefaultState({
|
396
|
+
defaultDoc,
|
397
|
+
defaultHTML,
|
398
|
+
defaultSelection
|
399
|
+
}) {
|
400
|
+
if (defaultHTML && defaultDoc) {
|
401
|
+
throw new ProseKitError(
|
402
|
+
"Only one of defaultHTML and defaultDoc can be provided"
|
403
|
+
);
|
430
404
|
}
|
431
|
-
return
|
405
|
+
return stateFacet.extension([
|
406
|
+
({ schema }) => {
|
407
|
+
const config = {};
|
408
|
+
if (defaultHTML) {
|
409
|
+
defaultDoc = htmlToJSON(defaultHTML, schema);
|
410
|
+
}
|
411
|
+
if (defaultDoc) {
|
412
|
+
config.doc = schema.nodeFromJSON(defaultDoc);
|
413
|
+
if (defaultSelection) {
|
414
|
+
config.selection = Selection.fromJSON(config.doc, defaultSelection);
|
415
|
+
}
|
416
|
+
}
|
417
|
+
return config;
|
418
|
+
}
|
419
|
+
]);
|
432
420
|
}
|
433
421
|
|
422
|
+
// src/types/priority.ts
|
423
|
+
var Priority = /* @__PURE__ */ ((Priority2) => {
|
424
|
+
Priority2[Priority2["lowest"] = 4] = "lowest";
|
425
|
+
Priority2[Priority2["low"] = 3] = "low";
|
426
|
+
Priority2[Priority2["default"] = 2] = "default";
|
427
|
+
Priority2[Priority2["high"] = 1] = "high";
|
428
|
+
Priority2[Priority2["highest"] = 0] = "highest";
|
429
|
+
return Priority2;
|
430
|
+
})(Priority || {});
|
431
|
+
|
434
432
|
// src/facets/command.ts
|
435
433
|
var commandFacet = Facet.defineRootFacet({
|
436
434
|
convert: (inputs) => {
|
@@ -454,6 +452,7 @@ var schemaFacet = Facet.defineRootFacet({
|
|
454
452
|
return { nodes, marks, topNode };
|
455
453
|
}
|
456
454
|
});
|
455
|
+
schemaFacet.isSchema = true;
|
457
456
|
|
458
457
|
// src/facets/view.ts
|
459
458
|
var viewFacet = Facet.defineRootFacet({
|
@@ -462,17 +461,7 @@ var viewFacet = Facet.defineRootFacet({
|
|
462
461
|
}
|
463
462
|
});
|
464
463
|
|
465
|
-
// src/
|
466
|
-
var Priority = /* @__PURE__ */ ((Priority2) => {
|
467
|
-
Priority2[Priority2["lowest"] = 4] = "lowest";
|
468
|
-
Priority2[Priority2["low"] = 3] = "low";
|
469
|
-
Priority2[Priority2["default"] = 2] = "default";
|
470
|
-
Priority2[Priority2["high"] = 1] = "high";
|
471
|
-
Priority2[Priority2["highest"] = 0] = "highest";
|
472
|
-
return Priority2;
|
473
|
-
})(Priority || {});
|
474
|
-
|
475
|
-
// src/editor/flatten.ts
|
464
|
+
// src/facets/flatten.ts
|
476
465
|
function flattenInputTuple(inputTuple) {
|
477
466
|
return [
|
478
467
|
...inputTuple[0],
|
@@ -521,7 +510,7 @@ function extractFacets(root) {
|
|
521
510
|
while (extensions.length > 0) {
|
522
511
|
const ext = extensions.pop();
|
523
512
|
const pri = priorities.pop();
|
524
|
-
if (ext instanceof
|
513
|
+
if (ext instanceof FacetExtensionImpl) {
|
525
514
|
const facet = ext.facet;
|
526
515
|
if (!facets[facet.index]) {
|
527
516
|
facets[facet.index] = facet;
|
@@ -646,26 +635,165 @@ function updateExtension(prevInputs, prevConverters, extension, mode) {
|
|
646
635
|
return { schemaInput, stateInput, viewInput, commandInput };
|
647
636
|
}
|
648
637
|
|
649
|
-
// src/
|
650
|
-
|
651
|
-
|
652
|
-
|
638
|
+
// src/utils/type-assertion.ts
|
639
|
+
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
640
|
+
function isProseMirrorNode(node) {
|
641
|
+
return node instanceof ProseMirrorNode;
|
642
|
+
}
|
643
|
+
function isMark(mark) {
|
644
|
+
return mark instanceof Mark;
|
645
|
+
}
|
646
|
+
|
647
|
+
// src/utils/is-mark-active.ts
|
648
|
+
function isMarkActive(state, type, attrs) {
|
649
|
+
const markType = getMarkType(state.schema, type);
|
650
|
+
const mark = attrs ? markType.create(attrs) : markType;
|
651
|
+
const { from, $from, to, empty } = state.selection;
|
652
|
+
if (empty) {
|
653
|
+
return hasMark(state.storedMarks || $from.marks(), mark);
|
654
|
+
} else {
|
655
|
+
return state.doc.rangeHasMark(from, to, mark);
|
656
|
+
}
|
657
|
+
}
|
658
|
+
function hasMark(marks, mark) {
|
659
|
+
if (marks.length === 0) {
|
660
|
+
return false;
|
661
|
+
}
|
662
|
+
if (isMark(mark)) {
|
663
|
+
return marks.some((m) => m.eq(mark));
|
664
|
+
} else {
|
665
|
+
return marks.some((m) => m.type === mark);
|
653
666
|
}
|
654
|
-
|
667
|
+
}
|
668
|
+
|
669
|
+
// src/editor/builder.ts
|
670
|
+
import "@prosekit/pm/model";
|
671
|
+
function createNodeBuilder(getState, type) {
|
672
|
+
const builder = (...args) => buildNode(type, args);
|
673
|
+
builder.isActive = (attrs) => {
|
674
|
+
const state = getState();
|
675
|
+
return state ? isNodeActive(state, type, attrs) : false;
|
676
|
+
};
|
677
|
+
return builder;
|
678
|
+
}
|
679
|
+
function createMarkBuilder(getState, type) {
|
680
|
+
const builder = (...args) => buildMark(type, args);
|
681
|
+
builder.isActive = (attrs) => {
|
682
|
+
const state = getState();
|
683
|
+
return state ? isMarkActive(state, type, attrs) : false;
|
684
|
+
};
|
685
|
+
return builder;
|
686
|
+
}
|
687
|
+
function buildMark(type, args) {
|
688
|
+
const [attrs, children] = normalizeArgs(args);
|
689
|
+
return flattenChildren(type.schema, children, type.create(attrs));
|
690
|
+
}
|
691
|
+
function buildNode(type, args) {
|
692
|
+
const [attrs, children] = normalizeArgs(args);
|
693
|
+
const node = type.createAndFill(attrs, flattenChildren(type.schema, children));
|
694
|
+
if (!node) {
|
695
|
+
throw new ProseKitError(`Couldn't create node ${type.name}`);
|
696
|
+
}
|
697
|
+
return node;
|
698
|
+
}
|
699
|
+
function flattenChildren(schema, children, mark) {
|
700
|
+
const nodes = [];
|
701
|
+
for (const child of children) {
|
702
|
+
if (typeof child === "string") {
|
703
|
+
if (child) {
|
704
|
+
nodes.push(schema.text(child, mark ? [mark] : null));
|
705
|
+
}
|
706
|
+
} else if (Array.isArray(child)) {
|
707
|
+
nodes.push(...flattenChildren(schema, child, mark));
|
708
|
+
} else if (isProseMirrorNode(child)) {
|
709
|
+
nodes.push(mark ? child.mark(mark.addToSet(child.marks)) : child);
|
710
|
+
} else {
|
711
|
+
throw new ProseKitError(`Invalid node child: ${typeof child}`);
|
712
|
+
}
|
713
|
+
}
|
714
|
+
return nodes;
|
715
|
+
}
|
716
|
+
function normalizeArgs(args) {
|
717
|
+
const [attrs, ...children] = args;
|
718
|
+
if (isNodeChild(args)) {
|
719
|
+
children.unshift(args);
|
720
|
+
return [null, children];
|
721
|
+
} else if (typeof attrs === "object") {
|
722
|
+
return [attrs, children];
|
723
|
+
} else {
|
724
|
+
return [null, children];
|
725
|
+
}
|
726
|
+
}
|
727
|
+
function isNodeChild(value) {
|
728
|
+
if (!value) {
|
729
|
+
return false;
|
730
|
+
}
|
731
|
+
return typeof value === "string" || Array.isArray(value) || isProseMirrorNode(value);
|
732
|
+
}
|
733
|
+
|
734
|
+
// src/facets/union-extension.ts
|
735
|
+
import { Schema as Schema5 } from "@prosekit/pm/model";
|
736
|
+
var UnionExtensionImpl = class extends BaseExtension {
|
737
|
+
constructor(extension = []) {
|
738
|
+
super();
|
739
|
+
this.extension = extension;
|
740
|
+
this._schema = void 0;
|
741
|
+
this.hasSchemaCount = 0;
|
742
|
+
for (const e of extension) {
|
743
|
+
if (e instanceof BaseExtension) {
|
744
|
+
this.hasSchemaCount += e.hasSchema ? 1 : 0;
|
745
|
+
} else {
|
746
|
+
throw new ProseKitError("Invalid extension");
|
747
|
+
}
|
748
|
+
}
|
749
|
+
}
|
750
|
+
get hasSchema() {
|
751
|
+
return this.hasSchemaCount > 0;
|
752
|
+
}
|
753
|
+
get schema() {
|
754
|
+
var _a;
|
755
|
+
if (this._schema !== void 0) {
|
756
|
+
return this._schema;
|
757
|
+
}
|
758
|
+
if (this.hasSchemaCount === 0) {
|
759
|
+
this._schema = null;
|
760
|
+
return this._schema;
|
761
|
+
}
|
762
|
+
if (this.hasSchemaCount === 1) {
|
763
|
+
const schema = (_a = this.extension.find((e) => e.hasSchema)) == null ? void 0 : _a.schema;
|
764
|
+
if (schema) {
|
765
|
+
this._schema = schema;
|
766
|
+
return this._schema;
|
767
|
+
}
|
768
|
+
}
|
769
|
+
const { schemaInput } = updateExtension([], [], this, "add");
|
770
|
+
this._schema = schemaInput ? new Schema5(schemaInput) : null;
|
771
|
+
return this._schema;
|
772
|
+
}
|
773
|
+
};
|
774
|
+
|
775
|
+
// src/editor/union.ts
|
776
|
+
function union(extension) {
|
777
|
+
const array = Array.isArray(extension) ? extension : [extension];
|
778
|
+
return new UnionExtensionImpl(
|
779
|
+
array
|
780
|
+
);
|
655
781
|
}
|
656
782
|
|
657
783
|
// src/editor/editor.ts
|
658
784
|
function createEditor({
|
659
785
|
extension,
|
660
786
|
defaultDoc,
|
787
|
+
defaultHTML,
|
661
788
|
defaultSelection
|
662
789
|
}) {
|
663
|
-
if (defaultDoc) {
|
790
|
+
if (defaultDoc || defaultHTML) {
|
664
791
|
extension = union([
|
665
792
|
extension,
|
666
793
|
defineDefaultState({
|
667
|
-
|
668
|
-
|
794
|
+
defaultDoc,
|
795
|
+
defaultHTML,
|
796
|
+
defaultSelection
|
669
797
|
})
|
670
798
|
]);
|
671
799
|
}
|
@@ -683,7 +811,7 @@ var EditorInstance = class {
|
|
683
811
|
if (!schemaInput) {
|
684
812
|
throw new ProseKitError("Schema must be defined");
|
685
813
|
}
|
686
|
-
const schema = new
|
814
|
+
const schema = new Schema6(schemaInput);
|
687
815
|
const stateConfig = stateInput ? stateInput({ schema }) : { schema };
|
688
816
|
const state = EditorState.create(stateConfig);
|
689
817
|
if (commandInput) {
|
@@ -805,7 +933,9 @@ var Editor = class _Editor {
|
|
805
933
|
this.unmount = this.unmount.bind(this);
|
806
934
|
this.use = this.use.bind(this);
|
807
935
|
}
|
808
|
-
/**
|
936
|
+
/**
|
937
|
+
* @internal
|
938
|
+
*/
|
809
939
|
static create(instance) {
|
810
940
|
if (!(instance instanceof EditorInstance)) {
|
811
941
|
throw new TypeError("Invalid EditorInstance");
|
@@ -872,7 +1002,9 @@ var Editor = class _Editor {
|
|
872
1002
|
|
873
1003
|
// src/editor/with-priority.ts
|
874
1004
|
function withPriority(extension, priority) {
|
875
|
-
|
1005
|
+
const result = union(extension);
|
1006
|
+
result.priority = priority;
|
1007
|
+
return result;
|
876
1008
|
}
|
877
1009
|
|
878
1010
|
// src/commands/insert-text.ts
|
@@ -949,7 +1081,9 @@ function defineBaseCommands() {
|
|
949
1081
|
insertNode: insertNode2,
|
950
1082
|
wrap,
|
951
1083
|
setBlockType,
|
952
|
-
selectAll
|
1084
|
+
selectAll,
|
1085
|
+
addMark,
|
1086
|
+
removeMark
|
953
1087
|
});
|
954
1088
|
}
|
955
1089
|
|
@@ -1246,7 +1380,6 @@ function defineText() {
|
|
1246
1380
|
export {
|
1247
1381
|
Editor,
|
1248
1382
|
Facet,
|
1249
|
-
FacetExtension,
|
1250
1383
|
Priority,
|
1251
1384
|
ProseKitError,
|
1252
1385
|
addMark,
|
@@ -1267,10 +1400,15 @@ export {
|
|
1267
1400
|
defineParagraph,
|
1268
1401
|
definePlugin,
|
1269
1402
|
defineText,
|
1403
|
+
elementToJSON,
|
1404
|
+
elementToNode,
|
1270
1405
|
getMarkType,
|
1271
1406
|
getNodeType,
|
1407
|
+
htmlToJSON,
|
1408
|
+
htmlToNode,
|
1272
1409
|
insertNode,
|
1273
1410
|
pluginFacet,
|
1411
|
+
removeMark,
|
1274
1412
|
setBlockType,
|
1275
1413
|
toggleMark,
|
1276
1414
|
toggleNode,
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.18",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -38,7 +38,7 @@
|
|
38
38
|
"dist"
|
39
39
|
],
|
40
40
|
"dependencies": {
|
41
|
-
"@prosekit/pm": "^0.0.
|
41
|
+
"@prosekit/pm": "^0.0.7",
|
42
42
|
"orderedmap": "^2.1.1",
|
43
43
|
"type-fest": "^4.6.0"
|
44
44
|
},
|
package/src/index.ts
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
export { addMark } from './commands/add-mark'
|
2
|
-
export { insertNode } from './commands/insert-node'
|
3
|
-
export { setBlockType } from './commands/set-block-type'
|
4
|
-
export { toggleMark } from './commands/toggle-mark'
|
5
|
-
export { toggleNode } from './commands/toggle-node'
|
6
|
-
export { Editor, createEditor, type EditorOptions } from './editor/editor'
|
7
|
-
export { union } from './editor/type-utils'
|
8
|
-
export { withPriority } from './editor/with-priority'
|
9
|
-
export { ProseKitError } from './error'
|
10
|
-
export { defineBaseCommands, defineCommands } from './extensions/command'
|
11
|
-
export {
|
12
|
-
defineDefaultState,
|
13
|
-
type DefaultStateOptions,
|
14
|
-
} from './extensions/default-state'
|
15
|
-
export { defineDoc } from './extensions/doc'
|
16
|
-
export { defineEventHandler } from './extensions/event-handler'
|
17
|
-
export { defineHistory } from './extensions/history'
|
18
|
-
export { defineInputRule } from './extensions/input-rules'
|
19
|
-
export {
|
20
|
-
defineBaseKeymap,
|
21
|
-
defineKeymap,
|
22
|
-
type Keymap,
|
23
|
-
} from './extensions/keymap'
|
24
|
-
export { defineMarkSpec, type MarkSpecOptions } from './extensions/mark-spec'
|
25
|
-
export { defineNodeSpec, type NodeSpecOptions } from './extensions/node-spec'
|
26
|
-
export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
|
27
|
-
export {
|
28
|
-
defineNodeViewEffect,
|
29
|
-
type NodeViewEffectOptions,
|
30
|
-
} from './extensions/node-view-effect'
|
31
|
-
export { defineParagraph } from './extensions/paragraph'
|
32
|
-
export {
|
33
|
-
definePlugin,
|
34
|
-
pluginFacet,
|
35
|
-
type PluginPayload,
|
36
|
-
} from './extensions/plugin'
|
37
|
-
export { defineText } from './extensions/text'
|
38
|
-
export { Facet, FacetExtension, type FacetOptions } from './facets/facet'
|
39
|
-
export { type CommandArgs as CommandArgs } from './types/command'
|
40
|
-
export {
|
41
|
-
type Extension,
|
42
|
-
type ExtractCommandAppliers,
|
43
|
-
type ExtractCommandCreators,
|
44
|
-
type ExtractMarks,
|
45
|
-
type ExtractNodes,
|
46
|
-
type SimplifyExtension,
|
47
|
-
} from './types/extension'
|
48
|
-
export { type ExtensionTyping } from './types/extension-typing'
|
49
|
-
export type { NodeJson, SelectionJson, StateJson } from './types/model'
|
50
|
-
export { Priority } from './types/priority'
|
51
|
-
export { type SimplifyUnion } from './types/simplify-union'
|
52
|
-
export { getMarkType } from './utils/get-mark-type'
|
53
|
-
export { getNodeType } from './utils/get-node-type'
|