@portabletext/editor 1.0.10 → 1.0.12

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.
@@ -146,17 +146,15 @@ export function createWithUndoRedo(
146
146
  ),
147
147
  )
148
148
  })
149
+ const reversedOperations = transformedOperations.map(Operation.inverse).reverse()
150
+
149
151
  try {
150
152
  Editor.withoutNormalizing(editor, () => {
151
153
  withPreserveKeys(editor, () => {
152
154
  withoutSaving(editor, () => {
153
- transformedOperations
154
- .map(Operation.inverse)
155
- .reverse()
156
- // eslint-disable-next-line max-nested-callbacks
157
- .forEach((op) => {
158
- editor.apply(op)
159
- })
155
+ reversedOperations.forEach((op) => {
156
+ editor.apply(op)
157
+ })
160
158
  })
161
159
  })
162
160
  })
@@ -101,6 +101,7 @@ Array [
101
101
  ],
102
102
  {schemaTypes},
103
103
  )
104
+
104
105
  expect(result).toMatchInlineSnapshot(`
105
106
  Array [
106
107
  Object {
@@ -9,6 +9,13 @@ export function withPreserveKeys(editor: Editor, fn: () => void): void {
9
9
  PRESERVE_KEYS.set(editor, prev)
10
10
  }
11
11
 
12
+ export function withoutPreserveKeys(editor: Editor, fn: () => void): void {
13
+ const prev = isPreservingKeys(editor)
14
+ PRESERVE_KEYS.set(editor, false)
15
+ fn()
16
+ PRESERVE_KEYS.set(editor, prev)
17
+ }
18
+
12
19
  export function isPreservingKeys(editor: Editor): boolean | undefined {
13
20
  return PRESERVE_KEYS.get(editor)
14
21
  }