@portabletext/editor 4.3.5 → 4.3.6
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-dts/behavior.types.action.d.ts +25 -19
- package/lib/_chunks-dts/behavior.types.action.d.ts.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +7 -19
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.js +29 -2
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Element as Element$1, Text, Range, Editor, Node, Point, Path, Transform
|
|
|
6
6
|
import { useSlateStatic, useSlateSelector, ReactEditor, useSlate, Editable, withReact, Slate } from "slate-react";
|
|
7
7
|
import rawDebug from "debug";
|
|
8
8
|
import { DOMEditor, isDOMNode, EDITOR_TO_PENDING_SELECTION, IS_FOCUSED, IS_READ_ONLY } from "slate-dom";
|
|
9
|
-
import { getBlockEndPoint, getBlockStartPoint, getBlockKeyFromSelectionPoint, isSelectionCollapsed, isKeyedSegment, isEqualSelectionPoints, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, defaultKeyGenerator, parseBlocks, parseBlock, isListBlock, isTypedObject, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint as getSelectionEndPoint$1, parseAnnotation, parseMarkDefs, parseSpan, parseInlineObject } from "./_chunks-es/util.slice-blocks.js";
|
|
9
|
+
import { getBlockEndPoint, getBlockStartPoint, getBlockKeyFromSelectionPoint, isSelectionCollapsed, isKeyedSegment, isEqualSelectionPoints, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, defaultKeyGenerator, parseBlocks, parseBlock, isListBlock, isTypedObject, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint as getSelectionEndPoint$1, parseAnnotation, parseMarkDefs, parseSpan, parseInlineObject, isEqualPathSegments } from "./_chunks-es/util.slice-blocks.js";
|
|
10
10
|
import { isTextBlock, isSpan, compileSchema } from "@portabletext/schema";
|
|
11
11
|
import { defineSchema } from "@portabletext/schema";
|
|
12
12
|
import { isEmptyTextBlock, sliceTextBlock, getTextBlockText } from "./_chunks-es/util.slice-text-block.js";
|
|
@@ -11327,6 +11327,13 @@ function sortByPriority(items) {
|
|
|
11327
11327
|
result.includes(item) || result.push(item);
|
|
11328
11328
|
return [...result, ...itemsWithoutPriority];
|
|
11329
11329
|
}
|
|
11330
|
+
function pathsOverlap(pathA, pathB) {
|
|
11331
|
+
const minLength = Math.min(pathA.length, pathB.length);
|
|
11332
|
+
for (let i = 0; i < minLength; i++)
|
|
11333
|
+
if (!isEqualPathSegments(pathA[i], pathB[i]))
|
|
11334
|
+
return !1;
|
|
11335
|
+
return !0;
|
|
11336
|
+
}
|
|
11330
11337
|
function rerouteExternalBehaviorEvent({
|
|
11331
11338
|
event,
|
|
11332
11339
|
slateEditor
|
|
@@ -11422,6 +11429,20 @@ const editorMachine = setup({
|
|
|
11422
11429
|
"clear pending events": assign({
|
|
11423
11430
|
pendingEvents: []
|
|
11424
11431
|
}),
|
|
11432
|
+
"discard conflicting pending patches": assign({
|
|
11433
|
+
pendingEvents: ({
|
|
11434
|
+
context,
|
|
11435
|
+
event
|
|
11436
|
+
}) => {
|
|
11437
|
+
if (event.type !== "patches")
|
|
11438
|
+
return context.pendingEvents;
|
|
11439
|
+
const incomingPaths = event.patches.map((patch) => patch.path);
|
|
11440
|
+
return context.pendingEvents.filter((pendingEvent) => pendingEvent.type !== "internal.patch" ? !0 : !incomingPaths.some((incomingPath) => pathsOverlap(pendingEvent.patch.path, incomingPath)));
|
|
11441
|
+
}
|
|
11442
|
+
}),
|
|
11443
|
+
"discard all pending events": assign({
|
|
11444
|
+
pendingEvents: []
|
|
11445
|
+
}),
|
|
11425
11446
|
"defer incoming patches": assign({
|
|
11426
11447
|
pendingIncomingPatchesEvents: ({
|
|
11427
11448
|
context,
|
|
@@ -11821,7 +11842,13 @@ const editorMachine = setup({
|
|
|
11821
11842
|
}, {
|
|
11822
11843
|
actions: "defer event",
|
|
11823
11844
|
target: "#editor.setup.set up.writing.dirty"
|
|
11824
|
-
}]
|
|
11845
|
+
}],
|
|
11846
|
+
patches: {
|
|
11847
|
+
actions: "discard conflicting pending patches"
|
|
11848
|
+
},
|
|
11849
|
+
"syncing value": {
|
|
11850
|
+
actions: "discard all pending events"
|
|
11851
|
+
}
|
|
11825
11852
|
}
|
|
11826
11853
|
}
|
|
11827
11854
|
}
|