@portabletext/editor 2.21.3 → 2.21.4
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.
|
@@ -1697,7 +1697,7 @@ declare const editorMachine: xstate229.StateMachine<{
|
|
|
1697
1697
|
}, xstate229.AnyEventObject>;
|
|
1698
1698
|
}) => {
|
|
1699
1699
|
behaviors: Set<{
|
|
1700
|
-
behavior: Behavior<"*" | "split" | `custom.${string}` | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "
|
|
1700
|
+
behavior: Behavior<"*" | "split" | `custom.${string}` | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "history.*" | "split.*" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "style.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*", true, {
|
|
1701
1701
|
type: StrictExtract<"split" | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle", "annotation.add">;
|
|
1702
1702
|
annotation: {
|
|
1703
1703
|
name: string;
|
package/lib/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import { toHTML } from "@portabletext/to-html";
|
|
|
24
24
|
import { Schema } from "@sanity/schema";
|
|
25
25
|
import flatten from "lodash/flatten.js";
|
|
26
26
|
import omit from "lodash/omit.js";
|
|
27
|
-
import { applyAll, unset, insert,
|
|
27
|
+
import { applyAll, unset, insert, setIfMissing, set, diffMatchPatch as diffMatchPatch$1 } from "@portabletext/patches";
|
|
28
28
|
import { createDraft, finishDraft } from "immer";
|
|
29
29
|
import { createKeyboardShortcut, code, underline, italic, bold, undo, redo } from "@portabletext/keyboard-shortcuts";
|
|
30
30
|
import { sliceTextBlock } from "./_chunks-es/util.slice-text-block.js";
|
|
@@ -6074,12 +6074,14 @@ function insertNodePatch(schema, children, operation, beforeValue) {
|
|
|
6074
6074
|
...operation.node
|
|
6075
6075
|
};
|
|
6076
6076
|
!node._type && Text.isText(node) && (node._type = "span", node.marks = []);
|
|
6077
|
-
const
|
|
6077
|
+
const setIfMissingPatch = setIfMissing([], [{
|
|
6078
|
+
_key: block._key
|
|
6079
|
+
}, "children"]), child = fromSlateValue([{
|
|
6078
6080
|
_key: "bogus",
|
|
6079
6081
|
_type: schema.block.name,
|
|
6080
6082
|
children: [node]
|
|
6081
6083
|
}], schema.block.name)[0].children[0];
|
|
6082
|
-
return [insert([child], position, [{
|
|
6084
|
+
return [setIfMissingPatch, insert([child], position, [{
|
|
6083
6085
|
_key: block._key
|
|
6084
6086
|
}, "children", block.children.length <= 1 || !block.children[operation.path[1] - 1] ? 0 : {
|
|
6085
6087
|
_key: block.children[operation.path[1] - 1]._key
|
|
@@ -6121,7 +6123,9 @@ function splitNodePatch(schema, children, operation, beforeValue) {
|
|
|
6121
6123
|
...splitBlock,
|
|
6122
6124
|
children: splitBlock.children.slice(operation.path[1] + 1, operation.path[1] + 2)
|
|
6123
6125
|
}], schema.block.name)[0].children;
|
|
6124
|
-
patches.push(
|
|
6126
|
+
patches.push(setIfMissing([], [{
|
|
6127
|
+
_key: splitBlock._key
|
|
6128
|
+
}, "children"])), patches.push(insert(targetSpans, "after", [{
|
|
6125
6129
|
_key: splitBlock._key
|
|
6126
6130
|
}, "children", {
|
|
6127
6131
|
_key: splitSpan._key
|
|
@@ -6210,7 +6214,9 @@ function moveNodePatch(schema, beforeValue, operation) {
|
|
|
6210
6214
|
_key: block._key
|
|
6211
6215
|
}, "children", {
|
|
6212
6216
|
_key: child._key
|
|
6213
|
-
}])), patches.push(
|
|
6217
|
+
}])), patches.push(setIfMissing([], [{
|
|
6218
|
+
_key: targetBlock._key
|
|
6219
|
+
}, "children"])), patches.push(insert([childToInsert], position, [{
|
|
6214
6220
|
_key: targetBlock._key
|
|
6215
6221
|
}, "children", {
|
|
6216
6222
|
_key: targetChild._key
|
|
@@ -12044,7 +12050,7 @@ function syncBlock({
|
|
|
12044
12050
|
type: "patch",
|
|
12045
12051
|
patch
|
|
12046
12052
|
});
|
|
12047
|
-
})), validation.valid || validation.resolution?.autoResolve ? (oldBlock._key === block._key ? (debug$2.enabled && debug$2("Updating block", oldBlock, block), Editor.withoutNormalizing(slateEditor, () => {
|
|
12053
|
+
})), 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, () => {
|
|
12048
12054
|
withRemoteChanges(slateEditor, () => {
|
|
12049
12055
|
withoutPatching(slateEditor, () => {
|
|
12050
12056
|
updateBlock({
|
|
@@ -12116,7 +12122,7 @@ function updateBlock({
|
|
|
12116
12122
|
}), slateBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
|
|
12117
12123
|
const oldBlockChild = oldBlock.children[currentBlockChildIndex], isChildChanged = !isEqual(currentBlockChild, oldBlockChild), isTextChanged = !isEqual(currentBlockChild.text, oldBlockChild?.text), path = [index, currentBlockChildIndex];
|
|
12118
12124
|
if (isChildChanged)
|
|
12119
|
-
if (currentBlockChild._key === oldBlockChild?._key) {
|
|
12125
|
+
if (currentBlockChild._key === oldBlockChild?._key && currentBlockChild._type === oldBlockChild?._type) {
|
|
12120
12126
|
debug$2("Updating changed child", currentBlockChild, oldBlockChild), Transforms.setNodes(slateEditor, currentBlockChild, {
|
|
12121
12127
|
at: path
|
|
12122
12128
|
});
|