@portabletext/editor 4.3.6 → 4.3.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 +12 -6
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -4919,6 +4919,12 @@ function unsetPatch(editor, patch) {
|
|
|
4919
4919
|
at: [block.index]
|
|
4920
4920
|
}), !0;
|
|
4921
4921
|
}
|
|
4922
|
+
if (editor.isTextBlock(block.node)) {
|
|
4923
|
+
const propEntry = patch.path.slice(1).at(0);
|
|
4924
|
+
return propEntry === void 0 || typeof propEntry != "string" || ["_key", "_type", "children"].includes(propEntry) ? !1 : (Transforms.unsetNodes(editor, [propEntry], {
|
|
4925
|
+
at: [block.index]
|
|
4926
|
+
}), !0);
|
|
4927
|
+
}
|
|
4922
4928
|
return !1;
|
|
4923
4929
|
}
|
|
4924
4930
|
return !1;
|
|
@@ -5653,11 +5659,11 @@ function isTextBlockNode(context, node) {
|
|
|
5653
5659
|
function isSpanNode(context, node) {
|
|
5654
5660
|
return typeof node != "object" || node === null || "children" in node ? !1 : "_type" in node ? node._type === context.schema.span.name : "text" in node;
|
|
5655
5661
|
}
|
|
5656
|
-
function isPartialSpanNode(node) {
|
|
5657
|
-
return typeof node
|
|
5662
|
+
function isPartialSpanNode(context, node) {
|
|
5663
|
+
return !(typeof node != "object" || node === null || !("text" in node) || typeof node.text != "string" || "_type" in node && node._type !== context.schema.span.name);
|
|
5658
5664
|
}
|
|
5659
5665
|
function isObjectNode(context, node) {
|
|
5660
|
-
return !isEditorNode(node) && !isTextBlockNode(context, node) && !isSpanNode(context, node) && !isPartialSpanNode(node);
|
|
5666
|
+
return !isEditorNode(node) && !isTextBlockNode(context, node) && !isSpanNode(context, node) && !isPartialSpanNode(context, node);
|
|
5661
5667
|
}
|
|
5662
5668
|
function getBlock(root, path) {
|
|
5663
5669
|
const index = path.at(0);
|
|
@@ -5743,7 +5749,7 @@ function applyOperationToPortableTextImmutable(context, root, operation) {
|
|
|
5743
5749
|
if (!isTextBlockNode(context, parent))
|
|
5744
5750
|
return root;
|
|
5745
5751
|
let newChild;
|
|
5746
|
-
if (isPartialSpanNode(insertedNode))
|
|
5752
|
+
if (isPartialSpanNode(context, insertedNode))
|
|
5747
5753
|
newChild = insertedNode;
|
|
5748
5754
|
else if ("__inline" in insertedNode)
|
|
5749
5755
|
newChild = {
|
|
@@ -5790,7 +5796,7 @@ function applyOperationToPortableTextImmutable(context, root, operation) {
|
|
|
5790
5796
|
if (!node || !prev || !parent)
|
|
5791
5797
|
return root;
|
|
5792
5798
|
const index = path[path.length - 1];
|
|
5793
|
-
if (isPartialSpanNode(node) && isPartialSpanNode(prev)) {
|
|
5799
|
+
if (isPartialSpanNode(context, node) && isPartialSpanNode(context, prev)) {
|
|
5794
5800
|
const blockIndex = path[0], newPrev = {
|
|
5795
5801
|
...prev,
|
|
5796
5802
|
text: prev.text + node.text
|
|
@@ -5945,7 +5951,7 @@ function applyOperationToPortableTextImmutable(context, root, operation) {
|
|
|
5945
5951
|
children: replaceChild(root.children, path[0], newNode)
|
|
5946
5952
|
};
|
|
5947
5953
|
}
|
|
5948
|
-
if (isPartialSpanNode(node)) {
|
|
5954
|
+
if (isPartialSpanNode(context, node)) {
|
|
5949
5955
|
const newNode = {
|
|
5950
5956
|
...node
|
|
5951
5957
|
};
|