@prosekit/core 0.7.14 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,19 +39,18 @@ import {
39
39
  stateFromJSON,
40
40
  toReversed,
41
41
  union
42
- } from "./chunk-6DIFWJEG.js";
42
+ } from "./chunk-B3WEP4DD.js";
43
43
 
44
44
  // src/commands/add-mark.ts
45
45
  function addMark(options) {
46
46
  return (state, dispatch) => {
47
- var _a, _b;
48
47
  const mark = getMarkType(state.schema, options.type).create(options.attrs);
49
- const from = (_a = options.from) != null ? _a : state.selection.from;
50
- const to = (_b = options.to) != null ? _b : state.selection.to;
48
+ const from = options.from ?? state.selection.from;
49
+ const to = options.to ?? state.selection.to;
51
50
  if (from > to) {
52
51
  return false;
53
52
  }
54
- dispatch == null ? void 0 : dispatch(state.tr.addMark(from, to, mark));
53
+ dispatch?.(state.tr.addMark(from, to, mark));
55
54
  return true;
56
55
  };
57
56
  }
@@ -128,7 +127,7 @@ function defaultBlockAt(match) {
128
127
  // src/commands/insert-default-block.ts
129
128
  function insertDefaultBlock(options) {
130
129
  return (state, dispatch) => {
131
- const $pos = (options == null ? void 0 : options.pos) == null ? state.selection.$to : state.doc.resolve(options.pos);
130
+ const $pos = options?.pos == null ? state.selection.$to : state.doc.resolve(options.pos);
132
131
  const depth = $pos.parent.isTextblock ? $pos.depth - 1 : $pos.depth;
133
132
  const parent = $pos.node(depth);
134
133
  const index = $pos.indexAfter(depth);
@@ -165,12 +164,11 @@ function setSelectionAround(tr, pos) {
165
164
  // src/commands/insert-node.ts
166
165
  function insertNode(options) {
167
166
  return (state, dispatch) => {
168
- var _a;
169
167
  const node = options.node ? options.node : options.type ? getNodeType(state.schema, options.type).createAndFill(options.attrs) : null;
170
168
  assert(node, "You must provide either a node or a type");
171
169
  const insertPos = insertPoint(
172
170
  state.doc,
173
- (_a = options.pos) != null ? _a : state.selection.anchor,
171
+ options.pos ?? state.selection.anchor,
174
172
  node.type
175
173
  );
176
174
  if (insertPos == null) return false;
@@ -186,15 +184,14 @@ function insertNode(options) {
186
184
  // src/commands/remove-mark.ts
187
185
  function removeMark(options) {
188
186
  return (state, dispatch) => {
189
- var _a, _b;
190
187
  const markType = getMarkType(state.schema, options.type);
191
188
  const mark = options.attrs ? markType.create(options.attrs) : markType;
192
- const from = (_a = options.from) != null ? _a : state.selection.from;
193
- const to = (_b = options.to) != null ? _b : state.selection.to;
189
+ const from = options.from ?? state.selection.from;
190
+ const to = options.to ?? state.selection.to;
194
191
  if (from > to) {
195
192
  return false;
196
193
  }
197
- dispatch == null ? void 0 : dispatch(state.tr.removeMark(from, to, mark));
194
+ dispatch?.(state.tr.removeMark(from, to, mark));
198
195
  return true;
199
196
  };
200
197
  }
@@ -224,7 +221,7 @@ function removeNode(options) {
224
221
  const found = findParentNodeOfType(options.type, $pos);
225
222
  if (!found) return false;
226
223
  const { pos, node } = found;
227
- dispatch == null ? void 0 : dispatch(state.tr.delete(pos, pos + node.nodeSize));
224
+ dispatch?.(state.tr.delete(pos, pos + node.nodeSize));
228
225
  return true;
229
226
  };
230
227
  }
@@ -234,10 +231,10 @@ import {
234
231
  TextSelection as TextSelection4
235
232
  } from "@prosekit/pm/state";
236
233
  function getCustomSelection(state, from, to) {
237
- const pos = from != null ? from : to;
234
+ const pos = from ?? to;
238
235
  if (pos != null) {
239
- const $from = state.doc.resolve(from != null ? from : pos);
240
- const $to = state.doc.resolve(to != null ? to : pos);
236
+ const $from = state.doc.resolve(from ?? pos);
237
+ const $to = state.doc.resolve(to ?? pos);
241
238
  return TextSelection4.between($from, $to);
242
239
  }
243
240
  return state.selection;
@@ -293,10 +290,9 @@ function getNodeTypes(schema, types) {
293
290
  // src/commands/set-node-attrs.ts
294
291
  function setNodeAttrs(options) {
295
292
  return (state, dispatch) => {
296
- var _a, _b;
297
293
  const nodeTypes = getNodeTypes(state.schema, options.type);
298
- const from = (_a = options.pos) != null ? _a : state.selection.from;
299
- const to = (_b = options.pos) != null ? _b : state.selection.to;
294
+ const from = options.pos ?? state.selection.from;
295
+ const to = options.pos ?? state.selection.to;
300
296
  const positions = [];
301
297
  state.doc.nodesBetween(from, to, (node, pos) => {
302
298
  if (nodeTypes.includes(node.type)) {
@@ -368,7 +364,7 @@ function wrap(options) {
368
364
  const nodeType = getNodeType(state.schema, options.nodeType || options.type);
369
365
  const wrapping = findWrapping(range, nodeType, options.attrs);
370
366
  if (!wrapping) return false;
371
- dispatch == null ? void 0 : dispatch(state.tr.wrap(range, wrapping));
367
+ dispatch?.(state.tr.wrap(range, wrapping));
372
368
  return true;
373
369
  };
374
370
  }
@@ -392,13 +388,12 @@ import {
392
388
  import { ReplaceAroundStep } from "@prosekit/pm/transform";
393
389
  function unsetBlockType(options) {
394
390
  return (state, dispatch) => {
395
- var _a, _b;
396
- const from = (_a = options == null ? void 0 : options.from) != null ? _a : state.selection.from;
397
- const to = (_b = options == null ? void 0 : options.to) != null ? _b : state.selection.to;
391
+ const from = options?.from ?? state.selection.from;
392
+ const to = options?.to ?? state.selection.to;
398
393
  if (from > to) return false;
399
394
  const tr = state.tr;
400
395
  if (unsetTextBlockType(tr, from, to)) {
401
- dispatch == null ? void 0 : dispatch(tr);
396
+ dispatch?.(tr);
402
397
  return true;
403
398
  }
404
399
  return false;
@@ -432,11 +427,10 @@ function unsetTextBlockType(tr, from, to) {
432
427
  // src/commands/unset-mark.ts
433
428
  function unsetMark(options) {
434
429
  return (state, dispatch) => {
435
- var _a, _b;
436
- const from = (_a = options == null ? void 0 : options.from) != null ? _a : state.selection.from;
437
- const to = (_b = options == null ? void 0 : options.to) != null ? _b : state.selection.to;
430
+ const from = options?.from ?? state.selection.from;
431
+ const to = options?.to ?? state.selection.to;
438
432
  if (from > to) return false;
439
- dispatch == null ? void 0 : dispatch(state.tr.removeMark(from, to));
433
+ dispatch?.(state.tr.removeMark(from, to));
440
434
  return true;
441
435
  };
442
436
  }
@@ -448,11 +442,112 @@ function withPriority(extension, priority) {
448
442
  return result;
449
443
  }
450
444
 
445
+ // src/extensions/clipboard-serializer.ts
446
+ import {
447
+ DOMSerializer
448
+ } from "@prosekit/pm/model";
449
+ import {
450
+ PluginKey,
451
+ ProseMirrorPlugin
452
+ } from "@prosekit/pm/state";
453
+
454
+ // src/extensions/plugin.ts
455
+ import {
456
+ Plugin
457
+ } from "@prosekit/pm/state";
458
+ function definePlugin(plugin) {
459
+ if (plugin instanceof Plugin || Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
460
+ return definePluginPayload(() => plugin);
461
+ }
462
+ if (typeof plugin === "function") {
463
+ return definePluginPayload(plugin);
464
+ }
465
+ throw new TypeError("Invalid plugin");
466
+ }
467
+ function definePluginPayload(payload) {
468
+ return defineFacetPayload(pluginFacet, [payload]);
469
+ }
470
+ var pluginFacet = defineFacet({
471
+ reducer: (payloads) => {
472
+ return ({ schema }) => {
473
+ const plugins = [];
474
+ for (const payload of payloads) {
475
+ if (payload instanceof Plugin) {
476
+ plugins.push(payload);
477
+ } else if (Array.isArray(payload) && payload.every((p) => p instanceof Plugin)) {
478
+ plugins.push(...payload);
479
+ } else if (typeof payload === "function") {
480
+ plugins.push(...[payload({ schema })].flat());
481
+ } else {
482
+ throw new ProseKitError("Invalid plugin");
483
+ }
484
+ }
485
+ plugins.reverse();
486
+ return { plugins };
487
+ };
488
+ },
489
+ parent: stateFacet
490
+ });
491
+
492
+ // src/extensions/clipboard-serializer.ts
493
+ function mergeWrappers(wrappers) {
494
+ return (fn) => wrappers.filter(isNotNullish).reduce((fn2, wrapper) => wrapper(fn2), fn);
495
+ }
496
+ function wrapFunction(fn, wrapper) {
497
+ return wrapper ? wrapper(fn) : fn;
498
+ }
499
+ var CustomDOMSerializer = class extends DOMSerializer {
500
+ constructor(nodes, marks, serializeFragmentWrapper, serializeNodeWrapper) {
501
+ super(nodes, marks);
502
+ this.serializeFragmentWrapper = serializeFragmentWrapper;
503
+ this.serializeNodeWrapper = serializeNodeWrapper;
504
+ }
505
+ serializeFragment(...args) {
506
+ const fn = (...args2) => super.serializeFragment(...args2);
507
+ return wrapFunction(fn, this.serializeFragmentWrapper)(...args);
508
+ }
509
+ serializeNode(...args) {
510
+ const fn = (...args2) => super.serializeNode(...args2);
511
+ return wrapFunction(fn, this.serializeNodeWrapper)(...args);
512
+ }
513
+ };
514
+ function createCustomDOMSerializer(schema, options) {
515
+ const nodesFromSchema = (...args) => DOMSerializer.nodesFromSchema(...args);
516
+ const marksFromSchema = (...args) => DOMSerializer.marksFromSchema(...args);
517
+ const nodes = wrapFunction(nodesFromSchema, options.nodesFromSchemaWrapper)(schema);
518
+ const marks = wrapFunction(marksFromSchema, options.marksFromSchemaWrapper)(schema);
519
+ return new CustomDOMSerializer(nodes, marks, options.serializeFragmentWrapper, options.serializeNodeWrapper);
520
+ }
521
+ var clipboardSerializerFacet = defineFacet({
522
+ reducer: (inputs) => {
523
+ const options = {
524
+ serializeFragmentWrapper: mergeWrappers(inputs.map((input) => input.serializeFragmentWrapper)),
525
+ serializeNodeWrapper: mergeWrappers(inputs.map((input) => input.serializeNodeWrapper)),
526
+ nodesFromSchemaWrapper: mergeWrappers(inputs.map((input) => input.nodesFromSchemaWrapper)),
527
+ marksFromSchemaWrapper: mergeWrappers(inputs.map((input) => input.marksFromSchemaWrapper))
528
+ };
529
+ return ({ schema }) => {
530
+ const clipboardSerializer = createCustomDOMSerializer(schema, options);
531
+ return [
532
+ new ProseMirrorPlugin({
533
+ key: new PluginKey("prosekit-clipboard-serializer"),
534
+ props: { clipboardSerializer }
535
+ })
536
+ ];
537
+ };
538
+ },
539
+ singleton: true,
540
+ parent: pluginFacet
541
+ });
542
+ function defineClipboardSerializer(options) {
543
+ return defineFacetPayload(clipboardSerializerFacet, [options]);
544
+ }
545
+
451
546
  // src/commands/insert-text.ts
452
547
  function insertText({ text, from, to }) {
453
548
  return (state, dispatch) => {
454
549
  if (text) {
455
- dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
550
+ dispatch?.(state.tr.insertText(text, from, to));
456
551
  }
457
552
  return true;
458
553
  };
@@ -464,7 +559,7 @@ import {
464
559
  } from "@prosekit/pm/state";
465
560
  function selectAll() {
466
561
  return (state, dispatch) => {
467
- dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
562
+ dispatch?.(state.tr.setSelection(new AllSelection(state.doc)));
468
563
  return true;
469
564
  };
470
565
  }
@@ -509,14 +604,13 @@ import OrderedMap2 from "orderedmap";
509
604
  import OrderedMap from "orderedmap";
510
605
  var schemaSpecFacet = defineFacet({
511
606
  reducer: (specs) => {
512
- var _a;
513
607
  let nodes = OrderedMap.from({});
514
608
  let marks = OrderedMap.from({});
515
609
  let topNode = void 0;
516
610
  for (const spec of specs) {
517
611
  nodes = nodes.append(spec.nodes);
518
- marks = marks.append((_a = spec.marks) != null ? _a : {});
519
- topNode = topNode != null ? topNode : spec.topNode;
612
+ marks = marks.append(spec.marks ?? {});
613
+ topNode = topNode ?? spec.topNode;
520
614
  }
521
615
  return { nodes, marks, topNode };
522
616
  },
@@ -562,21 +656,20 @@ function mergeObjects(...objects) {
562
656
 
563
657
  // src/utils/merge-specs.ts
564
658
  function mergeSpecs(a, b) {
565
- var _a, _b, _c, _d, _e, _f;
566
659
  const attrs = {};
567
660
  const attrNames = /* @__PURE__ */ new Set([
568
- ...Object.keys((_a = a.attrs) != null ? _a : {}),
569
- ...Object.keys((_b = b.attrs) != null ? _b : {})
661
+ ...Object.keys(a.attrs ?? {}),
662
+ ...Object.keys(b.attrs ?? {})
570
663
  ]);
571
664
  for (const name of attrNames) {
572
- const attrSpecA = (_c = a.attrs) == null ? void 0 : _c[name];
573
- const attrSpecB = (_d = b.attrs) == null ? void 0 : _d[name];
665
+ const attrSpecA = a.attrs?.[name];
666
+ const attrSpecB = b.attrs?.[name];
574
667
  const attrSpecMerged = mergeObjects(attrSpecA, attrSpecB);
575
668
  if (attrSpecMerged) {
576
669
  attrs[name] = attrSpecMerged;
577
670
  }
578
671
  }
579
- const parseDOM = [...(_e = a.parseDOM) != null ? _e : [], ...(_f = b.parseDOM) != null ? _f : []];
672
+ const parseDOM = [...a.parseDOM ?? [], ...b.parseDOM ?? []];
580
673
  return mergeObjects(a, b, { attrs, parseDOM });
581
674
  }
582
675
 
@@ -584,10 +677,7 @@ function mergeSpecs(a, b) {
584
677
  function wrapOutputSpecAttrs(toDOM, options) {
585
678
  return (node, ...args) => {
586
679
  const dom = toDOM(node, ...args);
587
- const pairs = options.map((option) => {
588
- var _a;
589
- return (_a = option.toDOM) == null ? void 0 : _a.call(option, node.attrs[option.attr]);
590
- }).filter(isNotNullish);
680
+ const pairs = options.map((option) => option.toDOM?.(node.attrs[option.attr])).filter(isNotNullish);
591
681
  return insertOutputSpecAttrs(dom, pairs);
592
682
  };
593
683
  }
@@ -597,10 +687,9 @@ function wrapTagParseRuleAttrs(rule, options) {
597
687
  return {
598
688
  ...rule,
599
689
  getAttrs: (dom) => {
600
- var _a, _b;
601
- const baseAttrs = (_b = (_a = existingGetAttrs == null ? void 0 : existingGetAttrs(dom)) != null ? _a : existingAttrs) != null ? _b : {};
690
+ const baseAttrs = existingGetAttrs?.(dom) ?? existingAttrs ?? {};
602
691
  if (baseAttrs === false || !dom || !isElement(dom)) {
603
- return baseAttrs != null ? baseAttrs : null;
692
+ return baseAttrs ?? null;
604
693
  }
605
694
  const insertedAttrs = {};
606
695
  for (const option of options) {
@@ -715,6 +804,9 @@ var nodeSpecFacet = defineFacet({
715
804
 
716
805
  // src/extensions/doc.ts
717
806
  function defineDoc() {
807
+ console.warn(
808
+ '[prosekit] The `defineDoc` function from `prosekit/core` is deprecated. Use the following import instead: `import { defineDoc } from "prosekit/extensions/doc"`.'
809
+ );
718
810
  return defineNodeSpec({
719
811
  name: "doc",
720
812
  content: "block+",
@@ -724,49 +816,9 @@ function defineDoc() {
724
816
 
725
817
  // src/extensions/events/plugin-view.ts
726
818
  import {
727
- PluginKey,
728
- ProseMirrorPlugin
729
- } from "@prosekit/pm/state";
730
-
731
- // src/extensions/plugin.ts
732
- import {
733
- Plugin
819
+ PluginKey as PluginKey2,
820
+ ProseMirrorPlugin as ProseMirrorPlugin2
734
821
  } from "@prosekit/pm/state";
735
- function definePlugin(plugin) {
736
- if (plugin instanceof Plugin || Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
737
- return definePluginPayload(() => plugin);
738
- }
739
- if (typeof plugin === "function") {
740
- return definePluginPayload(plugin);
741
- }
742
- throw new TypeError("Invalid plugin");
743
- }
744
- function definePluginPayload(payload) {
745
- return defineFacetPayload(pluginFacet, [payload]);
746
- }
747
- var pluginFacet = defineFacet({
748
- reducer: (payloads) => {
749
- return ({ schema }) => {
750
- const plugins = [];
751
- for (const payload of payloads) {
752
- if (payload instanceof Plugin) {
753
- plugins.push(payload);
754
- } else if (Array.isArray(payload) && payload.every((p) => p instanceof Plugin)) {
755
- plugins.push(...payload);
756
- } else if (typeof payload === "function") {
757
- plugins.push(...[payload({ schema })].flat());
758
- } else {
759
- throw new ProseKitError("Invalid plugin");
760
- }
761
- }
762
- plugins.reverse();
763
- return { plugins };
764
- };
765
- },
766
- parent: stateFacet
767
- });
768
-
769
- // src/extensions/events/plugin-view.ts
770
822
  function defineMountHandler(handler) {
771
823
  return definePluginViewFacetPayload(["mount", handler]);
772
824
  }
@@ -784,7 +836,7 @@ var pluginViewFacet = defineFacet({
784
836
  let mountHandlers = [];
785
837
  let updateHandlers = [];
786
838
  let unmountHandlers = [];
787
- const plugin = new ProseMirrorPlugin({
839
+ const plugin = new ProseMirrorPlugin2({
788
840
  key: pluginKey,
789
841
  view: (view) => {
790
842
  mountHandlers.forEach((fn) => fn(view));
@@ -824,7 +876,7 @@ var pluginViewFacet = defineFacet({
824
876
  parent: pluginFacet,
825
877
  singleton: true
826
878
  });
827
- var pluginKey = new PluginKey("prosekit-plugin-view-handler");
879
+ var pluginKey = new PluginKey2("prosekit-plugin-view-handler");
828
880
 
829
881
  // src/extensions/events/doc-change.ts
830
882
  function defineDocChangeHandler(handler) {
@@ -837,8 +889,8 @@ function defineDocChangeHandler(handler) {
837
889
 
838
890
  // src/extensions/events/dom-event.ts
839
891
  import {
840
- PluginKey as PluginKey2,
841
- ProseMirrorPlugin as ProseMirrorPlugin2
892
+ PluginKey as PluginKey3,
893
+ ProseMirrorPlugin as ProseMirrorPlugin3
842
894
  } from "@prosekit/pm/state";
843
895
 
844
896
  // src/utils/combine-event-handlers.ts
@@ -878,7 +930,6 @@ var domEventFacet = defineFacet(
878
930
  const combinedHandlerMap = {};
879
931
  let plugin;
880
932
  const update = (payloads) => {
881
- var _a;
882
933
  let hasNewEvent = false;
883
934
  for (const [event] of payloads) {
884
935
  if (!setHandlersMap[event]) {
@@ -893,19 +944,19 @@ var domEventFacet = defineFacet(
893
944
  }
894
945
  const map = groupEntries(payloads);
895
946
  for (const [event, setHandlers] of Object.entries(setHandlersMap)) {
896
- const handlers = (_a = map[event]) != null ? _a : [];
947
+ const handlers = map[event] ?? [];
897
948
  setHandlers(handlers);
898
949
  }
899
950
  if (hasNewEvent) {
900
- plugin = new ProseMirrorPlugin2({
901
- key: new PluginKey2("prosekit-dom-event-handler"),
951
+ plugin = new ProseMirrorPlugin3({
952
+ key: new PluginKey3("prosekit-dom-event-handler"),
902
953
  props: { handleDOMEvents: combinedHandlerMap }
903
954
  });
904
955
  }
905
956
  };
906
957
  return function reducer(inputs) {
907
958
  update(inputs);
908
- return plugin != null ? plugin : [];
959
+ return plugin ?? [];
909
960
  };
910
961
  },
911
962
  parent: pluginFacet,
@@ -915,8 +966,8 @@ var domEventFacet = defineFacet(
915
966
 
916
967
  // src/extensions/events/editor-event.ts
917
968
  import {
918
- PluginKey as PluginKey3,
919
- ProseMirrorPlugin as ProseMirrorPlugin3
969
+ PluginKey as PluginKey4,
970
+ ProseMirrorPlugin as ProseMirrorPlugin4
920
971
  } from "@prosekit/pm/state";
921
972
  function defineEventFacetPayload(payload) {
922
973
  return defineFacetPayload(editorEventFacet, [payload]);
@@ -982,23 +1033,22 @@ function setupEditorEventPlugin() {
982
1033
  const [setDropHandlers, handleDrop] = combineEventHandlers();
983
1034
  const [setScrollToSelectionHandlers, handleScrollToSelection] = combineEventHandlers();
984
1035
  const update = (entries) => {
985
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
986
1036
  const map = groupEntries(entries);
987
- setKeyDownHandlers((_a = map.keyDown) != null ? _a : []);
988
- setKeyPressHandlers((_b = map.keyPress) != null ? _b : []);
989
- setTextInputHandlers((_c = map.textInput) != null ? _c : []);
990
- setClickOnHandlers((_d = map.clickOn) != null ? _d : []);
991
- setClickHandlers((_e = map.click) != null ? _e : []);
992
- setDoubleClickOnHandlers((_f = map.doubleClickOn) != null ? _f : []);
993
- setDoubleClickHandlers((_g = map.doubleClick) != null ? _g : []);
994
- setTripleClickOnHandlers((_h = map.tripleClickOn) != null ? _h : []);
995
- setTripleClickHandlers((_i = map.tripleClick) != null ? _i : []);
996
- setPasteHandlers((_j = map.paste) != null ? _j : []);
997
- setDropHandlers((_k = map.drop) != null ? _k : []);
998
- setScrollToSelectionHandlers((_l = map.scrollToSelection) != null ? _l : []);
1037
+ setKeyDownHandlers(map.keyDown ?? []);
1038
+ setKeyPressHandlers(map.keyPress ?? []);
1039
+ setTextInputHandlers(map.textInput ?? []);
1040
+ setClickOnHandlers(map.clickOn ?? []);
1041
+ setClickHandlers(map.click ?? []);
1042
+ setDoubleClickOnHandlers(map.doubleClickOn ?? []);
1043
+ setDoubleClickHandlers(map.doubleClick ?? []);
1044
+ setTripleClickOnHandlers(map.tripleClickOn ?? []);
1045
+ setTripleClickHandlers(map.tripleClick ?? []);
1046
+ setPasteHandlers(map.paste ?? []);
1047
+ setDropHandlers(map.drop ?? []);
1048
+ setScrollToSelectionHandlers(map.scrollToSelection ?? []);
999
1049
  };
1000
- const plugin = new ProseMirrorPlugin3({
1001
- key: new PluginKey3("prosekit-editor-event"),
1050
+ const plugin = new ProseMirrorPlugin4({
1051
+ key: new PluginKey4("prosekit-editor-event"),
1002
1052
  props: {
1003
1053
  handleKeyDown,
1004
1054
  handleKeyPress,
@@ -1042,7 +1092,7 @@ import { chainCommands } from "@prosekit/pm/commands";
1042
1092
  import { keydownHandler } from "@prosekit/pm/keymap";
1043
1093
  import {
1044
1094
  Plugin as Plugin2,
1045
- PluginKey as PluginKey4
1095
+ PluginKey as PluginKey5
1046
1096
  } from "@prosekit/pm/state";
1047
1097
  import mapValues from "just-map-values";
1048
1098
  function defineKeymap(keymap2) {
@@ -1085,7 +1135,7 @@ function mergeKeymaps(keymaps) {
1085
1135
  function mergeCommands(commands2) {
1086
1136
  return chainCommands(...commands2);
1087
1137
  }
1088
- var keymapPluginKey = new PluginKey4("prosekit-keymap");
1138
+ var keymapPluginKey = new PluginKey5("prosekit-keymap");
1089
1139
 
1090
1140
  // src/extensions/history.ts
1091
1141
  var keymap = {
@@ -1139,8 +1189,7 @@ var customBaseKeymap = {
1139
1189
  Backspace: customBackspace
1140
1190
  };
1141
1191
  function defineBaseKeymap(options) {
1142
- var _a;
1143
- const priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 1 /* low */;
1192
+ const priority = options?.priority ?? 1 /* low */;
1144
1193
  return withPriority(defineKeymap(customBaseKeymap), priority);
1145
1194
  }
1146
1195
 
@@ -1205,8 +1254,8 @@ function wrapParseRuleAttrs(rule, attrs) {
1205
1254
 
1206
1255
  // src/extensions/mark-view.ts
1207
1256
  import {
1208
- PluginKey as PluginKey5,
1209
- ProseMirrorPlugin as ProseMirrorPlugin4
1257
+ PluginKey as PluginKey6,
1258
+ ProseMirrorPlugin as ProseMirrorPlugin5
1210
1259
  } from "@prosekit/pm/state";
1211
1260
  function defineMarkView(options) {
1212
1261
  return defineFacetPayload(markViewFacet, [options]);
@@ -1220,8 +1269,8 @@ var markViewFacet = defineFacet({
1220
1269
  }
1221
1270
  }
1222
1271
  return () => [
1223
- new ProseMirrorPlugin4({
1224
- key: new PluginKey5("prosekit-mark-view"),
1272
+ new ProseMirrorPlugin5({
1273
+ key: new PluginKey6("prosekit-mark-view"),
1225
1274
  props: { markViews }
1226
1275
  })
1227
1276
  ];
@@ -1231,8 +1280,8 @@ var markViewFacet = defineFacet({
1231
1280
 
1232
1281
  // src/extensions/mark-view-effect.ts
1233
1282
  import {
1234
- PluginKey as PluginKey6,
1235
- ProseMirrorPlugin as ProseMirrorPlugin5
1283
+ PluginKey as PluginKey7,
1284
+ ProseMirrorPlugin as ProseMirrorPlugin6
1236
1285
  } from "@prosekit/pm/state";
1237
1286
  function defineMarkViewFactory(options) {
1238
1287
  const input = [options, null];
@@ -1255,8 +1304,8 @@ var markViewFactoryFacet = defineFacet({
1255
1304
  markViews[name] = factory.factory(args);
1256
1305
  }
1257
1306
  return () => [
1258
- new ProseMirrorPlugin5({
1259
- key: new PluginKey6("prosekit-mark-view-effect"),
1307
+ new ProseMirrorPlugin6({
1308
+ key: new PluginKey7("prosekit-mark-view-effect"),
1260
1309
  props: { markViews }
1261
1310
  })
1262
1311
  ];
@@ -1266,8 +1315,8 @@ var markViewFactoryFacet = defineFacet({
1266
1315
 
1267
1316
  // src/extensions/node-view.ts
1268
1317
  import {
1269
- PluginKey as PluginKey7,
1270
- ProseMirrorPlugin as ProseMirrorPlugin6
1318
+ PluginKey as PluginKey8,
1319
+ ProseMirrorPlugin as ProseMirrorPlugin7
1271
1320
  } from "@prosekit/pm/state";
1272
1321
  function defineNodeView(options) {
1273
1322
  return defineFacetPayload(nodeViewFacet, [options]);
@@ -1281,8 +1330,8 @@ var nodeViewFacet = defineFacet({
1281
1330
  }
1282
1331
  }
1283
1332
  return () => [
1284
- new ProseMirrorPlugin6({
1285
- key: new PluginKey7("prosekit-node-view"),
1333
+ new ProseMirrorPlugin7({
1334
+ key: new PluginKey8("prosekit-node-view"),
1286
1335
  props: { nodeViews }
1287
1336
  })
1288
1337
  ];
@@ -1292,8 +1341,8 @@ var nodeViewFacet = defineFacet({
1292
1341
 
1293
1342
  // src/extensions/node-view-effect.ts
1294
1343
  import {
1295
- PluginKey as PluginKey8,
1296
- ProseMirrorPlugin as ProseMirrorPlugin7
1344
+ PluginKey as PluginKey9,
1345
+ ProseMirrorPlugin as ProseMirrorPlugin8
1297
1346
  } from "@prosekit/pm/state";
1298
1347
  function defineNodeViewFactory(options) {
1299
1348
  const input = [options, null];
@@ -1316,8 +1365,8 @@ var nodeViewFactoryFacet = defineFacet({
1316
1365
  nodeViews[name] = factory.factory(args);
1317
1366
  }
1318
1367
  return () => [
1319
- new ProseMirrorPlugin7({
1320
- key: new PluginKey8("prosekit-node-view-effect"),
1368
+ new ProseMirrorPlugin8({
1369
+ key: new PluginKey9("prosekit-node-view-effect"),
1321
1370
  props: { nodeViews }
1322
1371
  })
1323
1372
  ];
@@ -1338,11 +1387,17 @@ function defineParagraphSpec() {
1338
1387
  });
1339
1388
  }
1340
1389
  function defineParagraph() {
1390
+ console.warn(
1391
+ '[prosekit] The `defineParagraph` function from `prosekit/core` is deprecated. Use the following import instead: `import { defineParagraph } from "prosekit/extensions/paragraph"`.'
1392
+ );
1341
1393
  return withPriority(defineParagraphSpec(), 4 /* highest */);
1342
1394
  }
1343
1395
 
1344
1396
  // src/extensions/text.ts
1345
1397
  function defineText() {
1398
+ console.warn(
1399
+ '[prosekit] The `defineText` function from `prosekit/core` is deprecated. Use the following import instead: `import { defineText } from "prosekit/extensions/text"`.'
1400
+ );
1346
1401
  return defineNodeSpec({
1347
1402
  name: "text",
1348
1403
  group: "inline"
@@ -1364,7 +1419,7 @@ function cache(fn) {
1364
1419
  var canUseRegexLookbehind = cache(() => {
1365
1420
  try {
1366
1421
  return "ab".replace(new RegExp("(?<=a)b", "g"), "c") === "ac";
1367
- } catch (e) {
1422
+ } catch {
1368
1423
  return false;
1369
1424
  }
1370
1425
  });
@@ -1475,6 +1530,7 @@ export {
1475
1530
  defineBaseKeymap,
1476
1531
  defineClickHandler,
1477
1532
  defineClickOnHandler,
1533
+ defineClipboardSerializer,
1478
1534
  defineCommands,
1479
1535
  defineDOMEventHandler,
1480
1536
  defineDefaultState,
@@ -1526,6 +1582,7 @@ export {
1526
1582
  isAllSelection,
1527
1583
  isApple,
1528
1584
  isAtBlockStart,
1585
+ isElement,
1529
1586
  isFragment,
1530
1587
  isInCodeBlock,
1531
1588
  isMark,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.7.14",
4
+ "version": "0.8.0",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -45,19 +45,19 @@
45
45
  "just-map-values": "^3.2.0",
46
46
  "orderedmap": "^2.1.1",
47
47
  "prosemirror-splittable": "^0.1.1",
48
- "type-fest": "^4.30.2",
48
+ "type-fest": "^4.37.0",
49
49
  "@prosekit/pm": "^0.1.9"
50
50
  },
51
51
  "devDependencies": {
52
- "@vitest/browser": "^2.1.8",
53
- "tsup": "^8.3.5",
54
- "typescript": "~5.6.3",
55
- "vitest": "^2.1.8",
52
+ "@vitest/browser": "^3.0.9",
53
+ "tsup": "^8.4.0",
54
+ "typescript": "~5.7.3",
55
+ "vitest": "^3.0.9",
56
56
  "@prosekit/dev": "0.0.0"
57
57
  },
58
58
  "scripts": {
59
- "build:tsup": "tsup",
60
- "build:tsc": "tsc -b tsconfig.json"
59
+ "build:tsc": "tsc -b tsconfig.json",
60
+ "build:tsup": "tsup"
61
61
  },
62
62
  "types": "./dist/prosekit-core.d.ts",
63
63
  "typesVersions": {