@portabletext/editor 1.49.5 → 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 +32 -23
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +32 -23
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/editor/sync-machine.ts +39 -18
package/lib/index.js
CHANGED
|
@@ -3020,11 +3020,13 @@ async function updateValue({
|
|
|
3020
3020
|
streamBlocks,
|
|
3021
3021
|
value
|
|
3022
3022
|
}) {
|
|
3023
|
-
let isChanged = !1, isValid = !0;
|
|
3023
|
+
let doneSyncing = !1, isChanged = !1, isValid = !0;
|
|
3024
3024
|
const hadSelection = !!slateEditor.selection;
|
|
3025
3025
|
if ((!value || value.length === 0) && (debug$g("Value is empty"), Editor.withoutNormalizing(slateEditor, () => {
|
|
3026
3026
|
withoutSaving(slateEditor, () => {
|
|
3027
3027
|
withoutPatching(slateEditor, () => {
|
|
3028
|
+
if (doneSyncing)
|
|
3029
|
+
return;
|
|
3028
3030
|
hadSelection && Transforms.deselect(slateEditor);
|
|
3029
3031
|
const childrenLength = slateEditor.children.length;
|
|
3030
3032
|
slateEditor.children.forEach((_, index) => {
|
|
@@ -3045,34 +3047,41 @@ async function updateValue({
|
|
|
3045
3047
|
streamBlocks ? await new Promise((resolve) => {
|
|
3046
3048
|
Editor.withoutNormalizing(slateEditor, () => {
|
|
3047
3049
|
withRemoteChanges(slateEditor, () => {
|
|
3048
|
-
withoutPatching(slateEditor,
|
|
3050
|
+
withoutPatching(slateEditor, () => {
|
|
3051
|
+
if (doneSyncing) {
|
|
3052
|
+
resolve();
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3049
3055
|
isChanged = removeExtraBlocks({
|
|
3050
3056
|
slateEditor,
|
|
3051
3057
|
slateValueFromProps
|
|
3052
|
-
})
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3058
|
+
}), (async () => {
|
|
3059
|
+
for await (const [currentBlock, currentBlockIndex] of getStreamedBlocks({
|
|
3060
|
+
slateValue: slateValueFromProps
|
|
3061
|
+
})) {
|
|
3062
|
+
const {
|
|
3063
|
+
blockChanged,
|
|
3064
|
+
blockValid
|
|
3065
|
+
} = syncBlock({
|
|
3066
|
+
context,
|
|
3067
|
+
sendBack,
|
|
3068
|
+
block: currentBlock,
|
|
3069
|
+
index: currentBlockIndex,
|
|
3070
|
+
slateEditor,
|
|
3071
|
+
value
|
|
3072
|
+
});
|
|
3073
|
+
isChanged = blockChanged || isChanged, isValid = isValid && blockValid;
|
|
3074
|
+
}
|
|
3075
|
+
resolve();
|
|
3076
|
+
})();
|
|
3070
3077
|
});
|
|
3071
3078
|
});
|
|
3072
3079
|
});
|
|
3073
3080
|
}) : Editor.withoutNormalizing(slateEditor, () => {
|
|
3074
3081
|
withRemoteChanges(slateEditor, () => {
|
|
3075
3082
|
withoutPatching(slateEditor, () => {
|
|
3083
|
+
if (doneSyncing)
|
|
3084
|
+
return;
|
|
3076
3085
|
isChanged = removeExtraBlocks({
|
|
3077
3086
|
slateEditor,
|
|
3078
3087
|
slateValueFromProps
|
|
@@ -3097,7 +3106,7 @@ async function updateValue({
|
|
|
3097
3106
|
});
|
|
3098
3107
|
}
|
|
3099
3108
|
if (!isValid) {
|
|
3100
|
-
debug$g("Invalid value, returning"), sendBack({
|
|
3109
|
+
debug$g("Invalid value, returning"), doneSyncing = !0, sendBack({
|
|
3101
3110
|
type: "done syncing",
|
|
3102
3111
|
value
|
|
3103
3112
|
});
|
|
@@ -3112,7 +3121,7 @@ async function updateValue({
|
|
|
3112
3121
|
type: "invalid value",
|
|
3113
3122
|
resolution: null,
|
|
3114
3123
|
value
|
|
3115
|
-
}), sendBack({
|
|
3124
|
+
}), doneSyncing = !0, sendBack({
|
|
3116
3125
|
type: "done syncing",
|
|
3117
3126
|
value
|
|
3118
3127
|
});
|
|
@@ -3133,7 +3142,7 @@ async function updateValue({
|
|
|
3133
3142
|
});
|
|
3134
3143
|
} else
|
|
3135
3144
|
debug$g("Server value and editor value is equal, no need to sync.");
|
|
3136
|
-
sendBack({
|
|
3145
|
+
doneSyncing = !0, sendBack({
|
|
3137
3146
|
type: "done syncing",
|
|
3138
3147
|
value
|
|
3139
3148
|
});
|