@portabletext/editor 1.44.11 → 1.44.13

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/lib/index.cjs CHANGED
@@ -73,10 +73,14 @@ function getDragSelection({
73
73
  return dragSelection;
74
74
  }
75
75
  function getEventPosition({
76
- schema,
76
+ editorActor,
77
77
  slateEditor,
78
78
  event
79
79
  }) {
80
+ if (editorActor.getSnapshot().matches({
81
+ setup: "setting up"
82
+ }))
83
+ return;
80
84
  const node = getEventNode({
81
85
  slateEditor,
82
86
  event
@@ -85,14 +89,14 @@ function getEventPosition({
85
89
  return;
86
90
  const block = editorProvider.getNodeBlock({
87
91
  editor: slateEditor,
88
- schema,
92
+ schema: editorActor.getSnapshot().context.schema,
89
93
  node
90
94
  }), positionBlock = getEventPositionBlock({
91
95
  node,
92
96
  slateEditor,
93
97
  event
94
98
  }), selection = getEventSelection({
95
- schema,
99
+ schema: editorActor.getSnapshot().context.schema,
96
100
  slateEditor,
97
101
  event
98
102
  });
@@ -1100,7 +1104,11 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1100
1104
  onCopy(event) !== void 0 && event.preventDefault();
1101
1105
  else if (event.nativeEvent.clipboardData) {
1102
1106
  event.stopPropagation(), event.preventDefault();
1103
- const selection = editorActor.getSnapshot().context.selection, position = selection ? {
1107
+ const selection = slateEditor.selection ? editorProvider.slateRangeToSelection({
1108
+ schema: editorActor.getSnapshot().context.schema,
1109
+ editor: slateEditor,
1110
+ range: slateEditor.selection
1111
+ }) : void 0, position = selection ? {
1104
1112
  selection
1105
1113
  } : void 0;
1106
1114
  if (!position) {
@@ -1244,15 +1252,11 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1244
1252
  if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
1245
1253
  return;
1246
1254
  const position_3 = getEventPosition({
1247
- schema: editorActor.getSnapshot().context.schema,
1255
+ editorActor,
1248
1256
  slateEditor,
1249
1257
  event: event_3.nativeEvent
1250
1258
  });
1251
- if (!position_3) {
1252
- console.warn("Could not find EventPosition for MouseEvent");
1253
- return;
1254
- }
1255
- editorActor.send({
1259
+ position_3 && editorActor.send({
1256
1260
  type: "behavior event",
1257
1261
  behaviorEvent: {
1258
1262
  type: "mouse.click",
@@ -1361,7 +1365,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1361
1365
  if (onDragStart?.(event_8), event_8.isDefaultPrevented() || event_8.isPropagationStopped())
1362
1366
  return;
1363
1367
  const position_4 = getEventPosition({
1364
- schema: editorActor.getSnapshot().context.schema,
1368
+ editorActor,
1365
1369
  slateEditor,
1366
1370
  event: event_8.nativeEvent
1367
1371
  });
@@ -1441,7 +1445,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1441
1445
  }), !0;
1442
1446
  }, [onDragStart, editorActor, slateEditor]), handleDrag = React.useCallback((event_9) => {
1443
1447
  if (onDrag?.(event_9), !(event_9.isDefaultPrevented() || event_9.isPropagationStopped() || !getEventPosition({
1444
- schema: editorActor.getSnapshot().context.schema,
1448
+ editorActor,
1445
1449
  slateEditor,
1446
1450
  event: event_9.nativeEvent
1447
1451
  })))
@@ -1471,7 +1475,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1471
1475
  if (onDragEnter?.(event_11), event_11.isDefaultPrevented() || event_11.isPropagationStopped())
1472
1476
  return;
1473
1477
  const position_6 = getEventPosition({
1474
- schema: editorActor.getSnapshot().context.schema,
1478
+ editorActor,
1475
1479
  slateEditor,
1476
1480
  event: event_11.nativeEvent
1477
1481
  });
@@ -1491,7 +1495,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1491
1495
  if (onDragOver?.(event_12), event_12.isDefaultPrevented() || event_12.isPropagationStopped())
1492
1496
  return;
1493
1497
  const position_7 = getEventPosition({
1494
- schema: editorActor.getSnapshot().context.schema,
1498
+ editorActor,
1495
1499
  slateEditor,
1496
1500
  event: event_12.nativeEvent
1497
1501
  });
@@ -1512,7 +1516,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1512
1516
  if (onDrop?.(event_13), event_13.isDefaultPrevented() || event_13.isPropagationStopped())
1513
1517
  return;
1514
1518
  const position_8 = getEventPosition({
1515
- schema: editorActor.getSnapshot().context.schema,
1519
+ editorActor,
1516
1520
  slateEditor,
1517
1521
  event: event_13.nativeEvent
1518
1522
  });
@@ -1534,7 +1538,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1534
1538
  }), !0;
1535
1539
  }, [onDrop, editorActor, slateEditor]), handleDragLeave = React.useCallback((event_14) => {
1536
1540
  if (onDragLeave?.(event_14), !(event_14.isDefaultPrevented() || event_14.isPropagationStopped() || !getEventPosition({
1537
- schema: editorActor.getSnapshot().context.schema,
1541
+ editorActor,
1538
1542
  slateEditor,
1539
1543
  event: event_14.nativeEvent
1540
1544
  })))