@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.
- package/lib/index.esm.js +203 -202
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +199 -198
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +203 -202
- package/lib/index.mjs.map +1 -1
- package/package.json +20 -18
- package/src/editor/__tests__/PortableTextEditor.test.tsx +15 -1
- package/src/editor/__tests__/handleClick.test.tsx +40 -20
- package/src/editor/__tests__/insert-block.test.tsx +229 -0
- package/src/editor/__tests__/utils.ts +14 -15
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +62 -20
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +19 -0
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +259 -134
- package/src/editor/plugins/__tests__/withHotkeys.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withInsertBreak.test.tsx +18 -2
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +176 -154
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +17 -0
- package/src/editor/plugins/createWithEditableAPI.ts +41 -10
- package/src/editor/plugins/createWithObjectKeys.ts +23 -8
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +51 -1
- package/src/editor/plugins/createWithUndoRedo.ts +5 -7
- package/src/utils/__tests__/values.test.ts +1 -0
- package/src/utils/withPreserveKeys.ts +7 -0
|
@@ -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
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
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
|
})
|
|
@@ -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
|
}
|