@payloadcms/richtext-lexical 3.0.0-beta.90 → 3.0.0-beta.91
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/dist/exports/client/Field-SUWHJ4HF.js +2 -0
- package/dist/exports/client/Field-SUWHJ4HF.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js +2 -0
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-NI6Z4GBD.js → chunk-OLSILJA6.js} +1 -1
- package/dist/exports/client/{chunk-NI6Z4GBD.js.map → chunk-OLSILJA6.js.map} +1 -1
- package/dist/exports/client/{chunk-G5DTIOPI.js → chunk-TD7O23AB.js} +2 -2
- package/dist/exports/client/{chunk-G5DTIOPI.js.map → chunk-TD7O23AB.js.map} +2 -2
- package/dist/exports/client/{chunk-LGUXX2QH.js → chunk-UJDWBQ2K.js} +2 -2
- package/dist/exports/client/{chunk-LGUXX2QH.js.map → chunk-UJDWBQ2K.js.map} +2 -2
- package/dist/exports/client/{chunk-OKMIHD2R.js → chunk-YL453UOS.js} +2 -2
- package/dist/exports/client/chunk-YSI2QILQ.js +2 -0
- package/dist/exports/client/{chunk-TO2W7Q2G.js.map → chunk-YSI2QILQ.js.map} +2 -2
- package/dist/exports/client/component-2YLEVOFH.js +2 -0
- package/dist/exports/client/component-2YLEVOFH.js.map +7 -0
- package/dist/exports/client/{component-LCAAX56T.js → component-7RAP75FW.js} +2 -2
- package/dist/exports/client/{componentInline-72VZAAHP.js → componentInline-YSHGRL2J.js} +2 -2
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/debug/testRecorder/client/plugin/index.js +187 -363
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +234 -470
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -16
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +59 -123
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +5 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +8 -5
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +6 -4
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +53 -94
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +3 -0
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +9 -7
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -109
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +96 -135
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +114 -139
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +7 -25
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +4 -6
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/ui/icons/Caret/index.svg +2 -2
- package/dist/lexical/utils/setFloatingElemPosition.js +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +16 -1
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/package.json +13 -13
- package/dist/exports/client/Field-63NGLPJB.js +0 -2
- package/dist/exports/client/Field-63NGLPJB.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-3QWBV4GT.js +0 -2
- package/dist/exports/client/RelationshipComponent-3QWBV4GT.js.map +0 -7
- package/dist/exports/client/chunk-TO2W7Q2G.js +0 -2
- package/dist/exports/client/component-3OFD6Q4Z.js +0 -2
- package/dist/exports/client/component-3OFD6Q4Z.js.map +0 -7
- /package/dist/exports/client/{chunk-OKMIHD2R.js.map → chunk-YL453UOS.js.map} +0 -0
- /package/dist/exports/client/{component-LCAAX56T.js.map → component-7RAP75FW.js.map} +0 -0
- /package/dist/exports/client/{componentInline-72VZAAHP.js.map → componentInline-YSHGRL2J.js.map} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
5
|
import { eventFiles } from '@lexical/rich-text';
|
|
@@ -53,7 +52,6 @@ function hideTargetLine(targetLineElem, lastTargetBlockElem) {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
56
|
-
const $ = _c(19);
|
|
57
55
|
const scrollerElem = anchorElem.parentElement;
|
|
58
56
|
const menuRef = useRef(null);
|
|
59
57
|
const targetLineRef = useRef(null);
|
|
@@ -65,99 +63,65 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
65
63
|
editorConfig
|
|
66
64
|
} = useEditorConfigContext();
|
|
67
65
|
const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const topLevelNodeKeys = getTopLevelNodeKeys(editor);
|
|
86
|
-
const {
|
|
87
|
-
blockElem: _draggableBlockElem,
|
|
88
|
-
foundAtIndex,
|
|
89
|
-
isFoundNodeEmptyParagraph
|
|
90
|
-
} = getNodeCloseToPoint({
|
|
91
|
-
anchorElem,
|
|
92
|
-
cache_threshold: 0,
|
|
93
|
-
editor,
|
|
94
|
-
horizontalOffset: -distanceFromScrollerElem,
|
|
95
|
-
point: new Point(event.x, event.y),
|
|
96
|
-
startIndex: getCurrentIndex(topLevelNodeKeys.length),
|
|
97
|
-
useEdgeAsDefault: false,
|
|
98
|
-
verbose: false
|
|
99
|
-
});
|
|
100
|
-
prevIndex = foundAtIndex;
|
|
101
|
-
if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (draggableBlockElem !== _draggableBlockElem) {
|
|
105
|
-
setDraggableBlockElem(_draggableBlockElem);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
document?.addEventListener("mousemove", onDocumentMouseMove);
|
|
109
|
-
return () => {
|
|
110
|
-
document?.removeEventListener("mousemove", onDocumentMouseMove);
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
t1 = [scrollerElem, anchorElem, editor, draggableBlockElem];
|
|
114
|
-
$[0] = scrollerElem;
|
|
115
|
-
$[1] = editor;
|
|
116
|
-
$[2] = anchorElem;
|
|
117
|
-
$[3] = draggableBlockElem;
|
|
118
|
-
$[4] = t0;
|
|
119
|
-
$[5] = t1;
|
|
120
|
-
} else {
|
|
121
|
-
t0 = $[4];
|
|
122
|
-
t1 = $[5];
|
|
123
|
-
}
|
|
124
|
-
useEffect(t0, t1);
|
|
125
|
-
let t2;
|
|
126
|
-
let t3;
|
|
127
|
-
if ($[6] !== draggableBlockElem || $[7] !== anchorElem || $[8] !== blockHandleHorizontalOffset) {
|
|
128
|
-
t2 = () => {
|
|
129
|
-
if (menuRef.current) {
|
|
130
|
-
setHandlePosition(draggableBlockElem, menuRef.current, anchorElem, blockHandleHorizontalOffset);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
/**
|
|
68
|
+
* Handles positioning of the drag handle
|
|
69
|
+
*/
|
|
70
|
+
function onDocumentMouseMove(event) {
|
|
71
|
+
const target = event.target;
|
|
72
|
+
if (!isHTMLElement(target)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const distanceFromScrollerElem = calculateDistanceFromScrollerElem(scrollerElem, event.pageX, event.pageY, target);
|
|
76
|
+
if (distanceFromScrollerElem === -1) {
|
|
77
|
+
setDraggableBlockElem(null);
|
|
78
|
+
return;
|
|
131
79
|
}
|
|
80
|
+
if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const topLevelNodeKeys = getTopLevelNodeKeys(editor);
|
|
84
|
+
const {
|
|
85
|
+
blockElem: _draggableBlockElem,
|
|
86
|
+
foundAtIndex,
|
|
87
|
+
isFoundNodeEmptyParagraph
|
|
88
|
+
} = getNodeCloseToPoint({
|
|
89
|
+
anchorElem,
|
|
90
|
+
cache_threshold: 0,
|
|
91
|
+
editor,
|
|
92
|
+
horizontalOffset: -distanceFromScrollerElem,
|
|
93
|
+
point: new Point(event.x, event.y),
|
|
94
|
+
startIndex: getCurrentIndex(topLevelNodeKeys.length),
|
|
95
|
+
useEdgeAsDefault: false,
|
|
96
|
+
verbose: false
|
|
97
|
+
});
|
|
98
|
+
prevIndex = foundAtIndex;
|
|
99
|
+
//if (DEBUG && _draggableBlockElem) {
|
|
100
|
+
//targetBlockElem.style.border = '3px solid red'
|
|
101
|
+
// highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)
|
|
102
|
+
//}
|
|
103
|
+
if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (draggableBlockElem !== _draggableBlockElem) {
|
|
107
|
+
setDraggableBlockElem(_draggableBlockElem);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Since the draggableBlockElem is outside the actual editor, we need to listen to the document
|
|
111
|
+
// to be able to detect when the mouse is outside the editor and respect a buffer around
|
|
112
|
+
// the scrollerElem to avoid the draggableBlockElem disappearing too early.
|
|
113
|
+
document?.addEventListener('mousemove', onDocumentMouseMove);
|
|
114
|
+
return () => {
|
|
115
|
+
document?.removeEventListener('mousemove', onDocumentMouseMove);
|
|
132
116
|
};
|
|
133
|
-
|
|
134
|
-
$[6] = draggableBlockElem;
|
|
135
|
-
$[7] = anchorElem;
|
|
136
|
-
$[8] = blockHandleHorizontalOffset;
|
|
137
|
-
$[9] = t2;
|
|
138
|
-
$[10] = t3;
|
|
139
|
-
} else {
|
|
140
|
-
t2 = $[9];
|
|
141
|
-
t3 = $[10];
|
|
142
|
-
}
|
|
143
|
-
useEffect(t2, t3);
|
|
144
|
-
const t4 = editorConfig?.admin?.hideGutter;
|
|
145
|
-
let t5;
|
|
146
|
-
if ($[11] !== scrollerElem || $[12] !== blockHandleHorizontalOffset || $[13] !== anchorElem || $[14] !== editor || $[15] !== lastTargetBlock || $[16] !== draggableBlockElem || $[17] !== t4) {
|
|
147
|
-
t5 = [scrollerElem, blockHandleHorizontalOffset, anchorElem, editor, lastTargetBlock, draggableBlockElem, t4];
|
|
148
|
-
$[11] = scrollerElem;
|
|
149
|
-
$[12] = blockHandleHorizontalOffset;
|
|
150
|
-
$[13] = anchorElem;
|
|
151
|
-
$[14] = editor;
|
|
152
|
-
$[15] = lastTargetBlock;
|
|
153
|
-
$[16] = draggableBlockElem;
|
|
154
|
-
$[17] = t4;
|
|
155
|
-
$[18] = t5;
|
|
156
|
-
} else {
|
|
157
|
-
t5 = $[18];
|
|
158
|
-
}
|
|
117
|
+
}, [scrollerElem, anchorElem, editor, draggableBlockElem]);
|
|
159
118
|
useEffect(() => {
|
|
160
|
-
|
|
119
|
+
if (menuRef.current) {
|
|
120
|
+
setHandlePosition(draggableBlockElem, menuRef.current, anchorElem, blockHandleHorizontalOffset);
|
|
121
|
+
}
|
|
122
|
+
}, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset]);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
function onDragover(event_0) {
|
|
161
125
|
if (!isDraggingBlockRef.current) {
|
|
162
126
|
return false;
|
|
163
127
|
}
|
|
@@ -190,6 +154,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
190
154
|
});
|
|
191
155
|
prevIndex = foundAtIndex_0;
|
|
192
156
|
const targetLineElem = targetLineRef.current;
|
|
157
|
+
// targetBlockElem === null shouldn't happen
|
|
193
158
|
if (targetBlockElem === null || targetLineElem === null) {
|
|
194
159
|
return false;
|
|
195
160
|
}
|
|
@@ -197,7 +162,10 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
197
162
|
const {
|
|
198
163
|
isBelow,
|
|
199
164
|
willStayInSamePosition
|
|
200
|
-
} = setTargetLine(editorConfig?.admin?.hideGutter ?
|
|
165
|
+
} = setTargetLine(editorConfig?.admin?.hideGutter ? '0px' : '3rem', blockHandleHorizontalOffset + (editorConfig?.admin?.hideGutter ? menuRef?.current?.getBoundingClientRect()?.width ?? 0 : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)), targetLineElem, targetBlockElem, lastTargetBlock, pageY, anchorElem, event_0, debugHighlightRef, isFoundNodeEmptyParagraph_0);
|
|
166
|
+
// Prevent default event to be able to trigger onDrop events
|
|
167
|
+
// Calling preventDefault() adds the green plus icon to the cursor,
|
|
168
|
+
// indicating that the drop is allowed.
|
|
201
169
|
event_0.preventDefault();
|
|
202
170
|
if (!willStayInSamePosition) {
|
|
203
171
|
setLastTargetBlock({
|
|
@@ -215,8 +183,8 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
215
183
|
});
|
|
216
184
|
}
|
|
217
185
|
return true;
|
|
218
|
-
}
|
|
219
|
-
|
|
186
|
+
}
|
|
187
|
+
function onDrop(event_1) {
|
|
220
188
|
if (!isDraggingBlockRef.current) {
|
|
221
189
|
return false;
|
|
222
190
|
}
|
|
@@ -229,7 +197,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
229
197
|
pageY: pageY_0,
|
|
230
198
|
target: target_1
|
|
231
199
|
} = event_1;
|
|
232
|
-
const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) ||
|
|
200
|
+
const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || '';
|
|
233
201
|
editor.update(() => {
|
|
234
202
|
const draggedNode = $getNodeByKey(dragData);
|
|
235
203
|
if (!draggedNode) {
|
|
@@ -268,68 +236,77 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
268
236
|
const isBelow_0 = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY;
|
|
269
237
|
if (!isFoundNodeEmptyParagraph_1) {
|
|
270
238
|
if (isBelow_0) {
|
|
239
|
+
// below targetBlockElem
|
|
271
240
|
targetNode.insertAfter(draggedNode);
|
|
272
241
|
} else {
|
|
242
|
+
// above targetBlockElem
|
|
273
243
|
targetNode.insertBefore(draggedNode);
|
|
274
244
|
}
|
|
275
245
|
} else {
|
|
246
|
+
//
|
|
276
247
|
targetNode.insertBefore(draggedNode);
|
|
277
248
|
targetNode.remove();
|
|
278
249
|
}
|
|
250
|
+
/*
|
|
251
|
+
if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {
|
|
252
|
+
targetNode.insertAfter(draggedNode)
|
|
253
|
+
} else {
|
|
254
|
+
targetNode.insertBefore(draggedNode)
|
|
255
|
+
}*/
|
|
279
256
|
if (draggableBlockElem !== null) {
|
|
280
257
|
setDraggableBlockElem(null);
|
|
281
258
|
}
|
|
282
|
-
|
|
259
|
+
// find all previous elements with lexical-block-highlighter class and remove them
|
|
260
|
+
const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter');
|
|
283
261
|
allPrevHighlighters.forEach(highlighter => {
|
|
284
262
|
highlighter.remove();
|
|
285
263
|
});
|
|
286
264
|
const newInsertedElem = editor.getElementByKey(draggedNode.getKey());
|
|
287
265
|
setTimeout(() => {
|
|
266
|
+
// add new temp html element to newInsertedElem with the same height and width and the class block-selected
|
|
267
|
+
// to highlight the new inserted element
|
|
288
268
|
const newInsertedElemRect = newInsertedElem.getBoundingClientRect();
|
|
289
|
-
const highlightElem = document.createElement(
|
|
290
|
-
highlightElem.className =
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
highlightElem.style.
|
|
297
|
-
highlightElem.style.
|
|
298
|
-
highlightElem.style.pointerEvents = "none";
|
|
299
|
-
highlightElem.style.boxSizing = "border-box";
|
|
300
|
-
highlightElem.style.borderRadius = "4px";
|
|
301
|
-
highlightElem.style.position = "absolute";
|
|
269
|
+
const highlightElem = document.createElement('div');
|
|
270
|
+
highlightElem.className = 'lexical-block-highlighter';
|
|
271
|
+
highlightElem.style.backgroundColor = 'var(--theme-elevation-1000';
|
|
272
|
+
highlightElem.style.transition = 'opacity 0.5s ease-in-out';
|
|
273
|
+
highlightElem.style.zIndex = '1';
|
|
274
|
+
highlightElem.style.pointerEvents = 'none';
|
|
275
|
+
highlightElem.style.boxSizing = 'border-box';
|
|
276
|
+
highlightElem.style.borderRadius = '4px';
|
|
277
|
+
highlightElem.style.position = 'absolute';
|
|
302
278
|
document.body.appendChild(highlightElem);
|
|
303
|
-
highlightElem.style.opacity =
|
|
279
|
+
highlightElem.style.opacity = '0.1';
|
|
304
280
|
highlightElem.style.height = `${newInsertedElemRect.height + 8}px`;
|
|
305
281
|
highlightElem.style.width = `${newInsertedElemRect.width + 8}px`;
|
|
306
282
|
highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`;
|
|
307
283
|
highlightElem.style.left = `${newInsertedElemRect.left - 4}px`;
|
|
308
284
|
setTimeout(() => {
|
|
309
|
-
highlightElem.style.opacity =
|
|
285
|
+
highlightElem.style.opacity = '0';
|
|
310
286
|
setTimeout(() => {
|
|
311
287
|
highlightElem.remove();
|
|
312
|
-
},
|
|
313
|
-
},
|
|
288
|
+
}, 500);
|
|
289
|
+
}, 1000);
|
|
314
290
|
}, 120);
|
|
315
291
|
});
|
|
316
292
|
return true;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
document.addEventListener(
|
|
293
|
+
}
|
|
294
|
+
// register onDragover event listeners:
|
|
295
|
+
document.addEventListener('dragover', onDragover);
|
|
296
|
+
// register onDrop event listeners:
|
|
297
|
+
document.addEventListener('drop', onDrop);
|
|
320
298
|
return () => {
|
|
321
|
-
document.removeEventListener(
|
|
322
|
-
document.removeEventListener(
|
|
299
|
+
document.removeEventListener('dragover', onDragover);
|
|
300
|
+
document.removeEventListener('drop', onDrop);
|
|
323
301
|
};
|
|
324
|
-
},
|
|
325
|
-
|
|
302
|
+
}, [scrollerElem, blockHandleHorizontalOffset, anchorElem, editor, lastTargetBlock, draggableBlockElem, editorConfig?.admin?.hideGutter]);
|
|
303
|
+
function onDragStart(event_2) {
|
|
326
304
|
const dataTransfer_0 = event_2.dataTransfer;
|
|
327
305
|
if (!dataTransfer_0 || !draggableBlockElem) {
|
|
328
306
|
return;
|
|
329
307
|
}
|
|
330
308
|
setDragImage(dataTransfer_0, draggableBlockElem);
|
|
331
|
-
let nodeKey;
|
|
332
|
-
nodeKey = "";
|
|
309
|
+
let nodeKey = '';
|
|
333
310
|
editor.update(() => {
|
|
334
311
|
const node = $getNearestNodeFromDOMNode(draggableBlockElem);
|
|
335
312
|
if (node) {
|
|
@@ -338,35 +315,33 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
|
|
|
338
315
|
});
|
|
339
316
|
isDraggingBlockRef.current = true;
|
|
340
317
|
dataTransfer_0.setData(DRAG_DATA_FORMAT, nodeKey);
|
|
341
|
-
}
|
|
342
|
-
|
|
318
|
+
}
|
|
319
|
+
function onDragEnd() {
|
|
343
320
|
isDraggingBlockRef.current = false;
|
|
344
321
|
hideTargetLine(targetLineRef.current, lastTargetBlock?.elem);
|
|
345
|
-
}
|
|
346
|
-
return createPortal(_jsxs(React.Fragment, {
|
|
347
|
-
children: [_jsx("div", {
|
|
322
|
+
}
|
|
323
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/_jsxs(React.Fragment, {
|
|
324
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
348
325
|
className: "icon draggable-block-menu",
|
|
349
326
|
draggable: true,
|
|
350
|
-
onDragEnd,
|
|
351
|
-
onDragStart,
|
|
327
|
+
onDragEnd: onDragEnd,
|
|
328
|
+
onDragStart: onDragStart,
|
|
352
329
|
ref: menuRef,
|
|
353
|
-
children: _jsx("div", {
|
|
354
|
-
className: isEditable ?
|
|
330
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
331
|
+
className: isEditable ? 'icon' : ''
|
|
355
332
|
})
|
|
356
|
-
}), _jsx("div", {
|
|
333
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
357
334
|
className: "draggable-block-target-line",
|
|
358
335
|
ref: targetLineRef
|
|
359
|
-
}), _jsx("div", {
|
|
336
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
360
337
|
className: "debug-highlight",
|
|
361
338
|
ref: debugHighlightRef
|
|
362
339
|
})]
|
|
363
340
|
}), anchorElem);
|
|
364
341
|
}
|
|
365
|
-
export function DraggableBlockPlugin(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
} = t0;
|
|
369
|
-
const anchorElem = t1 === undefined ? document.body : t1;
|
|
342
|
+
export function DraggableBlockPlugin({
|
|
343
|
+
anchorElem = document.body
|
|
344
|
+
}) {
|
|
370
345
|
const [editor] = useLexicalComposerContext();
|
|
371
346
|
return useDraggableBlockMenu(editor, anchorElem, editor._editable);
|
|
372
347
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","eventFiles","$getNearestNodeFromDOMNode","$getNodeByKey","React","useEffect","useRef","useState","createPortal","useEditorConfigContext","isHTMLElement","Point","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","getBoundingClientRectWithoutTransform","setTargetLine","DRAGGABLE_BLOCK_MENU_CLASSNAME","DRAG_DATA_FORMAT","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","setDragImage","dataTransfer","draggableBlockElem","transform","style","setTimeout","hideTargetLine","targetLineElem","lastTargetBlockElem","opacity","marginBottom","marginTop","useDraggableBlockMenu","editor","anchorElem","isEditable","$","scrollerElem","parentElement","menuRef","targetLineRef","debugHighlightRef","isDraggingBlockRef","setDraggableBlockElem","lastTargetBlock","setLastTargetBlock","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","t0","t1","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_draggableBlockElem","foundAtIndex","isFoundNodeEmptyParagraph","cache_threshold","horizontalOffset","point","x","y","startIndex","length","useEdgeAsDefault","verbose","document","addEventListener","removeEventListener","t2","t3","current","t4","t5","onDragover","event_0","isFileTransfer","target_0","distanceFromScrollerElem_0","topLevelNodeKeys_0","targetBlockElem","foundAtIndex_0","isFoundNodeEmptyParagraph_0","fuzzy","isBelow","willStayInSamePosition","getBoundingClientRect","width","preventDefault","boundingBox","elem","onDrop","event_1","isFileTransfer_0","pageY_0","target_1","dragData","getData","update","draggedNode","distanceFromScrollerElem_1","targetBlockElem_0","isFoundNodeEmptyParagraph_1","targetNode","height","targetBlockElemHeight","top","targetBlockElemTop","mouseY","isBelow_0","window","scrollY","insertAfter","insertBefore","remove","allPrevHighlighters","querySelectorAll","forEach","highlighter","newInsertedElem","getElementByKey","getKey","newInsertedElemRect","highlightElem","createElement","className","documentElement","getAttribute","backgroundColor","transition","zIndex","pointerEvents","boxSizing","borderRadius","position","body","appendChild","left","onDragStart","event_2","dataTransfer_0","nodeKey","node","setData","onDragEnd","_jsxs","Fragment","children","_jsx","draggable","ref","DraggableBlockPlugin","undefined","_editable"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlock.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlock, setLastTargetBlock] = useState<{\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n }>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n if (distanceFromScrollerElem === -1) {\n setDraggableBlockElem(null)\n return\n }\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n verbose: false,\n })\n\n prevIndex = foundAtIndex\n\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n draggableBlockElem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n const { isBelow, willStayInSamePosition } = setTargetLine(\n editorConfig?.admin?.hideGutter ? '0px' : '3rem',\n blockHandleHorizontalOffset +\n (editorConfig?.admin?.hideGutter\n ? menuRef?.current?.getBoundingClientRect()?.width ?? 0\n : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)),\n targetLineElem,\n targetBlockElem,\n lastTargetBlock,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n\n if (!willStayInSamePosition) {\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow,\n })\n }\n } else {\n hideTargetLine(targetLineElem, lastTargetBlock?.elem)\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow: false,\n })\n }\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n\n // find all previous elements with lexical-block-highlighter class and remove them\n const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter')\n allPrevHighlighters.forEach((highlighter) => {\n highlighter.remove()\n })\n\n const newInsertedElem = editor.getElementByKey(draggedNode.getKey())\n setTimeout(() => {\n // add new temp html element to newInsertedElem with the same height and width and the class block-selected\n // to highlight the new inserted element\n const newInsertedElemRect = newInsertedElem.getBoundingClientRect()\n\n const highlightElem = document.createElement('div')\n highlightElem.className = 'lexical-block-highlighter'\n\n // if html data-theme is dark, set the highlighter color to white\n if (document.documentElement.getAttribute('data-theme') === 'dark') {\n highlightElem.style.backgroundColor = 'white'\n } else {\n highlightElem.style.backgroundColor = 'black'\n }\n\n highlightElem.style.transition = 'opacity 0.1s ease-in-out'\n highlightElem.style.zIndex = '1'\n highlightElem.style.pointerEvents = 'none'\n highlightElem.style.boxSizing = 'border-box'\n highlightElem.style.borderRadius = '4px'\n highlightElem.style.position = 'absolute'\n document.body.appendChild(highlightElem)\n\n highlightElem.style.opacity = '0.1'\n\n highlightElem.style.height = `${newInsertedElemRect.height + 8}px`\n highlightElem.style.width = `${newInsertedElemRect.width + 8}px`\n highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`\n highlightElem.style.left = `${newInsertedElemRect.left - 4}px`\n\n setTimeout(() => {\n highlightElem.style.opacity = '0'\n setTimeout(() => {\n highlightElem.remove()\n }, 1000)\n }, 3000)\n }, 120)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n scrollerElem,\n blockHandleHorizontalOffset,\n anchorElem,\n editor,\n lastTargetBlock,\n draggableBlockElem,\n editorConfig?.admin?.hideGutter,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n hideTargetLine(targetLineRef.current, lastTargetBlock?.elem)\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,EAAEC,aAAa,QAAQ;AAC1D,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,iCAAiC,QAAQ;A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CAAA,CAAUC,IAAA,CAAArB,MAAA,CAAW;MAArB;IAAA,CAEJ;IACArF,kBAAA,CAAAmC,OAAA;IACAxD,cAAA,CAAAgI,OAAA,CAAAxI,gBAAA,EAAuCsI,OAAA;EAAA;EAGzC,MAAAG,SAAA,YAAAA,UAAA;IACE5G,kBAAA,CAAAmC,OAAA;IACAnD,cAAA,CAAec,aAAA,CAAAqC,OAAA,EAAuBjC,eAAA,EAAAoD,IAAiB;EAAA;EACzD,OAEO/F,YAAA,CACLsJ,KAAA,CAAA1J,KAAA,CAAA2J,QAAA;IAAAC,QAAA,GACEC,IAAA,CAAC;MAAAvB,SAAA,EACW;MAAAwB,SAAA;MAAAL,SAAA;MAAAN,WAAA;MAAAY,GAAA,EAILrH,OAAA;MAAAkH,QAAA,EAELC,IAAA,CAAC;QAAAvB,SAAA,EAAehG,UAAA,GAAa,SAAS;MAAA,C;QAExCuH,IAAA,CAAC;MAAAvB,SAAA,EAAc;MAAAyB,GAAA,EAAmCpH;IAAA,C,GAClDkH,IAAA,CAAC;MAAAvB,SAAA,EAAc;MAAAyB,GAAA,EAAuBnH;IAAA,C;MAExCP,UAAA;AAAA;AAIJ,OAAO,SAAA2H,qBAAA3G,EAAA;EAA8B;IAAAhB,UAAA,EAAAiB;EAAA,IAAAD,EAIpC;EAHC,MAAAhB,UAAA,GAAAiB,EAA0B,KAAA2G,SAAA,GAAAtF,QAAA,CAAAqE,IAAA,GAA1B1F,EAA0B;EAI1B,OAAAlB,MAAA,IAAiBxC,yBAAA;EAAA,OACVuC,qBAAA,CAAsBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAA8H,SAAgB;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","eventFiles","$getNearestNodeFromDOMNode","$getNodeByKey","React","useEffect","useRef","useState","createPortal","useEditorConfigContext","isHTMLElement","Point","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","getBoundingClientRectWithoutTransform","setTargetLine","DRAGGABLE_BLOCK_MENU_CLASSNAME","DRAG_DATA_FORMAT","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","setDragImage","dataTransfer","draggableBlockElem","transform","style","setTimeout","hideTargetLine","targetLineElem","lastTargetBlockElem","opacity","marginBottom","marginTop","useDraggableBlockMenu","editor","anchorElem","isEditable","scrollerElem","parentElement","menuRef","targetLineRef","debugHighlightRef","isDraggingBlockRef","setDraggableBlockElem","lastTargetBlock","setLastTargetBlock","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_draggableBlockElem","foundAtIndex","isFoundNodeEmptyParagraph","cache_threshold","horizontalOffset","point","x","y","startIndex","length","useEdgeAsDefault","verbose","document","addEventListener","removeEventListener","current","onDragover","isFileTransfer","targetBlockElem","fuzzy","isBelow","willStayInSamePosition","getBoundingClientRect","width","preventDefault","boundingBox","elem","onDrop","dragData","getData","update","draggedNode","targetNode","height","targetBlockElemHeight","top","targetBlockElemTop","mouseY","window","scrollY","insertAfter","insertBefore","remove","allPrevHighlighters","querySelectorAll","forEach","highlighter","newInsertedElem","getElementByKey","getKey","newInsertedElemRect","highlightElem","createElement","className","backgroundColor","transition","zIndex","pointerEvents","boxSizing","borderRadius","position","body","appendChild","left","onDragStart","nodeKey","node","setData","onDragEnd","_jsxs","Fragment","_jsx","draggable","ref","DraggableBlockPlugin","_editable"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlock.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlock, setLastTargetBlock] = useState<{\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n }>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n if (distanceFromScrollerElem === -1) {\n setDraggableBlockElem(null)\n return\n }\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n verbose: false,\n })\n\n prevIndex = foundAtIndex\n\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n draggableBlockElem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n const { isBelow, willStayInSamePosition } = setTargetLine(\n editorConfig?.admin?.hideGutter ? '0px' : '3rem',\n blockHandleHorizontalOffset +\n (editorConfig?.admin?.hideGutter\n ? menuRef?.current?.getBoundingClientRect()?.width ?? 0\n : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)),\n targetLineElem,\n targetBlockElem,\n lastTargetBlock,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n\n if (!willStayInSamePosition) {\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow,\n })\n }\n } else {\n hideTargetLine(targetLineElem, lastTargetBlock?.elem)\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow: false,\n })\n }\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n\n // find all previous elements with lexical-block-highlighter class and remove them\n const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter')\n allPrevHighlighters.forEach((highlighter) => {\n highlighter.remove()\n })\n\n const newInsertedElem = editor.getElementByKey(draggedNode.getKey())\n setTimeout(() => {\n // add new temp html element to newInsertedElem with the same height and width and the class block-selected\n // to highlight the new inserted element\n const newInsertedElemRect = newInsertedElem.getBoundingClientRect()\n\n const highlightElem = document.createElement('div')\n highlightElem.className = 'lexical-block-highlighter'\n\n highlightElem.style.backgroundColor = 'var(--theme-elevation-1000'\n highlightElem.style.transition = 'opacity 0.5s ease-in-out'\n highlightElem.style.zIndex = '1'\n highlightElem.style.pointerEvents = 'none'\n highlightElem.style.boxSizing = 'border-box'\n highlightElem.style.borderRadius = '4px'\n highlightElem.style.position = 'absolute'\n document.body.appendChild(highlightElem)\n\n highlightElem.style.opacity = '0.1'\n\n highlightElem.style.height = `${newInsertedElemRect.height + 8}px`\n highlightElem.style.width = `${newInsertedElemRect.width + 8}px`\n highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`\n highlightElem.style.left = `${newInsertedElemRect.left - 4}px`\n\n setTimeout(() => {\n highlightElem.style.opacity = '0'\n setTimeout(() => {\n highlightElem.remove()\n }, 500)\n }, 1000)\n }, 120)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n scrollerElem,\n blockHandleHorizontalOffset,\n anchorElem,\n editor,\n lastTargetBlock,\n draggableBlockElem,\n editorConfig?.admin?.hideGutter,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n hideTargetLine(targetLineRef.current, lastTargetBlock?.elem)\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,EAAEC,aAAa,QAAQ;AAC1D,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qCAAqC,QAAQ;AAEtD,SAASC,aAAa,QAAQ;AAE9B,MAAMC,8BAAA,GAAiC;AACvC,MAAMC,gBAAA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A,CAAKjB,MAAM;MACvB;IACF;IACAjE,kBAAA,CAAmB+B,OAAO,GAAG;IAC7BnD,cAAA,CAAauG,OAAO,CAAC/G,gBAAA,EAAkB6G,OAAA;EACzC;EAEA,SAASG,UAAA;IACPpF,kBAAA,CAAmB+B,OAAO,GAAG;IAC7B9C,cAAA,CAAea,aAAA,CAAciC,OAAO,EAAE7B,eAAA,EAAiBwC,IAAA;EACzD;EAEA,oBAAOlF,YAAA,eACL6H,KAAA,CAACjI,KAAA,CAAMkI,QAAQ;4BACbC,IAAA,CAAC;MACClB,SAAA,EAAU;MACVmB,SAAS;MACTJ,SAAA,EAAWA,SAAA;MACXJ,WAAA,EAAaA,WAAA;MACbS,GAAA,EAAK5F,OAAA;gBAEL,aAAA0F,IAAA,CAAC;QAAIlB,SAAA,EAAW3E,UAAA,GAAa,SAAS;;qBAExC6F,IAAA,CAAC;MAAIlB,SAAA,EAAU;MAA8BoB,GAAA,EAAK3F;qBAClDyF,IAAA,CAAC;MAAIlB,SAAA,EAAU;MAAkBoB,GAAA,EAAK1F;;MAExCN,UAAA;AAEJ;AAEA,OAAO,SAASiG,qBAAqB;EACnCjG,UAAA,GAAamC,QAAA,CAASiD;AAAI,CAG3B;EACC,MAAM,CAACrF,MAAA,CAAO,GAAGxC,yBAAA;EACjB,OAAOuC,qBAAA,CAAsBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAOmG,SAAS;AACnE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTargetLine.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"names":[],"mappings":"AASA,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,WAAW,EAC5B,eAAe,EAAE;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;CACjB,EACD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,EACzD,yBAAyB,GAAE,OAAe;;;
|
|
1
|
+
{"version":3,"file":"setTargetLine.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"names":[],"mappings":"AASA,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,WAAW,EAC5B,eAAe,EAAE;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;CACjB,EACD,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,EACzD,yBAAyB,GAAE,OAAe;;;EA2H3C"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { getCollapsedMargins } from '../utils/getCollapsedMargins.js';
|
|
4
|
-
|
|
5
|
-
const TARGET_LINE_HALF_HEIGHT = 25;
|
|
4
|
+
const TARGET_LINE_HALF_HEIGHT = 0;
|
|
6
5
|
const TEXT_BOX_HORIZONTAL_PADDING = -24;
|
|
7
6
|
const DEBUG = false;
|
|
8
7
|
let animationTimer = 0;
|
|
@@ -83,29 +82,12 @@ export function setTargetLine(offsetWidth, offsetLeft, targetLineElem, targetBlo
|
|
|
83
82
|
const top = lineTop - anchorTop + targetElemTranslate2;
|
|
84
83
|
const left = TEXT_BOX_HORIZONTAL_PADDING - offsetLeft;
|
|
85
84
|
targetLineElem.style.width = `calc(${anchorWidth}px - ${offsetWidth})`;
|
|
86
|
-
targetLineElem.style.opacity = '.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const buffer = 12 // creates more spacing/padding so target line is not directly next to the targetBlockElem
|
|
93
|
-
;
|
|
94
|
-
if (!isFoundNodeEmptyParagraph) {
|
|
95
|
-
if (isBelow) {
|
|
96
|
-
targetBlockElem.style.marginBottom = TARGET_LINE_HALF_HEIGHT * 2 + buffer + 'px';
|
|
97
|
-
targetLineElem.style.transform = `translate(${left}px, calc(${top}px - ${'0px'}))`;
|
|
98
|
-
} else {
|
|
99
|
-
targetBlockElem.style.marginTop = TARGET_LINE_HALF_HEIGHT * 2 + buffer + 'px';
|
|
100
|
-
targetLineElem.style.transform = `translate(${left}px, calc(${top - TARGET_LINE_HALF_HEIGHT * 2}px - ${'0px'}))`;
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
targetLineElem.style.transform = `translate(${left}px, ${top - TARGET_LINE_HALF_HEIGHT}px)`;
|
|
104
|
-
}
|
|
105
|
-
if (DEBUG) {
|
|
106
|
-
//targetBlockElem.style.border = '3px solid red'
|
|
107
|
-
highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem);
|
|
108
|
-
}
|
|
85
|
+
targetLineElem.style.opacity = '.8';
|
|
86
|
+
// if (DEBUG) {
|
|
87
|
+
// //targetBlockElem.style.border = '3px solid red'
|
|
88
|
+
// highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem)
|
|
89
|
+
// }
|
|
90
|
+
targetLineElem.style.transform = `translate(${left}px, calc(${top}px - ${'2px'}))`;
|
|
109
91
|
/**
|
|
110
92
|
* Properly reset previous targetBlockElem styles
|
|
111
93
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTargetLine.js","names":["getCollapsedMargins","
|
|
1
|
+
{"version":3,"file":"setTargetLine.js","names":["getCollapsedMargins","TARGET_LINE_HALF_HEIGHT","TEXT_BOX_HORIZONTAL_PADDING","DEBUG","animationTimer","setTargetLine","offsetWidth","offsetLeft","targetLineElem","targetBlockElem","lastTargetBlock","mouseY","anchorElem","event","debugHighlightRef","isFoundNodeEmptyParagraph","height","targetBlockElemHeight","top","targetBlockElemTop","getBoundingClientRect","anchorTop","width","anchorWidth","marginBottom","marginTop","lineTop","isBelow","window","scrollY","willStayInSamePosition","elem","nextElementSibling","previousElementSibling","lastBoundingBoxPosition","boundingBox","y","currentBoundingBoxPosition","targetElemTranslate2","left","style","opacity","transform"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts"],"sourcesContent":["'use client'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { highlightElemOriginalPosition } from './highlightElemOriginalPosition.js'\nconst TARGET_LINE_HALF_HEIGHT = 0\nconst TEXT_BOX_HORIZONTAL_PADDING = -24\nconst DEBUG = false\n\nlet animationTimer = 0\n\nexport function setTargetLine(\n offsetWidth: string,\n offsetLeft: number,\n targetLineElem: HTMLElement,\n targetBlockElem: HTMLElement,\n lastTargetBlock: {\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n },\n mouseY: number,\n anchorElem: HTMLElement,\n event: DragEvent,\n debugHighlightRef: React.RefObject<HTMLDivElement | null>,\n isFoundNodeEmptyParagraph: boolean = false,\n) {\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n targetBlockElem.getBoundingClientRect() // used to be getBoundingClientRectWithoutTransform. Not sure what's better, but the normal getBoundingClientRect seems to work fine\n const { top: anchorTop, width: anchorWidth } = anchorElem.getBoundingClientRect()\n\n const { marginBottom, marginTop } = getCollapsedMargins(targetBlockElem)\n let lineTop = targetBlockElemTop\n\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n let willStayInSamePosition = false\n\n /**\n * Do not run any transform or changes if the actual new line position would be the same (even if it's now inserted BEFORE rather than AFTER - position would still be the same)\n * This prevents unnecessary flickering.\n *\n * We still need to let it run even if the position (IGNORING the transform) would not change, as the transform animation is not finished yet. This is what animationTimer does. Otherwise, the positioning will be inaccurate\n */\n if (lastTargetBlock?.elem) {\n if (targetBlockElem !== lastTargetBlock?.elem) {\n if (\n isBelow &&\n lastTargetBlock?.elem &&\n lastTargetBlock?.elem === targetBlockElem.nextElementSibling\n ) {\n animationTimer++\n\n if (animationTimer < 200) {\n willStayInSamePosition = true\n }\n } else if (\n !isBelow &&\n lastTargetBlock?.elem &&\n lastTargetBlock?.elem === targetBlockElem.previousElementSibling\n ) {\n animationTimer++\n if (animationTimer < 200) {\n willStayInSamePosition = true\n }\n }\n } else {\n animationTimer++\n\n const lastBoundingBoxPosition = lastTargetBlock?.boundingBox?.y\n const currentBoundingBoxPosition = targetBlockElem.getBoundingClientRect().y\n\n if (\n (isBelow === lastTargetBlock?.isBelow &&\n lastBoundingBoxPosition === currentBoundingBoxPosition) ||\n animationTimer < 200\n ) {\n willStayInSamePosition = false\n }\n }\n }\n if (willStayInSamePosition) {\n return {\n isBelow,\n willStayInSamePosition,\n }\n }\n\n /**\n * Paragraphs need no isBelow/above handling,\n */\n if (!isFoundNodeEmptyParagraph) {\n //if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n lineTop += targetBlockElemHeight + marginBottom / 2\n } else {\n // above targetBlockElem\n lineTop -= marginTop / 2\n }\n } else {\n lineTop += targetBlockElemHeight / 2\n }\n\n let targetElemTranslate2 = 0\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n targetElemTranslate2 = -TARGET_LINE_HALF_HEIGHT\n } else {\n targetElemTranslate2 = TARGET_LINE_HALF_HEIGHT\n }\n }\n\n const top = lineTop - anchorTop + targetElemTranslate2\n\n const left = TEXT_BOX_HORIZONTAL_PADDING - offsetLeft\n\n targetLineElem.style.width = `calc(${anchorWidth}px - ${offsetWidth})`\n targetLineElem.style.opacity = '.8'\n\n // if (DEBUG) {\n // //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem)\n // }\n\n targetLineElem.style.transform = `translate(${left}px, calc(${top}px - ${'2px'}))`\n\n /**\n * Properly reset previous targetBlockElem styles\n */\n lastTargetBlock.elem.style.opacity = ''\n\n if (lastTargetBlock?.elem === targetBlockElem) {\n if (isBelow) {\n lastTargetBlock.elem.style.marginTop = ''\n } else {\n lastTargetBlock.elem.style.marginBottom = ''\n }\n } else {\n lastTargetBlock.elem.style.marginBottom = ''\n lastTargetBlock.elem.style.marginTop = ''\n }\n animationTimer = 0\n return {\n isBelow,\n willStayInSamePosition,\n }\n}\n"],"mappings":"AAAA;;AACA,SAASA,mBAAmB,QAAQ;AAEpC,MAAMC,uBAAA,GAA0B;AAChC,MAAMC,2BAAA,GAA8B,CAAC;AACrC,MAAMC,KAAA,GAAQ;AAEd,IAAIC,cAAA,GAAiB;AAErB,OAAO,SAASC,cACdC,WAAmB,EACnBC,UAAkB,EAClBC,cAA2B,EAC3BC,eAA4B,EAC5BC,eAIC,EACDC,MAAc,EACdC,UAAuB,EACvBC,KAAgB,EAChBC,iBAAyD,EACzDC,yBAAA,GAAqC,KAAK;EAE1C,MAAM;IAAEC,MAAA,EAAQC,qBAAqB;IAAEC,GAAA,EAAKC;EAAkB,CAAE,GAC9DV,eAAA,CAAgBW,qBAAqB,GAAG;EAAA;EAC1C,MAAM;IAAEF,GAAA,EAAKG,SAAS;IAAEC,KAAA,EAAOC;EAAW,CAAE,GAAGX,UAAA,CAAWQ,qBAAqB;EAE/E,MAAM;IAAEI,YAAY;IAAEC;EAAS,CAAE,GAAGzB,mBAAA,CAAoBS,eAAA;EACxD,IAAIiB,OAAA,GAAUP,kBAAA;EAEd,MAAMQ,OAAA,GAAUhB,MAAA,IAAUQ,kBAAA,GAAqBF,qBAAA,GAAwB,IAAIW,MAAA,CAAOC,OAAO;EAEzF,IAAIC,sBAAA,GAAyB;EAE7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1B,OAAO;MACLqC,oBAAA,GAAuBrC,uBAAA;IACzB;EACF;EAEA,MAAMiB,GAAA,GAAMQ,OAAA,GAAUL,SAAA,GAAYiB,oBAAA;EAElC,MAAMC,IAAA,GAAOrC,2BAAA,GAA8BK,UAAA;EAE3CC,cAAA,CAAegC,KAAK,CAAClB,KAAK,GAAG,QAAQC,WAAA,QAAmBjB,WAAA,GAAc;EACtEE,cAAA,CAAegC,KAAK,CAACC,OAAO,GAAG;EAE/B;EACA;EACA;EACA;EAEAjC,cAAA,CAAegC,KAAK,CAACE,SAAS,GAAG,aAAaH,IAAA,YAAgBrB,GAAA,QAAW,SAAS;EAElF;;;EAGAR,eAAA,CAAgBqB,IAAI,CAACS,KAAK,CAACC,OAAO,GAAG;EAErC,IAAI/B,eAAA,EAAiBqB,IAAA,KAAStB,eAAA,EAAiB;IAC7C,IAAIkB,OAAA,EAAS;MACXjB,eAAA,CAAgBqB,IAAI,CAACS,KAAK,CAACf,SAAS,GAAG;IACzC,OAAO;MACLf,eAAA,CAAgBqB,IAAI,CAACS,KAAK,CAAChB,YAAY,GAAG;IAC5C;EACF,OAAO;IACLd,eAAA,CAAgBqB,IAAI,CAACS,KAAK,CAAChB,YAAY,GAAG;IAC1Cd,eAAA,CAAgBqB,IAAI,CAACS,KAAK,CAACf,SAAS,GAAG;EACzC;EACArB,cAAA,GAAiB;EACjB,OAAO;IACLuB,OAAA;IACAG;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setHandlePosition.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/utils/setHandlePosition.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,WAAW,GAAG,IAAI,EAC9B,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,WAAW,EACvB,UAAU,GAAE,MAAU,
|
|
1
|
+
{"version":3,"file":"setHandlePosition.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/utils/setHandlePosition.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,WAAW,GAAG,IAAI,EAC9B,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,WAAW,EACvB,UAAU,GAAE,MAAU,QAmCvB"}
|
|
@@ -12,16 +12,14 @@ export function setHandlePosition(targetElem, handleElem, anchorElem, leftOffset
|
|
|
12
12
|
const floatingElemRect = handleElem.getBoundingClientRect();
|
|
13
13
|
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
14
14
|
let top;
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
15
|
+
const isBlockStyle = ['lexical-block', 'lexical-upload', 'lexical-relationship'].some(classes => targetElem.firstElementChild?.classList.contains(classes));
|
|
16
|
+
if (!isBlockStyle) {
|
|
17
17
|
// No need to let line height affect the re-positioning of the floating element if line height has no
|
|
18
18
|
// visual effect on the element. Otherwise, the floating element will be positioned incorrectly.
|
|
19
19
|
const actualLineHeight = doesLineHeightAffectElement(targetElem) ? parseInt(targetStyle.lineHeight, 10) : 0;
|
|
20
|
-
top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top
|
|
21
|
-
;
|
|
20
|
+
top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top;
|
|
22
21
|
} else {
|
|
23
|
-
top = targetRect.top
|
|
24
|
-
;
|
|
22
|
+
top = targetRect.top + 8 - anchorElementRect.top;
|
|
25
23
|
}
|
|
26
24
|
const left = leftOffset;
|
|
27
25
|
handleElem.style.opacity = '1';
|