@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 CHANGED
@@ -2992,11 +2992,13 @@ async function updateValue({
2992
2992
  streamBlocks,
2993
2993
  value
2994
2994
  }) {
2995
- let isChanged = !1, isValid = !0;
2995
+ let doneSyncing = !1, isChanged = !1, isValid = !0;
2996
2996
  const hadSelection = !!slateEditor.selection;
2997
2997
  if ((!value || value.length === 0) && (debug$g("Value is empty"), slate.Editor.withoutNormalizing(slateEditor, () => {
2998
2998
  withoutSaving(slateEditor, () => {
2999
2999
  withoutPatching(slateEditor, () => {
3000
+ if (doneSyncing)
3001
+ return;
3000
3002
  hadSelection && slate.Transforms.deselect(slateEditor);
3001
3003
  const childrenLength = slateEditor.children.length;
3002
3004
  slateEditor.children.forEach((_, index) => {
@@ -3018,6 +3020,10 @@ async function updateValue({
3018
3020
  slate.Editor.withoutNormalizing(slateEditor, () => {
3019
3021
  withRemoteChanges(slateEditor, () => {
3020
3022
  withoutPatching(slateEditor, () => {
3023
+ if (doneSyncing) {
3024
+ resolve();
3025
+ return;
3026
+ }
3021
3027
  isChanged = removeExtraBlocks({
3022
3028
  slateEditor,
3023
3029
  slateValueFromProps
@@ -3046,6 +3052,8 @@ async function updateValue({
3046
3052
  }) : slate.Editor.withoutNormalizing(slateEditor, () => {
3047
3053
  withRemoteChanges(slateEditor, () => {
3048
3054
  withoutPatching(slateEditor, () => {
3055
+ if (doneSyncing)
3056
+ return;
3049
3057
  isChanged = removeExtraBlocks({
3050
3058
  slateEditor,
3051
3059
  slateValueFromProps
@@ -3070,7 +3078,7 @@ async function updateValue({
3070
3078
  });
3071
3079
  }
3072
3080
  if (!isValid) {
3073
- debug$g("Invalid value, returning"), sendBack({
3081
+ debug$g("Invalid value, returning"), doneSyncing = !0, sendBack({
3074
3082
  type: "done syncing",
3075
3083
  value
3076
3084
  });
@@ -3085,7 +3093,7 @@ async function updateValue({
3085
3093
  type: "invalid value",
3086
3094
  resolution: null,
3087
3095
  value
3088
- }), sendBack({
3096
+ }), doneSyncing = !0, sendBack({
3089
3097
  type: "done syncing",
3090
3098
  value
3091
3099
  });
@@ -3106,7 +3114,7 @@ async function updateValue({
3106
3114
  });
3107
3115
  } else
3108
3116
  debug$g("Server value and editor value is equal, no need to sync.");
3109
- sendBack({
3117
+ doneSyncing = !0, sendBack({
3110
3118
  type: "done syncing",
3111
3119
  value
3112
3120
  });