@prosekit/core 0.5.0 → 0.5.2

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.
@@ -463,7 +463,7 @@ function subtractInput(a, b) {
463
463
  if (!a)
464
464
  return null;
465
465
  if (!b)
466
- return [];
466
+ return [...a];
467
467
  return arraySubstract(a, b);
468
468
  }
469
469
  function unionChildren(a, b) {
@@ -478,7 +478,9 @@ function subtractChildren(a, b) {
478
478
  const merged = new Map(a);
479
479
  for (const [key, valueB] of b.entries()) {
480
480
  const valueA = a.get(key);
481
- merged.set(key, valueA ? subtractFacetNode(valueA, valueB) : valueB);
481
+ if (valueA) {
482
+ merged.set(key, subtractFacetNode(valueA, valueB));
483
+ }
482
484
  }
483
485
  return merged;
484
486
  }
@@ -1091,7 +1093,11 @@ var EditorInstance = class {
1091
1093
  return this.cachedState;
1092
1094
  }
1093
1095
  updateExtension(extension, add) {
1094
- var _a, _b, _c, _d, _e;
1096
+ var _a, _b, _c, _d;
1097
+ const view = this.view;
1098
+ if (!view || view.isDestroyed) {
1099
+ return;
1100
+ }
1095
1101
  const tree = extension.getTree();
1096
1102
  const payload = tree.getRootOutput();
1097
1103
  if (payload == null ? void 0 : payload.schema) {
@@ -1101,14 +1107,13 @@ var EditorInstance = class {
1101
1107
  throw new ProseKitError("View cannot be changed");
1102
1108
  }
1103
1109
  const oldPayload = this.tree.getRootOutput();
1104
- const oldPlugins = [...(_c = (_b = (_a = this.view) == null ? void 0 : _a.state) == null ? void 0 : _b.plugins) != null ? _c : []];
1110
+ const oldPlugins = [...(_b = (_a = view.state) == null ? void 0 : _a.plugins) != null ? _b : []];
1105
1111
  this.tree = add ? unionFacetNode(this.tree, tree) : subtractFacetNode(this.tree, tree);
1106
1112
  const newPayload = this.tree.getRootOutput();
1107
- const newPlugins = [...(_e = (_d = newPayload == null ? void 0 : newPayload.state) == null ? void 0 : _d.plugins) != null ? _e : []];
1113
+ const newPlugins = [...(_d = (_c = newPayload == null ? void 0 : newPayload.state) == null ? void 0 : _c.plugins) != null ? _d : []];
1108
1114
  if (!deepEquals(oldPlugins, newPlugins)) {
1109
- assert(this.view, "EditorInstance.view is not defined");
1110
- const state = this.view.state.reconfigure({ plugins: newPlugins });
1111
- this.view.updateState(state);
1115
+ const state = view.state.reconfigure({ plugins: newPlugins });
1116
+ view.updateState(state);
1112
1117
  }
1113
1118
  if ((newPayload == null ? void 0 : newPayload.commands) && !deepEquals(oldPayload == null ? void 0 : oldPayload.commands, newPayload == null ? void 0 : newPayload.commands)) {
1114
1119
  const commands = newPayload.commands;
@@ -1134,6 +1139,9 @@ var EditorInstance = class {
1134
1139
  this.view.destroy();
1135
1140
  this.view = null;
1136
1141
  }
1142
+ get mounted() {
1143
+ return !!this.view && !this.view.isDestroyed;
1144
+ }
1137
1145
  get assertView() {
1138
1146
  if (!this.view) {
1139
1147
  throw new ProseKitError("Editor is not mounted");
@@ -1200,7 +1208,7 @@ var Editor = class _Editor {
1200
1208
  * Whether the editor is mounted.
1201
1209
  */
1202
1210
  get mounted() {
1203
- return !!this.instance.view;
1211
+ return this.instance.mounted;
1204
1212
  }
1205
1213
  /**
1206
1214
  * The editor view.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -35,16 +35,16 @@
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@prosekit/pm": "^0.1.3",
38
+ "@prosekit/pm": "^0.1.4",
39
39
  "clsx": "^2.1.1",
40
40
  "orderedmap": "^2.1.1",
41
- "type-fest": "^4.18.1"
41
+ "type-fest": "^4.18.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@prosekit/dev": "*",
45
44
  "tsup": "^8.0.2",
46
45
  "typescript": "^5.4.5",
47
- "vitest": "^1.6.0"
46
+ "vitest": "^1.6.0",
47
+ "@prosekit/dev": "0.0.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build:tsup": "tsup",