@portabletext/editor 1.47.7 → 1.47.8
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.
|
@@ -14,7 +14,7 @@ import isPlainObject from "lodash/isPlainObject.js";
|
|
|
14
14
|
import uniq from "lodash/uniq.js";
|
|
15
15
|
import getRandomValues from "get-random-values-esm";
|
|
16
16
|
import { parseBlock, parseAnnotation, isTextBlock, parseInlineObject } from "./parse-blocks.js";
|
|
17
|
-
import { sliceBlocks, blockOffsetToSpanSelectionPoint, getBlockEndPoint, getBlockStartPoint, getTextBlockText } from "./util.slice-blocks.js";
|
|
17
|
+
import { sliceBlocks, blockOffsetToSpanSelectionPoint, isEmptyTextBlock, getBlockEndPoint, getBlockStartPoint, getTextBlockText } from "./util.slice-blocks.js";
|
|
18
18
|
import { htmlToBlocks } from "@portabletext/block-tools";
|
|
19
19
|
import { toHTML } from "@portabletext/to-html";
|
|
20
20
|
import { Schema } from "@sanity/schema";
|
|
@@ -5941,15 +5941,29 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
5941
5941
|
guard: ({
|
|
5942
5942
|
snapshot,
|
|
5943
5943
|
event
|
|
5944
|
-
}) =>
|
|
5944
|
+
}) => {
|
|
5945
|
+
if (event.placement !== "auto")
|
|
5946
|
+
return !1;
|
|
5947
|
+
const focusTextBlock = getFocusTextBlock(snapshot);
|
|
5948
|
+
return focusTextBlock ? {
|
|
5949
|
+
focusTextBlock
|
|
5950
|
+
} : !1;
|
|
5951
|
+
},
|
|
5945
5952
|
actions: [({
|
|
5946
5953
|
event
|
|
5954
|
+
}, {
|
|
5955
|
+
focusTextBlock
|
|
5947
5956
|
}) => event.blocks.length === 1 ? [raise({
|
|
5948
5957
|
type: "insert.block",
|
|
5949
5958
|
block: event.blocks[0],
|
|
5950
5959
|
placement: "auto",
|
|
5951
5960
|
select: "end"
|
|
5952
|
-
})] : event.blocks.
|
|
5961
|
+
})] : isEmptyTextBlock(focusTextBlock.node) ? event.blocks.map((block, index) => raise({
|
|
5962
|
+
type: "insert.block",
|
|
5963
|
+
block,
|
|
5964
|
+
placement: index === 0 ? "auto" : "after",
|
|
5965
|
+
select: "end"
|
|
5966
|
+
})) : event.blocks.flatMap((block, index) => index === 0 ? [raise({
|
|
5953
5967
|
type: "split.block"
|
|
5954
5968
|
}), raise({
|
|
5955
5969
|
type: "select.previous block",
|