@prosekit/extensions 0.11.0 → 0.11.1

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,4 @@
1
- import { defineFacet, defineFacetPayload, pluginFacet } from "@prosekit/core";
1
+ import { defineFacet, defineFacetPayload, isNodeSelection, pluginFacet } from "@prosekit/core";
2
2
  import { NodeSelection, Plugin, PluginKey, TextSelection } from "@prosekit/pm/state";
3
3
  import { isHTMLElement } from "@ocavue/utils";
4
4
 
@@ -68,6 +68,7 @@ function buildGetTarget(view, onDrag) {
68
68
  pos: target$1[0],
69
69
  event
70
70
  }) !== false);
71
+ if (target && isDraggingToItself(view, target[0])) return void 0;
71
72
  return target;
72
73
  };
73
74
  return getTarget;
@@ -78,6 +79,21 @@ function pointPointDistance(a, b) {
78
79
  function pointLineDistance(point, line) {
79
80
  return Math.min(pointPointDistance(point, [line[0], line[1]]), pointPointDistance(point, [line[2], line[3]]));
80
81
  }
82
+ /**
83
+ * Whether the dragging node is being dragged to the same position. For example,
84
+ * dragging a list node into a new position that is just below the list node, or
85
+ * dragging a nested quoteblock into itself.
86
+ */
87
+ function isDraggingToItself(view, pos) {
88
+ const dragging = view.dragging;
89
+ if (!dragging) return;
90
+ const { move } = dragging;
91
+ if (!move) return;
92
+ const selection = view.state.selection;
93
+ if (!isNodeSelection(selection)) return;
94
+ const { from, to } = selection;
95
+ return from <= pos && pos <= to;
96
+ }
81
97
 
82
98
  //#endregion
83
99
  //#region src/drop-indicator/drop-indicator-plugin.ts
@@ -1,5 +1,7 @@
1
1
  import { PlainExtension } from "@prosekit/core";
2
+ import { NodeSelection } from "@prosekit/pm/state";
2
3
  import { EditorView } from "@prosekit/pm/view";
4
+ import { Slice } from "@prosekit/pm/model";
3
5
 
4
6
  //#region src/drop-indicator/types.d.ts
5
7
 
@@ -69,6 +71,18 @@ interface Line {
69
71
  readonly p1: Point;
70
72
  readonly p2: Point;
71
73
  }
74
+ /**
75
+ * An interface matching the internal ProseMirror implementation.
76
+ *
77
+ * See https://github.com/ProseMirror/prosemirror-view/blob/1.38.1/src/input.ts#L657
78
+ *
79
+ * @internal
80
+ */
81
+ interface ViewDragging {
82
+ readonly slice: Slice;
83
+ readonly move: boolean;
84
+ readonly node?: NodeSelection;
85
+ }
72
86
  //#endregion
73
87
  //#region src/drop-indicator/drop-indicator-facet.d.ts
74
88
  /**
@@ -117,4 +131,4 @@ declare function defineDropIndicator(options?: DropIndicatorOptions): DropIndica
117
131
  */
118
132
  interface DropIndicatorOptions extends DropIndicatorPayload {}
119
133
  //#endregion
120
- export { type DragEventHandler, type DragEventHandlerOptions, type DropIndicatorExtension, type DropIndicatorOptions, type Line, type Point, type ShowHandler, type ShowHandlerOptions, defineDropIndicator };
134
+ export { type DragEventHandler, type DragEventHandlerOptions, type DropIndicatorExtension, type DropIndicatorOptions, type Line, type Point, type ShowHandler, type ShowHandlerOptions, type ViewDragging, defineDropIndicator };
@@ -1,3 +1,3 @@
1
- import { defineDropIndicator } from "./drop-indicator-CCCaHFvw.js";
1
+ import { defineDropIndicator } from "./drop-indicator-QKkPzJIx.js";
2
2
 
3
3
  export { defineDropIndicator };
@@ -1,5 +1,5 @@
1
1
  import { defineInputRule } from "./input-rule-Gji4N7Oe.js";
2
- import { defineDropIndicator } from "./drop-indicator-CCCaHFvw.js";
2
+ import { defineDropIndicator } from "./drop-indicator-QKkPzJIx.js";
3
3
  import { defineClipboardSerializer, defineCommands, defineKeymap, defineNodeSpec, definePlugin, insertNode, union } from "@prosekit/core";
4
4
  import { Plugin } from "@prosekit/pm/state";
5
5
  import { chainCommands, deleteSelection } from "@prosekit/pm/commands";
@@ -48,7 +48,7 @@ const virtualSelectionPlugin = new ProseMirrorPlugin({
48
48
  },
49
49
  decorations: (state) => {
50
50
  const { selection, doc } = state;
51
- if (selection.empty || !getFocusState(state)) return null;
51
+ if (selection.empty || !getFocusState(state) || !selection.visible) return null;
52
52
  return DecorationSet.create(doc, [Decoration.inline(selection.from, selection.to, { class: "prosekit-virtual-selection" })]);
53
53
  }
54
54
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.11.0",
4
+ "version": "0.11.1",
5
5
  "private": false,
6
6
  "description": "A collection of common extensions for ProseKit",
7
7
  "author": {
@@ -10,14 +10,14 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "funding": "https://github.com/sponsors/ocavue",
13
- "homepage": "https://github.com/ocavue/prosekit#readme",
13
+ "homepage": "https://github.com/prosekit/prosekit#readme",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://github.com/ocavue/prosekit.git",
16
+ "url": "git+https://github.com/prosekit/prosekit.git",
17
17
  "directory": "packages/extensions"
18
18
  },
19
19
  "bugs": {
20
- "url": "https://github.com/ocavue/prosekit/issues"
20
+ "url": "https://github.com/prosekit/prosekit/issues"
21
21
  },
22
22
  "keywords": [
23
23
  "ProseMirror"
@@ -211,8 +211,8 @@
211
211
  "prosemirror-search": "^1.1.0",
212
212
  "prosemirror-tables": "^1.7.1",
213
213
  "shiki": "^3.9.1",
214
- "@prosekit/core": "^0.8.3",
215
- "@prosekit/pm": "^0.1.11"
214
+ "@prosekit/pm": "^0.1.11",
215
+ "@prosekit/core": "^0.8.3"
216
216
  },
217
217
  "peerDependencies": {
218
218
  "loro-crdt": ">= 0.16.7",
@@ -254,8 +254,8 @@
254
254
  "y-prosemirror": "^1.3.7",
255
255
  "y-protocols": "^1.0.6",
256
256
  "yjs": "^13.6.27",
257
- "@prosekit/config-vitest": "0.0.0",
258
- "@prosekit/config-tsdown": "0.0.0"
257
+ "@prosekit/config-tsdown": "0.0.0",
258
+ "@prosekit/config-vitest": "0.0.0"
259
259
  },
260
260
  "publishConfig": {
261
261
  "dev": {}