@portabletext/editor 1.58.0 → 1.58.1

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.cjs CHANGED
@@ -4537,7 +4537,9 @@ function insertNodePatch(schema2, children, operation, beforeValue) {
4537
4537
  _type: schema2.block.name,
4538
4538
  children: [node]
4539
4539
  }], schema2.block.name)[0].children[0];
4540
- return [patches.insert([child], position, [{
4540
+ return [patches.setIfMissing([], [{
4541
+ _key: block._key
4542
+ }, "children"]), patches.insert([child], position, [{
4541
4543
  _key: block._key
4542
4544
  }, "children", block.children.length <= 1 || !block.children[operation.path[1] - 1] ? 0 : {
4543
4545
  _key: block.children[operation.path[1] - 1]._key
@@ -4579,7 +4581,9 @@ function splitNodePatch(schema2, children, operation, beforeValue) {
4579
4581
  ...splitBlock,
4580
4582
  children: splitBlock.children.slice(operation.path[1] + 1, operation.path[1] + 2)
4581
4583
  }], schema2.block.name)[0].children;
4582
- patches$1.push(patches.insert(targetSpans, "after", [{
4584
+ patches$1.push(patches.setIfMissing([], [{
4585
+ _key: splitBlock._key
4586
+ }, "children"])), patches$1.push(patches.insert(targetSpans, "after", [{
4583
4587
  _key: splitBlock._key
4584
4588
  }, "children", {
4585
4589
  _key: splitSpan._key
@@ -4668,7 +4672,9 @@ function moveNodePatch(schema2, beforeValue, operation) {
4668
4672
  _key: block._key
4669
4673
  }, "children", {
4670
4674
  _key: child._key
4671
- }])), patches$1.push(patches.insert([childToInsert], position, [{
4675
+ }])), patches$1.push(patches.setIfMissing([], [{
4676
+ _key: targetBlock._key
4677
+ }, "children"])), patches$1.push(patches.insert([childToInsert], position, [{
4672
4678
  _key: targetBlock._key
4673
4679
  }, "children", {
4674
4680
  _key: targetChild._key
@@ -9741,7 +9747,7 @@ function syncBlock({
9741
9747
  type: "patch",
9742
9748
  patch
9743
9749
  });
9744
- })), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === currentBlock._key ? (debug$4.enabled && debug$4("Updating block", oldBlock, currentBlock), _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex)) : (debug$4.enabled && debug$4("Replacing block", oldBlock, currentBlock), _replaceBlock(slateEditor, currentBlock, currentBlockIndex)), blockChanged = !0) : (sendBack({
9750
+ })), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === currentBlock._key && oldBlock._type === currentBlock._type ? (debug$4.enabled && debug$4("Updating block", oldBlock, currentBlock), _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex)) : (debug$4.enabled && debug$4("Replacing block", oldBlock, currentBlock), _replaceBlock(slateEditor, currentBlock, currentBlockIndex)), blockChanged = !0) : (sendBack({
9745
9751
  type: "invalid value",
9746
9752
  resolution: validation.resolution,
9747
9753
  value
@@ -9785,7 +9791,7 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
9785
9791
  }), currentBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
9786
9792
  const oldBlockChild = oldBlock.children[currentBlockChildIndex], isChildChanged = !isEqual__default.default(currentBlockChild, oldBlockChild), isTextChanged = !isEqual__default.default(currentBlockChild.text, oldBlockChild?.text), path = [currentBlockIndex, currentBlockChildIndex];
9787
9793
  if (isChildChanged)
9788
- if (currentBlockChild._key === oldBlockChild?._key) {
9794
+ if (currentBlockChild._key === oldBlockChild?._key && currentBlockChild._type === oldBlockChild?._type) {
9789
9795
  debug$4("Updating changed child", currentBlockChild, oldBlockChild), slate.Transforms.setNodes(slateEditor, currentBlockChild, {
9790
9796
  at: path
9791
9797
  });