@prosekit/core 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { Attrs } from '@prosekit/pm/model';
2
+ import { Attrs as Attrs_2 } from 'prosemirror-model';
2
3
  import { Command } from '@prosekit/pm/state';
3
4
  import type { ConditionalExcept } from 'type-fest';
4
5
  import type { DirectEditorProps } from '@prosekit/pm/view';
@@ -11,8 +12,10 @@ import type { IsEqual } from 'type-fest';
11
12
  import { Mark } from '@prosekit/pm/model';
12
13
  import type { MarkSpec } from '@prosekit/pm/model';
13
14
  import { MarkType } from '@prosekit/pm/model';
15
+ import { Node as Node_2 } from 'prosemirror-model';
14
16
  import type { NodeSpec } from '@prosekit/pm/model';
15
17
  import { NodeType } from '@prosekit/pm/model';
18
+ import { NodeType as NodeType_2 } from 'prosemirror-model';
16
19
  import { NodeViewConstructor } from '@prosekit/pm/view';
17
20
  import { Options } from 'tsup';
18
21
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
@@ -30,11 +33,7 @@ declare type Action = (options: {
30
33
  view?: EditorView;
31
34
  }) => boolean;
32
35
 
33
- declare function addMark(options: AddMarkOptions): Command;
34
- export { addMark }
35
- export { addMark as addMark_alias_1 }
36
-
37
- declare interface AddMarkOptions {
36
+ declare function addMark(options: {
38
37
  type: string | MarkType;
39
38
  attrs?: Attrs | null;
40
39
  /**
@@ -45,11 +44,9 @@ declare interface AddMarkOptions {
45
44
  * The end position of the mark. By default it will be the end position of current selection.
46
45
  */
47
46
  to?: number;
48
- }
49
- export { AddMarkOptions }
50
- export { AddMarkOptions as AddMarkOptions_alias_1 }
51
-
52
- export declare type AnySlot = Slot<any, any>;
47
+ }): Command;
48
+ export { addMark }
49
+ export { addMark as addMark_alias_1 }
53
50
 
54
51
  export declare function applyAction(operator: Action): Command;
55
52
 
@@ -78,9 +75,13 @@ export declare interface CommandCreators {
78
75
  [name: string]: CommandCreator;
79
76
  }
80
77
 
81
- export declare const commandSlot: Facet<CommandSlotInput, CommandSlotInput>;
78
+ export declare const commandFacet: Facet<CommandCreators, CommandCreators>;
79
+
80
+ export declare type CommandPayload = CommandCreators;
82
81
 
83
- export declare type CommandSlotInput = Record<string, CommandCreator<any>>;
82
+ export declare type Converters = ConverterTuple[];
83
+
84
+ declare type ConverterTuple = Tuple5<FacetConverter | undefined>;
84
85
 
85
86
  /** @public */
86
87
  declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultSelection, }: EditorOptions<E>): Editor<E>;
@@ -121,19 +122,14 @@ declare function defineBaseCommands(): Extension<{
121
122
  to?: number | undefined;
122
123
  }];
123
124
  insertNode: [{
124
- node: ProseMirrorNode;
125
+ node: Node_2;
125
126
  pos?: number | undefined;
126
127
  }];
127
128
  wrap: [{
128
- nodeType: NodeType;
129
- attrs?: Attrs | null | undefined;
130
- }];
131
- setBlockType: [{
132
- nodeType: NodeType;
133
- attrs?: Attrs | null | undefined;
134
- from?: number | undefined;
135
- to?: number | undefined;
129
+ nodeType: NodeType_2;
130
+ attrs?: Attrs_2 | null | undefined;
136
131
  }];
132
+ setBlockType: [nodeType: NodeType_2, attrs?: Attrs_2 | null | undefined];
137
133
  selectAll: [];
138
134
  };
139
135
  }>;
@@ -169,7 +165,7 @@ export { defineDoc as defineDoc_alias_1 }
169
165
  */
170
166
  declare function defineEventHandler(options: {
171
167
  update?: VoidFunction;
172
- }): FacetExtension<VoidFunction, PluginFacetInput>;
168
+ }): FacetExtension<VoidFunction, PluginPayload>;
173
169
  export { defineEventHandler }
174
170
  export { defineEventHandler as defineEventHandler_alias_1 }
175
171
 
@@ -221,6 +217,10 @@ declare function defineNodeView(options: NodeViewOptions): Extension;
221
217
  export { defineNodeView }
222
218
  export { defineNodeView as defineNodeView_alias_1 }
223
219
 
220
+ declare function defineNodeViewEffect(options: NodeViewEffectOptions): Extension;
221
+ export { defineNodeViewEffect }
222
+ export { defineNodeViewEffect as defineNodeViewEffect_alias_1 }
223
+
224
224
  /** @public */
225
225
  declare function defineParagraph(): Extension< {
226
226
  NODES: "paragraph";
@@ -377,40 +377,45 @@ declare class Facet<Input, Output> {
377
377
  /** @internal */
378
378
  readonly index: number;
379
379
  /** @internal */
380
- readonly slot: () => Slot<Input, Output>;
380
+ readonly converter: () => FacetConverter<Input, Output>;
381
381
  /** @internal */
382
382
  readonly next: Facet<Output, any> | null;
383
- /** @internal */
384
- readonly single: boolean;
385
383
  private constructor();
386
- static define<Input, Output>({ slot, combine, next, single, }: FacetOptions<Input, Output>): Facet<Input, Output>;
384
+ static define<Input, Output>({ converter: converter, convert: convert, next, }: FacetOptions<Input, Output>): Facet<Input, Output>;
387
385
  /** @internal */
388
- static defineSlot<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
389
- extension(inputs: Input[]): FacetExtension<Input, Output>;
386
+ static defineRootFacet<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
387
+ extension(payloads: Input[]): FacetExtension<Input, Output>;
390
388
  }
391
389
  export { Facet }
392
390
  export { Facet as Facet_alias_1 }
393
391
 
392
+ /** @public */
393
+ export declare interface FacetConverter<Input = any, Output = any> {
394
+ create: (inputs: Input[]) => Output;
395
+ update: (inputs: Input[]) => Output | null;
396
+ }
397
+
394
398
  /** @public */
395
399
  declare class FacetExtension<Input, Output> {
396
400
  readonly facet: Facet<Input, Output>;
397
- readonly inputs: Input[];
401
+ readonly payloads: Input[];
398
402
  extension: Extension;
399
- constructor(facet: Facet<Input, Output>, inputs: Input[]);
403
+ constructor(facet: Facet<Input, Output>, payloads: Input[]);
400
404
  }
401
405
  export { FacetExtension }
402
406
  export { FacetExtension as FacetExtension_alias_1 }
403
407
 
404
408
  /** @public */
405
409
  declare interface FacetOptions<Input, Output> {
406
- combine?: (inputs: Input[]) => Output;
407
- slot?: () => Slot<Input, Output>;
410
+ convert?: (payloads: Input[]) => Output;
411
+ converter?: () => FacetConverter<Input, Output>;
408
412
  next: Facet<Output, any>;
409
- single?: boolean;
410
413
  }
411
414
  export { FacetOptions }
412
415
  export { FacetOptions as FacetOptions_alias_1 }
413
416
 
417
+ export declare function getFacetCount(): number;
418
+
414
419
  /** @internal */
415
420
  declare function getMarkType(schema: Schema, type: string | MarkType): MarkType;
416
421
  export { getMarkType }
@@ -421,17 +426,30 @@ declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
421
426
  export { getNodeType }
422
427
  export { getNodeType as getNodeType_alias_1 }
423
428
 
424
- declare type Input = unknown;
425
-
426
- export declare type Inputs = InputTuple[];
429
+ declare function insertNode(options: {
430
+ node: ProseMirrorNode;
431
+ pos?: number;
432
+ }): Command;
427
433
 
428
- declare type InputTuple = [Input[], Input[], Input[], Input[], Input[]];
434
+ declare function insertNode(options: {
435
+ attrs?: Attrs;
436
+ type: string;
437
+ pos?: number;
438
+ }): Command;
439
+ export { insertNode }
440
+ export { insertNode as insertNode_alias_1 }
429
441
 
430
- export declare function insertNode({ node, pos, }: {
442
+ export declare function insertNode_alias_2({ node, pos, }: {
431
443
  node: ProseMirrorNode;
432
444
  pos?: number;
433
445
  }): Action;
434
446
 
447
+ export declare function insertText({ text, from, to, }: {
448
+ text: string;
449
+ from?: number;
450
+ to?: number;
451
+ }): Command;
452
+
435
453
  export declare const isMac: boolean;
436
454
 
437
455
  export declare function isMark(mark: unknown): mark is Mark;
@@ -499,6 +517,18 @@ declare interface NodeSpecOptions<NodeName extends string = string> extends Node
499
517
  export { NodeSpecOptions }
500
518
  export { NodeSpecOptions as NodeSpecOptions_alias_1 }
501
519
 
520
+ declare type NodeViewEffectOptions = {
521
+ group: string;
522
+ name: string;
523
+ args: unknown;
524
+ } | {
525
+ group: string;
526
+ name?: undefined;
527
+ factory: (args: unknown) => NodeViewConstructor;
528
+ };
529
+ export { NodeViewEffectOptions }
530
+ export { NodeViewEffectOptions as NodeViewEffectOptions_alias_1 }
531
+
502
532
  declare interface NodeViewOptions {
503
533
  name: string;
504
534
  constructor: NodeViewConstructor;
@@ -508,17 +538,23 @@ export { NodeViewOptions as NodeViewOptions_alias_1 }
508
538
 
509
539
  export declare function objectEqual<T>(a: T, b: T): boolean;
510
540
 
541
+ declare type Payload = unknown;
542
+
543
+ export declare type Payloads = PayloadTuple[];
544
+
545
+ declare type PayloadTuple = Tuple5<Payload[]>;
546
+
511
547
  /** @internal */
512
- declare const pluginFacet: Facet<PluginFacetInput, StateConfigCallback>;
548
+ declare const pluginFacet: Facet<PluginPayload, StatePayload>;
513
549
  export { pluginFacet }
514
550
  export { pluginFacet as pluginFacet_alias_1 }
515
551
 
516
552
  /** @internal */
517
- declare type PluginFacetInput = (context: {
553
+ declare type PluginPayload = (context: {
518
554
  schema: Schema;
519
555
  }) => Plugin_2[];
520
- export { PluginFacetInput }
521
- export { PluginFacetInput as PluginFacetInput_alias_1 }
556
+ export { PluginPayload }
557
+ export { PluginPayload as PluginPayload_alias_1 }
522
558
 
523
559
  /**
524
560
  * @public
@@ -541,7 +577,11 @@ declare class ProseKitError extends Error {
541
577
  export { ProseKitError }
542
578
  export { ProseKitError as ProseKitError_alias_1 }
543
579
 
544
- export declare const schemaSlot: Facet<SchemaSpec<any, any>, SchemaSpec<any, any>>;
580
+ export declare const schemaFacet: Facet<SchemaPayload, SchemaPayload>;
581
+
582
+ export declare type SchemaPayload = SchemaSpec;
583
+
584
+ export declare function selectAll(): Command;
545
585
 
546
586
  /**
547
587
  * A JSON representation of the prosemirror selection.
@@ -556,6 +596,13 @@ declare interface SelectionJson {
556
596
  export { SelectionJson }
557
597
  export { SelectionJson as SelectionJson_alias_1 }
558
598
 
599
+ export declare function setBlockType({ nodeType, attrs, from, to, }: {
600
+ nodeType: NodeType;
601
+ attrs?: Attrs | null;
602
+ from?: number;
603
+ to?: number;
604
+ }): Command;
605
+
559
606
  /**
560
607
  * @internal
561
608
  */
@@ -574,35 +621,7 @@ declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
574
621
  export { SimplifyUnion }
575
622
  export { SimplifyUnion as SimplifyUnion_alias_1 }
576
623
 
577
- export declare interface Slot<Input, Output> {
578
- create: (inputs: Input[]) => Output;
579
- update: (inputs: Input[]) => Output | null;
580
- }
581
-
582
- export declare type Slots = SlotTuple[];
583
-
584
- declare type SlotTuple = [
585
- AnySlot | undefined,
586
- AnySlot | undefined,
587
- AnySlot | undefined,
588
- AnySlot | undefined,
589
- AnySlot | undefined
590
- ];
591
-
592
- /**
593
- * Use topological sort algorithm to sort facets.
594
- */
595
- export declare function sortFacets(unsorted: readonly Facet<any, any>[]): Facet<any, any>[];
596
-
597
- declare type StateConfigCallback = (ctx: StateConfigContext) => EditorStateConfig;
598
- export { StateConfigCallback }
599
- export { StateConfigCallback as StateConfigCallback_alias_1 }
600
-
601
- declare interface StateConfigContext {
602
- schema: Schema;
603
- }
604
- export { StateConfigContext }
605
- export { StateConfigContext as StateConfigContext_alias_1 }
624
+ export declare const stateFacet: Facet<StatePayload, StatePayload>;
606
625
 
607
626
  /**
608
627
  * A JSON representation of the prosemirror state.
@@ -622,7 +641,9 @@ declare interface StateJson {
622
641
  export { StateJson }
623
642
  export { StateJson as StateJson_alias_1 }
624
643
 
625
- export declare const stateSlot: Facet<StateConfigCallback, StateConfigCallback>;
644
+ export declare type StatePayload = (ctx: {
645
+ schema: Schema;
646
+ }) => EditorStateConfig;
626
647
 
627
648
  export declare type ToCommandApplier<T extends CommandArgs> = {
628
649
  [K in keyof T]: CommandApplier<T[K]>;
@@ -636,27 +657,21 @@ export declare type ToCommandCreators<T extends CommandArgs> = {
636
657
  [K in keyof T]: CommandCreator<T[K]>;
637
658
  };
638
659
 
639
- declare function toggleMark(options: ToggleMarkOptions): Command;
660
+ declare function toggleMark({ type, attrs, }: {
661
+ type: string | MarkType;
662
+ attrs?: Attrs | null;
663
+ }): Command;
640
664
  export { toggleMark }
641
665
  export { toggleMark as toggleMark_alias_1 }
642
666
 
643
- declare interface ToggleMarkOptions {
644
- type: string | MarkType;
667
+ declare function toggleNode({ type, attrs, }: {
668
+ type: string | NodeType;
645
669
  attrs?: Attrs | null;
646
- }
647
- export { ToggleMarkOptions }
648
- export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
649
-
650
- declare function toggleNode(options: ToggleNodeOptions): Command;
670
+ }): Command;
651
671
  export { toggleNode }
652
672
  export { toggleNode as toggleNode_alias_1 }
653
673
 
654
- declare interface ToggleNodeOptions {
655
- type: string | NodeType;
656
- attrs?: Attrs | null;
657
- }
658
- export { ToggleNodeOptions }
659
- export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
674
+ declare type Tuple5<T> = [T, T, T, T, T];
660
675
 
661
676
  declare function union<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
662
677
  export { union }
@@ -666,18 +681,16 @@ export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[]
666
681
 
667
682
  export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
668
683
 
669
- export declare function updateExtension(prevInputs: Inputs, prevSlots: Slots, extension: Extension, mode: 'add' | 'remove'): {
670
- schemaInput: SchemaSpec<any, any> | null;
671
- stateInput: StateConfigCallback | null;
672
- viewInput: ViewProps | null;
673
- commandInput: CommandSlotInput | null;
684
+ export declare function updateExtension(prevInputs: Payloads, prevConverters: Converters, extension: Extension, mode: 'add' | 'remove'): {
685
+ schemaInput: SchemaPayload | null;
686
+ stateInput: StatePayload | null;
687
+ viewInput: ViewPayload | null;
688
+ commandInput: CommandCreators | null;
674
689
  };
675
690
 
676
- declare type ViewProps = Omit<DirectEditorProps, 'state'>;
677
- export { ViewProps }
678
- export { ViewProps as ViewProps_alias_1 }
691
+ export declare const viewFacet: Facet<ViewPayload, ViewPayload>;
679
692
 
680
- export declare const viewSlot: Facet<ViewProps, ViewProps>;
693
+ export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
681
694
 
682
695
  export declare function voidFunction(): void;
683
696
 
@@ -686,4 +699,9 @@ declare function withPriority<T extends Extension>(extension: T, priority: Prior
686
699
  export { withPriority }
687
700
  export { withPriority as withPriority_alias_1 }
688
701
 
702
+ export declare function wrap({ nodeType, attrs, }: {
703
+ nodeType: NodeType;
704
+ attrs?: Attrs | null;
705
+ }): Command;
706
+
689
707
  export { }
@@ -1,9 +1,7 @@
1
1
  export { addMark } from './_tsup-dts-rollup';
2
- export { AddMarkOptions } from './_tsup-dts-rollup';
3
2
  export { toggleMark } from './_tsup-dts-rollup';
4
- export { ToggleMarkOptions } from './_tsup-dts-rollup';
3
+ export { insertNode } from './_tsup-dts-rollup';
5
4
  export { toggleNode } from './_tsup-dts-rollup';
6
- export { ToggleNodeOptions } from './_tsup-dts-rollup';
7
5
  export { Editor } from './_tsup-dts-rollup';
8
6
  export { createEditor } from './_tsup-dts-rollup';
9
7
  export { EditorOptions } from './_tsup-dts-rollup';
@@ -30,10 +28,12 @@ export { defineNodeSpec } from './_tsup-dts-rollup';
30
28
  export { NodeSpecOptions } from './_tsup-dts-rollup';
31
29
  export { defineNodeView } from './_tsup-dts-rollup';
32
30
  export { NodeViewOptions } from './_tsup-dts-rollup';
31
+ export { defineNodeViewEffect } from './_tsup-dts-rollup';
32
+ export { NodeViewEffectOptions } from './_tsup-dts-rollup';
33
33
  export { defineParagraph } from './_tsup-dts-rollup';
34
34
  export { definePlugin } from './_tsup-dts-rollup';
35
35
  export { pluginFacet } from './_tsup-dts-rollup';
36
- export { PluginFacetInput } from './_tsup-dts-rollup';
36
+ export { PluginPayload } from './_tsup-dts-rollup';
37
37
  export { defineText } from './_tsup-dts-rollup';
38
38
  export { CommandArgs } from './_tsup-dts-rollup';
39
39
  export { Extension } from './_tsup-dts-rollup';
@@ -50,6 +50,3 @@ export { Priority } from './_tsup-dts-rollup';
50
50
  export { SimplifyUnion } from './_tsup-dts-rollup';
51
51
  export { getMarkType } from './_tsup-dts-rollup';
52
52
  export { getNodeType } from './_tsup-dts-rollup';
53
- export { StateConfigContext } from './_tsup-dts-rollup';
54
- export { StateConfigCallback } from './_tsup-dts-rollup';
55
- export { ViewProps } from './_tsup-dts-rollup';
@@ -40,19 +40,21 @@ function addMark(options) {
40
40
  import { toggleMark as baseToggleMark } from "@prosekit/pm/commands";
41
41
  import "@prosekit/pm/model";
42
42
  import "@prosekit/pm/state";
43
- function toggleMark(options) {
43
+ function toggleMark({
44
+ type,
45
+ attrs
46
+ }) {
44
47
  return (state, dispatch, view) => {
45
- return baseToggleMark(
46
- getMarkType(state.schema, options.type),
47
- options.attrs
48
- )(state, dispatch, view);
48
+ return baseToggleMark(getMarkType(state.schema, type), attrs)(
49
+ state,
50
+ dispatch,
51
+ view
52
+ );
49
53
  };
50
54
  }
51
55
 
52
- // src/commands/toggle-node.ts
53
- import { setBlockType } from "@prosekit/pm/commands";
54
- import "@prosekit/pm/model";
55
- import "@prosekit/pm/state";
56
+ // src/commands/insert-node.ts
57
+ import { insertPoint } from "@prosekit/pm/transform";
56
58
 
57
59
  // src/utils/get-node-type.ts
58
60
  import "@prosekit/pm/model";
@@ -67,6 +69,34 @@ function getNodeType(schema, type) {
67
69
  return type;
68
70
  }
69
71
 
72
+ // src/commands/insert-node.ts
73
+ function insertNode(options) {
74
+ return (state, dispatch) => {
75
+ var _a;
76
+ const node = options.node ? options.node : options.type ? getNodeType(state.schema, options.type).createChecked(options.attrs) : null;
77
+ if (!node) {
78
+ throw new ProseKitError("You must provide either a node or a type");
79
+ }
80
+ const insertPos = insertPoint(
81
+ state.doc,
82
+ (_a = options.pos) != null ? _a : state.selection.to,
83
+ node.type
84
+ );
85
+ if (insertPos == null)
86
+ return false;
87
+ if (dispatch) {
88
+ const tr = state.tr.insert(insertPos, node);
89
+ dispatch(tr);
90
+ }
91
+ return true;
92
+ };
93
+ }
94
+
95
+ // src/commands/toggle-node.ts
96
+ import { setBlockType } from "@prosekit/pm/commands";
97
+ import "@prosekit/pm/model";
98
+ import "@prosekit/pm/state";
99
+
70
100
  // src/utils/object-euqal.ts
71
101
  function objectEqual(a, b) {
72
102
  if (a === b) {
@@ -111,17 +141,20 @@ function isNodeActive(state, type, attrs) {
111
141
  }
112
142
 
113
143
  // src/commands/toggle-node.ts
114
- function toggleNode(options) {
144
+ function toggleNode({
145
+ type,
146
+ attrs
147
+ }) {
115
148
  return (state, dispatch, view) => {
116
- if (isNodeActive(state, options.type, options.attrs)) {
149
+ if (isNodeActive(state, type, attrs)) {
117
150
  const defaultType = state.schema.topNodeType.contentMatch.defaultType;
118
151
  if (!defaultType) {
119
152
  return false;
120
153
  }
121
154
  return setBlockType(defaultType)(state, dispatch, view);
122
155
  } else {
123
- const nodeType = getNodeType(state.schema, options.type);
124
- return setBlockType(nodeType, options.attrs)(state, dispatch, view);
156
+ const nodeType = getNodeType(state.schema, type);
157
+ return setBlockType(nodeType, attrs)(state, dispatch, view);
125
158
  }
126
159
  };
127
160
  }
@@ -134,9 +167,6 @@ import { EditorView } from "@prosekit/pm/view";
134
167
  // src/extensions/default-state.ts
135
168
  import { Selection } from "@prosekit/pm/state";
136
169
 
137
- // src/editor/slots.ts
138
- import OrderedMap from "orderedmap";
139
-
140
170
  // src/utils/uniq-array.ts
141
171
  function uniqPush(prev, next) {
142
172
  const result = [...prev];
@@ -158,115 +188,50 @@ function uniqRemove(prev, next) {
158
188
  return result;
159
189
  }
160
190
 
161
- // src/editor/facet.ts
162
- var nextIndex = 0;
191
+ // src/facets/facet.ts
192
+ var facetCount = 0;
193
+ function getFacetCount() {
194
+ return facetCount;
195
+ }
163
196
  var Facet = class _Facet {
164
- constructor(slot, next, single) {
197
+ constructor(converter, next) {
165
198
  /** @internal */
166
- this.index = nextIndex++;
167
- this.slot = slot;
199
+ this.index = facetCount++;
200
+ this.converter = converter;
168
201
  this.next = next;
169
- this.single = single;
170
202
  }
171
203
  static define({
172
- slot,
173
- combine,
174
- next,
175
- single
204
+ converter,
205
+ convert,
206
+ next
176
207
  }) {
177
- const slotFn = slot ? slot : combine ? () => ({
178
- create: combine,
179
- update: combine
208
+ const converterFunction = converter ? converter : convert ? () => ({
209
+ create: convert,
210
+ update: convert
180
211
  }) : null;
181
- if (!slotFn) {
182
- throw new ProseKitError(
183
- "Facet must have either 'slot' or 'combine' option"
184
- );
212
+ if (!converterFunction) {
213
+ throw new ProseKitError("Facet must have either 'convert' or 'converter'");
185
214
  }
186
- return new _Facet(slotFn, next, single != null ? single : false);
215
+ return new _Facet(converterFunction, next);
187
216
  }
188
217
  /** @internal */
189
- static defineSlot(options) {
218
+ static defineRootFacet(options) {
190
219
  return _Facet.define(options);
191
220
  }
192
- extension(inputs) {
193
- return new FacetExtension(this, inputs);
221
+ extension(payloads) {
222
+ return new FacetExtension(this, payloads);
194
223
  }
195
224
  };
196
225
  var FacetExtension = class {
197
- constructor(facet, inputs) {
226
+ constructor(facet, payloads) {
198
227
  this.facet = facet;
199
- this.inputs = inputs;
228
+ this.payloads = payloads;
200
229
  }
201
230
  };
202
- function sortFacets(unsorted) {
203
- var _a;
204
- const facets = unsorted.filter((val) => val);
205
- const facetMap = [];
206
- const inbounds = [];
207
- let facetCount = 0;
208
- for (const facet of facets) {
209
- const index = facet.index;
210
- if (facetMap[index] != null) {
211
- continue;
212
- }
213
- if (inbounds[index] == null) {
214
- inbounds[index] = 0;
215
- }
216
- facetCount++;
217
- facetMap[index] = facet;
218
- if (facet.next) {
219
- const nextIndex2 = facet.next.index;
220
- if (inbounds[nextIndex2] == null) {
221
- inbounds[nextIndex2] = 0;
222
- }
223
- inbounds[nextIndex2] += 1;
224
- if (facetMap[nextIndex2] == null) {
225
- facets.push(facet.next);
226
- }
227
- }
228
- }
229
- const sortedFacets = [];
230
- const sortedIndexes = [];
231
- inbounds.forEach((inbound, index) => {
232
- if (inbound === 0) {
233
- sortedIndexes.push(index);
234
- }
235
- });
236
- for (const index of sortedIndexes) {
237
- const facet = facetMap[index];
238
- sortedFacets.push(facet);
239
- const nextIndex2 = (_a = facet.next) == null ? void 0 : _a.index;
240
- if (nextIndex2 == null)
241
- continue;
242
- inbounds[nextIndex2] -= 1;
243
- if (inbounds[nextIndex2] === 0) {
244
- sortedIndexes.push(nextIndex2);
245
- }
246
- }
247
- if (facetCount !== sortedFacets.length) {
248
- throw new ProseKitError(`Facet has circular dependency`);
249
- }
250
- return sortedFacets;
251
- }
252
231
 
253
- // src/editor/slots.ts
254
- var schemaSlot = Facet.defineSlot({
255
- combine: (specs) => {
256
- var _a;
257
- let nodes = OrderedMap.from({});
258
- let marks = OrderedMap.from({});
259
- let topNode = void 0;
260
- for (const spec of specs) {
261
- nodes = nodes.append(spec.nodes);
262
- marks = marks.append((_a = spec.marks) != null ? _a : {});
263
- topNode = topNode != null ? topNode : spec.topNode;
264
- }
265
- return { nodes, marks, topNode };
266
- }
267
- });
268
- var stateSlot = Facet.defineSlot({
269
- combine: (callbacks) => {
232
+ // src/facets/state.ts
233
+ var stateFacet = Facet.defineRootFacet({
234
+ convert: (callbacks) => {
270
235
  return (ctx) => {
271
236
  var _a, _b, _c, _d, _e, _f;
272
237
  const configs = callbacks.map((cb) => cb(ctx));
@@ -294,20 +259,10 @@ var stateSlot = Facet.defineSlot({
294
259
  };
295
260
  }
296
261
  });
297
- var viewSlot = Facet.defineSlot({
298
- combine: (props) => {
299
- return Object.assign({}, ...props);
300
- }
301
- });
302
- var commandSlot = Facet.defineSlot({
303
- combine: (inputs) => {
304
- return Object.assign({}, ...inputs);
305
- }
306
- });
307
262
 
308
263
  // src/extensions/default-state.ts
309
264
  function defineDefaultState(options) {
310
- return stateSlot.extension([
265
+ return stateFacet.extension([
311
266
  ({ schema }) => {
312
267
  const config = {};
313
268
  if (options.doc) {
@@ -417,6 +372,37 @@ function isNodeChild(value) {
417
372
  return typeof value === "string" || Array.isArray(value) || isProseMirrorNode(value);
418
373
  }
419
374
 
375
+ // src/facets/command.ts
376
+ var commandFacet = Facet.defineRootFacet({
377
+ convert: (inputs) => {
378
+ return Object.assign({}, ...inputs);
379
+ }
380
+ });
381
+
382
+ // src/facets/schema.ts
383
+ import OrderedMap from "orderedmap";
384
+ var schemaFacet = Facet.defineRootFacet({
385
+ convert: (specs) => {
386
+ var _a;
387
+ let nodes = OrderedMap.from({});
388
+ let marks = OrderedMap.from({});
389
+ let topNode = void 0;
390
+ for (const spec of specs) {
391
+ nodes = nodes.append(spec.nodes);
392
+ marks = marks.append((_a = spec.marks) != null ? _a : {});
393
+ topNode = topNode != null ? topNode : spec.topNode;
394
+ }
395
+ return { nodes, marks, topNode };
396
+ }
397
+ });
398
+
399
+ // src/facets/view.ts
400
+ var viewFacet = Facet.defineRootFacet({
401
+ convert: (props) => {
402
+ return Object.assign({}, ...props);
403
+ }
404
+ });
405
+
420
406
  // src/types/priority.ts
421
407
  var Priority = /* @__PURE__ */ ((Priority2) => {
422
408
  Priority2[Priority2["lowest"] = 4] = "lowest";
@@ -472,7 +458,7 @@ function extractFacets(root) {
472
458
  const extensions = [root];
473
459
  const priorities = [2 /* default */];
474
460
  const facets = [];
475
- const inputs = [];
461
+ const payloads = [];
476
462
  while (extensions.length > 0) {
477
463
  const ext = extensions.pop();
478
464
  const pri = priorities.pop();
@@ -480,10 +466,10 @@ function extractFacets(root) {
480
466
  const facet = ext.facet;
481
467
  if (!facets[facet.index]) {
482
468
  facets[facet.index] = facet;
483
- inputs[facet.index] = [[], [], [], [], []];
469
+ payloads[facet.index] = [[], [], [], [], []];
484
470
  }
485
- const facetInputs = ext.inputs;
486
- inputs[facet.index][pri].push(...facetInputs);
471
+ const facetPayloads = ext.payloads;
472
+ payloads[facet.index][pri].push(...facetPayloads);
487
473
  } else if (ext.extension) {
488
474
  const p = (_a = ext.priority) != null ? _a : pri;
489
475
  if (Array.isArray(ext.extension)) {
@@ -499,25 +485,31 @@ function extractFacets(root) {
499
485
  throw new ProseKitError("Invalid extension");
500
486
  }
501
487
  }
502
- return [facets, inputs];
488
+ return [facets, payloads];
503
489
  }
504
- function updateExtension(prevInputs, prevSlots, extension, mode) {
490
+ function updateExtension(prevInputs, prevConverters, extension, mode) {
491
+ var _a;
505
492
  const modifyInputTuple = mode === "add" ? mergeInputTuple : removeInputTuple;
506
493
  const [facets, inputs] = extractFacets(extension);
507
494
  let schemaInput = null;
508
495
  let stateInput = null;
509
496
  let viewInput = null;
510
497
  let commandInput = null;
511
- for (const facet of sortFacets(facets)) {
498
+ for (let index = getFacetCount(); index >= 0; index--) {
499
+ const facet = facets[index];
500
+ if (!facet) {
501
+ continue;
502
+ }
503
+ const nextFacet = facet.next;
504
+ if (nextFacet) {
505
+ facets[_a = nextFacet.index] || (facets[_a] = nextFacet);
506
+ }
512
507
  if (!inputs[facet.index]) {
513
508
  continue;
514
509
  }
515
- const inputTuple = modifyInputTuple(
516
- prevInputs[facet.index],
517
- inputs[facet.index]
518
- );
519
- prevInputs[facet.index] = inputTuple;
520
- if (facet.next && !facet.single) {
510
+ const inputTuple = modifyInputTuple(prevInputs[index], inputs[index]);
511
+ prevInputs[index] = inputTuple;
512
+ if (facet.next) {
521
513
  let hasOutput = false;
522
514
  const outputTuple = [[], [], [], [], []];
523
515
  for (let pri = 0; pri < 5; pri++) {
@@ -525,17 +517,17 @@ function updateExtension(prevInputs, prevSlots, extension, mode) {
525
517
  if (inputArray.length === 0) {
526
518
  continue;
527
519
  }
528
- const slotTuple = prevSlots[facet.index] || (prevSlots[facet.index] = [
520
+ const converterTuple = prevConverters[index] || (prevConverters[index] = [
529
521
  void 0,
530
522
  void 0,
531
523
  void 0,
532
524
  void 0,
533
525
  void 0
534
526
  ]);
535
- const prevSlot = slotTuple[pri];
536
- const slot = prevSlot || facet.slot();
537
- prevSlots[facet.index][pri] = slot;
538
- const output = prevSlot ? slot.update(inputArray) : slot.create(inputArray);
527
+ const prevConverter = converterTuple[pri];
528
+ const converter = prevConverter || facet.converter();
529
+ prevConverters[index][pri] = converter;
530
+ const output = prevConverter ? converter.update(inputArray) : converter.create(inputArray);
539
531
  if (!output) {
540
532
  continue;
541
533
  }
@@ -552,44 +544,35 @@ function updateExtension(prevInputs, prevSlots, extension, mode) {
552
544
  continue;
553
545
  } else {
554
546
  const inputArray = flattenInputTuple(inputTuple);
555
- const slotTuple = prevSlots[facet.index] || (prevSlots[facet.index] = [
547
+ const converterTuple = prevConverters[index] || (prevConverters[index] = [
556
548
  void 0,
557
549
  void 0,
558
550
  void 0,
559
551
  void 0,
560
552
  void 0
561
553
  ]);
562
- const prevSlot = slotTuple[2 /* default */];
563
- const slot = prevSlot || facet.slot();
564
- prevSlots[facet.index][2 /* default */] = slot;
565
- const output = prevSlot ? slot.update(inputArray) : slot.create(inputArray);
554
+ const prevConverter = converterTuple[2 /* default */];
555
+ const converter = prevConverter || facet.converter();
556
+ prevConverters[index][2 /* default */] = converter;
557
+ const output = prevConverter ? converter.update(inputArray) : converter.create(inputArray);
566
558
  if (!output) {
567
559
  continue;
568
560
  }
569
- const outputTuple = [[], [], [output], [], []];
570
- if (facet.next) {
571
- inputs[facet.next.index] = modifyInputTuple(
572
- inputs[facet.next.index],
573
- outputTuple
574
- );
575
- continue;
576
- } else {
577
- switch (facet) {
578
- case schemaSlot:
579
- schemaInput = output;
580
- break;
581
- case stateSlot:
582
- stateInput = output;
583
- break;
584
- case viewSlot:
585
- viewInput = output;
586
- break;
587
- case commandSlot:
588
- commandInput = output;
589
- break;
590
- default:
591
- throw new ProseKitError("Invalid facet");
592
- }
561
+ switch (facet) {
562
+ case schemaFacet:
563
+ schemaInput = output;
564
+ break;
565
+ case stateFacet:
566
+ stateInput = output;
567
+ break;
568
+ case viewFacet:
569
+ viewInput = output;
570
+ break;
571
+ case commandFacet:
572
+ commandInput = output;
573
+ break;
574
+ default:
575
+ throw new ProseKitError("Invalid root facet");
593
576
  }
594
577
  }
595
578
  }
@@ -625,11 +608,11 @@ var EditorInstance = class {
625
608
  constructor(extension) {
626
609
  this.view = null;
627
610
  this.commandAppliers = {};
628
- this.inputs = [];
629
- this.slots = [];
611
+ this.payloads = [];
612
+ this.converters = [];
630
613
  this.mount = this.mount.bind(this);
631
614
  this.unmount = this.unmount.bind(this);
632
- const { schemaInput, stateInput, viewInput, commandInput } = updateExtension(this.inputs, this.slots, extension, "add");
615
+ const { schemaInput, stateInput, viewInput, commandInput } = updateExtension(this.payloads, this.converters, extension, "add");
633
616
  if (!schemaInput) {
634
617
  throw new ProseKitError("Schema must be defined");
635
618
  }
@@ -662,7 +645,7 @@ var EditorInstance = class {
662
645
  }
663
646
  updateExtension(extension, mode) {
664
647
  var _a;
665
- const { schemaInput, stateInput, viewInput, commandInput } = updateExtension(this.inputs, this.slots, extension, mode);
648
+ const { schemaInput, stateInput, viewInput, commandInput } = updateExtension(this.payloads, this.converters, extension, mode);
666
649
  if (schemaInput) {
667
650
  throw new ProseKitError("Schema cannot be changed");
668
651
  }
@@ -703,8 +686,9 @@ var EditorInstance = class {
703
686
  this.view = null;
704
687
  }
705
688
  get assertView() {
706
- if (!this.view)
689
+ if (!this.view) {
707
690
  throw new ProseKitError("Editor is not mounted");
691
+ }
708
692
  return this.view;
709
693
  }
710
694
  definePlugins(plugins) {
@@ -825,77 +809,83 @@ function withPriority(extension, priority) {
825
809
  }
826
810
 
827
811
  // src/extensions/command.ts
828
- import "@prosekit/pm/model";
812
+ import { setBlockType as setBlockType2 } from "@prosekit/pm/commands";
813
+
814
+ // src/commands/insert-text.ts
815
+ function insertText({
816
+ text,
817
+ from,
818
+ to
819
+ }) {
820
+ return (state, dispatch) => {
821
+ if (text) {
822
+ dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
823
+ }
824
+ return true;
825
+ };
826
+ }
827
+
828
+ // src/commands/select-all.ts
829
829
  import { AllSelection } from "@prosekit/pm/state";
830
- import { findWrapping, insertPoint } from "@prosekit/pm/transform";
830
+ function selectAll() {
831
+ return (state, dispatch) => {
832
+ dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
833
+ return true;
834
+ };
835
+ }
836
+
837
+ // src/commands/wrap.ts
838
+ import "@prosekit/pm/model";
839
+ import "@prosekit/pm/state";
840
+ import { findWrapping } from "@prosekit/pm/transform";
841
+ function wrap({
842
+ nodeType,
843
+ attrs
844
+ }) {
845
+ return (state, dispatch) => {
846
+ const { $from, $to } = state.selection;
847
+ const range = $from.blockRange($to);
848
+ if (!range)
849
+ return false;
850
+ const wrapping = findWrapping(range, nodeType, attrs);
851
+ if (!wrapping)
852
+ return false;
853
+ dispatch == null ? void 0 : dispatch(state.tr.wrap(range, wrapping));
854
+ return true;
855
+ };
856
+ }
857
+
858
+ // src/extensions/actions.ts
859
+ import "@prosekit/pm/model";
860
+ import { Selection as Selection2 } from "@prosekit/pm/state";
861
+ import { insertPoint as insertPoint2 } from "@prosekit/pm/transform";
862
+ function insertNode2({
863
+ node,
864
+ pos
865
+ }) {
866
+ return ({ tr }) => {
867
+ const insertPos = insertPoint2(tr.doc, pos != null ? pos : tr.selection.to, node.type);
868
+ if (insertPos == null) {
869
+ return false;
870
+ }
871
+ tr.insert(insertPos, node);
872
+ const $pos = tr.doc.resolve(insertPos);
873
+ tr.setSelection(Selection2.near($pos));
874
+ return true;
875
+ };
876
+ }
877
+
878
+ // src/extensions/command.ts
831
879
  function defineCommands(commands) {
832
- return commandSlot.extension([commands]);
880
+ return commandFacet.extension([commands]);
833
881
  }
834
882
  function defineBaseCommands() {
835
883
  return defineCommands({
836
- insertText: ({
837
- text,
838
- from,
839
- to
840
- }) => {
841
- return (state, dispatch) => {
842
- if (text) {
843
- dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
844
- }
845
- return true;
846
- };
847
- },
848
- insertNode: ({ node, pos }) => {
849
- return (state, dispatch) => {
850
- const insertPos = insertPoint(
851
- state.doc,
852
- pos != null ? pos : state.selection.to,
853
- node.type
854
- );
855
- if (insertPos == null)
856
- return false;
857
- if (dispatch) {
858
- const tr = state.tr.insert(insertPos, node);
859
- dispatch(tr);
860
- }
861
- return true;
862
- };
863
- },
864
- wrap: ({
865
- nodeType,
866
- attrs
867
- }) => {
868
- return (state, dispatch) => {
869
- const { $from, $to } = state.selection;
870
- const range = $from.blockRange($to);
871
- if (!range)
872
- return false;
873
- const wrapping = findWrapping(range, nodeType, attrs);
874
- if (!wrapping)
875
- return false;
876
- dispatch == null ? void 0 : dispatch(state.tr.wrap(range, wrapping));
877
- return true;
878
- };
879
- },
880
- setBlockType: ({
881
- nodeType,
882
- attrs,
883
- from,
884
- to
885
- }) => {
886
- return (state, dispatch) => {
887
- from = from != null ? from : state.selection.from;
888
- to = from != null ? from : state.selection.from;
889
- dispatch == null ? void 0 : dispatch(state.tr.setBlockType(from, to, nodeType, attrs));
890
- return true;
891
- };
892
- },
893
- selectAll: () => {
894
- return (state, dispatch) => {
895
- dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
896
- return true;
897
- };
898
- }
884
+ insertText,
885
+ insertNode: insertNode2,
886
+ wrap,
887
+ setBlockType: setBlockType2,
888
+ selectAll
899
889
  });
900
890
  }
901
891
 
@@ -904,7 +894,7 @@ function defineNodeSpec(options) {
904
894
  return nodeSpecFacet.extension([options]);
905
895
  }
906
896
  var nodeSpecFacet = Facet.define({
907
- combine: (options) => {
897
+ convert: (options) => {
908
898
  const nodes = {};
909
899
  let topNodeName = void 0;
910
900
  for (const { name, topNode, ...spec } of options) {
@@ -918,7 +908,7 @@ var nodeSpecFacet = Facet.define({
918
908
  }
919
909
  return { nodes, topNode: topNodeName };
920
910
  },
921
- next: schemaSlot
911
+ next: schemaFacet
922
912
  });
923
913
 
924
914
  // src/extensions/doc.ts
@@ -952,13 +942,13 @@ function definePlugin(plugin) {
952
942
  throw new TypeError("Invalid plugin");
953
943
  }
954
944
  var pluginFacet = Facet.define({
955
- combine: (callbacks) => {
945
+ convert: (callbacks) => {
956
946
  return ({ schema }) => {
957
947
  const plugins = callbacks.flatMap((func) => func({ schema }));
958
948
  return { plugins };
959
949
  };
960
950
  },
961
- next: stateSlot
951
+ next: stateFacet
962
952
  });
963
953
 
964
954
  // src/extensions/event-handler.ts
@@ -968,7 +958,7 @@ function defineEventHandler(options) {
968
958
  return eventFacet.extension([updateHandler]);
969
959
  }
970
960
  var eventFacet = Facet.define({
971
- slot: () => {
961
+ converter: () => {
972
962
  let updateHandlers = [];
973
963
  const plugin = new ProseMirrorPlugin({
974
964
  key: pluginKey,
@@ -993,8 +983,7 @@ var eventFacet = Facet.define({
993
983
  }
994
984
  };
995
985
  },
996
- next: pluginFacet,
997
- single: true
986
+ next: pluginFacet
998
987
  });
999
988
  var pluginKey = new PluginKey("prosekit-event-handler");
1000
989
 
@@ -1015,7 +1004,7 @@ function defineBaseKeymap() {
1015
1004
  return defineKeymap(baseKeymap);
1016
1005
  }
1017
1006
  var keymapFacet = Facet.define({
1018
- slot: () => {
1007
+ converter: () => {
1019
1008
  let handler = null;
1020
1009
  const handlerWrapper = (view, event) => {
1021
1010
  if (handler)
@@ -1038,8 +1027,7 @@ var keymapFacet = Facet.define({
1038
1027
  }
1039
1028
  };
1040
1029
  },
1041
- next: pluginFacet,
1042
- single: true
1030
+ next: pluginFacet
1043
1031
  });
1044
1032
  function mergeKeymaps(keymaps) {
1045
1033
  const bindings = {};
@@ -1085,7 +1073,7 @@ function defineInputRule(rules) {
1085
1073
  return inputRuleFacet.extension([rules]);
1086
1074
  }
1087
1075
  var inputRuleFacet = Facet.define({
1088
- combine: (inputs) => {
1076
+ convert: (inputs) => {
1089
1077
  return (context) => {
1090
1078
  const rules = inputs.flatMap((callback) => callback(context));
1091
1079
  return [inputRules({ rules })];
@@ -1099,7 +1087,7 @@ function defineMarkSpec(options) {
1099
1087
  return markSpecFacet.extension([options]);
1100
1088
  }
1101
1089
  var markSpecFacet = Facet.define({
1102
- combine: (options) => {
1090
+ convert: (options) => {
1103
1091
  const marks = {};
1104
1092
  for (const { name, ...spec } of options) {
1105
1093
  if (marks[name]) {
@@ -1109,24 +1097,58 @@ var markSpecFacet = Facet.define({
1109
1097
  }
1110
1098
  return { marks, nodes: {} };
1111
1099
  },
1112
- next: schemaSlot
1100
+ next: schemaFacet
1113
1101
  });
1114
1102
 
1115
1103
  // src/extensions/node-view.ts
1116
- import { Plugin as Plugin5 } from "@prosekit/pm/state";
1104
+ import { ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
1117
1105
  import "@prosekit/pm/view";
1118
1106
  function defineNodeView(options) {
1119
1107
  return nodeViewFacet.extension([options]);
1120
1108
  }
1121
1109
  var nodeViewFacet = Facet.define({
1122
- combine: (inputs) => {
1110
+ convert: (inputs) => {
1123
1111
  const nodeViews = {};
1124
1112
  for (const input of inputs) {
1125
1113
  if (!nodeViews[input.name]) {
1126
1114
  nodeViews[input.name] = input.constructor;
1127
1115
  }
1128
1116
  }
1129
- return () => [new Plugin5({ props: { nodeViews } })];
1117
+ return () => [new ProseMirrorPlugin2({ props: { nodeViews } })];
1118
+ },
1119
+ next: pluginFacet
1120
+ });
1121
+
1122
+ // src/extensions/node-view-effect.ts
1123
+ import { ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
1124
+ import "@prosekit/pm/view";
1125
+ function defineNodeViewEffect(options) {
1126
+ return nodeViewEffectFacet.extension([options]);
1127
+ }
1128
+ var nodeViewEffectFacet = Facet.define({
1129
+ convert: (inputs) => {
1130
+ const nodeViews = {};
1131
+ const options = {};
1132
+ const factories = {};
1133
+ for (const input of inputs) {
1134
+ const group = input.group;
1135
+ if (input.name == null) {
1136
+ factories[group] = input.factory;
1137
+ } else {
1138
+ options[group] || (options[group] = []);
1139
+ options[group].push({
1140
+ name: input.name,
1141
+ args: input.args
1142
+ });
1143
+ }
1144
+ }
1145
+ for (const [group, factory] of Object.entries(factories)) {
1146
+ const groupOptions = options[group] || [];
1147
+ for (const { name, args } of groupOptions) {
1148
+ nodeViews[name] = factory(args);
1149
+ }
1150
+ }
1151
+ return () => Object.keys(nodeViews).length > 0 ? [new ProseMirrorPlugin3({ props: { nodeViews } })] : [];
1130
1152
  },
1131
1153
  next: pluginFacet
1132
1154
  });
@@ -1171,11 +1193,13 @@ export {
1171
1193
  defineMarkSpec,
1172
1194
  defineNodeSpec,
1173
1195
  defineNodeView,
1196
+ defineNodeViewEffect,
1174
1197
  defineParagraph,
1175
1198
  definePlugin,
1176
1199
  defineText,
1177
1200
  getMarkType,
1178
1201
  getNodeType,
1202
+ insertNode,
1179
1203
  pluginFacet,
1180
1204
  toggleMark,
1181
1205
  toggleNode,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.0.12",
4
+ "version": "0.0.14",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "@prosekit/pm": "^0.0.6",
42
42
  "orderedmap": "^2.1.1",
43
- "type-fest": "^4.4.0"
43
+ "type-fest": "^4.5.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@prosekit/dev": "*",
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
- export { addMark, type AddMarkOptions } from './commands/add-mark'
2
- export { toggleMark, type ToggleMarkOptions } from './commands/toggle-mark'
3
- export { toggleNode, type ToggleNodeOptions } from './commands/toggle-node'
1
+ export { addMark } from './commands/add-mark'
2
+ export { toggleMark } from './commands/toggle-mark'
3
+ export { insertNode } from './commands/insert-node'
4
+ export { toggleNode } from './commands/toggle-node'
4
5
  export { Editor, createEditor, type EditorOptions } from './editor/editor'
5
- export { Facet, FacetExtension, type FacetOptions } from './editor/facet'
6
+ export { Facet, FacetExtension, type FacetOptions } from './facets/facet'
6
7
  export { union } from './editor/type-utils'
7
8
  export { withPriority } from './editor/with-priority'
8
9
  export { ProseKitError } from './error'
@@ -23,15 +24,18 @@ export {
23
24
  export { defineMarkSpec, type MarkSpecOptions } from './extensions/mark-spec'
24
25
  export { defineNodeSpec, type NodeSpecOptions } from './extensions/node-spec'
25
26
  export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
27
+ export {
28
+ defineNodeViewEffect,
29
+ type NodeViewEffectOptions,
30
+ } from './extensions/node-view-effect'
26
31
  export { defineParagraph } from './extensions/paragraph'
27
32
  export {
28
33
  definePlugin,
29
34
  pluginFacet,
30
- type PluginFacetInput,
35
+ type PluginPayload,
31
36
  } from './extensions/plugin'
32
37
  export { defineText } from './extensions/text'
33
38
  export { type CommandArgs as CommandArgs } from './types/command'
34
- export * from './types/editor'
35
39
  export {
36
40
  type Extension,
37
41
  type ExtractCommandAppliers,