@portabletext/editor 1.47.7 → 1.47.9
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/editor-provider.cjs +16 -2
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +17 -3
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/index.cjs +11 -8
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +12 -9
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +40 -30
- package/src/editor/range-decorations-machine.ts +19 -11
package/lib/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import isEqual from "lodash/isEqual.js";
|
|
|
18
18
|
import { isSelectingEntireBlocks } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
|
|
19
19
|
import { defineBehavior, isHotkey } from "./_chunks-es/behavior.core.js";
|
|
20
20
|
import uniq from "lodash/uniq.js";
|
|
21
|
-
import { setup, fromCallback, assign,
|
|
21
|
+
import { setup, fromCallback, assign, and } from "xstate";
|
|
22
22
|
function EditorEventListener(props) {
|
|
23
23
|
const $ = c(5), editor = useEditor(), on = useEffectEvent(props.on);
|
|
24
24
|
let t0;
|
|
@@ -762,15 +762,14 @@ const slateOperationCallback = ({
|
|
|
762
762
|
actions: {
|
|
763
763
|
"update pending range decorations": assign({
|
|
764
764
|
pendingRangeDecorations: ({
|
|
765
|
+
context,
|
|
765
766
|
event
|
|
766
|
-
}) =>
|
|
767
|
+
}) => event.type !== "range decorations updated" ? context.pendingRangeDecorations : event.rangeDecorations
|
|
767
768
|
}),
|
|
768
769
|
"set up initial range decorations": assign({
|
|
769
770
|
decoratedRanges: ({
|
|
770
|
-
context
|
|
771
|
-
event
|
|
771
|
+
context
|
|
772
772
|
}) => {
|
|
773
|
-
assertEvent(event, "ready");
|
|
774
773
|
const rangeDecorationState = [];
|
|
775
774
|
for (const rangeDecoration of context.pendingRangeDecorations) {
|
|
776
775
|
const slateRange = toSlateRange(rangeDecoration.selection, context.slateEditor);
|
|
@@ -795,7 +794,8 @@ const slateOperationCallback = ({
|
|
|
795
794
|
context,
|
|
796
795
|
event
|
|
797
796
|
}) => {
|
|
798
|
-
|
|
797
|
+
if (event.type !== "range decorations updated")
|
|
798
|
+
return context.decoratedRanges;
|
|
799
799
|
const rangeDecorationState = [];
|
|
800
800
|
for (const rangeDecoration of event.rangeDecorations) {
|
|
801
801
|
const slateRange = toSlateRange(rangeDecoration.selection, context.slateEditor);
|
|
@@ -820,7 +820,8 @@ const slateOperationCallback = ({
|
|
|
820
820
|
context,
|
|
821
821
|
event
|
|
822
822
|
}) => {
|
|
823
|
-
|
|
823
|
+
if (event.type !== "slate operation")
|
|
824
|
+
return context.decoratedRanges;
|
|
824
825
|
const rangeDecorationState = [];
|
|
825
826
|
for (const decoratedRange of context.decoratedRanges) {
|
|
826
827
|
const slateRange = toSlateRange(decoratedRange.rangeDecoration.selection, context.slateEditor);
|
|
@@ -862,8 +863,9 @@ const slateOperationCallback = ({
|
|
|
862
863
|
}),
|
|
863
864
|
"assign readOnly": assign({
|
|
864
865
|
readOnly: ({
|
|
866
|
+
context,
|
|
865
867
|
event
|
|
866
|
-
}) =>
|
|
868
|
+
}) => event.type !== "update read only" ? context.readOnly : event.readOnly
|
|
867
869
|
}),
|
|
868
870
|
"increment update count": assign({
|
|
869
871
|
updateCount: ({
|
|
@@ -885,7 +887,8 @@ const slateOperationCallback = ({
|
|
|
885
887
|
context,
|
|
886
888
|
event
|
|
887
889
|
}) => {
|
|
888
|
-
|
|
890
|
+
if (event.type !== "range decorations updated")
|
|
891
|
+
return !1;
|
|
889
892
|
const existingRangeDecorations = context.decoratedRanges.map((decoratedRange) => ({
|
|
890
893
|
anchor: decoratedRange.rangeDecoration.selection?.anchor,
|
|
891
894
|
focus: decoratedRange.rangeDecoration.selection?.focus
|