@portabletext/editor 1.44.7 → 1.44.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.
package/lib/index.js CHANGED
@@ -859,6 +859,9 @@ const slateOperationCallback = ({
859
859
  "slate operation listener": fromCallback(slateOperationCallback)
860
860
  },
861
861
  guards: {
862
+ "has pending range decorations": ({
863
+ context
864
+ }) => context.pendingRangeDecorations.length > 0,
862
865
  "has range decorations": ({
863
866
  context
864
867
  }) => context.decoratedRanges.length > 0,
@@ -912,10 +915,13 @@ const slateOperationCallback = ({
912
915
  "range decorations updated": {
913
916
  actions: ["update pending range decorations"]
914
917
  },
915
- ready: {
918
+ ready: [{
916
919
  target: "ready",
917
- actions: ["set up initial range decorations"]
918
- }
920
+ guard: "has pending range decorations",
921
+ actions: ["set up initial range decorations", "increment update count"]
922
+ }, {
923
+ target: "ready"
924
+ }]
919
925
  }
920
926
  },
921
927
  ready: {
@@ -947,7 +953,7 @@ const slateOperationCallback = ({
947
953
  }
948
954
  });
949
955
  function createDecorate(rangeDecorationActor) {
950
- return function([, path]) {
956
+ return function([node, path]) {
951
957
  if (isEqualToEmptyEditor(rangeDecorationActor.getSnapshot().context.slateEditor.children, rangeDecorationActor.getSnapshot().context.schema))
952
958
  return [{
953
959
  anchor: {
@@ -962,7 +968,10 @@ function createDecorate(rangeDecorationActor) {
962
968
  }];
963
969
  if (path.length === 0)
964
970
  return [];
965
- const result = rangeDecorationActor.getSnapshot().context.decoratedRanges.filter((item) => Range.isCollapsed(item) ? path.length !== 2 ? !1 : Path.equals(item.focus.path, path) && Path.equals(item.anchor.path, path) : Range.intersection(item, {
971
+ if (!Element$2.isElement(node) || node.children.length === 0)
972
+ return [];
973
+ const blockIndex = path.at(0);
974
+ return blockIndex === void 0 ? [] : rangeDecorationActor.getSnapshot().context.decoratedRanges.filter((decoratedRange) => Range.isCollapsed(decoratedRange) ? node.children.some((_, childIndex) => Path.equals(decoratedRange.anchor.path, [blockIndex, childIndex]) && Path.equals(decoratedRange.focus.path, [blockIndex, childIndex])) : Range.intersection(decoratedRange, {
966
975
  anchor: {
967
976
  path,
968
977
  offset: 0
@@ -971,8 +980,7 @@ function createDecorate(rangeDecorationActor) {
971
980
  path,
972
981
  offset: 0
973
982
  }
974
- }) || Range.includes(item, path));
975
- return result.length > 0 ? result : [];
983
+ }) || Range.includes(decoratedRange, path));
976
984
  };
977
985
  }
978
986
  const debug = debugWithName("component:Editable"), PLACEHOLDER_STYLE = {