@portabletext/editor 1.0.13 → 1.0.15
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 +162 -123
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +162 -123
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +162 -123
- package/lib/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/editor/hooks/useSyncValue.ts +8 -17
- package/src/editor/plugins/createWithMaxBlocks.ts +20 -0
- package/src/editor/plugins/createWithObjectKeys.ts +22 -11
- package/src/editor/plugins/createWithPatches.ts +3 -6
- package/src/editor/plugins/createWithPlaceholderBlock.ts +20 -0
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +103 -97
- package/src/editor/plugins/createWithUndoRedo.ts +5 -3
- package/src/utils/withUndoRedo.ts +34 -0
- package/src/utils/withPreserveKeys.ts +0 -21
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {type Editor} from 'slate'
|
|
2
|
-
|
|
3
|
-
export const PRESERVE_KEYS: WeakMap<Editor, boolean | undefined> = new WeakMap()
|
|
4
|
-
|
|
5
|
-
export function withPreserveKeys(editor: Editor, fn: () => void): void {
|
|
6
|
-
const prev = isPreservingKeys(editor)
|
|
7
|
-
PRESERVE_KEYS.set(editor, true)
|
|
8
|
-
fn()
|
|
9
|
-
PRESERVE_KEYS.set(editor, prev)
|
|
10
|
-
}
|
|
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
|
-
|
|
19
|
-
export function isPreservingKeys(editor: Editor): boolean | undefined {
|
|
20
|
-
return PRESERVE_KEYS.get(editor)
|
|
21
|
-
}
|