@prosekit/core 0.7.12 → 0.7.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.
@@ -39,7 +39,7 @@ import {
39
39
  stateFromJSON,
40
40
  toReversed,
41
41
  union
42
- } from "./chunk-LAFNHJDR.js";
42
+ } from "./chunk-6DIFWJEG.js";
43
43
 
44
44
  // src/commands/add-mark.ts
45
45
  function addMark(options) {
@@ -57,7 +57,9 @@ function addMark(options) {
57
57
  }
58
58
 
59
59
  // src/commands/expand-mark.ts
60
- import { TextSelection } from "@prosekit/pm/state";
60
+ import {
61
+ TextSelection
62
+ } from "@prosekit/pm/state";
61
63
  function expandMark(options) {
62
64
  return (state, dispatch) => {
63
65
  const markType = getMarkType(state.schema, options.type);
@@ -110,7 +112,9 @@ function expandMarkAfter($pos, predicate) {
110
112
  }
111
113
 
112
114
  // src/commands/insert-default-block.ts
113
- import { TextSelection as TextSelection2 } from "@prosekit/pm/state";
115
+ import {
116
+ TextSelection as TextSelection2
117
+ } from "@prosekit/pm/state";
114
118
 
115
119
  // src/utils/default-block-at.ts
116
120
  function defaultBlockAt(match) {
@@ -148,7 +152,9 @@ function insertDefaultBlock(options) {
148
152
  import { insertPoint } from "@prosekit/pm/transform";
149
153
 
150
154
  // src/utils/set-selection-around.ts
151
- import { TextSelection as TextSelection3 } from "@prosekit/pm/state";
155
+ import {
156
+ TextSelection as TextSelection3
157
+ } from "@prosekit/pm/state";
152
158
  function setSelectionAround(tr, pos) {
153
159
  const docSize = tr.doc.content.size;
154
160
  const $pos = tr.doc.resolve(pos > docSize ? docSize : pos < 0 ? 0 : pos);
@@ -379,7 +385,10 @@ function toggleWrap(options) {
379
385
  }
380
386
 
381
387
  // src/commands/unset-block-type.ts
382
- import { Fragment, Slice } from "@prosekit/pm/model";
388
+ import {
389
+ Fragment,
390
+ Slice
391
+ } from "@prosekit/pm/model";
383
392
  import { ReplaceAroundStep } from "@prosekit/pm/transform";
384
393
  function unsetBlockType(options) {
385
394
  return (state, dispatch) => {
@@ -450,7 +459,9 @@ function insertText({ text, from, to }) {
450
459
  }
451
460
 
452
461
  // src/commands/select-all.ts
453
- import { AllSelection } from "@prosekit/pm/state";
462
+ import {
463
+ AllSelection
464
+ } from "@prosekit/pm/state";
454
465
  function selectAll() {
455
466
  return (state, dispatch) => {
456
467
  dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
@@ -692,9 +703,7 @@ var nodeSpecFacet = defineFacet({
692
703
  spec.toDOM = wrapOutputSpecAttrs(spec.toDOM, attrs);
693
704
  }
694
705
  if (spec.parseDOM) {
695
- spec.parseDOM = spec.parseDOM.map(
696
- (rule) => wrapTagParseRuleAttrs(rule, attrs)
697
- );
706
+ spec.parseDOM = spec.parseDOM.map((rule) => wrapTagParseRuleAttrs(rule, attrs));
698
707
  }
699
708
  specs = specs.update(type, spec);
700
709
  }
@@ -720,7 +729,9 @@ import {
720
729
  } from "@prosekit/pm/state";
721
730
 
722
731
  // src/extensions/plugin.ts
723
- import { Plugin } from "@prosekit/pm/state";
732
+ import {
733
+ Plugin
734
+ } from "@prosekit/pm/state";
724
735
  function definePlugin(plugin) {
725
736
  if (plugin instanceof Plugin || Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
726
737
  return definePluginPayload(() => plugin);
@@ -825,7 +836,10 @@ function defineDocChangeHandler(handler) {
825
836
  }
826
837
 
827
838
  // src/extensions/events/dom-event.ts
828
- import { PluginKey as PluginKey2, ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
839
+ import {
840
+ PluginKey as PluginKey2,
841
+ ProseMirrorPlugin as ProseMirrorPlugin2
842
+ } from "@prosekit/pm/state";
829
843
 
830
844
  // src/utils/combine-event-handlers.ts
831
845
  function combineEventHandlers() {
@@ -900,7 +914,10 @@ var domEventFacet = defineFacet(
900
914
  );
901
915
 
902
916
  // src/extensions/events/editor-event.ts
903
- import { PluginKey as PluginKey3, ProseMirrorPlugin as ProseMirrorPlugin3 } from "@prosekit/pm/state";
917
+ import {
918
+ PluginKey as PluginKey3,
919
+ ProseMirrorPlugin as ProseMirrorPlugin3
920
+ } from "@prosekit/pm/state";
904
921
  function defineEventFacetPayload(payload) {
905
922
  return defineFacetPayload(editorEventFacet, [payload]);
906
923
  }
@@ -1011,7 +1028,11 @@ function defineFocusChangeHandler(handler) {
1011
1028
  }
1012
1029
 
1013
1030
  // src/extensions/history.ts
1014
- import { history, redo, undo } from "@prosekit/pm/history";
1031
+ import {
1032
+ history,
1033
+ redo,
1034
+ undo
1035
+ } from "@prosekit/pm/history";
1015
1036
 
1016
1037
  // src/utils/env.ts
1017
1038
  var isApple = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : false;
@@ -1019,7 +1040,10 @@ var isApple = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navig
1019
1040
  // src/extensions/keymap.ts
1020
1041
  import { chainCommands } from "@prosekit/pm/commands";
1021
1042
  import { keydownHandler } from "@prosekit/pm/keymap";
1022
- import { Plugin as Plugin2, PluginKey as PluginKey4 } from "@prosekit/pm/state";
1043
+ import {
1044
+ Plugin as Plugin2,
1045
+ PluginKey as PluginKey4
1046
+ } from "@prosekit/pm/state";
1023
1047
  import mapValues from "just-map-values";
1024
1048
  function defineKeymap(keymap2) {
1025
1049
  return defineFacetPayload(keymapFacet, [keymap2]);
@@ -1163,9 +1187,7 @@ var markSpecFacet = defineFacet({
1163
1187
  spec.toDOM = wrapOutputSpecAttrs(spec.toDOM, attrs);
1164
1188
  }
1165
1189
  if (spec.parseDOM) {
1166
- spec.parseDOM = spec.parseDOM.map(
1167
- (rule) => wrapParseRuleAttrs(rule, attrs)
1168
- );
1190
+ spec.parseDOM = spec.parseDOM.map((rule) => wrapParseRuleAttrs(rule, attrs));
1169
1191
  }
1170
1192
  specs = specs.update(type, spec);
1171
1193
  }
@@ -1181,8 +1203,72 @@ function wrapParseRuleAttrs(rule, attrs) {
1181
1203
  return rule;
1182
1204
  }
1183
1205
 
1206
+ // src/extensions/mark-view.ts
1207
+ import {
1208
+ PluginKey as PluginKey5,
1209
+ ProseMirrorPlugin as ProseMirrorPlugin4
1210
+ } from "@prosekit/pm/state";
1211
+ function defineMarkView(options) {
1212
+ return defineFacetPayload(markViewFacet, [options]);
1213
+ }
1214
+ var markViewFacet = defineFacet({
1215
+ reducer: (inputs) => {
1216
+ const markViews = {};
1217
+ for (const input of inputs) {
1218
+ if (!markViews[input.name]) {
1219
+ markViews[input.name] = input.constructor;
1220
+ }
1221
+ }
1222
+ return () => [
1223
+ new ProseMirrorPlugin4({
1224
+ key: new PluginKey5("prosekit-mark-view"),
1225
+ props: { markViews }
1226
+ })
1227
+ ];
1228
+ },
1229
+ parent: pluginFacet
1230
+ });
1231
+
1232
+ // src/extensions/mark-view-effect.ts
1233
+ import {
1234
+ PluginKey as PluginKey6,
1235
+ ProseMirrorPlugin as ProseMirrorPlugin5
1236
+ } from "@prosekit/pm/state";
1237
+ function defineMarkViewFactory(options) {
1238
+ const input = [options, null];
1239
+ return defineFacetPayload(markViewFactoryFacet, [input]);
1240
+ }
1241
+ function defineMarkViewComponent(options) {
1242
+ const input = [null, options];
1243
+ return defineFacetPayload(markViewFactoryFacet, [input]);
1244
+ }
1245
+ var isServer = typeof window === "undefined";
1246
+ var markViewFactoryFacet = defineFacet({
1247
+ reducer: (inputs) => {
1248
+ if (isServer) return [];
1249
+ const markViews = {};
1250
+ const factories = inputs.map((x) => x[0]).filter(isNotNullish);
1251
+ const options = inputs.map((x) => x[1]).filter(isNotNullish);
1252
+ for (const { group, name, args } of options) {
1253
+ const factory = factories.find((factory2) => factory2.group === group);
1254
+ if (!factory) continue;
1255
+ markViews[name] = factory.factory(args);
1256
+ }
1257
+ return () => [
1258
+ new ProseMirrorPlugin5({
1259
+ key: new PluginKey6("prosekit-mark-view-effect"),
1260
+ props: { markViews }
1261
+ })
1262
+ ];
1263
+ },
1264
+ parent: pluginFacet
1265
+ });
1266
+
1184
1267
  // src/extensions/node-view.ts
1185
- import { PluginKey as PluginKey5, ProseMirrorPlugin as ProseMirrorPlugin4 } from "@prosekit/pm/state";
1268
+ import {
1269
+ PluginKey as PluginKey7,
1270
+ ProseMirrorPlugin as ProseMirrorPlugin6
1271
+ } from "@prosekit/pm/state";
1186
1272
  function defineNodeView(options) {
1187
1273
  return defineFacetPayload(nodeViewFacet, [options]);
1188
1274
  }
@@ -1195,8 +1281,8 @@ var nodeViewFacet = defineFacet({
1195
1281
  }
1196
1282
  }
1197
1283
  return () => [
1198
- new ProseMirrorPlugin4({
1199
- key: new PluginKey5("prosekit-node-view"),
1284
+ new ProseMirrorPlugin6({
1285
+ key: new PluginKey7("prosekit-node-view"),
1200
1286
  props: { nodeViews }
1201
1287
  })
1202
1288
  ];
@@ -1205,7 +1291,10 @@ var nodeViewFacet = defineFacet({
1205
1291
  });
1206
1292
 
1207
1293
  // src/extensions/node-view-effect.ts
1208
- import { PluginKey as PluginKey6, ProseMirrorPlugin as ProseMirrorPlugin5 } from "@prosekit/pm/state";
1294
+ import {
1295
+ PluginKey as PluginKey8,
1296
+ ProseMirrorPlugin as ProseMirrorPlugin7
1297
+ } from "@prosekit/pm/state";
1209
1298
  function defineNodeViewFactory(options) {
1210
1299
  const input = [options, null];
1211
1300
  return defineFacetPayload(nodeViewFactoryFacet, [input]);
@@ -1214,10 +1303,10 @@ function defineNodeViewComponent(options) {
1214
1303
  const input = [null, options];
1215
1304
  return defineFacetPayload(nodeViewFactoryFacet, [input]);
1216
1305
  }
1217
- var isServer = typeof window === "undefined";
1306
+ var isServer2 = typeof window === "undefined";
1218
1307
  var nodeViewFactoryFacet = defineFacet({
1219
1308
  reducer: (inputs) => {
1220
- if (isServer) return [];
1309
+ if (isServer2) return [];
1221
1310
  const nodeViews = {};
1222
1311
  const factories = inputs.map((x) => x[0]).filter(isNotNullish);
1223
1312
  const options = inputs.map((x) => x[1]).filter(isNotNullish);
@@ -1227,8 +1316,8 @@ var nodeViewFactoryFacet = defineFacet({
1227
1316
  nodeViews[name] = factory.factory(args);
1228
1317
  }
1229
1318
  return () => [
1230
- new ProseMirrorPlugin5({
1231
- key: new PluginKey6("prosekit-node-view-effect"),
1319
+ new ProseMirrorPlugin7({
1320
+ key: new PluginKey8("prosekit-node-view-effect"),
1232
1321
  props: { nodeViews }
1233
1322
  })
1234
1323
  ];
@@ -1294,7 +1383,10 @@ function collectChildren(parent) {
1294
1383
  }
1295
1384
 
1296
1385
  // src/utils/collect-nodes.ts
1297
- import { ProseMirrorFragment, ProseMirrorNode } from "@prosekit/pm/model";
1386
+ import {
1387
+ ProseMirrorFragment,
1388
+ ProseMirrorNode
1389
+ } from "@prosekit/pm/model";
1298
1390
  function collectNodes(content) {
1299
1391
  if (Array.isArray(content)) {
1300
1392
  return content.flatMap(collectNodes);
@@ -1332,8 +1424,9 @@ function getId() {
1332
1424
  // src/utils/is-at-block-start.ts
1333
1425
  function isAtBlockStart(state, view) {
1334
1426
  const { $cursor } = state.selection;
1335
- if (!$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0))
1427
+ if (!$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0)) {
1336
1428
  return null;
1429
+ }
1337
1430
  return $cursor;
1338
1431
  }
1339
1432
 
@@ -1399,6 +1492,9 @@ export {
1399
1492
  defineKeymap,
1400
1493
  defineMarkAttr,
1401
1494
  defineMarkSpec,
1495
+ defineMarkView,
1496
+ defineMarkViewComponent,
1497
+ defineMarkViewFactory,
1402
1498
  defineMountHandler,
1403
1499
  defineNodeAttr,
1404
1500
  defineNodeSpec,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.7.12",
4
+ "version": "0.7.14",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -45,14 +45,14 @@
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.26.1",
49
- "@prosekit/pm": "^0.1.8"
48
+ "type-fest": "^4.30.2",
49
+ "@prosekit/pm": "^0.1.9"
50
50
  },
51
51
  "devDependencies": {
52
- "@vitest/browser": "^2.1.3",
53
- "tsup": "^8.3.0",
54
- "typescript": "^5.6.3",
55
- "vitest": "^2.1.3",
52
+ "@vitest/browser": "^2.1.8",
53
+ "tsup": "^8.3.5",
54
+ "typescript": "~5.6.3",
55
+ "vitest": "^2.1.8",
56
56
  "@prosekit/dev": "0.0.0"
57
57
  },
58
58
  "scripts": {