@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/_chunks-cjs/behavior.core.cjs +38 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +51 -29
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +38 -8
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +51 -29
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/index.cjs +20 -16
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +20 -16
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/behaviors/behavior.core.block-objects.ts +56 -8
- package/src/editor/Editable.tsx +24 -21
- package/src/editor/define-schema.ts +45 -9
- package/src/editor/editor-machine.ts +1 -0
- package/src/internal-utils/event-position.ts +9 -4
package/lib/index.js
CHANGED
|
@@ -87,10 +87,14 @@ function getDragSelection({
|
|
|
87
87
|
return dragSelection;
|
|
88
88
|
}
|
|
89
89
|
function getEventPosition({
|
|
90
|
-
|
|
90
|
+
editorActor,
|
|
91
91
|
slateEditor,
|
|
92
92
|
event
|
|
93
93
|
}) {
|
|
94
|
+
if (editorActor.getSnapshot().matches({
|
|
95
|
+
setup: "setting up"
|
|
96
|
+
}))
|
|
97
|
+
return;
|
|
94
98
|
const node = getEventNode({
|
|
95
99
|
slateEditor,
|
|
96
100
|
event
|
|
@@ -99,14 +103,14 @@ function getEventPosition({
|
|
|
99
103
|
return;
|
|
100
104
|
const block = getNodeBlock({
|
|
101
105
|
editor: slateEditor,
|
|
102
|
-
schema,
|
|
106
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
103
107
|
node
|
|
104
108
|
}), positionBlock = getEventPositionBlock({
|
|
105
109
|
node,
|
|
106
110
|
slateEditor,
|
|
107
111
|
event
|
|
108
112
|
}), selection = getEventSelection({
|
|
109
|
-
schema,
|
|
113
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
110
114
|
slateEditor,
|
|
111
115
|
event
|
|
112
116
|
});
|
|
@@ -1114,7 +1118,11 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1114
1118
|
onCopy(event) !== void 0 && event.preventDefault();
|
|
1115
1119
|
else if (event.nativeEvent.clipboardData) {
|
|
1116
1120
|
event.stopPropagation(), event.preventDefault();
|
|
1117
|
-
const selection =
|
|
1121
|
+
const selection = slateEditor.selection ? slateRangeToSelection({
|
|
1122
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
1123
|
+
editor: slateEditor,
|
|
1124
|
+
range: slateEditor.selection
|
|
1125
|
+
}) : void 0, position = selection ? {
|
|
1118
1126
|
selection
|
|
1119
1127
|
} : void 0;
|
|
1120
1128
|
if (!position) {
|
|
@@ -1258,15 +1266,11 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1258
1266
|
if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
|
|
1259
1267
|
return;
|
|
1260
1268
|
const position_3 = getEventPosition({
|
|
1261
|
-
|
|
1269
|
+
editorActor,
|
|
1262
1270
|
slateEditor,
|
|
1263
1271
|
event: event_3.nativeEvent
|
|
1264
1272
|
});
|
|
1265
|
-
|
|
1266
|
-
console.warn("Could not find EventPosition for MouseEvent");
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
editorActor.send({
|
|
1273
|
+
position_3 && editorActor.send({
|
|
1270
1274
|
type: "behavior event",
|
|
1271
1275
|
behaviorEvent: {
|
|
1272
1276
|
type: "mouse.click",
|
|
@@ -1375,7 +1379,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1375
1379
|
if (onDragStart?.(event_8), event_8.isDefaultPrevented() || event_8.isPropagationStopped())
|
|
1376
1380
|
return;
|
|
1377
1381
|
const position_4 = getEventPosition({
|
|
1378
|
-
|
|
1382
|
+
editorActor,
|
|
1379
1383
|
slateEditor,
|
|
1380
1384
|
event: event_8.nativeEvent
|
|
1381
1385
|
});
|
|
@@ -1455,7 +1459,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1455
1459
|
}), !0;
|
|
1456
1460
|
}, [onDragStart, editorActor, slateEditor]), handleDrag = useCallback((event_9) => {
|
|
1457
1461
|
if (onDrag?.(event_9), !(event_9.isDefaultPrevented() || event_9.isPropagationStopped() || !getEventPosition({
|
|
1458
|
-
|
|
1462
|
+
editorActor,
|
|
1459
1463
|
slateEditor,
|
|
1460
1464
|
event: event_9.nativeEvent
|
|
1461
1465
|
})))
|
|
@@ -1485,7 +1489,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1485
1489
|
if (onDragEnter?.(event_11), event_11.isDefaultPrevented() || event_11.isPropagationStopped())
|
|
1486
1490
|
return;
|
|
1487
1491
|
const position_6 = getEventPosition({
|
|
1488
|
-
|
|
1492
|
+
editorActor,
|
|
1489
1493
|
slateEditor,
|
|
1490
1494
|
event: event_11.nativeEvent
|
|
1491
1495
|
});
|
|
@@ -1505,7 +1509,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1505
1509
|
if (onDragOver?.(event_12), event_12.isDefaultPrevented() || event_12.isPropagationStopped())
|
|
1506
1510
|
return;
|
|
1507
1511
|
const position_7 = getEventPosition({
|
|
1508
|
-
|
|
1512
|
+
editorActor,
|
|
1509
1513
|
slateEditor,
|
|
1510
1514
|
event: event_12.nativeEvent
|
|
1511
1515
|
});
|
|
@@ -1526,7 +1530,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1526
1530
|
if (onDrop?.(event_13), event_13.isDefaultPrevented() || event_13.isPropagationStopped())
|
|
1527
1531
|
return;
|
|
1528
1532
|
const position_8 = getEventPosition({
|
|
1529
|
-
|
|
1533
|
+
editorActor,
|
|
1530
1534
|
slateEditor,
|
|
1531
1535
|
event: event_13.nativeEvent
|
|
1532
1536
|
});
|
|
@@ -1548,7 +1552,7 @@ const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
|
|
|
1548
1552
|
}), !0;
|
|
1549
1553
|
}, [onDrop, editorActor, slateEditor]), handleDragLeave = useCallback((event_14) => {
|
|
1550
1554
|
if (onDragLeave?.(event_14), !(event_14.isDefaultPrevented() || event_14.isPropagationStopped() || !getEventPosition({
|
|
1551
|
-
|
|
1555
|
+
editorActor,
|
|
1552
1556
|
slateEditor,
|
|
1553
1557
|
event: event_14.nativeEvent
|
|
1554
1558
|
})))
|