@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 +11 -5
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +12 -6
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/editor/sync-machine.ts +9 -3
- package/src/internal-utils/operation-to-patches.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "1.58.
|
|
3
|
+
"version": "1.58.1",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"slate-react": "0.117.3",
|
|
81
81
|
"use-effect-event": "^1.0.2",
|
|
82
82
|
"xstate": "^5.20.1",
|
|
83
|
-
"@portabletext/
|
|
83
|
+
"@portabletext/patches": "1.1.5",
|
|
84
84
|
"@portabletext/keyboard-shortcuts": "1.1.0",
|
|
85
|
-
"@portabletext/
|
|
85
|
+
"@portabletext/block-tools": "1.1.38"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@portabletext/toolkit": "^2.0.17",
|
|
@@ -680,7 +680,10 @@ function syncBlock({
|
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
if (validation.valid || validation.resolution?.autoResolve) {
|
|
683
|
-
if (
|
|
683
|
+
if (
|
|
684
|
+
oldBlock._key === currentBlock._key &&
|
|
685
|
+
oldBlock._type === currentBlock._type
|
|
686
|
+
) {
|
|
684
687
|
if (debug.enabled) debug('Updating block', oldBlock, currentBlock)
|
|
685
688
|
_updateBlock(
|
|
686
689
|
slateEditor,
|
|
@@ -806,8 +809,11 @@ function _updateBlock(
|
|
|
806
809
|
)
|
|
807
810
|
const path = [currentBlockIndex, currentBlockChildIndex]
|
|
808
811
|
if (isChildChanged) {
|
|
809
|
-
// Update if this is the same child
|
|
810
|
-
if (
|
|
812
|
+
// Update if this is the same child (same key and type)
|
|
813
|
+
if (
|
|
814
|
+
currentBlockChild._key === oldBlockChild?._key &&
|
|
815
|
+
currentBlockChild._type === oldBlockChild?._type
|
|
816
|
+
) {
|
|
811
817
|
debug('Updating changed child', currentBlockChild, oldBlockChild)
|
|
812
818
|
Transforms.setNodes(
|
|
813
819
|
slateEditor,
|
|
@@ -217,7 +217,9 @@ export function insertNodePatch(
|
|
|
217
217
|
schema.block.name,
|
|
218
218
|
)[0] as PortableTextTextBlock
|
|
219
219
|
const child = blk.children[0]
|
|
220
|
+
const setIfMissingPatch = setIfMissing([], [{_key: block._key}, 'children'])
|
|
220
221
|
return [
|
|
222
|
+
setIfMissingPatch,
|
|
221
223
|
insert([child], position, [
|
|
222
224
|
{_key: block._key},
|
|
223
225
|
'children',
|
|
@@ -281,6 +283,7 @@ export function splitNodePatch(
|
|
|
281
283
|
)[0] as PortableTextTextBlock
|
|
282
284
|
).children
|
|
283
285
|
|
|
286
|
+
patches.push(setIfMissing([], [{_key: splitBlock._key}, 'children']))
|
|
284
287
|
patches.push(
|
|
285
288
|
insert(targetSpans, 'after', [
|
|
286
289
|
{_key: splitBlock._key},
|
|
@@ -455,6 +458,7 @@ export function moveNodePatch(
|
|
|
455
458
|
fromSlateValue([block], schema.block.name)[0] as PortableTextTextBlock
|
|
456
459
|
).children[operation.path[1]]
|
|
457
460
|
patches.push(unset([{_key: block._key}, 'children', {_key: child._key}]))
|
|
461
|
+
patches.push(setIfMissing([], [{_key: targetBlock._key}, 'children']))
|
|
458
462
|
patches.push(
|
|
459
463
|
insert([childToInsert], position, [
|
|
460
464
|
{_key: targetBlock._key},
|