@portabletext/editor 1.49.6 → 1.49.7
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 +12 -4
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +12 -4
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/editor/sync-machine.ts +17 -0
package/package.json
CHANGED
|
@@ -383,6 +383,7 @@ async function updateValue({
|
|
|
383
383
|
streamBlocks: boolean
|
|
384
384
|
value: PortableTextBlock[] | undefined
|
|
385
385
|
}) {
|
|
386
|
+
let doneSyncing = false
|
|
386
387
|
let isChanged = false
|
|
387
388
|
let isValid = true
|
|
388
389
|
|
|
@@ -394,6 +395,10 @@ async function updateValue({
|
|
|
394
395
|
Editor.withoutNormalizing(slateEditor, () => {
|
|
395
396
|
withoutSaving(slateEditor, () => {
|
|
396
397
|
withoutPatching(slateEditor, () => {
|
|
398
|
+
if (doneSyncing) {
|
|
399
|
+
return
|
|
400
|
+
}
|
|
401
|
+
|
|
397
402
|
if (hadSelection) {
|
|
398
403
|
Transforms.deselect(slateEditor)
|
|
399
404
|
}
|
|
@@ -428,6 +433,11 @@ async function updateValue({
|
|
|
428
433
|
Editor.withoutNormalizing(slateEditor, () => {
|
|
429
434
|
withRemoteChanges(slateEditor, () => {
|
|
430
435
|
withoutPatching(slateEditor, () => {
|
|
436
|
+
if (doneSyncing) {
|
|
437
|
+
resolve()
|
|
438
|
+
return
|
|
439
|
+
}
|
|
440
|
+
|
|
431
441
|
isChanged = removeExtraBlocks({
|
|
432
442
|
slateEditor,
|
|
433
443
|
slateValueFromProps,
|
|
@@ -465,6 +475,10 @@ async function updateValue({
|
|
|
465
475
|
Editor.withoutNormalizing(slateEditor, () => {
|
|
466
476
|
withRemoteChanges(slateEditor, () => {
|
|
467
477
|
withoutPatching(slateEditor, () => {
|
|
478
|
+
if (doneSyncing) {
|
|
479
|
+
return
|
|
480
|
+
}
|
|
481
|
+
|
|
468
482
|
isChanged = removeExtraBlocks({
|
|
469
483
|
slateEditor,
|
|
470
484
|
slateValueFromProps,
|
|
@@ -494,6 +508,7 @@ async function updateValue({
|
|
|
494
508
|
|
|
495
509
|
if (!isValid) {
|
|
496
510
|
debug('Invalid value, returning')
|
|
511
|
+
doneSyncing = true
|
|
497
512
|
sendBack({type: 'done syncing', value})
|
|
498
513
|
return
|
|
499
514
|
}
|
|
@@ -509,6 +524,7 @@ async function updateValue({
|
|
|
509
524
|
resolution: null,
|
|
510
525
|
value,
|
|
511
526
|
})
|
|
527
|
+
doneSyncing = true
|
|
512
528
|
sendBack({type: 'done syncing', value})
|
|
513
529
|
return
|
|
514
530
|
}
|
|
@@ -524,6 +540,7 @@ async function updateValue({
|
|
|
524
540
|
debug('Server value and editor value is equal, no need to sync.')
|
|
525
541
|
}
|
|
526
542
|
|
|
543
|
+
doneSyncing = true
|
|
527
544
|
sendBack({type: 'done syncing', value})
|
|
528
545
|
}
|
|
529
546
|
|