@tiptap/extension-drag-handle 2.22.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.
- package/README.md +14 -0
- package/dist/drag-handle-plugin.d.ts +20 -0
- package/dist/drag-handle-plugin.d.ts.map +1 -0
- package/dist/drag-handle.d.ts +44 -0
- package/dist/drag-handle.d.ts.map +1 -0
- package/dist/helpers/cloneElement.d.ts +2 -0
- package/dist/helpers/cloneElement.d.ts.map +1 -0
- package/dist/helpers/dragHandler.d.ts +3 -0
- package/dist/helpers/dragHandler.d.ts.map +1 -0
- package/dist/helpers/findNextElementFromCursor.d.ts +14 -0
- package/dist/helpers/findNextElementFromCursor.d.ts.map +1 -0
- package/dist/helpers/getComputedStyle.d.ts +2 -0
- package/dist/helpers/getComputedStyle.d.ts.map +1 -0
- package/dist/helpers/getInnerCoords.d.ts +6 -0
- package/dist/helpers/getInnerCoords.d.ts.map +1 -0
- package/dist/helpers/getOuterNode.d.ts +4 -0
- package/dist/helpers/getOuterNode.d.ts.map +1 -0
- package/dist/helpers/minMax.d.ts +2 -0
- package/dist/helpers/minMax.d.ts.map +1 -0
- package/dist/helpers/removeNode.d.ts +2 -0
- package/dist/helpers/removeNode.d.ts.map +1 -0
- package/dist/index.cjs +504 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +493 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +499 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +58 -0
- package/src/drag-handle-plugin.ts +370 -0
- package/src/drag-handle.ts +92 -0
- package/src/helpers/cloneElement.ts +22 -0
- package/src/helpers/dragHandler.ts +102 -0
- package/src/helpers/findNextElementFromCursor.ts +55 -0
- package/src/helpers/getComputedStyle.ts +5 -0
- package/src/helpers/getInnerCoords.ts +22 -0
- package/src/helpers/getOuterNode.ts +34 -0
- package/src/helpers/minMax.ts +3 -0
- package/src/helpers/removeNode.ts +3 -0
- package/src/index.ts +6 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@tiptap/core');
|
|
6
|
+
var extensionCollaboration = require('@tiptap/extension-collaboration');
|
|
7
|
+
var state = require('@tiptap/pm/state');
|
|
8
|
+
var tippy = require('tippy.js');
|
|
9
|
+
var yProsemirror = require('y-prosemirror');
|
|
10
|
+
var extensionNodeRange = require('@tiptap/extension-node-range');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var tippy__default = /*#__PURE__*/_interopDefaultCompat(tippy);
|
|
15
|
+
|
|
16
|
+
function getCSSText(element) {
|
|
17
|
+
let value = '';
|
|
18
|
+
const style = getComputedStyle(element);
|
|
19
|
+
for (let i = 0; i < style.length; i += 1) {
|
|
20
|
+
value += `${style[i]}:${style.getPropertyValue(style[i])};`;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function cloneElement(node) {
|
|
25
|
+
const clonedNode = node.cloneNode(true);
|
|
26
|
+
const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))];
|
|
27
|
+
const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))];
|
|
28
|
+
sourceElements.forEach((sourceElement, index) => {
|
|
29
|
+
targetElements[index].style.cssText = getCSSText(sourceElement);
|
|
30
|
+
});
|
|
31
|
+
return clonedNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const findElementNextToCoords = (options) => {
|
|
35
|
+
const { x, y, direction, editor, } = options;
|
|
36
|
+
let resultElement = null;
|
|
37
|
+
let resultNode = null;
|
|
38
|
+
let pos = null;
|
|
39
|
+
let currentX = x;
|
|
40
|
+
while (resultNode === null && currentX < window.innerWidth && currentX > 0) {
|
|
41
|
+
const allElements = document.elementsFromPoint(currentX, y);
|
|
42
|
+
const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'));
|
|
43
|
+
const filteredElements = allElements.slice(0, prosemirrorIndex);
|
|
44
|
+
if (filteredElements.length > 0) {
|
|
45
|
+
const target = filteredElements[0];
|
|
46
|
+
resultElement = target;
|
|
47
|
+
pos = editor.view.posAtDOM(target, 0);
|
|
48
|
+
if (pos >= 0) {
|
|
49
|
+
resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0));
|
|
50
|
+
if (resultNode === null || resultNode === void 0 ? void 0 : resultNode.isText) {
|
|
51
|
+
resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0));
|
|
52
|
+
}
|
|
53
|
+
if (!resultNode) {
|
|
54
|
+
resultNode = editor.state.doc.nodeAt(Math.max(pos, 0));
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (direction === 'left') {
|
|
60
|
+
currentX -= 1;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
currentX += 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { resultElement, resultNode, pos: pos !== null && pos !== void 0 ? pos : null };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function getComputedStyle$1(node, property) {
|
|
70
|
+
const style = window.getComputedStyle(node);
|
|
71
|
+
return style[property];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function minMax(value = 0, min = 0, max = 0) {
|
|
75
|
+
return Math.min(Math.max(value, min), max);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getInnerCoords(view, x, y) {
|
|
79
|
+
const paddingLeft = parseInt(getComputedStyle$1(view.dom, 'paddingLeft'), 10);
|
|
80
|
+
const paddingRight = parseInt(getComputedStyle$1(view.dom, 'paddingRight'), 10);
|
|
81
|
+
const borderLeft = parseInt(getComputedStyle$1(view.dom, 'borderLeftWidth'), 10);
|
|
82
|
+
const borderRight = parseInt(getComputedStyle$1(view.dom, 'borderLeftWidth'), 10);
|
|
83
|
+
const bounds = view.dom.getBoundingClientRect();
|
|
84
|
+
const coords = {
|
|
85
|
+
left: minMax(x, bounds.left + paddingLeft + borderLeft, bounds.right - paddingRight - borderRight),
|
|
86
|
+
top: y,
|
|
87
|
+
};
|
|
88
|
+
return coords;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function removeNode(node) {
|
|
92
|
+
var _a;
|
|
93
|
+
(_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(node);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getDragHandleRanges(event, editor) {
|
|
97
|
+
const { doc } = editor.view.state;
|
|
98
|
+
const result = findElementNextToCoords({
|
|
99
|
+
editor, x: event.clientX, y: event.clientY, direction: 'right',
|
|
100
|
+
});
|
|
101
|
+
if (!result.resultNode || result.pos === null) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const x = event.clientX;
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
const coords = getInnerCoords(editor.view, x, event.clientY);
|
|
107
|
+
const posAtCoords = editor.view.posAtCoords(coords);
|
|
108
|
+
if (!posAtCoords) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
const { pos } = posAtCoords;
|
|
112
|
+
const nodeAt = doc.resolve(pos).parent;
|
|
113
|
+
if (!nodeAt) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
const $from = doc.resolve(result.pos);
|
|
117
|
+
const $to = doc.resolve(result.pos + 1);
|
|
118
|
+
return extensionNodeRange.getSelectionRanges($from, $to, 0);
|
|
119
|
+
}
|
|
120
|
+
function dragHandler(event, editor) {
|
|
121
|
+
const { view } = editor;
|
|
122
|
+
if (!event.dataTransfer) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const { empty, $from, $to } = view.state.selection;
|
|
126
|
+
const dragHandleRanges = getDragHandleRanges(event, editor);
|
|
127
|
+
const selectionRanges = extensionNodeRange.getSelectionRanges($from, $to, 0);
|
|
128
|
+
const isDragHandleWithinSelection = selectionRanges.some(range => {
|
|
129
|
+
return dragHandleRanges.find(dragHandleRange => {
|
|
130
|
+
return dragHandleRange.$from === range.$from
|
|
131
|
+
&& dragHandleRange.$to === range.$to;
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
const ranges = empty || !isDragHandleWithinSelection
|
|
135
|
+
? dragHandleRanges
|
|
136
|
+
: selectionRanges;
|
|
137
|
+
if (!ranges.length) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const { tr } = view.state;
|
|
141
|
+
const wrapper = document.createElement('div');
|
|
142
|
+
const from = ranges[0].$from.pos;
|
|
143
|
+
const to = ranges[ranges.length - 1].$to.pos;
|
|
144
|
+
const selection = extensionNodeRange.NodeRangeSelection.create(view.state.doc, from, to);
|
|
145
|
+
const slice = selection.content();
|
|
146
|
+
ranges.forEach(range => {
|
|
147
|
+
const element = view.nodeDOM(range.$from.pos);
|
|
148
|
+
const clonedElement = cloneElement(element);
|
|
149
|
+
wrapper.append(clonedElement);
|
|
150
|
+
});
|
|
151
|
+
wrapper.style.position = 'absolute';
|
|
152
|
+
wrapper.style.top = '-10000px';
|
|
153
|
+
document.body.append(wrapper);
|
|
154
|
+
event.dataTransfer.clearData();
|
|
155
|
+
event.dataTransfer.setDragImage(wrapper, 0, 0);
|
|
156
|
+
// tell ProseMirror the dragged content
|
|
157
|
+
view.dragging = { slice, move: true };
|
|
158
|
+
tr.setSelection(selection);
|
|
159
|
+
view.dispatch(tr);
|
|
160
|
+
// clean up
|
|
161
|
+
document.addEventListener('drop', () => removeNode(wrapper), { once: true });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const getOuterNodePos = (doc, pos) => {
|
|
165
|
+
const resolvedPos = doc.resolve(pos);
|
|
166
|
+
const { depth } = resolvedPos;
|
|
167
|
+
if (depth === 0) {
|
|
168
|
+
return pos;
|
|
169
|
+
}
|
|
170
|
+
const a = resolvedPos.pos - resolvedPos.parentOffset;
|
|
171
|
+
return a - 1;
|
|
172
|
+
};
|
|
173
|
+
const getOuterNode = (doc, pos) => {
|
|
174
|
+
const node = doc.nodeAt(pos);
|
|
175
|
+
const resolvedPos = doc.resolve(pos);
|
|
176
|
+
let { depth } = resolvedPos;
|
|
177
|
+
let parent = node;
|
|
178
|
+
while (depth > 0) {
|
|
179
|
+
const currentNode = resolvedPos.node(depth);
|
|
180
|
+
depth -= 1;
|
|
181
|
+
if (depth === 0) {
|
|
182
|
+
parent = currentNode;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return parent;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const getRelativePos = (state, absolutePos) => {
|
|
189
|
+
const ystate = yProsemirror.ySyncPluginKey.getState(state);
|
|
190
|
+
if (!ystate) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return yProsemirror.absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping);
|
|
194
|
+
};
|
|
195
|
+
const getAbsolutePos = (state, relativePos) => {
|
|
196
|
+
const ystate = yProsemirror.ySyncPluginKey.getState(state);
|
|
197
|
+
if (!ystate) {
|
|
198
|
+
return -1;
|
|
199
|
+
}
|
|
200
|
+
return yProsemirror.relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
|
|
201
|
+
};
|
|
202
|
+
const getOuterDomNode = (view, domNode) => {
|
|
203
|
+
let tmpDomNode = domNode;
|
|
204
|
+
// Traverse to top level node.
|
|
205
|
+
while (tmpDomNode && tmpDomNode.parentNode) {
|
|
206
|
+
if (tmpDomNode.parentNode === view.dom) {
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
tmpDomNode = tmpDomNode.parentNode;
|
|
210
|
+
}
|
|
211
|
+
return tmpDomNode;
|
|
212
|
+
};
|
|
213
|
+
const dragHandlePluginDefaultKey = new state.PluginKey('dragHandle');
|
|
214
|
+
const DragHandlePlugin = ({ pluginKey = dragHandlePluginDefaultKey, element, editor, tippyOptions, onNodeChange, }) => {
|
|
215
|
+
const wrapper = document.createElement('div');
|
|
216
|
+
let popup = null;
|
|
217
|
+
let locked = false;
|
|
218
|
+
let currentNode = null;
|
|
219
|
+
let currentNodePos = -1;
|
|
220
|
+
let currentNodeRelPos;
|
|
221
|
+
element.addEventListener('dragstart', e => {
|
|
222
|
+
// Push this to the end of the event cue
|
|
223
|
+
// Fixes bug where incorrect drag pos is returned if drag handle has position: absolute
|
|
224
|
+
// @ts-ignore
|
|
225
|
+
dragHandler(e, editor);
|
|
226
|
+
setTimeout(() => {
|
|
227
|
+
if (element) {
|
|
228
|
+
element.style.pointerEvents = 'none';
|
|
229
|
+
}
|
|
230
|
+
}, 0);
|
|
231
|
+
});
|
|
232
|
+
element.addEventListener('dragend', () => {
|
|
233
|
+
if (element) {
|
|
234
|
+
element.style.pointerEvents = 'auto';
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return new state.Plugin({
|
|
238
|
+
key: typeof pluginKey === 'string' ? new state.PluginKey(pluginKey) : pluginKey,
|
|
239
|
+
state: {
|
|
240
|
+
init() {
|
|
241
|
+
return { locked: false };
|
|
242
|
+
},
|
|
243
|
+
apply(tr, value, oldState, state) {
|
|
244
|
+
const isLocked = tr.getMeta('lockDragHandle');
|
|
245
|
+
const hideDragHandle = tr.getMeta('hideDragHandle');
|
|
246
|
+
if (isLocked !== undefined) {
|
|
247
|
+
locked = isLocked;
|
|
248
|
+
}
|
|
249
|
+
if (hideDragHandle && popup) {
|
|
250
|
+
popup.hide();
|
|
251
|
+
locked = false;
|
|
252
|
+
currentNode = null;
|
|
253
|
+
currentNodePos = -1;
|
|
254
|
+
onNodeChange === null || onNodeChange === void 0 ? void 0 : onNodeChange({ editor, node: null, pos: -1 });
|
|
255
|
+
return value;
|
|
256
|
+
}
|
|
257
|
+
// Something has changed and drag handler is visible…
|
|
258
|
+
if (tr.docChanged && currentNodePos !== -1 && element && popup) {
|
|
259
|
+
// Yjs replaces the entire document on every incoming change and needs a special handling.
|
|
260
|
+
// If change comes from another user …
|
|
261
|
+
if (extensionCollaboration.isChangeOrigin(tr)) {
|
|
262
|
+
// https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3
|
|
263
|
+
const newPos = getAbsolutePos(state, currentNodeRelPos);
|
|
264
|
+
if (newPos !== currentNodePos) {
|
|
265
|
+
// Set the new position for our current node.
|
|
266
|
+
currentNodePos = newPos;
|
|
267
|
+
// We will get the outer node with data and position in views update method.
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
// … otherwise use ProseMirror mapping to update the position.
|
|
272
|
+
const newPos = tr.mapping.map(currentNodePos);
|
|
273
|
+
if (newPos !== currentNodePos) {
|
|
274
|
+
// TODO: Remove
|
|
275
|
+
// console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);
|
|
276
|
+
// Set the new position for our current node.
|
|
277
|
+
currentNodePos = newPos;
|
|
278
|
+
// Memorize relative position to retrieve absolute position in case of collaboration
|
|
279
|
+
currentNodeRelPos = getRelativePos(state, currentNodePos);
|
|
280
|
+
// We will get the outer node with data and position in views update method.
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return value;
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
view: view => {
|
|
288
|
+
var _a;
|
|
289
|
+
element.draggable = true;
|
|
290
|
+
element.style.pointerEvents = 'auto';
|
|
291
|
+
(_a = editor.view.dom.parentElement) === null || _a === void 0 ? void 0 : _a.appendChild(wrapper);
|
|
292
|
+
wrapper.appendChild(element);
|
|
293
|
+
wrapper.style.pointerEvents = 'none';
|
|
294
|
+
wrapper.style.position = 'absolute';
|
|
295
|
+
wrapper.style.top = '0';
|
|
296
|
+
wrapper.style.left = '0';
|
|
297
|
+
return {
|
|
298
|
+
update(_, oldState) {
|
|
299
|
+
if (!element) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (!editor.isEditable) {
|
|
303
|
+
popup === null || popup === void 0 ? void 0 : popup.destroy();
|
|
304
|
+
popup = null;
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (!popup) {
|
|
308
|
+
popup = tippy__default.default(view.dom, {
|
|
309
|
+
getReferenceClientRect: null,
|
|
310
|
+
interactive: true,
|
|
311
|
+
trigger: 'manual',
|
|
312
|
+
placement: 'left-start',
|
|
313
|
+
hideOnClick: false,
|
|
314
|
+
duration: 100,
|
|
315
|
+
popperOptions: {
|
|
316
|
+
modifiers: [
|
|
317
|
+
{ name: 'flip', enabled: false },
|
|
318
|
+
{
|
|
319
|
+
name: 'preventOverflow',
|
|
320
|
+
options: {
|
|
321
|
+
rootBoundary: 'document',
|
|
322
|
+
mainAxis: false,
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
},
|
|
327
|
+
...tippyOptions,
|
|
328
|
+
appendTo: wrapper,
|
|
329
|
+
content: element,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
// Prevent element being draggend while being open.
|
|
333
|
+
if (locked) {
|
|
334
|
+
element.draggable = false;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
element.draggable = true;
|
|
338
|
+
}
|
|
339
|
+
// Do not close on updates (e.g. changing padding of a section or collaboration events)
|
|
340
|
+
// popup?.hide();
|
|
341
|
+
// Recalculate popup position if doc has changend and drag handler is visible.
|
|
342
|
+
if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
// Get domNode from (new) position.
|
|
346
|
+
let domNode = view.nodeDOM(currentNodePos);
|
|
347
|
+
// Since old element could have been wrapped, we need to find
|
|
348
|
+
// the outer node and take its position and node data.
|
|
349
|
+
domNode = getOuterDomNode(view, domNode);
|
|
350
|
+
// Skip if domNode is editor dom.
|
|
351
|
+
if (domNode === view.dom) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
// We only want `Element`.
|
|
355
|
+
if ((domNode === null || domNode === void 0 ? void 0 : domNode.nodeType) !== 1) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const domNodePos = view.posAtDOM(domNode, 0);
|
|
359
|
+
const outerNode = getOuterNode(editor.state.doc, domNodePos);
|
|
360
|
+
const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos); // TODO: needed?
|
|
361
|
+
currentNode = outerNode;
|
|
362
|
+
currentNodePos = outerNodePos;
|
|
363
|
+
// Memorize relative position to retrieve absolute position in case of collaboration
|
|
364
|
+
currentNodeRelPos = getRelativePos(view.state, currentNodePos);
|
|
365
|
+
// TODO: Remove
|
|
366
|
+
// console.log('View has updated: callback with new data and repositioning of popup …', {
|
|
367
|
+
// domNode,
|
|
368
|
+
// currentNodePos,
|
|
369
|
+
// currentNode,
|
|
370
|
+
// rect: (domNode as Element).getBoundingClientRect(),
|
|
371
|
+
// });
|
|
372
|
+
onNodeChange === null || onNodeChange === void 0 ? void 0 : onNodeChange({ editor, node: currentNode, pos: currentNodePos });
|
|
373
|
+
// Update Tippys getReferenceClientRect since domNode might have changed.
|
|
374
|
+
popup.setProps({
|
|
375
|
+
getReferenceClientRect: () => domNode.getBoundingClientRect(),
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
// TODO: Kills even on hot reload
|
|
379
|
+
destroy() {
|
|
380
|
+
popup === null || popup === void 0 ? void 0 : popup.destroy();
|
|
381
|
+
if (element) {
|
|
382
|
+
removeNode(wrapper);
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
},
|
|
387
|
+
props: {
|
|
388
|
+
handleDOMEvents: {
|
|
389
|
+
mouseleave(_view, e) {
|
|
390
|
+
// Do not hide open popup on mouseleave.
|
|
391
|
+
if (locked) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
// If e.target is not inside the wrapper, hide.
|
|
395
|
+
if (e.target && !wrapper.contains(e.relatedTarget)) {
|
|
396
|
+
popup === null || popup === void 0 ? void 0 : popup.hide();
|
|
397
|
+
currentNode = null;
|
|
398
|
+
currentNodePos = -1;
|
|
399
|
+
onNodeChange === null || onNodeChange === void 0 ? void 0 : onNodeChange({ editor, node: null, pos: -1 });
|
|
400
|
+
}
|
|
401
|
+
return false;
|
|
402
|
+
},
|
|
403
|
+
mousemove(view, e) {
|
|
404
|
+
// Do not continue if popup is not initialized or open.
|
|
405
|
+
if (!element || !popup || locked) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
const nodeData = findElementNextToCoords({
|
|
409
|
+
x: e.clientX,
|
|
410
|
+
y: e.clientY,
|
|
411
|
+
direction: 'right',
|
|
412
|
+
editor,
|
|
413
|
+
});
|
|
414
|
+
// Skip if there is no node next to coords
|
|
415
|
+
if (!nodeData.resultElement) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
let domNode = nodeData.resultElement;
|
|
419
|
+
domNode = getOuterDomNode(view, domNode);
|
|
420
|
+
// Skip if domNode is editor dom.
|
|
421
|
+
if (domNode === view.dom) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
// We only want `Element`.
|
|
425
|
+
if ((domNode === null || domNode === void 0 ? void 0 : domNode.nodeType) !== 1) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
const domNodePos = view.posAtDOM(domNode, 0);
|
|
429
|
+
const outerNode = getOuterNode(editor.state.doc, domNodePos);
|
|
430
|
+
if (outerNode !== currentNode) {
|
|
431
|
+
const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos);
|
|
432
|
+
currentNode = outerNode;
|
|
433
|
+
currentNodePos = outerNodePos;
|
|
434
|
+
// Memorize relative position to retrieve absolute position in case of collaboration
|
|
435
|
+
currentNodeRelPos = getRelativePos(view.state, currentNodePos);
|
|
436
|
+
// TODO: Remove
|
|
437
|
+
// console.log('Mousemove with changed node / node data …', {
|
|
438
|
+
// domNode,
|
|
439
|
+
// currentNodePos,
|
|
440
|
+
// currentNode,
|
|
441
|
+
// rect: (domNode as Element).getBoundingClientRect(),
|
|
442
|
+
// });
|
|
443
|
+
onNodeChange === null || onNodeChange === void 0 ? void 0 : onNodeChange({ editor, node: currentNode, pos: currentNodePos });
|
|
444
|
+
// Set nodes clientRect.
|
|
445
|
+
popup.setProps({
|
|
446
|
+
getReferenceClientRect: () => domNode.getBoundingClientRect(),
|
|
447
|
+
});
|
|
448
|
+
popup.show();
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
const DragHandle = core.Extension.create({
|
|
458
|
+
name: 'dragHandle',
|
|
459
|
+
addOptions() {
|
|
460
|
+
return {
|
|
461
|
+
render() {
|
|
462
|
+
const element = document.createElement('div');
|
|
463
|
+
element.classList.add('drag-handle');
|
|
464
|
+
return element;
|
|
465
|
+
},
|
|
466
|
+
tippyOptions: {},
|
|
467
|
+
locked: false,
|
|
468
|
+
onNodeChange: () => { return null; },
|
|
469
|
+
};
|
|
470
|
+
},
|
|
471
|
+
addCommands() {
|
|
472
|
+
return {
|
|
473
|
+
lockDragHandle: () => ({ editor }) => {
|
|
474
|
+
this.options.locked = true;
|
|
475
|
+
return editor.commands.setMeta('lockDragHandle', this.options.locked);
|
|
476
|
+
},
|
|
477
|
+
unlockDragHandle: () => ({ editor }) => {
|
|
478
|
+
this.options.locked = false;
|
|
479
|
+
return editor.commands.setMeta('lockDragHandle', this.options.locked);
|
|
480
|
+
},
|
|
481
|
+
toggleDragHandle: () => ({ editor }) => {
|
|
482
|
+
this.options.locked = !this.options.locked;
|
|
483
|
+
return editor.commands.setMeta('lockDragHandle', this.options.locked);
|
|
484
|
+
},
|
|
485
|
+
};
|
|
486
|
+
},
|
|
487
|
+
addProseMirrorPlugins() {
|
|
488
|
+
const element = this.options.render();
|
|
489
|
+
return [
|
|
490
|
+
DragHandlePlugin({
|
|
491
|
+
tippyOptions: this.options.tippyOptions,
|
|
492
|
+
element,
|
|
493
|
+
editor: this.editor,
|
|
494
|
+
onNodeChange: this.options.onNodeChange,
|
|
495
|
+
}),
|
|
496
|
+
];
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
exports.DragHandle = DragHandle;
|
|
501
|
+
exports.DragHandlePlugin = DragHandlePlugin;
|
|
502
|
+
exports.default = DragHandle;
|
|
503
|
+
exports.dragHandlePluginDefaultKey = dragHandlePluginDefaultKey;
|
|
504
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/helpers/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport { Node } from '@tiptap/pm/model'\nimport {\n EditorState, Plugin, PluginKey,\n Transaction,\n} from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\nimport tippy, { Instance, Props as TippyProps } from 'tippy.js'\nimport { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean;\n};\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping)\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string;\n editor: Editor;\n element: HTMLElement;\n onNodeChange?: (data: { editor: Editor; node: Node | null; pos: number }) => void;\n tippyOptions?: Partial<TippyProps>;\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(tr: Transaction, value: PluginState, oldState: EditorState, state: EditorState) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle","getSelectionRanges","NodeRangeSelection","ySyncPluginKey","absolutePositionToRelativePosition","relativePositionToAbsolutePosition","PluginKey","Plugin","isChangeOrigin","tippy","Extension"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,UAAU,CAAC,OAAgB,EAAA;IAClC,IAAI,KAAK,GAAG,EAAE;AACd,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAEvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AACxC,QAAA,KAAK,IAAI,CAAG,EAAA,KAAK,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;;AAG7D,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,YAAY,CAAC,IAAiB,EAAA;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAgB;AACtD,IAAA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