@portabletext/editor 1.44.4 → 1.44.5

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.
@@ -1,32 +0,0 @@
1
- import type {BaseEditor, Operation} from 'slate'
2
- import type {ReactEditor} from 'slate-react'
3
- import type {PortableTextSlateEditor} from '../types/editor'
4
- import type {EditorActor} from './editor-machine'
5
-
6
- // React Compiler considers `slateEditor` as immutable, and opts-out if we do this inline in a useEffect, doing it in a function moves it out of the scope, and opts-in again for the rest of the component.
7
- export function withSyncRangeDecorations({
8
- editorActor,
9
- slateEditor,
10
- syncRangeDecorations,
11
- }: {
12
- editorActor: EditorActor
13
- slateEditor: BaseEditor & ReactEditor & PortableTextSlateEditor
14
- syncRangeDecorations: (operation?: Operation) => void
15
- }) {
16
- const originalApply = slateEditor.apply
17
-
18
- slateEditor.apply = (op: Operation) => {
19
- originalApply(op)
20
-
21
- if (
22
- !editorActor.getSnapshot().matches({'edit mode': 'read only'}) &&
23
- op.type !== 'set_selection'
24
- ) {
25
- syncRangeDecorations(op)
26
- }
27
- }
28
-
29
- return () => {
30
- slateEditor.apply = originalApply
31
- }
32
- }