@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.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) => {
@@ -3046,6 +3048,10 @@ async function updateValue({
3046
3048
  Editor.withoutNormalizing(slateEditor, () => {
3047
3049
  withRemoteChanges(slateEditor, () => {
3048
3050
  withoutPatching(slateEditor, () => {
3051
+ if (doneSyncing) {
3052
+ resolve();
3053
+ return;
3054
+ }
3049
3055
  isChanged = removeExtraBlocks({
3050
3056
  slateEditor,
3051
3057
  slateValueFromProps
@@ -3074,6 +3080,8 @@ async function updateValue({
3074
3080
  }) : Editor.withoutNormalizing(slateEditor, () => {
3075
3081
  withRemoteChanges(slateEditor, () => {
3076
3082
  withoutPatching(slateEditor, () => {
3083
+ if (doneSyncing)
3084
+ return;
3077
3085
  isChanged = removeExtraBlocks({
3078
3086
  slateEditor,
3079
3087
  slateValueFromProps
@@ -3098,7 +3106,7 @@ async function updateValue({
3098
3106
  });
3099
3107
  }
3100
3108
  if (!isValid) {
3101
- debug$g("Invalid value, returning"), sendBack({
3109
+ debug$g("Invalid value, returning"), doneSyncing = !0, sendBack({
3102
3110
  type: "done syncing",
3103
3111
  value
3104
3112
  });
@@ -3113,7 +3121,7 @@ async function updateValue({
3113
3121
  type: "invalid value",
3114
3122
  resolution: null,
3115
3123
  value
3116
- }), sendBack({
3124
+ }), doneSyncing = !0, sendBack({
3117
3125
  type: "done syncing",
3118
3126
  value
3119
3127
  });
@@ -3134,7 +3142,7 @@ async function updateValue({
3134
3142
  });
3135
3143
  } else
3136
3144
  debug$g("Server value and editor value is equal, no need to sync.");
3137
- sendBack({
3145
+ doneSyncing = !0, sendBack({
3138
3146
  type: "done syncing",
3139
3147
  value
3140
3148
  });