@prosekit/core 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,627 @@
1
+ import { Attrs } from '@prosekit/pm/model';
2
+ import { Command } from '@prosekit/pm/state';
3
+ import type { ConditionalExcept } from 'type-fest';
4
+ import type { DirectEditorProps } from '@prosekit/pm/view';
5
+ import type { EditorState } from '@prosekit/pm/state';
6
+ import type { EditorStateConfig } from '@prosekit/pm/state';
7
+ import { EditorView } from '@prosekit/pm/view';
8
+ import type { EmptyObject } from 'type-fest';
9
+ import { InputRule } from '@prosekit/pm/inputrules';
10
+ import type { IsEqual } from 'type-fest';
11
+ import type { MarkSpec } from '@prosekit/pm/model';
12
+ import { MarkType } from '@prosekit/pm/model';
13
+ import type { NodeSpec } from '@prosekit/pm/model';
14
+ import { NodeType } from '@prosekit/pm/model';
15
+ import { NodeViewConstructor } from '@prosekit/pm/view';
16
+ import { Options } from 'tsup';
17
+ import { Plugin as Plugin_2 } from '@prosekit/pm/state';
18
+ import { ProseMirrorNode } from '@prosekit/pm/model';
19
+ import { Schema } from '@prosekit/pm/model';
20
+ import type { SchemaSpec } from '@prosekit/pm/model';
21
+ import type { Simplify } from 'type-fest';
22
+ import { Transaction } from '@prosekit/pm/state';
23
+ import type { UnionToIntersection } from 'type-fest';
24
+ import { UserProjectConfigExport } from 'vitest/dist/config.js';
25
+
26
+ declare type Action = (options: {
27
+ tr: Transaction;
28
+ view?: EditorView;
29
+ }) => boolean;
30
+
31
+ /**
32
+ * Add some base commands
33
+ *
34
+ * @public
35
+ */
36
+ declare function addBaseCommands(): Extension<{
37
+ COMMAND_ARGS: {
38
+ insertText: [{
39
+ text: string;
40
+ from?: number | undefined;
41
+ to?: number | undefined;
42
+ }];
43
+ insertNode: [{
44
+ node: ProseMirrorNode;
45
+ pos?: number | undefined;
46
+ }];
47
+ wrap: [{
48
+ nodeType: NodeType;
49
+ attrs?: Attrs | null | undefined;
50
+ }];
51
+ setBlockType: [{
52
+ nodeType: NodeType;
53
+ attrs?: Attrs | null | undefined;
54
+ from?: number | undefined;
55
+ to?: number | undefined;
56
+ }];
57
+ selectAll: [];
58
+ };
59
+ }>;
60
+ export { addBaseCommands }
61
+ export { addBaseCommands as addBaseCommands_alias_1 }
62
+
63
+ /** @public */
64
+ declare function addBaseKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
65
+ export { addBaseKeymap }
66
+ export { addBaseKeymap as addBaseKeymap_alias_1 }
67
+
68
+ declare function addCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
69
+ COMMAND_ARGS: {
70
+ [K in keyof T]: Parameters<T[K]>;
71
+ };
72
+ }>;
73
+ export { addCommands }
74
+ export { addCommands as addCommands_alias_1 }
75
+
76
+ declare function addDefaultState(options: DefaultStateOptions): Extension;
77
+ export { addDefaultState }
78
+ export { addDefaultState as addDefaultState_alias_1 }
79
+
80
+ /** @public */
81
+ declare function addDoc(): Extension< {
82
+ NODES: "doc";
83
+ }>;
84
+ export { addDoc }
85
+ export { addDoc as addDoc_alias_1 }
86
+
87
+ /**
88
+ * @public
89
+ */
90
+ declare function addInputRule(rules: (context: {
91
+ schema: Schema;
92
+ }) => InputRule[]): Extension;
93
+ export { addInputRule }
94
+ export { addInputRule as addInputRule_alias_1 }
95
+
96
+ /** @public */
97
+ declare function addKeymap(keymap: Keymap): Extension;
98
+ export { addKeymap }
99
+ export { addKeymap as addKeymap_alias_1 }
100
+
101
+ declare function addMark(options: AddMarkOptions): Command;
102
+ export { addMark }
103
+ export { addMark as addMark_alias_1 }
104
+
105
+ declare interface AddMarkOptions {
106
+ type: string | MarkType;
107
+ attrs?: Attrs | null;
108
+ /**
109
+ * The start position of the mark. By default it will be the start position of current selection.
110
+ */
111
+ from?: number;
112
+ /**
113
+ * The end position of the mark. By default it will be the end position of current selection.
114
+ */
115
+ to?: number;
116
+ }
117
+ export { AddMarkOptions }
118
+ export { AddMarkOptions as AddMarkOptions_alias_1 }
119
+
120
+ /**
121
+ * @public
122
+ */
123
+ declare function addMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
124
+ MARKS: Mark;
125
+ }>;
126
+ export { addMarkSpec }
127
+ export { addMarkSpec as addMarkSpec_alias_1 }
128
+
129
+ /**
130
+ * @public
131
+ */
132
+ declare function addNodeSpec<NodeName extends string>(options: NodeSpecOptions<NodeName>): Extension<{
133
+ NODES: NodeName;
134
+ }>;
135
+ export { addNodeSpec }
136
+ export { addNodeSpec as addNodeSpec_alias_1 }
137
+
138
+ declare function addNodeView(options: NodeViewOptions): Extension;
139
+ export { addNodeView }
140
+ export { addNodeView as addNodeView_alias_1 }
141
+
142
+ /** @public */
143
+ declare function addParagraph(): Extension< {
144
+ NODES: "paragraph";
145
+ }>;
146
+ export { addParagraph }
147
+ export { addParagraph as addParagraph_alias_1 }
148
+
149
+ /**
150
+ * Adds a ProseMirror plugin to the editor.
151
+ *
152
+ * @param plugin - The ProseMirror plugin to add, or an array of plugins, or a
153
+ * function that returns an array of plugins.
154
+ *
155
+ * @public
156
+ */
157
+ declare function addPlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
158
+ schema: Schema;
159
+ }) => Plugin_2[])): Extension;
160
+ export { addPlugin }
161
+ export { addPlugin as addPlugin_alias_1 }
162
+
163
+ /** @public */
164
+ declare function addText(): Extension< {
165
+ NODES: "text";
166
+ }>;
167
+ export { addText }
168
+ export { addText as addText_alias_1 }
169
+
170
+ export declare type AnySlot = Slot<any, any>;
171
+
172
+ export declare function applyAction(operator: Action): Command;
173
+
174
+ /**
175
+ * Utility function assert that two types are equal in tests.
176
+ */
177
+ export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
178
+
179
+ /** @internal */
180
+ declare interface CommandArgs {
181
+ [name: string]: any[];
182
+ }
183
+ export { CommandArgs }
184
+ export { CommandArgs as CommandArgs_alias_1 }
185
+
186
+ export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
187
+
188
+ export declare interface CommandCreators {
189
+ [name: string]: CommandCreator;
190
+ }
191
+
192
+ export declare type CommandDispatcher<Args extends any[] = any[]> = (...arg: Args) => boolean;
193
+
194
+ export declare const commandSlot: Facet<CommandSlotInput, CommandSlotInput>;
195
+
196
+ export declare type CommandSlotInput = Record<string, CommandCreator<any>>;
197
+
198
+ /** @public */
199
+ declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultSelection, }: EditorOptions<E>): Editor<E>;
200
+ export { createEditor }
201
+ export { createEditor as createEditor_alias_1 }
202
+
203
+ export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
204
+
205
+ export declare const default_alias_1: UserProjectConfigExport;
206
+
207
+ declare interface DefaultStateOptions {
208
+ /**
209
+ * A JSON representation of a ProseMirror document.
210
+ */
211
+ doc?: NodeJson;
212
+ /**
213
+ * A JSON representation of a ProseMirror selection.
214
+ */
215
+ selection?: SelectionJson;
216
+ }
217
+ export { DefaultStateOptions }
218
+ export { DefaultStateOptions as DefaultStateOptions_alias_1 }
219
+
220
+ declare function defineExtension<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
221
+ export { defineExtension }
222
+ export { defineExtension as defineExtension_alias_1 }
223
+
224
+ /** @public */
225
+ declare class Editor<E extends Extension = any> {
226
+ private instance;
227
+ private constructor();
228
+ private afterMounted;
229
+ /** @internal */
230
+ static create(instance: any): Editor<any>;
231
+ get mounted(): boolean;
232
+ get view(): EditorView;
233
+ get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
234
+ get commands(): ExtractCommandDispatchers<E>;
235
+ mount(place: HTMLElement | null | undefined | void): void;
236
+ unmount(): void;
237
+ use(extension: Extension): VoidFunction;
238
+ isNodeActive(nodeType: string | NodeType, attrs?: Attrs): boolean;
239
+ isMarkActive(markType: string | MarkType, attrs?: Attrs): boolean;
240
+ }
241
+ export { Editor }
242
+ export { Editor as Editor_alias_1 }
243
+
244
+ /** @public */
245
+ declare interface EditorOptions<E extends Extension> {
246
+ /**
247
+ * The extension to use when creating the editor.
248
+ */
249
+ extension: E;
250
+ /**
251
+ * A JSON object representing the starting document to use when creating the
252
+ * editor.
253
+ */
254
+ defaultDoc?: NodeJson;
255
+ /**
256
+ * A JSON object representing the starting selection to use when creating the
257
+ * editor. It's only used when `defaultDoc` is also provided.
258
+ */
259
+ defaultSelection?: SelectionJson;
260
+ }
261
+ export { EditorOptions }
262
+ export { EditorOptions as EditorOptions_alias_1 }
263
+
264
+ declare type EmptyValue = never | undefined | null | EmptyObject;
265
+
266
+ export declare type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
267
+
268
+ /**
269
+ * @public
270
+ */
271
+ declare interface Extension<T extends ExtensionTyping = ExtensionTyping> {
272
+ extension: Extension | Extension[];
273
+ priority?: Priority;
274
+ _type?: T;
275
+ }
276
+ export { Extension }
277
+ export { Extension as Extension_alias_1 }
278
+
279
+ /**
280
+ * @internal
281
+ */
282
+ declare interface ExtensionTyping<Node extends string = string, Mark extends string = string, Commands extends CommandArgs = CommandArgs> {
283
+ NODES?: Node;
284
+ MARKS?: Mark;
285
+ COMMAND_ARGS?: Commands;
286
+ }
287
+ export { ExtensionTyping }
288
+ export { ExtensionTyping as ExtensionTyping_alias_1 }
289
+
290
+ /**
291
+ * @internal
292
+ */
293
+ export declare type ExtractCommandArgs<E extends Extension> = ExtractCommandArgsFromTyping<ExtractTyping<E>>;
294
+
295
+ export declare type ExtractCommandArgsFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'COMMAND_ARGS'>;
296
+
297
+ /**
298
+ * @public
299
+ */
300
+ declare type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommandArgs<E>>;
301
+ export { ExtractCommandCreators }
302
+ export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
303
+
304
+ /**
305
+ * @public
306
+ */
307
+ declare type ExtractCommandDispatchers<E extends Extension> = ToCommandDispatcher<ExtractCommandArgs<E>>;
308
+ export { ExtractCommandDispatchers }
309
+ export { ExtractCommandDispatchers as ExtractCommandDispatchers_alias_1 }
310
+
311
+ /**
312
+ * @intneral
313
+ */
314
+ export declare type ExtractKey<T, K extends string> = Extract<T, Record<K, any>>[K];
315
+
316
+ /**
317
+ * @public
318
+ */
319
+ declare type ExtractMarks<E extends Extension> = ExtractMarksFromTyping<ExtractTyping<E>>;
320
+ export { ExtractMarks }
321
+ export { ExtractMarks as ExtractMarks_alias_1 }
322
+
323
+ export declare type ExtractMarksFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'MARKS'>;
324
+
325
+ /**
326
+ * @public
327
+ */
328
+ declare type ExtractNodes<E extends Extension> = ExtractNodesFromTyping<ExtractTyping<E>>;
329
+ export { ExtractNodes }
330
+ export { ExtractNodes as ExtractNodes_alias_1 }
331
+
332
+ export declare type ExtractNodesFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'NODES'>;
333
+
334
+ /**
335
+ * @internal
336
+ */
337
+ export declare type ExtractTyping<E extends Extension> = E extends Extension<infer T> ? T : never;
338
+
339
+ /** @public */
340
+ declare class Facet<Input, Output> {
341
+ /** @internal */
342
+ readonly index: number;
343
+ /** @internal */
344
+ readonly slot: () => Slot<Input, Output>;
345
+ /** @internal */
346
+ readonly next: Facet<Output, any> | null;
347
+ /** @internal */
348
+ readonly single: boolean;
349
+ private constructor();
350
+ static define<Input, Output>({ slot, combine, next, single, }: FacetOptions<Input, Output>): Facet<Input, Output>;
351
+ /** @internal */
352
+ static defineSlot<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
353
+ extension(inputs: Input[]): FacetExtension<Input, Output>;
354
+ }
355
+ export { Facet }
356
+ export { Facet as Facet_alias_1 }
357
+
358
+ /** @public */
359
+ declare class FacetExtension<Input, Output> {
360
+ readonly facet: Facet<Input, Output>;
361
+ readonly inputs: Input[];
362
+ extension: Extension;
363
+ constructor(facet: Facet<Input, Output>, inputs: Input[]);
364
+ }
365
+ export { FacetExtension }
366
+ export { FacetExtension as FacetExtension_alias_1 }
367
+
368
+ /** @public */
369
+ declare interface FacetOptions<Input, Output> {
370
+ combine?: (inputs: Input[]) => Output;
371
+ slot?: () => Slot<Input, Output>;
372
+ next: Facet<Output, any>;
373
+ single?: boolean;
374
+ }
375
+ export { FacetOptions }
376
+ export { FacetOptions as FacetOptions_alias_1 }
377
+
378
+ /** @internal */
379
+ declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;
380
+ export { getMarkType }
381
+ export { getMarkType as getMarkType_alias_1 }
382
+
383
+ /** @internal */
384
+ declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
385
+ export { getNodeType }
386
+ export { getNodeType as getNodeType_alias_1 }
387
+
388
+ declare type Input = unknown;
389
+
390
+ export declare type Inputs = InputTuple[];
391
+
392
+ declare type InputTuple = [Input[], Input[], Input[], Input[], Input[]];
393
+
394
+ export declare function insertNode({ node, pos, }: {
395
+ node: ProseMirrorNode;
396
+ pos?: number;
397
+ }): Action;
398
+
399
+ export declare function isMarkActive(state: EditorState, type: string | MarkType, attrs?: Attrs | null): boolean;
400
+
401
+ export declare function isNodeActive(state: EditorState, type: string | NodeType, attrs?: Attrs | null): boolean;
402
+
403
+ /** @public */
404
+ declare interface Keymap {
405
+ [key: string]: Command;
406
+ }
407
+ export { Keymap }
408
+ export { Keymap as Keymap_alias_1 }
409
+
410
+ /**
411
+ * @public
412
+ */
413
+ declare interface MarkSpecOptions<MarkName extends string = string> extends MarkSpec {
414
+ name: MarkName;
415
+ }
416
+ export { MarkSpecOptions }
417
+ export { MarkSpecOptions as MarkSpecOptions_alias_1 }
418
+
419
+ /**
420
+ * A JSON representation of the prosemirror node.
421
+ *
422
+ * @public
423
+ */
424
+ declare interface NodeJson {
425
+ type: string;
426
+ marks?: Array<any>;
427
+ text?: string;
428
+ content?: NodeJson[];
429
+ attrs?: Record<string, any>;
430
+ }
431
+ export { NodeJson }
432
+ export { NodeJson as NodeJson_alias_1 }
433
+
434
+ /**
435
+ * @public
436
+ */
437
+ declare interface NodeSpecOptions<NodeName extends string = string> extends NodeSpec {
438
+ name: NodeName;
439
+ topNode?: boolean;
440
+ }
441
+ export { NodeSpecOptions }
442
+ export { NodeSpecOptions as NodeSpecOptions_alias_1 }
443
+
444
+ declare interface NodeViewOptions {
445
+ name: string;
446
+ constructor: NodeViewConstructor;
447
+ }
448
+ export { NodeViewOptions }
449
+ export { NodeViewOptions as NodeViewOptions_alias_1 }
450
+
451
+ export declare function objectEqual<T>(a: T, b: T): boolean;
452
+
453
+ /** @internal */
454
+ declare const pluginFacet: Facet<PluginFacetInput, StateConfigCallback>;
455
+ export { pluginFacet }
456
+ export { pluginFacet as pluginFacet_alias_1 }
457
+
458
+ /** @internal */
459
+ declare type PluginFacetInput = (context: {
460
+ schema: Schema;
461
+ }) => Plugin_2[];
462
+ export { PluginFacetInput }
463
+ export { PluginFacetInput as PluginFacetInput_alias_1 }
464
+
465
+ /**
466
+ * @public
467
+ */
468
+ declare const enum Priority {
469
+ lowest = 4,
470
+ low = 3,
471
+ default = 2,
472
+ high = 1,
473
+ highest = 0
474
+ }
475
+ export { Priority }
476
+ export { Priority as Priority_alias_1 }
477
+
478
+ /**
479
+ * Base class for all ProseKit errors.
480
+ */
481
+ declare class ProseKitError extends Error {
482
+ }
483
+ export { ProseKitError }
484
+ export { ProseKitError as ProseKitError_alias_1 }
485
+
486
+ export declare const schemaSlot: Facet<SchemaSpec<any, any>, SchemaSpec<any, any>>;
487
+
488
+ /**
489
+ * A JSON representation of the prosemirror selection.
490
+ *
491
+ * @public
492
+ */
493
+ declare interface SelectionJson {
494
+ from: number;
495
+ to: number;
496
+ type: string;
497
+ }
498
+ export { SelectionJson }
499
+ export { SelectionJson as SelectionJson_alias_1 }
500
+
501
+ /**
502
+ * @internal
503
+ */
504
+ declare type SimplifyExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<ExceptEmptyValue<{
505
+ NODES: ExtractNodes<E[number]>;
506
+ MARKS: ExtractMarks<E[number]>;
507
+ COMMAND_ARGS: SimplifyUnion<ExtractCommandArgs<E[number]>>;
508
+ }>> : E;
509
+ export { SimplifyExtension }
510
+ export { SimplifyExtension as SimplifyExtension_alias_1 }
511
+
512
+ /**
513
+ * @intneral
514
+ */
515
+ declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
516
+ export { SimplifyUnion }
517
+ export { SimplifyUnion as SimplifyUnion_alias_1 }
518
+
519
+ export declare interface Slot<Input, Output> {
520
+ create: (inputs: Input[]) => Output;
521
+ update: (inputs: Input[]) => Output | null;
522
+ }
523
+
524
+ export declare type Slots = SlotTuple[];
525
+
526
+ declare type SlotTuple = [
527
+ AnySlot | undefined,
528
+ AnySlot | undefined,
529
+ AnySlot | undefined,
530
+ AnySlot | undefined,
531
+ AnySlot | undefined
532
+ ];
533
+
534
+ /**
535
+ * Use topological sort algorithm to sort facets.
536
+ */
537
+ export declare function sortFacets(unsorted: readonly Facet<any, any>[]): Facet<any, any>[];
538
+
539
+ declare type StateConfigCallback = (ctx: StateConfigContext) => EditorStateConfig;
540
+ export { StateConfigCallback }
541
+ export { StateConfigCallback as StateConfigCallback_alias_1 }
542
+
543
+ declare interface StateConfigContext {
544
+ schema: Schema;
545
+ }
546
+ export { StateConfigContext }
547
+ export { StateConfigContext as StateConfigContext_alias_1 }
548
+
549
+ /**
550
+ * A JSON representation of the prosemirror state.
551
+ *
552
+ * @public
553
+ */
554
+ declare interface StateJson {
555
+ /**
556
+ * The main `ProseMirror` doc.
557
+ */
558
+ doc: NodeJson;
559
+ /**
560
+ * The current selection.
561
+ */
562
+ selection: SelectionJson;
563
+ }
564
+ export { StateJson }
565
+ export { StateJson as StateJson_alias_1 }
566
+
567
+ export declare const stateSlot: Facet<StateConfigCallback, StateConfigCallback>;
568
+
569
+ export declare type ToCommandArgs<T extends CommandCreators> = {
570
+ [K in keyof T]: Parameters<T[K]>;
571
+ };
572
+
573
+ export declare type ToCommandCreators<T extends CommandArgs> = {
574
+ [K in keyof T]: CommandCreator<T[K]>;
575
+ };
576
+
577
+ export declare type ToCommandDispatcher<T extends CommandArgs> = {
578
+ [K in keyof T]: CommandDispatcher<T[K]>;
579
+ };
580
+
581
+ declare function toggleMark(options: ToggleMarkOptions): Command;
582
+ export { toggleMark }
583
+ export { toggleMark as toggleMark_alias_1 }
584
+
585
+ declare interface ToggleMarkOptions {
586
+ type: string | MarkType;
587
+ attrs?: Attrs | null;
588
+ }
589
+ export { ToggleMarkOptions }
590
+ export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
591
+
592
+ declare function toggleNode(options: ToggleNodeOptions): Command;
593
+ export { toggleNode }
594
+ export { toggleNode as toggleNode_alias_1 }
595
+
596
+ declare interface ToggleNodeOptions {
597
+ type: string | NodeType;
598
+ attrs?: Attrs | null;
599
+ }
600
+ export { ToggleNodeOptions }
601
+ export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
602
+
603
+ export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
604
+
605
+ export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
606
+
607
+ export declare function updateExtension(prevInputs: Inputs, prevSlots: Slots, extension: Extension, mode: 'add' | 'remove'): {
608
+ schemaInput: SchemaSpec<any, any> | null;
609
+ stateInput: StateConfigCallback | null;
610
+ viewInput: ViewProps | null;
611
+ commandInput: CommandSlotInput | null;
612
+ };
613
+
614
+ declare type ViewProps = Omit<DirectEditorProps, 'state'>;
615
+ export { ViewProps }
616
+ export { ViewProps as ViewProps_alias_1 }
617
+
618
+ export declare const viewSlot: Facet<ViewProps, ViewProps>;
619
+
620
+ export declare function voidFunction(): void;
621
+
622
+ /** @public */
623
+ declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
624
+ export { withPriority }
625
+ export { withPriority as withPriority_alias_1 }
626
+
627
+ export { }
@@ -1,306 +1,53 @@
1
- import { MarkType, Attrs, NodeType, Schema, ProseMirrorNode, MarkSpec, NodeSpec } from '@prosekit/pm/model';
2
- import { Command, EditorStateConfig, Plugin } from '@prosekit/pm/state';
3
- import { EditorView, NodeViewConstructor, DirectEditorProps } from '@prosekit/pm/view';
4
- import { ConditionalExcept, EmptyObject, Simplify, UnionToIntersection } from 'type-fest';
5
- import { InputRule } from '@prosekit/pm/inputrules';
6
-
7
- interface ToggleMarkOptions {
8
- type: string | MarkType;
9
- attrs?: Attrs | null;
10
- }
11
- declare function toggleMark(options: ToggleMarkOptions): Command;
12
-
13
- interface ToggleNodeOptions {
14
- type: string | NodeType;
15
- attrs?: Attrs | null;
16
- }
17
- declare function toggleNode(options: ToggleNodeOptions): Command;
18
-
19
- type CommandDispatcher<Args extends any[] = any[]> = (...arg: Args) => boolean;
20
- type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
21
- /** @internal */
22
- interface CommandArgs {
23
- [name: string]: any[];
24
- }
25
- type ToCommandCreators<T extends CommandArgs> = {
26
- [K in keyof T]: CommandCreator<T[K]>;
27
- };
28
- type ToCommandDispatcher<T extends CommandArgs> = {
29
- [K in keyof T]: CommandDispatcher<T[K]>;
30
- };
31
-
32
- type EmptyValue = never | undefined | null | EmptyObject;
33
- type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
34
-
35
- /**
36
- * @intneral
37
- */
38
- type ExtractKey<T, K extends string> = Extract<T, Record<K, any>>[K];
39
-
40
- /**
41
- * @internal
42
- */
43
- interface ExtensionTyping<Node extends string = string, Mark extends string = string, Commands extends CommandArgs = CommandArgs> {
44
- NODES?: Node;
45
- MARKS?: Mark;
46
- COMMAND_ARGS?: Commands;
47
- }
48
- type ExtractNodesFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'NODES'>;
49
- type ExtractMarksFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'MARKS'>;
50
- type ExtractCommandArgsFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'COMMAND_ARGS'>;
51
-
52
- /**
53
- * @public
54
- */
55
- declare const enum Priority {
56
- lowest = 4,
57
- low = 3,
58
- default = 2,
59
- high = 1,
60
- highest = 0
61
- }
62
-
63
- /**
64
- * @intneral
65
- */
66
- type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
67
-
68
- /**
69
- * @public
70
- */
71
- interface Extension<T extends ExtensionTyping = ExtensionTyping> {
72
- extension: Extension | Extension[];
73
- priority?: Priority;
74
- _type?: T;
75
- }
76
- /**
77
- * @internal
78
- */
79
- type ExtractTyping<E extends Extension> = E extends Extension<infer T> ? T : never;
80
- /**
81
- * @public
82
- */
83
- type ExtractNodes<E extends Extension> = ExtractNodesFromTyping<ExtractTyping<E>>;
84
- /**
85
- * @public
86
- */
87
- type ExtractMarks<E extends Extension> = ExtractMarksFromTyping<ExtractTyping<E>>;
88
- /**
89
- * @internal
90
- */
91
- type ExtractCommandArgs<E extends Extension> = ExtractCommandArgsFromTyping<ExtractTyping<E>>;
92
- /**
93
- * @public
94
- */
95
- type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommandArgs<E>>;
96
- /**
97
- * @public
98
- */
99
- type ExtractCommandDispatchers<E extends Extension> = ToCommandDispatcher<ExtractCommandArgs<E>>;
100
- /**
101
- * @internal
102
- */
103
- type SimplifyExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<ExceptEmptyValue<{
104
- NODES: ExtractNodes<E[number]>;
105
- MARKS: ExtractMarks<E[number]>;
106
- COMMAND_ARGS: SimplifyUnion<ExtractCommandArgs<E[number]>>;
107
- }>> : E;
108
-
109
- /** @public */
110
- interface EditorOptions<E extends Extension> {
111
- extension: E;
112
- }
113
- /** @public */
114
- declare function createEditor<E extends Extension>({ extension, }: EditorOptions<E>): Editor<E>;
115
- /** @public */
116
- declare class Editor<E extends Extension = any> {
117
- private instance;
118
- private constructor();
119
- private afterMounted;
120
- /** @internal */
121
- static create(instance: any): Editor<any>;
122
- get mounted(): boolean;
123
- get view(): EditorView;
124
- get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
125
- get commands(): ExtractCommandDispatchers<E>;
126
- mount(place: HTMLElement | null | undefined | void): void;
127
- unmount(): void;
128
- use(extension: Extension): VoidFunction;
129
- isNodeActive(nodeType: string | NodeType, attrs?: Attrs): boolean;
130
- isMarkActive(markType: string | MarkType, attrs?: Attrs): boolean;
131
- }
132
-
133
- interface Slot<Input, Output> {
134
- create: (inputs: Input[]) => Output;
135
- update: (inputs: Input[]) => Output | null;
136
- }
137
-
138
- /** @public */
139
- interface FacetOptions<Input, Output> {
140
- combine?: (inputs: Input[]) => Output;
141
- slot?: () => Slot<Input, Output>;
142
- next: Facet<Output, any>;
143
- single?: boolean;
144
- }
145
- /** @public */
146
- declare class Facet<Input, Output> {
147
- /** @internal */
148
- readonly index: number;
149
- /** @internal */
150
- readonly slot: () => Slot<Input, Output>;
151
- /** @internal */
152
- readonly next: Facet<Output, any> | null;
153
- /** @internal */
154
- readonly single: boolean;
155
- private constructor();
156
- static define<Input, Output>({ slot, combine, next, single, }: FacetOptions<Input, Output>): Facet<Input, Output>;
157
- /** @internal */
158
- static defineSlot<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
159
- extension(inputs: Input[]): FacetExtension<Input, Output>;
160
- }
161
- /** @public */
162
- declare class FacetExtension<Input, Output> {
163
- readonly facet: Facet<Input, Output>;
164
- readonly inputs: Input[];
165
- extension: Extension;
166
- constructor(facet: Facet<Input, Output>, inputs: Input[]);
167
- }
168
-
169
- declare function defineExtension<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
170
-
171
- /** @public */
172
- declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
173
-
174
- /**
175
- * Base class for all ProseKit errors.
176
- */
177
- declare class ProseKitError extends Error {
178
- }
179
-
180
- declare function addCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
181
- COMMAND_ARGS: {
182
- [K in keyof T]: Parameters<T[K]>;
183
- };
184
- }>;
185
- /**
186
- * Add some base commands
187
- *
188
- * @public
189
- */
190
- declare function addBaseCommands(): Extension<{
191
- COMMAND_ARGS: {
192
- insertText: [{
193
- text: string;
194
- from?: number | undefined;
195
- to?: number | undefined;
196
- }];
197
- insertNode: [{
198
- node: ProseMirrorNode;
199
- pos?: number | undefined;
200
- }];
201
- wrap: [{
202
- nodeType: NodeType;
203
- attrs?: Attrs | null | undefined;
204
- }];
205
- setBlockType: [{
206
- nodeType: NodeType;
207
- attrs?: Attrs | null | undefined;
208
- from?: number | undefined;
209
- to?: number | undefined;
210
- }];
211
- selectAll: [];
212
- };
213
- }>;
214
-
215
- /** @public */
216
- declare function addDoc(): Extension<{
217
- NODES: "doc";
218
- }>;
219
-
220
- /** @public */
221
- declare function addInputRule(rules: (context: {
222
- schema: Schema;
223
- }) => InputRule[]): Extension;
224
-
225
- /** @public */
226
- interface Keymap {
227
- [key: string]: Command;
228
- }
229
- /** @public */
230
- declare function addKeymap(keymap: Keymap): Extension;
231
- /** @public */
232
- declare function addBaseKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
233
-
234
- /**
235
- * @public
236
- */
237
- interface MarkSpecOptions<M extends string = string> {
238
- name: M;
239
- spec: MarkSpec;
240
- }
241
- /**
242
- * @public
243
- */
244
- declare function addMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
245
- MARKS: Mark;
246
- }>;
247
-
248
- /**
249
- * @public
250
- */
251
- interface NodeSpecOptions<N extends string = string> {
252
- name: N;
253
- spec: NodeSpec;
254
- topNode?: boolean;
255
- }
256
- /**
257
- * @public
258
- */
259
- declare function addNodeSpec<Node extends string>(options: NodeSpecOptions<Node>): Extension<{
260
- NODES: Node;
261
- }>;
262
-
263
- interface NodeViewOptions {
264
- name: string;
265
- constructor: NodeViewConstructor;
266
- }
267
- declare function addNodeView(options: NodeViewOptions): Extension;
268
-
269
- /** @public */
270
- declare function addParagraph(): Extension<{
271
- NODES: "paragraph";
272
- }>;
273
-
274
- interface StateConfigContext {
275
- schema: Schema;
276
- }
277
- type StateConfigCallback = (ctx: StateConfigContext) => EditorStateConfig;
278
- type ViewProps = Omit<DirectEditorProps, 'state'>;
279
-
280
- /** @public */
281
- interface PluginOptions {
282
- plugins: Plugin[] | ((context: {
283
- schema: Schema;
284
- }) => Plugin[]);
285
- }
286
- /** @public */
287
- declare function addPlugin({ plugins }: PluginOptions): Extension;
288
- /** @internal */
289
- type PluginFacetInput = (context: {
290
- schema: Schema;
291
- }) => Plugin[];
292
- /** @internal */
293
- declare const pluginFacet: Facet<PluginFacetInput, StateConfigCallback>;
294
-
295
- /** @public */
296
- declare function addText(): Extension<{
297
- NODES: "text";
298
- }>;
299
-
300
- /** @internal */
301
- declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;
302
-
303
- /** @internal */
304
- declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
305
-
306
- export { CommandArgs, Editor, EditorOptions, Extension, ExtensionTyping, ExtractCommandCreators, ExtractCommandDispatchers, ExtractMarks, ExtractNodes, Facet, FacetExtension, FacetOptions, Keymap, MarkSpecOptions, NodeSpecOptions, NodeViewOptions, PluginFacetInput, PluginOptions, Priority, ProseKitError, SimplifyExtension, SimplifyUnion, StateConfigCallback, StateConfigContext, ToggleMarkOptions, ToggleNodeOptions, ViewProps, addBaseCommands, addBaseKeymap, addCommands, addDoc, addInputRule, addKeymap, addMarkSpec, addNodeSpec, addNodeView, addParagraph, addPlugin, addText, createEditor, defineExtension, getMarkType, getNodeType, pluginFacet, toggleMark, toggleNode, withPriority };
1
+ export { addMark } from './_tsup-dts-rollup';
2
+ export { AddMarkOptions } from './_tsup-dts-rollup';
3
+ export { toggleMark } from './_tsup-dts-rollup';
4
+ export { ToggleMarkOptions } from './_tsup-dts-rollup';
5
+ export { toggleNode } from './_tsup-dts-rollup';
6
+ export { ToggleNodeOptions } from './_tsup-dts-rollup';
7
+ export { Editor } from './_tsup-dts-rollup';
8
+ export { createEditor } from './_tsup-dts-rollup';
9
+ export { EditorOptions } from './_tsup-dts-rollup';
10
+ export { Facet } from './_tsup-dts-rollup';
11
+ export { FacetExtension } from './_tsup-dts-rollup';
12
+ export { FacetOptions } from './_tsup-dts-rollup';
13
+ export { defineExtension } from './_tsup-dts-rollup';
14
+ export { withPriority } from './_tsup-dts-rollup';
15
+ export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
16
+ export { addBaseCommands } from './_tsup-dts-rollup';
17
+ export { addCommands } from './_tsup-dts-rollup';
18
+ export { addDefaultState } from './_tsup-dts-rollup';
19
+ export { DefaultStateOptions } from './_tsup-dts-rollup';
20
+ export { addDoc } from './_tsup-dts-rollup';
21
+ export { addInputRule } from './_tsup-dts-rollup';
22
+ export { addBaseKeymap } from './_tsup-dts-rollup';
23
+ export { addKeymap } from './_tsup-dts-rollup';
24
+ export { Keymap } from './_tsup-dts-rollup';
25
+ export { addMarkSpec } from './_tsup-dts-rollup';
26
+ export { MarkSpecOptions } from './_tsup-dts-rollup';
27
+ export { addNodeSpec } from './_tsup-dts-rollup';
28
+ export { NodeSpecOptions } from './_tsup-dts-rollup';
29
+ export { addNodeView } from './_tsup-dts-rollup';
30
+ export { NodeViewOptions } from './_tsup-dts-rollup';
31
+ export { addParagraph } from './_tsup-dts-rollup';
32
+ export { addPlugin } from './_tsup-dts-rollup';
33
+ export { pluginFacet } from './_tsup-dts-rollup';
34
+ export { PluginFacetInput } from './_tsup-dts-rollup';
35
+ export { addText } from './_tsup-dts-rollup';
36
+ export { CommandArgs } from './_tsup-dts-rollup';
37
+ export { Extension } from './_tsup-dts-rollup';
38
+ export { ExtractCommandCreators } from './_tsup-dts-rollup';
39
+ export { ExtractCommandDispatchers } from './_tsup-dts-rollup';
40
+ export { ExtractMarks } from './_tsup-dts-rollup';
41
+ export { ExtractNodes } from './_tsup-dts-rollup';
42
+ export { SimplifyExtension } from './_tsup-dts-rollup';
43
+ export { ExtensionTyping } from './_tsup-dts-rollup';
44
+ export { NodeJson } from './_tsup-dts-rollup';
45
+ export { SelectionJson } from './_tsup-dts-rollup';
46
+ export { StateJson } from './_tsup-dts-rollup';
47
+ export { Priority } from './_tsup-dts-rollup';
48
+ export { SimplifyUnion } from './_tsup-dts-rollup';
49
+ export { getMarkType } from './_tsup-dts-rollup';
50
+ export { getNodeType } from './_tsup-dts-rollup';
51
+ export { StateConfigContext } from './_tsup-dts-rollup';
52
+ export { StateConfigCallback } from './_tsup-dts-rollup';
53
+ export { ViewProps } from './_tsup-dts-rollup';
@@ -1,5 +1,4 @@
1
- // src/commands/toggle-mark.ts
2
- import { toggleMark as baseToggleMark } from "@prosekit/pm/commands";
1
+ // src/commands/add-mark.ts
3
2
  import "@prosekit/pm/model";
4
3
  import "@prosekit/pm/state";
5
4
 
@@ -22,7 +21,25 @@ function getMarkType(schema, type) {
22
21
  return type;
23
22
  }
24
23
 
24
+ // src/commands/add-mark.ts
25
+ function addMark(options) {
26
+ return (state, dispatch) => {
27
+ var _a, _b;
28
+ const mark = getMarkType(state.schema, options.type).create(options.attrs);
29
+ const from = (_a = options.from) != null ? _a : state.selection.from;
30
+ const to = (_b = options.to) != null ? _b : state.selection.to;
31
+ if (from > to) {
32
+ return false;
33
+ }
34
+ dispatch == null ? void 0 : dispatch(state.tr.addMark(from, to, mark));
35
+ return true;
36
+ };
37
+ }
38
+
25
39
  // src/commands/toggle-mark.ts
40
+ import { toggleMark as baseToggleMark } from "@prosekit/pm/commands";
41
+ import "@prosekit/pm/model";
42
+ import "@prosekit/pm/state";
26
43
  function toggleMark(options) {
27
44
  return (state, dispatch, view) => {
28
45
  return baseToggleMark(
@@ -470,11 +487,20 @@ function updateExtension(prevInputs, prevSlots, extension, mode) {
470
487
 
471
488
  // src/editor/editor.ts
472
489
  function createEditor({
473
- extension
490
+ extension,
491
+ defaultDoc,
492
+ defaultSelection
474
493
  }) {
475
- const instance = new EditorInstance(extension);
476
- const editor = Editor.create(instance);
477
- return editor;
494
+ if (defaultDoc) {
495
+ extension = defineExtension([
496
+ extension,
497
+ addDefaultState({
498
+ doc: defaultDoc,
499
+ selection: defaultSelection
500
+ })
501
+ ]);
502
+ }
503
+ return Editor.create(new EditorInstance(extension));
478
504
  }
479
505
  var EditorInstance = class {
480
506
  constructor(extension) {
@@ -723,6 +749,23 @@ function addBaseCommands() {
723
749
  });
724
750
  }
725
751
 
752
+ // src/extensions/default-state.ts
753
+ import { Selection } from "@prosekit/pm/state";
754
+ function addDefaultState(options) {
755
+ return stateSlot.extension([
756
+ ({ schema }) => {
757
+ const config = {};
758
+ if (options.doc) {
759
+ config.doc = schema.nodeFromJSON(options.doc);
760
+ if (options.selection) {
761
+ config.selection = Selection.fromJSON(config.doc, options.selection);
762
+ }
763
+ }
764
+ return config;
765
+ }
766
+ ]);
767
+ }
768
+
726
769
  // src/extensions/node-spec.ts
727
770
  function addNodeSpec(options) {
728
771
  return nodeSpecFacet.extension([options]);
@@ -730,17 +773,17 @@ function addNodeSpec(options) {
730
773
  var nodeSpecFacet = Facet.define({
731
774
  combine: (options) => {
732
775
  const nodes = {};
733
- let topNode = void 0;
734
- for (const { name, spec, topNode: isTopNode } of options) {
776
+ let topNodeName = void 0;
777
+ for (const { name, topNode, ...spec } of options) {
735
778
  if (nodes[name]) {
736
779
  throw new Error(`Node type ${name} has already been defined`);
737
780
  }
738
- nodes[name] = spec;
739
- if (isTopNode && !topNode) {
740
- topNode = name;
781
+ if (topNodeName && !topNode) {
782
+ topNodeName = name;
741
783
  }
784
+ nodes[name] = spec;
742
785
  }
743
- return { nodes, topNode };
786
+ return { nodes, topNode: topNodeName };
744
787
  },
745
788
  next: schemaSlot
746
789
  });
@@ -749,9 +792,7 @@ var nodeSpecFacet = Facet.define({
749
792
  function addDoc() {
750
793
  return addNodeSpec({
751
794
  name: "doc",
752
- spec: {
753
- content: "block+"
754
- }
795
+ content: "block+"
755
796
  });
756
797
  }
757
798
 
@@ -762,15 +803,18 @@ import "@prosekit/pm/state";
762
803
 
763
804
  // src/extensions/plugin.ts
764
805
  import "@prosekit/pm/model";
765
- import "@prosekit/pm/state";
766
- function addPlugin({ plugins }) {
767
- if (typeof plugins === "function") {
768
- return pluginFacet.extension([plugins]);
769
- } else if (Array.isArray(plugins)) {
770
- return pluginFacet.extension([() => plugins]);
771
- } else {
772
- throw new TypeError("plugins must be a function or an array");
806
+ import { Plugin as Plugin2 } from "@prosekit/pm/state";
807
+ function addPlugin(plugin) {
808
+ if (plugin instanceof Plugin2) {
809
+ return pluginFacet.extension([() => [plugin]]);
810
+ }
811
+ if (Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin2)) {
812
+ return pluginFacet.extension([() => plugin]);
773
813
  }
814
+ if (typeof plugin === "function") {
815
+ return pluginFacet.extension([plugin]);
816
+ }
817
+ throw new TypeError("Invalid plugin");
774
818
  }
775
819
  var pluginFacet = Facet.define({
776
820
  combine: (callbacks) => {
@@ -799,7 +843,7 @@ var inputRuleFacet = Facet.define({
799
843
  // src/extensions/keymap.ts
800
844
  import { baseKeymap, chainCommands } from "@prosekit/pm/commands";
801
845
  import { keydownHandler } from "@prosekit/pm/keymap";
802
- import { Plugin as Plugin3, PluginKey } from "@prosekit/pm/state";
846
+ import { Plugin as Plugin4, PluginKey } from "@prosekit/pm/state";
803
847
  function addKeymap(keymap) {
804
848
  return keymapFacet.extension([keymap]);
805
849
  }
@@ -814,7 +858,7 @@ var keymapFacet = Facet.define({
814
858
  return handler(view, event);
815
859
  return false;
816
860
  };
817
- const plugin = new Plugin3({
861
+ const plugin = new Plugin4({
818
862
  key: keymapPluginKey,
819
863
  props: { handleKeyDown: handlerWrapper }
820
864
  });
@@ -857,7 +901,7 @@ function addMarkSpec(options) {
857
901
  var markSpecFacet = Facet.define({
858
902
  combine: (options) => {
859
903
  const marks = {};
860
- for (const { name, spec } of options) {
904
+ for (const { name, ...spec } of options) {
861
905
  if (marks[name]) {
862
906
  throw new Error(`Mark type ${name} has already been defined`);
863
907
  }
@@ -869,7 +913,7 @@ var markSpecFacet = Facet.define({
869
913
  });
870
914
 
871
915
  // src/extensions/node-view.ts
872
- import { Plugin as Plugin4 } from "@prosekit/pm/state";
916
+ import { Plugin as Plugin5 } from "@prosekit/pm/state";
873
917
  import "@prosekit/pm/view";
874
918
  function addNodeView(options) {
875
919
  return nodeViewFacet.extension([options]);
@@ -882,7 +926,7 @@ var nodeViewFacet = Facet.define({
882
926
  nodeViews[input.name] = input.constructor;
883
927
  }
884
928
  }
885
- return () => [new Plugin4({ props: { nodeViews } })];
929
+ return () => [new Plugin5({ props: { nodeViews } })];
886
930
  },
887
931
  next: pluginFacet
888
932
  });
@@ -891,13 +935,11 @@ var nodeViewFacet = Facet.define({
891
935
  function addParagraph() {
892
936
  return addNodeSpec({
893
937
  name: "paragraph",
894
- spec: {
895
- content: "inline*",
896
- group: "block",
897
- parseDOM: [{ tag: "p" }],
898
- toDOM() {
899
- return ["p", 0];
900
- }
938
+ content: "inline*",
939
+ group: "block",
940
+ parseDOM: [{ tag: "p" }],
941
+ toDOM() {
942
+ return ["p", 0];
901
943
  }
902
944
  });
903
945
  }
@@ -906,9 +948,7 @@ function addParagraph() {
906
948
  function addText() {
907
949
  return addNodeSpec({
908
950
  name: "text",
909
- spec: {
910
- group: "inline"
911
- }
951
+ group: "inline"
912
952
  });
913
953
  }
914
954
  export {
@@ -920,9 +960,11 @@ export {
920
960
  addBaseCommands,
921
961
  addBaseKeymap,
922
962
  addCommands,
963
+ addDefaultState,
923
964
  addDoc,
924
965
  addInputRule,
925
966
  addKeymap,
967
+ addMark,
926
968
  addMarkSpec,
927
969
  addNodeSpec,
928
970
  addNodeView,
package/dist/style.css CHANGED
@@ -1,4 +1,4 @@
1
- /* ../../node_modules/.pnpm/prosemirror-view@1.31.6/node_modules/prosemirror-view/style/prosemirror.css */
1
+ /* ../../node_modules/.pnpm/prosemirror-view@1.31.7/node_modules/prosemirror-view/style/prosemirror.css */
2
2
  .ProseMirror {
3
3
  position: relative;
4
4
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -40,13 +40,13 @@
40
40
  "dependencies": {
41
41
  "@prosekit/pm": "^0.0.3",
42
42
  "orderedmap": "^2.1.1",
43
- "type-fest": "^4.0.0"
43
+ "type-fest": "^4.3.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@prosekit/dev": "*",
47
- "tsup": "^7.1.0",
48
- "typescript": "^5.1.6",
49
- "vitest": "^0.33.0"
47
+ "tsup": "^7.2.0",
48
+ "typescript": "^5.2.2",
49
+ "vitest": "^0.34.3"
50
50
  },
51
51
  "scripts": {
52
52
  "build:tsup": "tsup",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { addMark, type AddMarkOptions } from './commands/add-mark'
1
2
  export { toggleMark, type ToggleMarkOptions } from './commands/toggle-mark'
2
3
  export { toggleNode, type ToggleNodeOptions } from './commands/toggle-node'
3
4
  export { Editor, createEditor, type EditorOptions } from './editor/editor'
@@ -6,6 +7,10 @@ export { defineExtension } from './editor/type-utils'
6
7
  export { withPriority } from './editor/with-priority'
7
8
  export { ProseKitError } from './error'
8
9
  export { addBaseCommands, addCommands } from './extensions/command'
10
+ export {
11
+ addDefaultState,
12
+ type DefaultStateOptions,
13
+ } from './extensions/default-state'
9
14
  export { addDoc } from './extensions/doc'
10
15
  export { addInputRule } from './extensions/input-rules'
11
16
  export { addBaseKeymap, addKeymap, type Keymap } from './extensions/keymap'
@@ -15,9 +20,8 @@ export { addNodeView, type NodeViewOptions } from './extensions/node-view'
15
20
  export { addParagraph } from './extensions/paragraph'
16
21
  export {
17
22
  addPlugin,
18
- type PluginOptions,
19
- type PluginFacetInput,
20
23
  pluginFacet,
24
+ type PluginFacetInput,
21
25
  } from './extensions/plugin'
22
26
  export { addText } from './extensions/text'
23
27
  export { type CommandArgs as CommandArgs } from './types/command'
@@ -31,6 +35,7 @@ export {
31
35
  type SimplifyExtension,
32
36
  } from './types/extension'
33
37
  export { type ExtensionTyping } from './types/extension-typing'
38
+ export type { NodeJson, SelectionJson, StateJson } from './types/model'
34
39
  export { Priority } from './types/priority'
35
40
  export { type SimplifyUnion } from './types/simplify-union'
36
41
  export { getMarkType } from './utils/get-mark-type'