@portabletext/editor 1.40.4 → 1.41.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.
@@ -1,7 +1,11 @@
1
+ function getSelectionEndPoint(selection) {
2
+ return selection ? selection.backward ? selection.anchor : selection.focus : null;
3
+ }
1
4
  function isSelectionCollapsed(selection) {
2
5
  return selection ? selection.anchor.path.join() === selection.focus.path.join() && selection.anchor.offset === selection.focus.offset : !1;
3
6
  }
4
7
  export {
8
+ getSelectionEndPoint,
5
9
  isSelectionCollapsed
6
10
  };
7
11
  //# sourceMappingURL=util.is-selection-collapsed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.is-selection-collapsed.js","sources":["../../src/utils/util.is-selection-collapsed.ts"],"sourcesContent":["import type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function isSelectionCollapsed(selection: EditorSelection) {\n if (!selection) {\n return false\n }\n\n return (\n selection.anchor.path.join() === selection.focus.path.join() &&\n selection.anchor.offset === selection.focus.offset\n )\n}\n"],"names":["isSelectionCollapsed","selection","anchor","path","join","focus","offset"],"mappings":"AAKO,SAASA,qBAAqBC,WAA4B;AAC/D,SAAKA,YAKHA,UAAUC,OAAOC,KAAKC,KAAAA,MAAWH,UAAUI,MAAMF,KAAKC,KAAAA,KACtDH,UAAUC,OAAOI,WAAWL,UAAUI,MAAMC,SALrC;AAOX;"}
1
+ {"version":3,"file":"util.is-selection-collapsed.js","sources":["../../src/utils/util.get-selection-end-point.ts","../../src/utils/util.is-selection-collapsed.ts"],"sourcesContent":["import type {EditorSelection, EditorSelectionPoint} from '..'\n\n/**\n * @public\n */\nexport function getSelectionEndPoint<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n TEditorSelectionPoint extends\n EditorSelectionPoint | null = TEditorSelection extends NonNullable<EditorSelection>\n ? EditorSelectionPoint\n : null,\n>(selection: TEditorSelection): TEditorSelectionPoint {\n if (!selection) {\n return null as TEditorSelectionPoint\n }\n\n return (\n selection.backward ? selection.anchor : selection.focus\n ) as TEditorSelectionPoint\n}\n","import type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function isSelectionCollapsed(selection: EditorSelection) {\n if (!selection) {\n return false\n }\n\n return (\n selection.anchor.path.join() === selection.focus.path.join() &&\n selection.anchor.offset === selection.focus.offset\n )\n}\n"],"names":["getSelectionEndPoint","selection","backward","anchor","focus","isSelectionCollapsed","path","join","offset"],"mappings":"AAKO,SAASA,qBAMdC,WAAoD;AACpD,SAAKA,YAKHA,UAAUC,WAAWD,UAAUE,SAASF,UAAUG,QAJ3C;AAMX;ACdO,SAASC,qBAAqBJ,WAA4B;AAC/D,SAAKA,YAKHA,UAAUE,OAAOG,KAAKC,KAAAA,MAAWN,UAAUG,MAAME,KAAKC,KAAAA,KACtDN,UAAUE,OAAOK,WAAWP,UAAUG,MAAMI,SALrC;AAOX;"}
package/lib/index.cjs CHANGED
@@ -65,6 +65,19 @@ function getDragSelection({
65
65
  }
66
66
  return dragSelection;
67
67
  }
68
+ function draggingOnDragOrigin({
69
+ snapshot,
70
+ position
71
+ }) {
72
+ const dragOrigin = snapshot.beta.internalDrag?.origin;
73
+ return dragOrigin ? selector_isOverlappingSelection.isOverlappingSelection(position.selection)({
74
+ ...snapshot,
75
+ context: {
76
+ ...snapshot.context,
77
+ selection: dragOrigin.selection
78
+ }
79
+ }) : !1;
80
+ }
68
81
  function getEventPosition({
69
82
  schema,
70
83
  slateEditor,
@@ -146,6 +159,22 @@ function getEventPositionBlock({
146
159
  slateEditor,
147
160
  event
148
161
  }) {
162
+ const [firstBlock] = editorProvider.getFirstBlock({
163
+ editor: slateEditor
164
+ });
165
+ if (!firstBlock)
166
+ return;
167
+ const firstBlockRect = slateDom.DOMEditor.toDOMNode(slateEditor, firstBlock).getBoundingClientRect();
168
+ if (event.pageY < firstBlockRect.top)
169
+ return "start";
170
+ const [lastBlock] = editorProvider.getLastBlock({
171
+ editor: slateEditor
172
+ });
173
+ if (!lastBlock)
174
+ return;
175
+ const lastBlockRef = slateDom.DOMEditor.toDOMNode(slateEditor, lastBlock).getBoundingClientRect();
176
+ if (event.pageY > lastBlockRef.bottom)
177
+ return "end";
149
178
  const elementRect = slateDom.DOMEditor.toDOMNode(slateEditor, node).getBoundingClientRect(), top = elementRect.top, height = elementRect.height;
150
179
  return Math.abs(top - event.pageY) < height / 2 ? "start" : "end";
151
180
  }
@@ -164,7 +193,11 @@ function getSlateRangeFromEvent(editor, event) {
164
193
  let domRange;
165
194
  if (window2.document.caretPositionFromPoint !== void 0) {
166
195
  const position = window2.document.caretPositionFromPoint(event.clientX, event.clientY);
167
- position && (domRange = window2.document.createRange(), domRange.setStart(position.offsetNode, position.offset), domRange.setEnd(position.offsetNode, position.offset));
196
+ if (position)
197
+ try {
198
+ domRange = window2.document.createRange(), domRange.setStart(position.offsetNode, position.offset), domRange.setEnd(position.offsetNode, position.offset);
199
+ } catch {
200
+ }
168
201
  } else if (window2.document.caretRangeFromPoint !== void 0)
169
202
  domRange = window2.document.caretRangeFromPoint(event.clientX, event.clientY) ?? void 0;
170
203
  else {
@@ -292,13 +325,13 @@ function DefaultInlineObject(props) {
292
325
  function DropIndicator() {
293
326
  const $ = reactCompilerRuntime.c(1);
294
327
  let t0;
295
- return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-drop-indicator", style: {
328
+ return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("div", { contentEditable: !1, className: "pt-drop-indicator", style: {
296
329
  position: "absolute",
297
330
  width: "100%",
298
331
  height: 1,
299
332
  borderBottom: "1px solid currentColor",
300
333
  zIndex: 5
301
- } }), $[0] = t0) : t0 = $[0], t0;
334
+ }, children: /* @__PURE__ */ jsxRuntime.jsx("span", {}) }), $[0] = t0) : t0 = $[0], t0;
302
335
  }
303
336
  editorProvider.debugWithName("components:Element");
304
337
  const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
@@ -1111,78 +1144,111 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1111
1144
  };
1112
1145
  }, [slateEditor, editorActor]);
1113
1146
  const handleDragStart = React.useCallback((event_8) => {
1114
- if (onDragStart?.(event_8), !event_8.isDefaultPrevented() && !event_8.isPropagationStopped()) {
1115
- const position_4 = getEventPosition({
1116
- schema: editorActor.getSnapshot().context.schema,
1117
- slateEditor,
1118
- event: event_8.nativeEvent
1119
- });
1120
- if (!position_4) {
1121
- console.warn("Could not find position for dragstart event");
1122
- return;
1147
+ if (onDragStart?.(event_8), event_8.isDefaultPrevented() || event_8.isPropagationStopped())
1148
+ return;
1149
+ event_8.stopPropagation();
1150
+ const position_4 = getEventPosition({
1151
+ schema: editorActor.getSnapshot().context.schema,
1152
+ slateEditor,
1153
+ event: event_8.nativeEvent
1154
+ });
1155
+ if (!position_4) {
1156
+ console.warn("Could not find position for dragstart event");
1157
+ return;
1158
+ }
1159
+ const snapshot = editorProvider.getEditorSnapshot({
1160
+ editorActorSnapshot: editorActor.getSnapshot(),
1161
+ slateEditorInstance: slateEditor
1162
+ }), dragSelection = getDragSelection({
1163
+ eventSelection: position_4.selection,
1164
+ snapshot
1165
+ }), selectingEntireBlocks = selector_isOverlappingSelection.isSelectingEntireBlocks({
1166
+ context: {
1167
+ ...snapshot.context,
1168
+ selection: dragSelection
1123
1169
  }
1124
- const snapshot = editorProvider.getEditorSnapshot({
1125
- editorActorSnapshot: editorActor.getSnapshot(),
1126
- slateEditorInstance: slateEditor
1127
- }), dragSelection = getDragSelection({
1128
- eventSelection: position_4.selection,
1129
- snapshot
1130
- }), selectingEntireBlocks = selector_isOverlappingSelection.isSelectingEntireBlocks({
1170
+ }), dragGhost = document.createElement("div"), draggedDomNodes = getSelectionDomNodes({
1171
+ snapshot: {
1131
1172
  context: {
1132
1173
  ...snapshot.context,
1133
1174
  selection: dragSelection
1134
1175
  }
1135
- }), dragGhost = document.createElement("div"), draggedDomNodes = getSelectionDomNodes({
1136
- snapshot: {
1137
- context: {
1138
- ...snapshot.context,
1139
- selection: dragSelection
1140
- }
1141
- },
1142
- slateEditor
1143
- });
1144
- if (selectingEntireBlocks) {
1145
- const clonedBlockNodes = draggedDomNodes.blockNodes.map((node) => node.cloneNode(!0));
1146
- for (const block of clonedBlockNodes)
1147
- block instanceof HTMLElement && (block.style.position = "relative"), dragGhost.appendChild(block);
1148
- const customGhost = dragGhost.querySelector("[data-pt-drag-ghost-element]");
1149
- if (customGhost && dragGhost.replaceChildren(customGhost), dragGhost.setAttribute("data-dragged", ""), dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost), customGhost) {
1150
- const customGhostRect = customGhost.getBoundingClientRect(), x = event_8.clientX - customGhostRect.left, y = event_8.clientY - customGhostRect.top;
1151
- dragGhost.style.width = `${customGhostRect.width}px`, dragGhost.style.height = `${customGhostRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x, y);
1152
- } else {
1153
- const blocksDomRect = getCompoundClientRect(draggedDomNodes.blockNodes), x_0 = event_8.clientX - blocksDomRect.left, y_0 = event_8.clientY - blocksDomRect.top;
1154
- dragGhost.style.width = `${blocksDomRect.width}px`, dragGhost.style.height = `${blocksDomRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x_0, y_0);
1155
- }
1176
+ },
1177
+ slateEditor
1178
+ });
1179
+ if (selectingEntireBlocks) {
1180
+ const clonedBlockNodes = draggedDomNodes.blockNodes.map((node) => node.cloneNode(!0));
1181
+ for (const block of clonedBlockNodes)
1182
+ block instanceof HTMLElement && (block.style.position = "relative"), dragGhost.appendChild(block);
1183
+ const customGhost = dragGhost.querySelector("[data-pt-drag-ghost-element]");
1184
+ if (customGhost && dragGhost.replaceChildren(customGhost), dragGhost.setAttribute("data-dragged", ""), dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost), customGhost) {
1185
+ const customGhostRect = customGhost.getBoundingClientRect(), x = event_8.clientX - customGhostRect.left, y = event_8.clientY - customGhostRect.top;
1186
+ dragGhost.style.width = `${customGhostRect.width}px`, dragGhost.style.height = `${customGhostRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x, y);
1156
1187
  } else {
1157
- const clonedChildNodes = draggedDomNodes.childNodes.map((node_0) => node_0.cloneNode(!0));
1158
- for (const child of clonedChildNodes)
1159
- dragGhost.appendChild(child);
1160
- dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost);
1161
- const childrenDomRect = getCompoundClientRect(draggedDomNodes.childNodes), x_1 = event_8.clientX - childrenDomRect.left, y_1 = event_8.clientY - childrenDomRect.top;
1162
- dragGhost.style.width = `${childrenDomRect.width}px`, dragGhost.style.height = `${childrenDomRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x_1, y_1);
1188
+ const blocksDomRect = getCompoundClientRect(draggedDomNodes.blockNodes), x_0 = event_8.clientX - blocksDomRect.left, y_0 = event_8.clientY - blocksDomRect.top;
1189
+ dragGhost.style.width = `${blocksDomRect.width}px`, dragGhost.style.height = `${blocksDomRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x_0, y_0);
1163
1190
  }
1164
- editorActor.send({
1165
- type: "dragstart",
1166
- origin: {
1167
- selection: dragSelection
1168
- },
1169
- ghost: dragGhost
1170
- }), editorActor.send({
1171
- type: "behavior event",
1172
- behaviorEvent: {
1173
- type: "drag.dragstart",
1174
- originEvent: {
1175
- dataTransfer: event_8.dataTransfer
1176
- },
1177
- position: {
1178
- selection: dragSelection
1179
- }
1180
- },
1181
- editor: slateEditor
1182
- }), event_8.stopPropagation();
1191
+ } else {
1192
+ const clonedChildNodes = draggedDomNodes.childNodes.map((node_0) => node_0.cloneNode(!0));
1193
+ for (const child of clonedChildNodes)
1194
+ dragGhost.appendChild(child);
1195
+ dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost);
1196
+ const childrenDomRect = getCompoundClientRect(draggedDomNodes.childNodes), x_1 = event_8.clientX - childrenDomRect.left, y_1 = event_8.clientY - childrenDomRect.top;
1197
+ dragGhost.style.width = `${childrenDomRect.width}px`, dragGhost.style.height = `${childrenDomRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x_1, y_1);
1183
1198
  }
1199
+ editorActor.send({
1200
+ type: "behavior event",
1201
+ behaviorEvent: {
1202
+ type: "select",
1203
+ selection: util_isSelectionCollapsed.isSelectionCollapsed(dragSelection) ? dragSelection : {
1204
+ anchor: util_isSelectionCollapsed.getSelectionEndPoint(dragSelection),
1205
+ focus: util_isSelectionCollapsed.getSelectionEndPoint(dragSelection),
1206
+ backward: !1
1207
+ }
1208
+ },
1209
+ editor: slateEditor
1210
+ }), editorActor.send({
1211
+ type: "dragstart",
1212
+ origin: {
1213
+ selection: dragSelection
1214
+ },
1215
+ ghost: dragGhost
1216
+ }), editorActor.send({
1217
+ type: "behavior event",
1218
+ behaviorEvent: {
1219
+ type: "drag.dragstart",
1220
+ originEvent: {
1221
+ dataTransfer: event_8.dataTransfer
1222
+ },
1223
+ position: {
1224
+ selection: dragSelection
1225
+ }
1226
+ },
1227
+ editor: slateEditor
1228
+ });
1184
1229
  }, [onDragStart, editorActor, slateEditor]), handleDrag = React.useCallback((event_9) => {
1185
- onDrag?.(event_9), !event_9.isDefaultPrevented() && !event_9.isPropagationStopped() && (editorActor.send({
1230
+ if (onDrag?.(event_9), event_9.isDefaultPrevented() || event_9.isPropagationStopped())
1231
+ return;
1232
+ event_9.stopPropagation();
1233
+ const position_5 = getEventPosition({
1234
+ schema: editorActor.getSnapshot().context.schema,
1235
+ slateEditor,
1236
+ event: event_9.nativeEvent
1237
+ });
1238
+ if (!position_5)
1239
+ return;
1240
+ const snapshot_0 = editorProvider.getEditorSnapshot({
1241
+ editorActorSnapshot: editorActor.getSnapshot(),
1242
+ slateEditorInstance: slateEditor
1243
+ });
1244
+ if (draggingOnDragOrigin({
1245
+ snapshot: snapshot_0,
1246
+ position: position_5
1247
+ })) {
1248
+ event_9.preventDefault();
1249
+ return;
1250
+ }
1251
+ editorActor.send({
1186
1252
  type: "behavior event",
1187
1253
  behaviorEvent: {
1188
1254
  type: "drag.drag",
@@ -1191,9 +1257,9 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1191
1257
  }
1192
1258
  },
1193
1259
  editor: slateEditor
1194
- }), event_9.stopPropagation());
1260
+ });
1195
1261
  }, [onDrag, editorActor, slateEditor]), handleDragEnd = React.useCallback((event_10) => {
1196
- onDragEnd?.(event_10), !event_10.isDefaultPrevented() && !event_10.isPropagationStopped() && (editorActor.send({
1262
+ onDragEnd?.(event_10), !(event_10.isDefaultPrevented() || event_10.isPropagationStopped()) && (event_10.stopPropagation(), editorActor.send({
1197
1263
  type: "behavior event",
1198
1264
  behaviorEvent: {
1199
1265
  type: "drag.dragend",
@@ -1202,76 +1268,139 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1202
1268
  }
1203
1269
  },
1204
1270
  editor: slateEditor
1205
- }), event_10.stopPropagation());
1271
+ }));
1206
1272
  }, [onDragEnd, editorActor, slateEditor]), handleDragEnter = React.useCallback((event_11) => {
1207
- if (onDragEnter?.(event_11), !event_11.isDefaultPrevented() && !event_11.isPropagationStopped()) {
1208
- const position_5 = getEventPosition({
1209
- schema: editorActor.getSnapshot().context.schema,
1210
- slateEditor,
1211
- event: event_11.nativeEvent
1212
- });
1213
- if (!position_5)
1214
- return;
1215
- editorActor.send({
1216
- type: "behavior event",
1217
- behaviorEvent: {
1218
- type: "drag.dragenter",
1219
- originEvent: {
1220
- dataTransfer: event_11.dataTransfer
1221
- },
1222
- position: position_5
1223
- },
1224
- editor: slateEditor
1225
- }), event_11.stopPropagation();
1273
+ if (onDragEnter?.(event_11), event_11.isDefaultPrevented() || event_11.isPropagationStopped())
1274
+ return;
1275
+ event_11.stopPropagation();
1276
+ const position_6 = getEventPosition({
1277
+ schema: editorActor.getSnapshot().context.schema,
1278
+ slateEditor,
1279
+ event: event_11.nativeEvent
1280
+ });
1281
+ if (!position_6)
1282
+ return;
1283
+ const snapshot_1 = editorProvider.getEditorSnapshot({
1284
+ editorActorSnapshot: editorActor.getSnapshot(),
1285
+ slateEditorInstance: slateEditor
1286
+ });
1287
+ if (draggingOnDragOrigin({
1288
+ snapshot: snapshot_1,
1289
+ position: position_6
1290
+ })) {
1291
+ event_11.preventDefault();
1292
+ return;
1226
1293
  }
1227
- }, [onDragEnter, editorActor, slateEditor]), handleDragOver = React.useCallback((event_12) => {
1228
- if (onDragOver?.(event_12), !event_12.isDefaultPrevented() && !event_12.isPropagationStopped()) {
1229
- const position_6 = getEventPosition({
1230
- schema: editorActor.getSnapshot().context.schema,
1231
- slateEditor,
1232
- event: event_12.nativeEvent
1233
- });
1234
- if (!position_6)
1235
- return;
1236
- editorActor.send({
1237
- type: "behavior event",
1238
- behaviorEvent: {
1239
- type: "drag.dragover",
1240
- originEvent: {
1241
- dataTransfer: event_12.dataTransfer
1242
- },
1243
- position: position_6
1294
+ editorActor.send({
1295
+ type: "behavior event",
1296
+ behaviorEvent: {
1297
+ type: "drag.dragenter",
1298
+ originEvent: {
1299
+ dataTransfer: event_11.dataTransfer
1244
1300
  },
1245
- editor: slateEditor,
1246
- nativeEvent: event_12
1247
- }), event_12.stopPropagation();
1301
+ position: position_6
1302
+ },
1303
+ editor: slateEditor
1304
+ });
1305
+ }, [onDragEnter, editorActor, slateEditor]), handleDragOver = React.useCallback((event_12) => {
1306
+ if (onDragOver?.(event_12), event_12.isDefaultPrevented() || event_12.isPropagationStopped())
1307
+ return;
1308
+ event_12.stopPropagation();
1309
+ const position_7 = getEventPosition({
1310
+ schema: editorActor.getSnapshot().context.schema,
1311
+ slateEditor,
1312
+ event: event_12.nativeEvent
1313
+ });
1314
+ if (!position_7)
1315
+ return;
1316
+ const snapshot_2 = editorProvider.getEditorSnapshot({
1317
+ editorActorSnapshot: editorActor.getSnapshot(),
1318
+ slateEditorInstance: slateEditor
1319
+ });
1320
+ if (draggingOnDragOrigin({
1321
+ snapshot: snapshot_2,
1322
+ position: position_7
1323
+ })) {
1324
+ event_12.preventDefault();
1325
+ return;
1248
1326
  }
1249
- }, [onDragOver, editorActor, slateEditor]), handleDrop = React.useCallback((event_13) => {
1250
- if (onDrop?.(event_13), !event_13.isDefaultPrevented() && !event_13.isPropagationStopped()) {
1251
- const position_7 = getEventPosition({
1252
- schema: editorActor.getSnapshot().context.schema,
1253
- slateEditor,
1254
- event: event_13.nativeEvent
1255
- });
1256
- if (!position_7) {
1257
- console.warn("Could not find position for drop event");
1258
- return;
1259
- }
1260
- const range = slateReact.ReactEditor.findEventRange(slateEditor, event_13);
1261
- slateEditor.select(range), editorActor.send({
1262
- type: "behavior event",
1263
- behaviorEvent: {
1264
- type: "drag.drop",
1265
- originEvent: {
1266
- dataTransfer: event_13.dataTransfer
1267
- },
1268
- position: position_7
1327
+ editorActor.send({
1328
+ type: "behavior event",
1329
+ behaviorEvent: {
1330
+ type: "drag.dragover",
1331
+ originEvent: {
1332
+ dataTransfer: event_12.dataTransfer
1269
1333
  },
1270
- editor: slateEditor
1271
- }), event_13.preventDefault();
1334
+ position: position_7
1335
+ },
1336
+ editor: slateEditor,
1337
+ nativeEvent: event_12
1338
+ });
1339
+ }, [onDragOver, editorActor, slateEditor]), handleDrop = React.useCallback((event_13) => {
1340
+ if (onDrop?.(event_13), event_13.isDefaultPrevented() || event_13.isPropagationStopped())
1341
+ return;
1342
+ event_13.preventDefault();
1343
+ const position_8 = getEventPosition({
1344
+ schema: editorActor.getSnapshot().context.schema,
1345
+ slateEditor,
1346
+ event: event_13.nativeEvent
1347
+ });
1348
+ if (!position_8) {
1349
+ console.warn("Could not find position for drop event");
1350
+ return;
1272
1351
  }
1352
+ const snapshot_3 = editorProvider.getEditorSnapshot({
1353
+ editorActorSnapshot: editorActor.getSnapshot(),
1354
+ slateEditorInstance: slateEditor
1355
+ });
1356
+ if (draggingOnDragOrigin({
1357
+ snapshot: snapshot_3,
1358
+ position: position_8
1359
+ })) {
1360
+ event_13.preventDefault();
1361
+ return;
1362
+ }
1363
+ editorActor.send({
1364
+ type: "behavior event",
1365
+ behaviorEvent: {
1366
+ type: "select",
1367
+ selection: position_8.selection
1368
+ },
1369
+ editor: slateEditor
1370
+ }), editorActor.send({
1371
+ type: "behavior event",
1372
+ behaviorEvent: {
1373
+ type: "drag.drop",
1374
+ originEvent: {
1375
+ dataTransfer: event_13.dataTransfer
1376
+ },
1377
+ position: position_8
1378
+ },
1379
+ editor: slateEditor
1380
+ });
1273
1381
  }, [onDrop, editorActor, slateEditor]), handleDragLeave = React.useCallback((event_14) => {
1274
- onDragLeave?.(event_14), !event_14.isDefaultPrevented() && !event_14.isPropagationStopped() && editorActor.send({
1382
+ if (onDragLeave?.(event_14), event_14.isDefaultPrevented() || event_14.isPropagationStopped())
1383
+ return;
1384
+ event_14.stopPropagation();
1385
+ const position_9 = getEventPosition({
1386
+ schema: editorActor.getSnapshot().context.schema,
1387
+ slateEditor,
1388
+ event: event_14.nativeEvent
1389
+ });
1390
+ if (!position_9)
1391
+ return;
1392
+ const snapshot_4 = editorProvider.getEditorSnapshot({
1393
+ editorActorSnapshot: editorActor.getSnapshot(),
1394
+ slateEditorInstance: slateEditor
1395
+ });
1396
+ if (draggingOnDragOrigin({
1397
+ snapshot: snapshot_4,
1398
+ position: position_9
1399
+ })) {
1400
+ event_14.preventDefault();
1401
+ return;
1402
+ }
1403
+ editorActor.send({
1275
1404
  type: "behavior event",
1276
1405
  behaviorEvent: {
1277
1406
  type: "drag.dragleave",