@portabletext/editor 1.44.10 → 1.44.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/_chunks-cjs/behavior.core.cjs +38 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +2 -2
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +38 -8
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +2 -2
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/index.cjs +20 -16
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +20 -16
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/behavior.core.block-objects.ts +56 -8
- package/src/editor/Editable.tsx +24 -21
- package/src/editor/__tests__/PortableTextEditor.test.tsx +10 -0
- package/src/editor/__tests__/PortableTextEditorTester.tsx +3 -17
- package/src/editor/__tests__/RangeDecorations.test.tsx +6 -0
- package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +12 -5
- package/src/editor/__tests__/sync-value.test.tsx +5 -0
- package/src/editor/editor-machine.ts +1 -0
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +8 -3
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +3 -0
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +20 -12
- package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +5 -0
- package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +2 -0
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +10 -289
- package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +2 -0
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +3 -0
- package/src/editor/sync-machine.ts +8 -6
- package/src/internal-utils/__tests__/valueNormalization.test.tsx +2 -0
- package/src/internal-utils/event-position.ts +9 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {Editor, type BaseRange, type Node} from 'slate'
|
|
2
2
|
import {DOMEditor, isDOMNode} from 'slate-dom'
|
|
3
3
|
import type {EditorSchema, EditorSelection} from '..'
|
|
4
|
+
import type {EditorActor} from '../editor/editor-machine'
|
|
4
5
|
import type {PortableTextSlateEditor} from '../types/editor'
|
|
5
6
|
import * as utils from '../utils'
|
|
6
7
|
import {
|
|
@@ -21,14 +22,18 @@ export type EventPosition = {
|
|
|
21
22
|
export type EventPositionBlock = EventPosition['block']
|
|
22
23
|
|
|
23
24
|
export function getEventPosition({
|
|
24
|
-
|
|
25
|
+
editorActor,
|
|
25
26
|
slateEditor,
|
|
26
27
|
event,
|
|
27
28
|
}: {
|
|
28
|
-
|
|
29
|
+
editorActor: EditorActor
|
|
29
30
|
slateEditor: PortableTextSlateEditor
|
|
30
31
|
event: DragEvent | MouseEvent
|
|
31
32
|
}): EventPosition | undefined {
|
|
33
|
+
if (editorActor.getSnapshot().matches({setup: 'setting up'})) {
|
|
34
|
+
return undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
const node = getEventNode({slateEditor, event})
|
|
33
38
|
|
|
34
39
|
if (!node) {
|
|
@@ -37,13 +42,13 @@ export function getEventPosition({
|
|
|
37
42
|
|
|
38
43
|
const block = getNodeBlock({
|
|
39
44
|
editor: slateEditor,
|
|
40
|
-
schema,
|
|
45
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
41
46
|
node,
|
|
42
47
|
})
|
|
43
48
|
|
|
44
49
|
const positionBlock = getEventPositionBlock({node, slateEditor, event})
|
|
45
50
|
const selection = getEventSelection({
|
|
46
|
-
schema,
|
|
51
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
47
52
|
slateEditor,
|
|
48
53
|
event,
|
|
49
54
|
})
|