@portabletext/editor 2.13.3 → 2.13.4
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/{selector.is-selection-expanded.cjs → selector.get-selection-text.cjs} +25 -25
- package/lib/_chunks-cjs/selector.get-selection-text.cjs.map +1 -0
- package/lib/_chunks-cjs/selector.get-text-before.cjs +4 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/{selector.is-selecting-entire-blocks.cjs → selector.is-active-style.cjs} +408 -399
- package/lib/_chunks-cjs/selector.is-active-style.cjs.map +1 -0
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +3 -3
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/{util.slice-blocks.cjs → util.get-text-block-text.cjs} +25 -26
- package/lib/_chunks-cjs/util.get-text-block-text.cjs.map +1 -0
- package/lib/_chunks-cjs/{util.is-selection-collapsed.cjs → util.is-empty-text-block.cjs} +9 -9
- package/lib/_chunks-cjs/util.is-empty-text-block.cjs.map +1 -0
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +2 -2
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-text-block.cjs +5 -5
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +270 -270
- package/lib/_chunks-dts/behavior.types.action.d.ts +315 -315
- package/lib/_chunks-es/{selector.is-selection-expanded.js → selector.get-selection-text.js} +20 -20
- package/lib/_chunks-es/selector.get-selection-text.js.map +1 -0
- package/lib/_chunks-es/selector.get-text-before.js +2 -2
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/{selector.is-selecting-entire-blocks.js → selector.is-active-style.js} +385 -376
- package/lib/_chunks-es/selector.is-active-style.js.map +1 -0
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/{util.slice-blocks.js → util.get-text-block-text.js} +25 -26
- package/lib/_chunks-es/util.get-text-block-text.js.map +1 -0
- package/lib/_chunks-es/{util.is-selection-collapsed.js → util.is-empty-text-block.js} +8 -8
- package/lib/_chunks-es/util.is-empty-text-block.js.map +1 -0
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-text-block.js +1 -1
- package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
- package/lib/index.cjs +225 -225
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +18 -18
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +21 -21
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +4 -4
- package/lib/plugins/index.d.ts +4 -4
- package/lib/plugins/index.js +3 -3
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +52 -52
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +5 -5
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +14 -14
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2 -2
- package/lib/utils/index.d.ts +2 -2
- package/lib/utils/index.js +3 -3
- package/lib/utils/index.js.map +1 -1
- package/package.json +12 -12
- package/src/behaviors/behavior.abstract.annotation.ts +3 -3
- package/src/behaviors/behavior.abstract.decorator.ts +2 -2
- package/src/behaviors/behavior.abstract.delete.ts +25 -16
- package/src/behaviors/behavior.abstract.deserialize.ts +4 -3
- package/src/behaviors/behavior.abstract.insert.ts +6 -7
- package/src/behaviors/behavior.abstract.keyboard.ts +7 -8
- package/src/behaviors/behavior.abstract.list-item.ts +2 -1
- package/src/behaviors/behavior.abstract.move.ts +2 -1
- package/src/behaviors/behavior.abstract.select.ts +4 -2
- package/src/behaviors/behavior.abstract.split.ts +33 -24
- package/src/behaviors/behavior.abstract.style.ts +2 -1
- package/src/behaviors/behavior.abstract.ts +8 -7
- package/src/behaviors/behavior.core.annotations.ts +8 -7
- package/src/behaviors/behavior.core.block-element.ts +7 -5
- package/src/behaviors/behavior.core.block-objects.ts +25 -27
- package/src/behaviors/behavior.core.dnd.ts +10 -8
- package/src/behaviors/behavior.core.insert-break.ts +45 -36
- package/src/behaviors/behavior.core.lists.ts +31 -25
- package/src/behaviors/behavior.decorator-pair.ts +26 -23
- package/src/behaviors/behavior.markdown.ts +26 -21
- package/src/converters/converter.portable-text.ts +3 -3
- package/src/converters/converter.text-html.serialize.test.ts +1 -1
- package/src/converters/converter.text-html.ts +3 -3
- package/src/converters/converter.text-plain.test.ts +1 -1
- package/src/converters/converter.text-plain.ts +3 -3
- package/src/editor/Editable.tsx +2 -2
- package/src/editor/components/render-span.tsx +3 -5
- package/src/editor/create-editor.ts +2 -2
- package/src/editor/create-slate-editor.tsx +1 -4
- package/src/editor/editor-dom.ts +2 -2
- package/src/editor/plugins/createWithEditableAPI.ts +5 -10
- package/src/editor/plugins/createWithMaxBlocks.ts +2 -2
- package/src/editor/plugins/createWithObjectKeys.ts +2 -2
- package/src/editor/plugins/createWithPatches.ts +3 -10
- package/src/editor/plugins/createWithPlaceholderBlock.ts +2 -2
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +2 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +1 -1
- package/src/editor/plugins/createWithUndoRedo.ts +6 -6
- package/src/editor/plugins/slate-plugin.update-selection.ts +1 -1
- package/src/editor/sync-machine.ts +2 -5
- package/src/{internal-utils → editor}/weakMaps.ts +1 -1
- package/src/editor/with-undo-step.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internal-utils/applyPatch.ts +2 -2
- package/src/internal-utils/build-index-maps.test.ts +1 -1
- package/src/internal-utils/create-test-snapshot.ts +1 -1
- package/src/internal-utils/event-position.ts +11 -9
- package/src/internal-utils/operation-to-patches.test.ts +1 -1
- package/src/internal-utils/portable-text-node.ts +1 -1
- package/src/internal-utils/selection-block-keys.ts +1 -1
- package/src/internal-utils/selection-focus-text.ts +1 -1
- package/src/internal-utils/to-slate-range.ts +4 -4
- package/src/operations/behavior.operation.annotation.add.ts +1 -1
- package/src/operations/behavior.operation.block.set.ts +1 -1
- package/src/operations/behavior.operation.block.unset.ts +2 -2
- package/src/operations/behavior.operation.decorator.add.ts +11 -9
- package/src/operations/behavior.operation.delete.ts +1 -1
- package/src/operations/behavior.operation.insert.block.ts +2 -2
- package/src/operations/behavior.operation.insert.child.ts +1 -1
- package/src/operations/behavior.operation.move.block.ts +1 -1
- package/src/plugins/plugin.behavior.tsx +1 -1
- package/src/plugins/plugin.decorator-shortcut.ts +3 -3
- package/src/plugins/plugin.internal.auto-close-brackets.ts +2 -1
- package/src/plugins/plugin.one-line.tsx +11 -11
- package/src/priority/priority.types.ts +1 -1
- package/src/{internal-utils → selectors}/drag-selection.test.ts +1 -1
- package/src/{internal-utils → selectors}/drag-selection.ts +26 -19
- package/src/selectors/selector.get-anchor-block.ts +1 -1
- package/src/selectors/selector.get-anchor-child.ts +1 -1
- package/src/selectors/selector.get-block-offsets.ts +3 -3
- package/src/selectors/selector.get-caret-word-selection.test.ts +1 -1
- package/src/selectors/selector.get-focus-block.ts +1 -1
- package/src/selectors/selector.get-focus-child.ts +1 -1
- package/src/selectors/selector.get-focus-list-block.ts +1 -1
- package/src/selectors/selector.get-list-state.test.ts +1 -1
- package/src/selectors/selector.get-mark-state.ts +1 -1
- package/src/selectors/selector.get-next-inline-object.ts +1 -1
- package/src/selectors/selector.get-next-span.ts +1 -1
- package/src/selectors/selector.get-previous-inline-object.ts +1 -1
- package/src/selectors/selector.get-previous-span.ts +1 -1
- package/src/selectors/selector.get-selected-blocks.ts +1 -1
- package/src/selectors/selector.get-selected-spans.test.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +2 -2
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -2
- package/src/selectors/selector.get-selected-value.test.ts +87 -1
- package/src/selectors/selector.get-selected-value.ts +4 -6
- package/src/selectors/selector.get-selection-end-point.ts +1 -1
- package/src/selectors/selector.get-selection-start-point.ts +1 -1
- package/src/selectors/selector.get-selection-text.test.ts +1 -1
- package/src/selectors/selector.get-selection.ts +1 -1
- package/src/selectors/selector.get-text-before.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.test.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.ts +5 -7
- package/src/selectors/selector.is-active-decorator.test.ts +2 -1
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -3
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -3
- package/src/selectors/selector.is-overlapping-selection.test.ts +1 -1
- package/src/selectors/selector.is-overlapping-selection.ts +1 -1
- package/src/selectors/selector.is-point-after-selection.ts +3 -3
- package/src/selectors/selector.is-point-before-selection.ts +3 -3
- package/src/selectors/selector.is-selecting-entire-blocks.ts +7 -5
- package/src/test/gherkin-parameter-types.ts +1 -1
- package/src/test/vitest/step-definitions.tsx +19 -9
- package/src/types/paths.ts +4 -1
- package/src/utils/util.at-the-beginning-of-block.ts +1 -1
- package/src/utils/util.block-offset.ts +4 -4
- package/src/utils/util.block-offsets-to-selection.ts +1 -1
- package/src/utils/util.child-selection-point-to-block-offset.ts +3 -3
- package/src/utils/util.get-selection-end-point.ts +1 -1
- package/src/utils/util.get-selection-start-point.ts +1 -1
- package/src/utils/util.merge-text-blocks.ts +2 -2
- package/src/utils/util.selection-point-to-block-offset.ts +1 -1
- package/src/{selection/selection-point.ts → utils/util.selection-point.ts} +1 -1
- package/src/utils/util.slice-blocks.ts +6 -6
- package/src/utils/util.slice-text-block.test.ts +3 -1
- package/src/utils/util.slice-text-block.ts +3 -3
- package/src/utils/util.split-text-block.ts +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +0 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +0 -1
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +0 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +0 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +0 -1
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +0 -1
- package/lib/_chunks-es/util.slice-blocks.js.map +0 -1
- /package/src/{internal-utils → editor}/withChanges.ts +0 -0
- /package/src/{internal-utils → editor}/withUndoRedo.ts +0 -0
- /package/src/{internal-utils → editor}/withoutPatching.ts +0 -0
- /package/src/{internal-utils → utils}/asserters.ts +0 -0
- /package/src/{editor → utils}/key-generator.ts +0 -0
- /package/src/{internal-utils → utils}/parse-blocks.test.ts +0 -0
- /package/src/{internal-utils → utils}/parse-blocks.ts +0 -0
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import {isTextBlock} from '@portabletext/schema'
|
|
2
|
-
import {isListBlock} from '../internal-utils/parse-blocks'
|
|
3
2
|
import {defaultKeyboardShortcuts} from '../keyboard-shortcuts/default-keyboard-shortcuts'
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '../
|
|
3
|
+
import {getFocusListBlock} from '../selectors/selector.get-focus-list-block'
|
|
4
|
+
import {getFocusSpan} from '../selectors/selector.get-focus-span'
|
|
5
|
+
import {getFocusTextBlock} from '../selectors/selector.get-focus-text-block'
|
|
6
|
+
import {getNextBlock} from '../selectors/selector.get-next-block'
|
|
7
|
+
import {getPreviousBlock} from '../selectors/selector.get-previous-block'
|
|
8
|
+
import {getSelectedBlocks} from '../selectors/selector.get-selected-blocks'
|
|
9
|
+
import {getSelectionEndPoint} from '../selectors/selector.get-selection-end-point'
|
|
10
|
+
import {getSelectionStartPoint} from '../selectors/selector.get-selection-start-point'
|
|
11
|
+
import {isSelectionCollapsed} from '../selectors/selector.is-selection-collapsed'
|
|
12
|
+
import {isListBlock} from '../utils/parse-blocks'
|
|
10
13
|
import {isAtTheBeginningOfBlock} from '../utils/util.at-the-beginning-of-block'
|
|
14
|
+
import {getBlockEndPoint} from '../utils/util.get-block-end-point'
|
|
15
|
+
import {getBlockStartPoint} from '../utils/util.get-block-start-point'
|
|
11
16
|
import {isEmptyTextBlock} from '../utils/util.is-empty-text-block'
|
|
17
|
+
import {isEqualSelectionPoints} from '../utils/util.is-equal-selection-points'
|
|
12
18
|
import {sliceTextBlock} from '../utils/util.slice-text-block'
|
|
13
19
|
import {raise} from './behavior.types.action'
|
|
14
20
|
import {defineBehavior} from './behavior.types.behavior'
|
|
@@ -18,7 +24,7 @@ const MAX_LIST_LEVEL = 10
|
|
|
18
24
|
const clearListOnBackspace = defineBehavior({
|
|
19
25
|
on: 'delete.backward',
|
|
20
26
|
guard: ({snapshot}) => {
|
|
21
|
-
const focusTextBlock =
|
|
27
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
22
28
|
|
|
23
29
|
if (!focusTextBlock) {
|
|
24
30
|
return false
|
|
@@ -53,9 +59,9 @@ const clearListOnBackspace = defineBehavior({
|
|
|
53
59
|
const unindentListOnBackspace = defineBehavior({
|
|
54
60
|
on: 'delete.backward',
|
|
55
61
|
guard: ({snapshot}) => {
|
|
56
|
-
const selectionCollapsed =
|
|
57
|
-
const focusTextBlock =
|
|
58
|
-
const focusSpan =
|
|
62
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
63
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
64
|
+
const focusSpan = getFocusSpan(snapshot)
|
|
59
65
|
|
|
60
66
|
if (!selectionCollapsed || !focusTextBlock || !focusSpan) {
|
|
61
67
|
return false
|
|
@@ -94,8 +100,8 @@ const unindentListOnBackspace = defineBehavior({
|
|
|
94
100
|
const mergeTextIntoListOnDelete = defineBehavior({
|
|
95
101
|
on: 'delete.forward',
|
|
96
102
|
guard: ({snapshot}) => {
|
|
97
|
-
const focusListBlock =
|
|
98
|
-
const nextBlock =
|
|
103
|
+
const focusListBlock = getFocusListBlock(snapshot)
|
|
104
|
+
const nextBlock = getNextBlock(snapshot)
|
|
99
105
|
|
|
100
106
|
if (!focusListBlock || !nextBlock) {
|
|
101
107
|
return false
|
|
@@ -135,8 +141,8 @@ const mergeTextIntoListOnDelete = defineBehavior({
|
|
|
135
141
|
const mergeTextIntoListOnBackspace = defineBehavior({
|
|
136
142
|
on: 'delete.backward',
|
|
137
143
|
guard: ({snapshot}) => {
|
|
138
|
-
const focusTextBlock =
|
|
139
|
-
const previousBlock =
|
|
144
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
145
|
+
const previousBlock = getPreviousBlock(snapshot)
|
|
140
146
|
|
|
141
147
|
if (!focusTextBlock || !previousBlock) {
|
|
142
148
|
return false
|
|
@@ -198,7 +204,7 @@ const mergeTextIntoListOnBackspace = defineBehavior({
|
|
|
198
204
|
const deletingListFromStart = defineBehavior({
|
|
199
205
|
on: 'delete',
|
|
200
206
|
guard: ({snapshot, event}) => {
|
|
201
|
-
const blocksToDelete =
|
|
207
|
+
const blocksToDelete = getSelectedBlocks({
|
|
202
208
|
...snapshot,
|
|
203
209
|
context: {
|
|
204
210
|
...snapshot.context,
|
|
@@ -223,14 +229,14 @@ const deletingListFromStart = defineBehavior({
|
|
|
223
229
|
return false
|
|
224
230
|
}
|
|
225
231
|
|
|
226
|
-
const deleteStartPoint =
|
|
232
|
+
const deleteStartPoint = getSelectionStartPoint({
|
|
227
233
|
...snapshot,
|
|
228
234
|
context: {
|
|
229
235
|
...snapshot.context,
|
|
230
236
|
selection: event.at,
|
|
231
237
|
},
|
|
232
238
|
})
|
|
233
|
-
const deleteEndPoint =
|
|
239
|
+
const deleteEndPoint = getSelectionEndPoint({
|
|
234
240
|
...snapshot,
|
|
235
241
|
context: {
|
|
236
242
|
...snapshot.context,
|
|
@@ -338,8 +344,8 @@ const deletingListFromStart = defineBehavior({
|
|
|
338
344
|
const clearListOnEnter = defineBehavior({
|
|
339
345
|
on: 'insert.break',
|
|
340
346
|
guard: ({snapshot}) => {
|
|
341
|
-
const selectionCollapsed =
|
|
342
|
-
const focusListBlock =
|
|
347
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
348
|
+
const focusListBlock = getFocusListBlock(snapshot)
|
|
343
349
|
|
|
344
350
|
if (
|
|
345
351
|
!selectionCollapsed ||
|
|
@@ -374,7 +380,7 @@ const indentListOnTab = defineBehavior({
|
|
|
374
380
|
return false
|
|
375
381
|
}
|
|
376
382
|
|
|
377
|
-
const selectedBlocks =
|
|
383
|
+
const selectedBlocks = getSelectedBlocks(snapshot)
|
|
378
384
|
const selectedListBlocks = selectedBlocks.flatMap((block) =>
|
|
379
385
|
isListBlock(snapshot.context, block.node)
|
|
380
386
|
? [
|
|
@@ -423,7 +429,7 @@ const unindentListOnShiftTab = defineBehavior({
|
|
|
423
429
|
return false
|
|
424
430
|
}
|
|
425
431
|
|
|
426
|
-
const selectedBlocks =
|
|
432
|
+
const selectedBlocks = getSelectedBlocks(snapshot)
|
|
427
433
|
const selectedListBlocks = selectedBlocks.flatMap((block) =>
|
|
428
434
|
isListBlock(snapshot.context, block.node)
|
|
429
435
|
? [
|
|
@@ -465,7 +471,7 @@ const unindentListOnShiftTab = defineBehavior({
|
|
|
465
471
|
const inheritListLevel = defineBehavior({
|
|
466
472
|
on: 'insert.blocks',
|
|
467
473
|
guard: ({snapshot, event}) => {
|
|
468
|
-
const focusListBlock =
|
|
474
|
+
const focusListBlock = getFocusListBlock(snapshot)
|
|
469
475
|
|
|
470
476
|
if (!focusListBlock) {
|
|
471
477
|
return false
|
|
@@ -541,7 +547,7 @@ const inheritListLevel = defineBehavior({
|
|
|
541
547
|
const inheritListItem = defineBehavior({
|
|
542
548
|
on: 'insert.blocks',
|
|
543
549
|
guard: ({snapshot, event}) => {
|
|
544
|
-
const focusListBlock =
|
|
550
|
+
const focusListBlock = getFocusListBlock(snapshot)
|
|
545
551
|
|
|
546
552
|
if (!focusListBlock) {
|
|
547
553
|
return false
|
|
@@ -635,7 +641,7 @@ const inheritListProperties = defineBehavior({
|
|
|
635
641
|
return false
|
|
636
642
|
}
|
|
637
643
|
|
|
638
|
-
const focusListBlock =
|
|
644
|
+
const focusListBlock = getFocusListBlock(snapshot)
|
|
639
645
|
|
|
640
646
|
if (!focusListBlock) {
|
|
641
647
|
return false
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type {EditorSchema} from '../editor/editor-schema'
|
|
2
2
|
import {createPairRegex} from '../internal-utils/get-text-to-emphasize'
|
|
3
|
-
import
|
|
3
|
+
import {getFocusTextBlock} from '../selectors/selector.get-focus-text-block'
|
|
4
|
+
import {getPreviousInlineObject} from '../selectors/selector.get-previous-inline-object'
|
|
5
|
+
import {getSelectionStartPoint} from '../selectors/selector.get-selection-start-point'
|
|
6
|
+
import {getBlockTextBefore} from '../selectors/selector.get-text-before'
|
|
4
7
|
import type {BlockOffset} from '../types/block-offset'
|
|
5
|
-
import
|
|
8
|
+
import {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'
|
|
9
|
+
import {blockOffsetsToSelection} from '../utils/util.block-offsets-to-selection'
|
|
10
|
+
import {childSelectionPointToBlockOffset} from '../utils/util.child-selection-point-to-block-offset'
|
|
6
11
|
import {effect, execute} from './behavior.types.action'
|
|
7
12
|
import {defineBehavior} from './behavior.types.behavior'
|
|
8
13
|
|
|
@@ -33,10 +38,10 @@ export function createDecoratorPairBehavior(config: {
|
|
|
33
38
|
return false
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
const focusTextBlock =
|
|
37
|
-
const selectionStartPoint =
|
|
41
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
42
|
+
const selectionStartPoint = getSelectionStartPoint(snapshot)
|
|
38
43
|
const selectionStartOffset = selectionStartPoint
|
|
39
|
-
?
|
|
44
|
+
? spanSelectionPointToBlockOffset({
|
|
40
45
|
context: {
|
|
41
46
|
schema: snapshot.context.schema,
|
|
42
47
|
value: snapshot.context.value,
|
|
@@ -49,7 +54,7 @@ export function createDecoratorPairBehavior(config: {
|
|
|
49
54
|
return false
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
const textBefore =
|
|
57
|
+
const textBefore = getBlockTextBefore(snapshot)
|
|
53
58
|
const newText = `${textBefore}${event.text}`
|
|
54
59
|
const textToDecorate = newText.match(regEx)?.at(0)
|
|
55
60
|
|
|
@@ -92,27 +97,25 @@ export function createDecoratorPairBehavior(config: {
|
|
|
92
97
|
// If the prefix is more than one character, then we need to check if
|
|
93
98
|
// there is an inline object inside it
|
|
94
99
|
if (prefixOffsets.focus.offset - prefixOffsets.anchor.offset > 1) {
|
|
95
|
-
const prefixSelection =
|
|
100
|
+
const prefixSelection = blockOffsetsToSelection({
|
|
96
101
|
context: snapshot.context,
|
|
97
102
|
offsets: prefixOffsets,
|
|
98
103
|
})
|
|
99
|
-
const inlineObjectBeforePrefixFocus =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
context
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
: null,
|
|
110
|
-
},
|
|
104
|
+
const inlineObjectBeforePrefixFocus = getPreviousInlineObject({
|
|
105
|
+
...snapshot,
|
|
106
|
+
context: {
|
|
107
|
+
...snapshot.context,
|
|
108
|
+
selection: prefixSelection
|
|
109
|
+
? {
|
|
110
|
+
anchor: prefixSelection.focus,
|
|
111
|
+
focus: prefixSelection.focus,
|
|
112
|
+
}
|
|
113
|
+
: null,
|
|
111
114
|
},
|
|
112
|
-
)
|
|
115
|
+
})
|
|
113
116
|
const inlineObjectBeforePrefixFocusOffset =
|
|
114
117
|
inlineObjectBeforePrefixFocus
|
|
115
|
-
?
|
|
118
|
+
? childSelectionPointToBlockOffset({
|
|
116
119
|
context: {
|
|
117
120
|
schema: snapshot.context.schema,
|
|
118
121
|
value: snapshot.context.value,
|
|
@@ -138,9 +141,9 @@ export function createDecoratorPairBehavior(config: {
|
|
|
138
141
|
// If the suffix is more than one character, then we need to check if
|
|
139
142
|
// there is an inline object inside it
|
|
140
143
|
if (suffixOffsets.focus.offset - suffixOffsets.anchor.offset > 1) {
|
|
141
|
-
const previousInlineObject =
|
|
144
|
+
const previousInlineObject = getPreviousInlineObject(snapshot)
|
|
142
145
|
const previousInlineObjectOffset = previousInlineObject
|
|
143
|
-
?
|
|
146
|
+
? childSelectionPointToBlockOffset({
|
|
144
147
|
context: {
|
|
145
148
|
schema: snapshot.context.schema,
|
|
146
149
|
value: snapshot.context.value,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {isTextBlock} from '@portabletext/schema'
|
|
2
2
|
import type {EditorSchema} from '../editor/editor-schema'
|
|
3
|
-
import
|
|
3
|
+
import {getFocusBlock} from '../selectors/selector.get-focus-block'
|
|
4
|
+
import {getFocusSpan} from '../selectors/selector.get-focus-span'
|
|
5
|
+
import {getFocusTextBlock} from '../selectors/selector.get-focus-text-block'
|
|
6
|
+
import {getPreviousInlineObject} from '../selectors/selector.get-previous-inline-object'
|
|
7
|
+
import {getBlockTextBefore} from '../selectors/selector.get-text-before'
|
|
8
|
+
import {isSelectionCollapsed} from '../selectors/selector.is-selection-collapsed'
|
|
4
9
|
import {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'
|
|
5
10
|
import {getTextBlockText} from '../utils/util.get-text-block-text'
|
|
6
11
|
import {execute} from './behavior.types.action'
|
|
@@ -30,15 +35,15 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
30
35
|
return false
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
const selectionCollapsed =
|
|
34
|
-
const focusTextBlock =
|
|
35
|
-
const focusSpan =
|
|
38
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
39
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
40
|
+
const focusSpan = getFocusSpan(snapshot)
|
|
36
41
|
|
|
37
42
|
if (!selectionCollapsed || !focusTextBlock || !focusSpan) {
|
|
38
43
|
return false
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
const previousInlineObject =
|
|
46
|
+
const previousInlineObject = getPreviousInlineObject(snapshot)
|
|
42
47
|
const blockOffset = spanSelectionPointToBlockOffset({
|
|
43
48
|
context: snapshot.context,
|
|
44
49
|
selectionPoint: {
|
|
@@ -121,15 +126,15 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
const hrObject = config.horizontalRuleObject?.(snapshot.context)
|
|
124
|
-
const focusBlock =
|
|
125
|
-
const selectionCollapsed =
|
|
129
|
+
const focusBlock = getFocusTextBlock(snapshot)
|
|
130
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
126
131
|
|
|
127
132
|
if (!hrObject || !focusBlock || !selectionCollapsed) {
|
|
128
133
|
return false
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
const previousInlineObject =
|
|
132
|
-
const textBefore =
|
|
136
|
+
const previousInlineObject = getPreviousInlineObject(snapshot)
|
|
137
|
+
const textBefore = getBlockTextBefore(snapshot)
|
|
133
138
|
const hrBlockOffsets = {
|
|
134
139
|
anchor: {
|
|
135
140
|
path: focusBlock.path,
|
|
@@ -180,7 +185,7 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
180
185
|
const hrRegExp = /^(---)$|(___)$|(\*\*\*)$/
|
|
181
186
|
const hrCharacters = text.match(hrRegExp)?.[0]
|
|
182
187
|
const hrObject = config.horizontalRuleObject?.(snapshot.context)
|
|
183
|
-
const focusBlock =
|
|
188
|
+
const focusBlock = getFocusBlock(snapshot)
|
|
184
189
|
|
|
185
190
|
if (!hrCharacters || !hrObject || !focusBlock) {
|
|
186
191
|
return false
|
|
@@ -240,9 +245,9 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
240
245
|
return false
|
|
241
246
|
}
|
|
242
247
|
|
|
243
|
-
const selectionCollapsed =
|
|
244
|
-
const focusTextBlock =
|
|
245
|
-
const focusSpan =
|
|
248
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
249
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
250
|
+
const focusSpan = getFocusSpan(snapshot)
|
|
246
251
|
|
|
247
252
|
if (!selectionCollapsed || !focusTextBlock || !focusSpan) {
|
|
248
253
|
return false
|
|
@@ -264,7 +269,7 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
264
269
|
return false
|
|
265
270
|
}
|
|
266
271
|
|
|
267
|
-
const previousInlineObject =
|
|
272
|
+
const previousInlineObject = getPreviousInlineObject(snapshot)
|
|
268
273
|
const blockText = getTextBlockText(focusTextBlock.node)
|
|
269
274
|
const markdownHeadingSearch = /^#+/.exec(blockText)
|
|
270
275
|
const level = markdownHeadingSearch
|
|
@@ -323,9 +328,9 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
323
328
|
const clearStyleOnBackspace = defineBehavior({
|
|
324
329
|
on: 'delete.backward',
|
|
325
330
|
guard: ({snapshot}) => {
|
|
326
|
-
const selectionCollapsed =
|
|
327
|
-
const focusTextBlock =
|
|
328
|
-
const focusSpan =
|
|
331
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
332
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
333
|
+
const focusSpan = getFocusSpan(snapshot)
|
|
329
334
|
|
|
330
335
|
if (!selectionCollapsed || !focusTextBlock || !focusSpan) {
|
|
331
336
|
return false
|
|
@@ -366,15 +371,15 @@ export function createMarkdownBehaviors(config: MarkdownBehaviorsConfig) {
|
|
|
366
371
|
return false
|
|
367
372
|
}
|
|
368
373
|
|
|
369
|
-
const selectionCollapsed =
|
|
370
|
-
const focusTextBlock =
|
|
371
|
-
const focusSpan =
|
|
374
|
+
const selectionCollapsed = isSelectionCollapsed(snapshot)
|
|
375
|
+
const focusTextBlock = getFocusTextBlock(snapshot)
|
|
376
|
+
const focusSpan = getFocusSpan(snapshot)
|
|
372
377
|
|
|
373
378
|
if (!selectionCollapsed || !focusTextBlock || !focusSpan) {
|
|
374
379
|
return false
|
|
375
380
|
}
|
|
376
381
|
|
|
377
|
-
const previousInlineObject =
|
|
382
|
+
const previousInlineObject = getPreviousInlineObject(snapshot)
|
|
378
383
|
const blockOffset = spanSelectionPointToBlockOffset({
|
|
379
384
|
context: snapshot.context,
|
|
380
385
|
selectionPoint: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import {getSelectedValue} from '../selectors/selector.get-selected-value'
|
|
2
|
+
import {parseBlock} from '../utils/parse-blocks'
|
|
3
3
|
import {defineConverter} from './converter.types'
|
|
4
4
|
|
|
5
5
|
export const converterPortableText = defineConverter({
|
|
@@ -16,7 +16,7 @@ export const converterPortableText = defineConverter({
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const blocks =
|
|
19
|
+
const blocks = getSelectedValue(snapshot)
|
|
20
20
|
|
|
21
21
|
if (blocks.length === 0) {
|
|
22
22
|
return {
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from '@portabletext/schema'
|
|
7
7
|
import type {PortableTextBlock, PortableTextTextBlock} from '@sanity/types'
|
|
8
8
|
import {describe, expect, test} from 'vitest'
|
|
9
|
-
import type {EditorSelection} from '..'
|
|
10
9
|
import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
|
|
10
|
+
import type {EditorSelection} from '../types/editor'
|
|
11
11
|
import {createConverterTextHtml} from './converter.text-html'
|
|
12
12
|
|
|
13
13
|
const decoratedParagraph: PortableTextTextBlock = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {htmlToBlocks} from '@portabletext/block-tools'
|
|
2
2
|
import {toHTML} from '@portabletext/to-html'
|
|
3
3
|
import type {PortableTextBlock} from '@sanity/types'
|
|
4
|
-
import {
|
|
5
|
-
import * as selectors from '../selectors'
|
|
4
|
+
import {getSelectedValue} from '../selectors/selector.get-selected-value'
|
|
6
5
|
import type {PortableTextMemberSchemaTypes} from '../types/editor'
|
|
6
|
+
import {parseBlock} from '../utils/parse-blocks'
|
|
7
7
|
import {defineConverter} from './converter.types'
|
|
8
8
|
|
|
9
9
|
export function createConverterTextHtml(
|
|
@@ -23,7 +23,7 @@ export function createConverterTextHtml(
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const blocks =
|
|
26
|
+
const blocks = getSelectedValue(snapshot)
|
|
27
27
|
|
|
28
28
|
const html = toHTML(blocks, {
|
|
29
29
|
onMissingComponent: false,
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from '@portabletext/schema'
|
|
7
7
|
import type {PortableTextBlock, PortableTextTextBlock} from '@sanity/types'
|
|
8
8
|
import {expect, test} from 'vitest'
|
|
9
|
-
import type {EditorSelection} from '..'
|
|
10
9
|
import {createTestSnapshot} from '../internal-utils/create-test-snapshot'
|
|
10
|
+
import type {EditorSelection} from '../types/editor'
|
|
11
11
|
import {createConverterTextPlain} from './converter.text-plain'
|
|
12
12
|
|
|
13
13
|
const b1: PortableTextTextBlock = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {htmlToBlocks} from '@portabletext/block-tools'
|
|
2
2
|
import {isTextBlock} from '@portabletext/schema'
|
|
3
3
|
import type {PortableTextBlock} from '@sanity/types'
|
|
4
|
-
import {
|
|
5
|
-
import * as selectors from '../selectors'
|
|
4
|
+
import {getSelectedValue} from '../selectors/selector.get-selected-value'
|
|
6
5
|
import type {PortableTextMemberSchemaTypes} from '../types/editor'
|
|
6
|
+
import {parseBlock} from '../utils/parse-blocks'
|
|
7
7
|
import {defineConverter} from './converter.types'
|
|
8
8
|
|
|
9
9
|
export function createConverterTextPlain(
|
|
@@ -23,7 +23,7 @@ export function createConverterTextPlain(
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const blocks =
|
|
26
|
+
const blocks = getSelectedValue(snapshot)
|
|
27
27
|
|
|
28
28
|
const data = blocks
|
|
29
29
|
.map((block) => {
|
package/src/editor/Editable.tsx
CHANGED
|
@@ -22,12 +22,10 @@ import {
|
|
|
22
22
|
} from 'slate-react'
|
|
23
23
|
import {debugWithName} from '../internal-utils/debug'
|
|
24
24
|
import {getEventPosition} from '../internal-utils/event-position'
|
|
25
|
-
import {parseBlocks} from '../internal-utils/parse-blocks'
|
|
26
25
|
import {normalizeSelection} from '../internal-utils/selection'
|
|
27
26
|
import {slateRangeToSelection} from '../internal-utils/slate-utils'
|
|
28
27
|
import {toSlateRange} from '../internal-utils/to-slate-range'
|
|
29
28
|
import {fromSlateValue, isEqualToEmptyEditor} from '../internal-utils/values'
|
|
30
|
-
import {KEY_TO_VALUE_ELEMENT} from '../internal-utils/weakMaps'
|
|
31
29
|
import type {
|
|
32
30
|
EditorSelection,
|
|
33
31
|
OnCopyFn,
|
|
@@ -43,6 +41,7 @@ import type {
|
|
|
43
41
|
ScrollSelectionIntoViewFunction,
|
|
44
42
|
} from '../types/editor'
|
|
45
43
|
import type {HotkeyOptions} from '../types/options'
|
|
44
|
+
import {parseBlocks} from '../utils/parse-blocks'
|
|
46
45
|
import {RenderElement} from './components/render-element'
|
|
47
46
|
import {RenderLeaf} from './components/render-leaf'
|
|
48
47
|
import {RenderText, type RenderTextProps} from './components/render-text'
|
|
@@ -52,6 +51,7 @@ import {createWithHotkeys} from './plugins/createWithHotKeys'
|
|
|
52
51
|
import {rangeDecorationsMachine} from './range-decorations-machine'
|
|
53
52
|
import {RelayActorContext} from './relay-actor-context'
|
|
54
53
|
import {validateSelectionMachine} from './validate-selection-machine'
|
|
54
|
+
import {KEY_TO_VALUE_ELEMENT} from './weakMaps'
|
|
55
55
|
|
|
56
56
|
const debug = debugWithName('component:Editable')
|
|
57
57
|
|
|
@@ -3,11 +3,9 @@ import {useSelector} from '@xstate/react'
|
|
|
3
3
|
import {uniq} from 'lodash'
|
|
4
4
|
import {useContext, useMemo, useRef, type ReactElement} from 'react'
|
|
5
5
|
import {useSlateStatic, type RenderLeafProps} from 'slate-react'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
isSelectionCollapsed,
|
|
10
|
-
} from '../../selectors'
|
|
6
|
+
import {getFocusSpan} from '../../selectors/selector.get-focus-span'
|
|
7
|
+
import {isOverlappingSelection} from '../../selectors/selector.is-overlapping-selection'
|
|
8
|
+
import {isSelectionCollapsed} from '../../selectors/selector.is-selection-collapsed'
|
|
11
9
|
import type {
|
|
12
10
|
BlockAnnotationRenderProps,
|
|
13
11
|
BlockChildRenderProps,
|
|
@@ -10,20 +10,20 @@ import type {Editor, EditorConfig} from '../editor'
|
|
|
10
10
|
import {debugWithName} from '../internal-utils/debug'
|
|
11
11
|
import {compileType} from '../internal-utils/schema'
|
|
12
12
|
import {fromSlateValue} from '../internal-utils/values'
|
|
13
|
-
import {KEY_TO_VALUE_ELEMENT} from '../internal-utils/weakMaps'
|
|
14
13
|
import {corePriority} from '../priority/priority.core'
|
|
15
14
|
import {createEditorPriority} from '../priority/priority.types'
|
|
16
15
|
import type {EditableAPI, PortableTextSlateEditor} from '../types/editor'
|
|
16
|
+
import {defaultKeyGenerator} from '../utils/key-generator'
|
|
17
17
|
import {createSlateEditor, type SlateEditor} from './create-slate-editor'
|
|
18
18
|
import {createEditorDom} from './editor-dom'
|
|
19
19
|
import type {EditorActor} from './editor-machine'
|
|
20
20
|
import {editorMachine, rerouteExternalBehaviorEvent} from './editor-machine'
|
|
21
21
|
import {getEditorSnapshot} from './editor-selector'
|
|
22
|
-
import {defaultKeyGenerator} from './key-generator'
|
|
23
22
|
import {mutationMachine, type MutationActor} from './mutation-machine'
|
|
24
23
|
import {createEditableAPI} from './plugins/createWithEditableAPI'
|
|
25
24
|
import {relayMachine, type RelayActor} from './relay-machine'
|
|
26
25
|
import {syncMachine, type SyncActor} from './sync-machine'
|
|
26
|
+
import {KEY_TO_VALUE_ELEMENT} from './weakMaps'
|
|
27
27
|
|
|
28
28
|
const debug = debugWithName('setup')
|
|
29
29
|
|
|
@@ -4,14 +4,11 @@ import {buildIndexMaps} from '../internal-utils/build-index-maps'
|
|
|
4
4
|
import {createPlaceholderBlock} from '../internal-utils/create-placeholder-block'
|
|
5
5
|
import {debugWithName} from '../internal-utils/debug'
|
|
6
6
|
import {toSlateValue} from '../internal-utils/values'
|
|
7
|
-
import {
|
|
8
|
-
KEY_TO_SLATE_ELEMENT,
|
|
9
|
-
KEY_TO_VALUE_ELEMENT,
|
|
10
|
-
} from '../internal-utils/weakMaps'
|
|
11
7
|
import type {PortableTextSlateEditor} from '../types/editor'
|
|
12
8
|
import type {EditorActor} from './editor-machine'
|
|
13
9
|
import {withPlugins} from './plugins/with-plugins'
|
|
14
10
|
import type {RelayActor} from './relay-machine'
|
|
11
|
+
import {KEY_TO_SLATE_ELEMENT, KEY_TO_VALUE_ELEMENT} from './weakMaps'
|
|
15
12
|
|
|
16
13
|
const debug = debugWithName('setup')
|
|
17
14
|
|
package/src/editor/editor-dom.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {Editor} from 'slate'
|
|
2
2
|
import {DOMEditor} from 'slate-dom'
|
|
3
|
-
import type {
|
|
4
|
-
import type {BehaviorEvent} from '../behaviors'
|
|
3
|
+
import type {BehaviorEvent} from '../behaviors/behavior.types.event'
|
|
5
4
|
import {toSlateRange} from '../internal-utils/to-slate-range'
|
|
6
5
|
import type {PickFromUnion} from '../type-utils'
|
|
7
6
|
import type {PortableTextSlateEditor} from '../types/editor'
|
|
7
|
+
import type {EditorSnapshot} from './editor-snapshot'
|
|
8
8
|
|
|
9
9
|
export type EditorDom = {
|
|
10
10
|
getBlockNodes: (snapshot: EditorSnapshot) => Array<Node>
|
|
@@ -26,18 +26,12 @@ import {
|
|
|
26
26
|
} from '../../internal-utils/slate-utils'
|
|
27
27
|
import {toSlateRange} from '../../internal-utils/to-slate-range'
|
|
28
28
|
import {fromSlateValue, toSlateValue} from '../../internal-utils/values'
|
|
29
|
-
import {
|
|
30
|
-
KEY_TO_VALUE_ELEMENT,
|
|
31
|
-
SLATE_TO_PORTABLE_TEXT_RANGE,
|
|
32
|
-
} from '../../internal-utils/weakMaps'
|
|
33
|
-
import {
|
|
34
|
-
getFocusBlock,
|
|
35
|
-
getFocusSpan,
|
|
36
|
-
getSelectedValue,
|
|
37
|
-
isActiveAnnotation,
|
|
38
|
-
} from '../../selectors'
|
|
39
29
|
import {getActiveAnnotationsMarks} from '../../selectors/selector.get-active-annotation-marks'
|
|
40
30
|
import {getActiveDecorators} from '../../selectors/selector.get-active-decorators'
|
|
31
|
+
import {getFocusBlock} from '../../selectors/selector.get-focus-block'
|
|
32
|
+
import {getFocusSpan} from '../../selectors/selector.get-focus-span'
|
|
33
|
+
import {getSelectedValue} from '../../selectors/selector.get-selected-value'
|
|
34
|
+
import {isActiveAnnotation} from '../../selectors/selector.is-active-annotation'
|
|
41
35
|
import type {
|
|
42
36
|
EditableAPI,
|
|
43
37
|
EditableAPIDeleteOptions,
|
|
@@ -46,6 +40,7 @@ import type {
|
|
|
46
40
|
} from '../../types/editor'
|
|
47
41
|
import type {EditorActor} from '../editor-machine'
|
|
48
42
|
import {getEditorSnapshot} from '../editor-selector'
|
|
43
|
+
import {KEY_TO_VALUE_ELEMENT, SLATE_TO_PORTABLE_TEXT_RANGE} from '../weakMaps'
|
|
49
44
|
|
|
50
45
|
const debug = debugWithName('API:editable')
|
|
51
46
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {isChangingRemotely} from '../../internal-utils/withChanges'
|
|
2
|
-
import {isRedoing, isUndoing} from '../../internal-utils/withUndoRedo'
|
|
3
1
|
import type {PortableTextSlateEditor} from '../../types/editor'
|
|
4
2
|
import type {EditorActor} from '../editor-machine'
|
|
3
|
+
import {isChangingRemotely} from '../withChanges'
|
|
4
|
+
import {isRedoing, isUndoing} from '../withUndoRedo'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* This plugin makes sure that the PTE maxBlocks prop is respected
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {isSpan, isTextBlock} from '@portabletext/schema'
|
|
2
2
|
import {isEqual} from 'lodash'
|
|
3
3
|
import {Editor, Element, Node, Path, Transforms} from 'slate'
|
|
4
|
-
import {isChangingRemotely} from '../../internal-utils/withChanges'
|
|
5
|
-
import {isRedoing, isUndoing} from '../../internal-utils/withUndoRedo'
|
|
6
4
|
import type {PortableTextSlateEditor} from '../../types/editor'
|
|
7
5
|
import type {EditorActor} from '../editor-machine'
|
|
6
|
+
import {isChangingRemotely} from '../withChanges'
|
|
7
|
+
import {isRedoing, isUndoing} from '../withUndoRedo'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* This plugin makes sure that every new node in the editor get a new _key prop when created
|
|
@@ -13,20 +13,13 @@ import {
|
|
|
13
13
|
splitNodePatch,
|
|
14
14
|
} from '../../internal-utils/operation-to-patches'
|
|
15
15
|
import {fromSlateValue, isEqualToEmptyEditor} from '../../internal-utils/values'
|
|
16
|
-
import {
|
|
17
|
-
IS_PROCESSING_REMOTE_CHANGES,
|
|
18
|
-
KEY_TO_VALUE_ELEMENT,
|
|
19
|
-
} from '../../internal-utils/weakMaps'
|
|
20
|
-
import {withRemoteChanges} from '../../internal-utils/withChanges'
|
|
21
|
-
import {
|
|
22
|
-
isPatching,
|
|
23
|
-
PATCHING,
|
|
24
|
-
withoutPatching,
|
|
25
|
-
} from '../../internal-utils/withoutPatching'
|
|
26
16
|
import type {PortableTextSlateEditor} from '../../types/editor'
|
|
27
17
|
import type {EditorActor} from '../editor-machine'
|
|
28
18
|
import type {RelayActor} from '../relay-machine'
|
|
19
|
+
import {IS_PROCESSING_REMOTE_CHANGES, KEY_TO_VALUE_ELEMENT} from '../weakMaps'
|
|
29
20
|
import {getCurrentUndoStepId} from '../with-undo-step'
|
|
21
|
+
import {withRemoteChanges} from '../withChanges'
|
|
22
|
+
import {isPatching, PATCHING, withoutPatching} from '../withoutPatching'
|
|
30
23
|
import {withoutSaving} from './createWithUndoRedo'
|
|
31
24
|
|
|
32
25
|
const debug = debugWithName('plugin:withPatches')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {Editor} from 'slate'
|
|
2
2
|
import {debugWithName} from '../../internal-utils/debug'
|
|
3
|
-
import {isChangingRemotely} from '../../internal-utils/withChanges'
|
|
4
|
-
import {isRedoing, isUndoing} from '../../internal-utils/withUndoRedo'
|
|
5
3
|
import type {PortableTextSlateEditor} from '../../types/editor'
|
|
6
4
|
import type {EditorActor} from '../editor-machine'
|
|
5
|
+
import {isChangingRemotely} from '../withChanges'
|
|
6
|
+
import {isRedoing, isUndoing} from '../withUndoRedo'
|
|
7
7
|
|
|
8
8
|
const debug = debugWithName('plugin:withPlaceholderBlock')
|
|
9
9
|
|
|
@@ -10,14 +10,14 @@ import {isEqual, uniq} from 'lodash'
|
|
|
10
10
|
import {Editor, Element, Node, Path, Range, Text, Transforms} from 'slate'
|
|
11
11
|
import {debugWithName} from '../../internal-utils/debug'
|
|
12
12
|
import {getNextSpan, getPreviousSpan} from '../../internal-utils/sibling-utils'
|
|
13
|
-
import {isChangingRemotely} from '../../internal-utils/withChanges'
|
|
14
|
-
import {isRedoing, isUndoing} from '../../internal-utils/withUndoRedo'
|
|
15
13
|
import type {BehaviorOperationImplementation} from '../../operations/behavior.operations'
|
|
16
14
|
import {getActiveDecorators} from '../../selectors/selector.get-active-decorators'
|
|
17
15
|
import {getMarkState} from '../../selectors/selector.get-mark-state'
|
|
18
16
|
import type {PortableTextSlateEditor} from '../../types/editor'
|
|
19
17
|
import type {EditorActor} from '../editor-machine'
|
|
20
18
|
import {getEditorSnapshot} from '../editor-selector'
|
|
19
|
+
import {isChangingRemotely} from '../withChanges'
|
|
20
|
+
import {isRedoing, isUndoing} from '../withUndoRedo'
|
|
21
21
|
|
|
22
22
|
const debug = debugWithName('plugin:withPortableTextMarkModel')
|
|
23
23
|
|