Skip to content

Commit 0883082

Browse files
authored
Remove yjs dependency from editor package (#7971)
1 parent d39c371 commit 0883082

File tree

4 files changed

+86
-13
lines changed

4 files changed

+86
-13
lines changed

ui/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@
188188
"core-js",
189189
"esbuild",
190190
"vue-demi"
191-
]
191+
],
192+
"patchedDependencies": {
193+
"@tiptap/[email protected]": "patches/@[email protected]"
194+
}
192195
}
193196
}

ui/packages/editor/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@tiptap/extension-color": "^3.11.0",
5050
"@tiptap/extension-details": "^3.11.0",
5151
"@tiptap/extension-document": "^3.11.0",
52+
"@tiptap/extension-drag-handle": "^3.11.0",
5253
"@tiptap/extension-drag-handle-vue-3": "^3.11.0",
5354
"@tiptap/extension-hard-break": "^3.11.0",
5455
"@tiptap/extension-heading": "^3.11.0",

ui/patches/@[email protected]

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
diff --git a/dist/index.js b/dist/index.js
2+
index ad58ef1637a6e5544733f4002cd0cfcc8e43022a..b5b2d3d1a2b24340b688fe1d22e3c435da313d8d 100644
3+
--- a/dist/index.js
4+
+++ b/dist/index.js
5+
@@ -3,13 +3,7 @@ import { Extension } from "@tiptap/core";
6+
7+
// src/drag-handle-plugin.ts
8+
import { computePosition } from "@floating-ui/dom";
9+
-import { isChangeOrigin } from "@tiptap/extension-collaboration";
10+
import { Plugin, PluginKey } from "@tiptap/pm/state";
11+
-import {
12+
- absolutePositionToRelativePosition,
13+
- relativePositionToAbsolutePosition,
14+
- ySyncPluginKey
15+
-} from "@tiptap/y-tiptap";
16+
17+
// src/helpers/dragHandler.ts
18+
import { getSelectionRanges, NodeRangeSelection } from "@tiptap/extension-node-range";
19+
@@ -220,18 +214,10 @@ var getOuterNode = (doc, pos) => {
20+
21+
// src/drag-handle-plugin.ts
22+
var getRelativePos = (state, absolutePos) => {
23+
- const ystate = ySyncPluginKey.getState(state);
24+
- if (!ystate) {
25+
- return null;
26+
- }
27+
- return absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping);
28+
+ return null;
29+
};
30+
var getAbsolutePos = (state, relativePos) => {
31+
- const ystate = ySyncPluginKey.getState(state);
32+
- if (!ystate) {
33+
- return -1;
34+
- }
35+
- return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
36+
+ return -1;
37+
};
38+
var getOuterDomNode = (view, domNode) => {
39+
let tmpDomNode = domNode;
40+
@@ -341,17 +327,10 @@ var DragHandlePlugin = ({
41+
return value;
42+
}
43+
if (tr.docChanged && currentNodePos !== -1 && element) {
44+
- if (isChangeOrigin(tr)) {
45+
- const newPos = getAbsolutePos(state, currentNodeRelPos);
46+
- if (newPos !== currentNodePos) {
47+
- currentNodePos = newPos;
48+
- }
49+
- } else {
50+
- const newPos = tr.mapping.map(currentNodePos);
51+
- if (newPos !== currentNodePos) {
52+
- currentNodePos = newPos;
53+
- currentNodeRelPos = getRelativePos(state, currentNodePos);
54+
- }
55+
+ const newPos = tr.mapping.map(currentNodePos);
56+
+ if (newPos !== currentNodePos) {
57+
+ currentNodePos = newPos;
58+
+ currentNodeRelPos = getRelativePos(state, currentNodePos);
59+
}
60+
}
61+
return value;

ui/pnpm-lock.yaml

Lines changed: 20 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)