@portabletext/editor 3.3.16 → 3.3.17

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
@@ -6611,11 +6611,13 @@ function insertNodePatch(schema, children, operation, beforeValue) {
6611
6611
  _key: block._key
6612
6612
  }, "children", {
6613
6613
  _key: block.children[operation.path[1] - 1]._key
6614
- }];
6614
+ }], setIfMissingPatch = setIfMissing([], [{
6615
+ _key: block._key
6616
+ }, "children"]);
6615
6617
  if (Text.isText(operation.node))
6616
- return [insert([operation.node], position, path)];
6618
+ return [setIfMissingPatch, insert([operation.node], position, path)];
6617
6619
  const _type = operation.node._type, _key = operation.node._key, value = "value" in operation.node && typeof operation.node.value == "object" ? operation.node.value : {};
6618
- return [insert([{
6620
+ return [setIfMissingPatch, insert([{
6619
6621
  _type,
6620
6622
  _key,
6621
6623
  ...value
@@ -6657,7 +6659,9 @@ function splitNodePatch(schema, children, operation, beforeValue) {
6657
6659
  ...splitBlock,
6658
6660
  children: splitBlock.children.slice(operation.path[1] + 1, operation.path[1] + 2)
6659
6661
  }, schema.block.name).children;
6660
- patches.push(insert(targetSpans, "after", [{
6662
+ patches.push(setIfMissing([], [{
6663
+ _key: splitBlock._key
6664
+ }, "children"])), patches.push(insert(targetSpans, "after", [{
6661
6665
  _key: splitBlock._key
6662
6666
  }, "children", {
6663
6667
  _key: splitSpan._key
@@ -6746,7 +6750,9 @@ function moveNodePatch(schema, beforeValue, operation) {
6746
6750
  _key: block._key
6747
6751
  }, "children", {
6748
6752
  _key: child._key
6749
- }])), patches.push(insert([childToInsert], position, [{
6753
+ }])), patches.push(setIfMissing([], [{
6754
+ _key: targetBlock._key
6755
+ }, "children"])), patches.push(insert([childToInsert], position, [{
6750
6756
  _key: targetBlock._key
6751
6757
  }, "children", {
6752
6758
  _key: targetChild._key
@@ -12296,7 +12302,7 @@ function syncBlock({
12296
12302
  type: "patch",
12297
12303
  patch
12298
12304
  });
12299
- })), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === block._key ? (debug$2.enabled && debug$2("Updating block", oldBlock, block), Editor.withoutNormalizing(slateEditor, () => {
12305
+ })), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === block._key && oldBlock._type === block._type ? (debug$2.enabled && debug$2("Updating block", oldBlock, block), Editor.withoutNormalizing(slateEditor, () => {
12300
12306
  withRemoteChanges(slateEditor, () => {
12301
12307
  withoutPatching(slateEditor, () => {
12302
12308
  updateBlock({
@@ -12366,9 +12372,9 @@ function updateBlock({
12366
12372
  at: [index2, childIndex]
12367
12373
  }));
12368
12374
  }), slateBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
12369
- const oldBlockChild = oldBlock.children.at(currentBlockChildIndex), isChildChanged = oldBlockChild && !isEqualChild(currentBlockChild, oldBlockChild), isTextChanged = oldBlockChild && Text.isText(oldBlockChild) && currentBlockChild.text !== oldBlockChild.text, path = [index, currentBlockChildIndex];
12375
+ const oldBlockChild = oldBlock.children.at(currentBlockChildIndex), isChildChanged = !oldBlockChild || !isEqualChild(currentBlockChild, oldBlockChild), isTextChanged = oldBlockChild && Text.isText(oldBlockChild) && currentBlockChild.text !== oldBlockChild.text, path = [index, currentBlockChildIndex];
12370
12376
  if (isChildChanged)
12371
- if (currentBlockChild._key === oldBlockChild?._key) {
12377
+ if (currentBlockChild._key === oldBlockChild?._key && currentBlockChild._type === oldBlockChild?._type) {
12372
12378
  debug$2("Updating changed child", currentBlockChild, oldBlockChild), Transforms.setNodes(slateEditor, currentBlockChild, {
12373
12379
  at: path
12374
12380
  });