@portabletext/editor 1.48.13 → 1.48.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.
Files changed (78) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +682 -609
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-es/editor-provider.js +683 -610
  4. package/lib/_chunks-es/editor-provider.js.map +1 -1
  5. package/lib/behaviors/index.cjs.map +1 -1
  6. package/lib/behaviors/index.d.cts +226 -2772
  7. package/lib/behaviors/index.d.ts +226 -2772
  8. package/lib/behaviors/index.js.map +1 -1
  9. package/lib/index.cjs +22 -6
  10. package/lib/index.cjs.map +1 -1
  11. package/lib/index.d.cts +227 -2780
  12. package/lib/index.d.ts +227 -2780
  13. package/lib/index.js +23 -7
  14. package/lib/index.js.map +1 -1
  15. package/lib/plugins/index.cjs +1 -7
  16. package/lib/plugins/index.cjs.map +1 -1
  17. package/lib/plugins/index.d.cts +226 -2785
  18. package/lib/plugins/index.d.ts +226 -2785
  19. package/lib/plugins/index.js +2 -8
  20. package/lib/plugins/index.js.map +1 -1
  21. package/lib/selectors/index.d.cts +225 -2771
  22. package/lib/selectors/index.d.ts +225 -2771
  23. package/lib/utils/index.d.cts +227 -2772
  24. package/lib/utils/index.d.ts +227 -2772
  25. package/package.json +1 -1
  26. package/src/behaviors/behavior.abstract.keyboard.ts +16 -0
  27. package/src/behaviors/{behavior.default.ts → behavior.abstract.ts} +3 -3
  28. package/src/behaviors/behavior.config.ts +7 -0
  29. package/src/behaviors/behavior.core.ts +6 -5
  30. package/src/behaviors/behavior.perform-event.ts +27 -51
  31. package/src/behaviors/behavior.types.action.ts +1 -11
  32. package/src/editor/PortableTextEditor.tsx +1 -1
  33. package/src/editor/components/Element.tsx +30 -4
  34. package/src/editor/create-editor.ts +17 -5
  35. package/src/editor/editor-machine.ts +23 -17
  36. package/src/editor/mutation-machine.ts +6 -6
  37. package/src/editor/plugins/create-with-event-listeners.ts +25 -25
  38. package/src/editor/plugins/createWithEditableAPI.ts +3 -3
  39. package/src/editor/plugins/createWithPatches.ts +13 -5
  40. package/src/editor/plugins/createWithPortableTextMarkModel.ts +5 -5
  41. package/src/editor/plugins/createWithUndoRedo.ts +8 -8
  42. package/src/editor/with-applying-behavior-operations.ts +18 -0
  43. package/src/editor/{with-applying-behavior-actions.ts → with-undo-step.ts} +1 -19
  44. package/src/index.ts +1 -1
  45. package/src/{behavior-actions/behavior.action.annotation.add.ts → operations/behavior.operation.annotation.add.ts} +7 -7
  46. package/src/{behavior-actions/behavior.action.annotation.remove.ts → operations/behavior.operation.annotation.remove.ts} +6 -6
  47. package/src/{behavior-actions/behavior.action.block.set.ts → operations/behavior.operation.block.set.ts} +14 -14
  48. package/src/{behavior-actions/behavior.action.block.unset.ts → operations/behavior.operation.block.unset.ts} +19 -17
  49. package/src/{behavior-actions/behavior.action.decorator.add.ts → operations/behavior.operation.decorator.add.ts} +10 -10
  50. package/src/operations/behavior.operation.delete.backward.ts +8 -0
  51. package/src/operations/behavior.operation.delete.block.ts +24 -0
  52. package/src/operations/behavior.operation.delete.forward.ts +8 -0
  53. package/src/{behavior-actions/behavior.action.delete.ts → operations/behavior.operation.delete.ts} +8 -8
  54. package/src/{behavior-actions/behavior.action.insert-inline-object.ts → operations/behavior.operation.insert-inline-object.ts} +11 -11
  55. package/src/{behavior-actions/behavior.action.insert-span.ts → operations/behavior.operation.insert-span.ts} +15 -15
  56. package/src/{behavior-actions/behavior.action.insert.block.ts → operations/behavior.operation.insert.block.ts} +8 -8
  57. package/src/operations/behavior.operation.insert.text.ts +17 -0
  58. package/src/operations/behavior.operation.move.backward.ts +12 -0
  59. package/src/operations/behavior.operation.move.block.ts +16 -0
  60. package/src/operations/behavior.operation.move.forward.ts +11 -0
  61. package/src/operations/behavior.operation.select.ts +15 -0
  62. package/src/operations/behavior.operations.ts +239 -0
  63. package/src/plugins/index.ts +0 -1
  64. package/src/priority/priority.core.ts +3 -0
  65. package/src/priority/priority.sort.test.ts +319 -0
  66. package/src/priority/priority.sort.ts +121 -0
  67. package/src/priority/priority.types.ts +24 -0
  68. package/src/behavior-actions/behavior.action.delete.backward.ts +0 -7
  69. package/src/behavior-actions/behavior.action.delete.block.ts +0 -24
  70. package/src/behavior-actions/behavior.action.delete.forward.ts +0 -7
  71. package/src/behavior-actions/behavior.action.insert.text.ts +0 -17
  72. package/src/behavior-actions/behavior.action.move.backward.ts +0 -12
  73. package/src/behavior-actions/behavior.action.move.block.ts +0 -16
  74. package/src/behavior-actions/behavior.action.move.forward.ts +0 -11
  75. package/src/behavior-actions/behavior.action.select.ts +0 -15
  76. package/src/behavior-actions/behavior.actions.ts +0 -219
  77. package/src/behaviors/behavior.default.raise-soft-break.ts +0 -14
  78. package/src/plugins/plugin.core.tsx +0 -9
@@ -0,0 +1,319 @@
1
+ import {describe, expect, test} from 'vitest'
2
+ import {sortByPriority} from './priority.sort'
3
+ import {createEditorPriority} from './priority.types'
4
+
5
+ describe(sortByPriority.name, () => {
6
+ test('empty array', () => {
7
+ const result = sortByPriority([])
8
+ expect(result).toEqual([])
9
+ })
10
+
11
+ test('single item', () => {
12
+ const item = {priority: createEditorPriority({name: 'single'})}
13
+ const result = sortByPriority([item])
14
+ expect(result).toEqual([item])
15
+ })
16
+
17
+ test('two sets of priorities', () => {
18
+ const a = createEditorPriority({name: 'a'})
19
+ const b = createEditorPriority({
20
+ name: 'b',
21
+ reference: {priority: a, importance: 'higher'},
22
+ })
23
+ const b1 = createEditorPriority({
24
+ name: 'b1',
25
+ reference: {priority: b, importance: 'lower'},
26
+ })
27
+ const b2 = createEditorPriority({
28
+ name: 'b2',
29
+ reference: {priority: b, importance: 'lower'},
30
+ })
31
+ const c = createEditorPriority({
32
+ name: 'c',
33
+ reference: {priority: a, importance: 'higher'},
34
+ })
35
+ const c1 = createEditorPriority({
36
+ name: 'c1',
37
+ reference: {priority: c, importance: 'lower'},
38
+ })
39
+ const c2 = createEditorPriority({
40
+ name: 'c2',
41
+ reference: {priority: c, importance: 'lower'},
42
+ })
43
+
44
+ const items = [
45
+ {priority: c1},
46
+ {priority: c2},
47
+ {priority: a},
48
+ {priority: b1},
49
+ {priority: b2},
50
+ {priority: b},
51
+ {priority: c},
52
+ ]
53
+
54
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
55
+ 'b',
56
+ 'c',
57
+ 'b1',
58
+ 'b2',
59
+ 'c1',
60
+ 'c2',
61
+ 'a',
62
+ ])
63
+ })
64
+
65
+ test('sub-priorities', () => {
66
+ const a = createEditorPriority({name: 'a'})
67
+ const b = createEditorPriority({
68
+ name: 'b',
69
+ reference: {priority: a, importance: 'lower'},
70
+ })
71
+ const b1 = createEditorPriority({
72
+ name: 'b1',
73
+ reference: {priority: b, importance: 'lower'},
74
+ })
75
+ const b2 = createEditorPriority({
76
+ name: 'b2',
77
+ reference: {priority: b1, importance: 'higher'},
78
+ })
79
+
80
+ const items = [{priority: b2}, {priority: b1}, {priority: a}]
81
+
82
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
83
+ 'a',
84
+ 'b2',
85
+ 'b1',
86
+ ])
87
+ })
88
+
89
+ test('direct higher reference', () => {
90
+ const a = createEditorPriority({
91
+ name: 'a',
92
+ })
93
+ const b = createEditorPriority({
94
+ name: 'b',
95
+ reference: {priority: a, importance: 'higher'},
96
+ })
97
+
98
+ const items = [{priority: b}, {priority: a}]
99
+
100
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
101
+ 'b',
102
+ 'a',
103
+ ])
104
+ })
105
+
106
+ test('direct lower reference', () => {
107
+ const a = createEditorPriority({name: 'a'})
108
+ const b = createEditorPriority({
109
+ name: 'b',
110
+ reference: {priority: a, importance: 'lower'},
111
+ })
112
+
113
+ const items = [{priority: b}, {priority: a}]
114
+
115
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
116
+ 'a',
117
+ 'b',
118
+ ])
119
+ })
120
+
121
+ test('transitive references', () => {
122
+ const a = createEditorPriority({name: 'a'})
123
+ const b = createEditorPriority({
124
+ name: 'b',
125
+ reference: {priority: a, importance: 'lower'},
126
+ })
127
+ const c = createEditorPriority({
128
+ name: 'c',
129
+ reference: {priority: b, importance: 'higher'},
130
+ })
131
+
132
+ const items = [{priority: c}, {priority: b}, {priority: a}]
133
+
134
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
135
+ 'a',
136
+ 'c',
137
+ 'b',
138
+ ])
139
+ })
140
+
141
+ test('transitive references #2', () => {
142
+ const a = createEditorPriority({name: 'a'})
143
+ const b = createEditorPriority({
144
+ name: 'b',
145
+ reference: {priority: a, importance: 'higher'},
146
+ })
147
+ const c = createEditorPriority({
148
+ name: 'c',
149
+ reference: {priority: b, importance: 'lower'},
150
+ })
151
+
152
+ const items = [{priority: c}, {priority: b}, {priority: a}]
153
+
154
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
155
+ 'b',
156
+ 'c',
157
+ 'a',
158
+ ])
159
+ })
160
+
161
+ test('references to missing priorities', () => {
162
+ const a = createEditorPriority({name: 'a'})
163
+ const b = createEditorPriority({
164
+ name: 'b',
165
+ reference: {priority: a, importance: 'lower'},
166
+ })
167
+ const c = createEditorPriority({
168
+ name: 'c',
169
+ reference: {priority: b, importance: 'higher'},
170
+ })
171
+ const items = [{priority: a}, {priority: c}]
172
+
173
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
174
+ 'a',
175
+ 'c',
176
+ ])
177
+ })
178
+
179
+ test('references to missing priorities #2', () => {
180
+ const a = createEditorPriority({name: 'a'})
181
+ const b = createEditorPriority({
182
+ name: 'b',
183
+ reference: {priority: a, importance: 'higher'},
184
+ })
185
+ const c = createEditorPriority({
186
+ name: 'c',
187
+ reference: {priority: b, importance: 'lower'},
188
+ })
189
+ const items = [{priority: a}, {priority: c}]
190
+
191
+ expect(sortByPriority(items).map((item) => item.priority.name)).toEqual([
192
+ 'c',
193
+ 'a',
194
+ ])
195
+ })
196
+
197
+ test('complex reference chains', () => {
198
+ const a = createEditorPriority({
199
+ name: 'a',
200
+ })
201
+ const b = createEditorPriority({
202
+ name: 'b',
203
+ reference: {priority: a, importance: 'lower'},
204
+ })
205
+ const c = createEditorPriority({
206
+ name: 'c',
207
+ reference: {priority: b, importance: 'higher'},
208
+ })
209
+ const d = createEditorPriority({
210
+ name: 'd',
211
+ reference: {priority: c, importance: 'lower'},
212
+ })
213
+
214
+ const items = [{priority: d}, {priority: c}, {priority: b}, {priority: a}]
215
+
216
+ const result = sortByPriority(items)
217
+ expect(result.map((item) => item.priority.name)).toEqual([
218
+ 'a',
219
+ 'c',
220
+ 'd',
221
+ 'b',
222
+ ])
223
+ })
224
+
225
+ test('complex reference chains #2', () => {
226
+ const a = createEditorPriority({
227
+ name: 'a',
228
+ })
229
+ const b = createEditorPriority({
230
+ name: 'b',
231
+ reference: {priority: a, importance: 'higher'},
232
+ })
233
+ const c = createEditorPriority({
234
+ name: 'c',
235
+ reference: {priority: b, importance: 'lower'},
236
+ })
237
+ const d = createEditorPriority({
238
+ name: 'd',
239
+ reference: {priority: c, importance: 'higher'},
240
+ })
241
+
242
+ const items = [{priority: d}, {priority: c}, {priority: b}, {priority: a}]
243
+
244
+ const result = sortByPriority(items)
245
+ expect(result.map((item) => item.priority.name)).toEqual([
246
+ 'b',
247
+ 'd',
248
+ 'c',
249
+ 'a',
250
+ ])
251
+ })
252
+
253
+ test('multiple independent chains', () => {
254
+ const a1 = createEditorPriority({name: 'a1'})
255
+ const a2 = createEditorPriority({
256
+ name: 'a2',
257
+ reference: {priority: a1, importance: 'lower'},
258
+ })
259
+
260
+ const b1 = createEditorPriority({name: 'b1'})
261
+ const b2 = createEditorPriority({
262
+ name: 'b2',
263
+ reference: {priority: b1, importance: 'lower'},
264
+ })
265
+
266
+ const items = [
267
+ {priority: a2},
268
+ {priority: b1},
269
+ {priority: a1},
270
+ {priority: b2},
271
+ ]
272
+
273
+ const result = sortByPriority(items)
274
+ const names = result.map((item) => item.priority.name)
275
+
276
+ // Verify that a1 comes before a2 and b1 comes before b2
277
+ expect(names.indexOf('a1')).toBeLessThan(names.indexOf('a2'))
278
+ expect(names.indexOf('b1')).toBeLessThan(names.indexOf('b2'))
279
+ })
280
+
281
+ test('cyclic references', () => {
282
+ const a = createEditorPriority({name: 'a'})
283
+ const b = createEditorPriority({
284
+ name: 'b',
285
+ reference: {priority: a, importance: 'lower'},
286
+ })
287
+ const c = createEditorPriority({
288
+ name: 'c',
289
+ reference: {priority: b, importance: 'lower'},
290
+ })
291
+ a.reference = {priority: c, importance: 'lower'}
292
+
293
+ const items = [{priority: a}, {priority: b}, {priority: c}]
294
+
295
+ expect(() => sortByPriority(items)).toThrow()
296
+ })
297
+
298
+ test('missing priorities', () => {
299
+ const a = createEditorPriority({name: 'a'})
300
+ const b = createEditorPriority({
301
+ name: 'b',
302
+ reference: {priority: a, importance: 'lower'},
303
+ })
304
+
305
+ const items = [
306
+ {name: 'd'},
307
+ {name: 'c'},
308
+ {priority: a, name: 'a'},
309
+ {priority: b, name: 'b'},
310
+ ]
311
+
312
+ expect(sortByPriority(items).map((item) => item.name)).toEqual([
313
+ 'a',
314
+ 'b',
315
+ 'd',
316
+ 'c',
317
+ ])
318
+ })
319
+ })
@@ -0,0 +1,121 @@
1
+ import type {EditorPriority} from './priority.types'
2
+
3
+ export function sortByPriority<
4
+ T extends {
5
+ priority?: EditorPriority
6
+ },
7
+ >(items: Array<T>): Array<T> {
8
+ if (items.length === 0) {
9
+ return []
10
+ }
11
+
12
+ // Separate items with and without priority
13
+ const itemsWithPriority = items.filter(
14
+ (item): item is T & {priority: EditorPriority} =>
15
+ item.priority !== undefined,
16
+ )
17
+ const itemsWithoutPriority = items.filter(
18
+ (item) => item.priority === undefined,
19
+ )
20
+
21
+ if (itemsWithPriority.length === 0) {
22
+ return items
23
+ }
24
+
25
+ // Create a map of items by their priority ID
26
+ const itemsByPriorityId = new Map(
27
+ itemsWithPriority.map((item) => [item.priority.id, item]),
28
+ )
29
+
30
+ // Build the dependency graph
31
+ const graph = new Map<string, Set<string>>()
32
+ const inDegree = new Map<string, number>()
33
+
34
+ // Helper function to ensure a node exists in the graph
35
+ function ensureNode(id: string) {
36
+ if (!graph.has(id)) {
37
+ graph.set(id, new Set())
38
+ inDegree.set(id, 0)
39
+ }
40
+ }
41
+
42
+ // Initialize graph and in-degree for all items
43
+ for (const item of itemsWithPriority) {
44
+ const id = item.priority.id
45
+ ensureNode(id)
46
+ }
47
+
48
+ // Helper function to add an edge to the graph
49
+ function addEdge(fromId: string, toId: string) {
50
+ if (!graph.has(fromId) || !graph.has(toId)) return
51
+ graph.get(fromId)?.add(toId)
52
+ inDegree.set(toId, (inDegree.get(toId) ?? 0) + 1)
53
+ }
54
+
55
+ // Add edges based on references
56
+ for (const item of itemsWithPriority) {
57
+ const id = item.priority.id
58
+ const visited = new Set<string>()
59
+ let ref = item.priority.reference
60
+
61
+ while (ref) {
62
+ const refId = ref.priority.id
63
+ ensureNode(refId)
64
+
65
+ // Check for cyclic reference
66
+ if (visited.has(refId)) {
67
+ throw new Error('Circular dependency detected in priorities')
68
+ }
69
+ visited.add(refId)
70
+
71
+ if (ref.importance === 'higher') {
72
+ // Reference must come before current item
73
+ addEdge(id, refId)
74
+ } else {
75
+ // Current item must come before reference
76
+ addEdge(refId, id)
77
+ }
78
+
79
+ ref = ref.priority.reference
80
+ }
81
+ }
82
+
83
+ const queue: string[] = []
84
+
85
+ // Find all nodes with no incoming edges
86
+ for (const [id, degree] of inDegree) {
87
+ if (degree === 0) {
88
+ queue.push(id)
89
+ }
90
+ }
91
+
92
+ const result: T[] = []
93
+
94
+ // Perform topological sort
95
+ while (queue.length > 0) {
96
+ const currentId = queue.shift()!
97
+ const currentItem = itemsByPriorityId.get(currentId)
98
+ if (currentItem) {
99
+ result.push(currentItem)
100
+ }
101
+
102
+ // Decrease in-degree of neighbors
103
+ for (const neighborId of graph.get(currentId) ?? []) {
104
+ const newDegree = (inDegree.get(neighborId) ?? 0) - 1
105
+ inDegree.set(neighborId, newDegree)
106
+ if (newDegree === 0) {
107
+ queue.push(neighborId)
108
+ }
109
+ }
110
+ }
111
+
112
+ // Add any remaining items that weren't processed
113
+ for (const item of itemsWithPriority) {
114
+ if (!result.includes(item)) {
115
+ result.push(item)
116
+ }
117
+ }
118
+
119
+ // Append items without priority at the end in their original order
120
+ return [...result, ...itemsWithoutPriority]
121
+ }
@@ -0,0 +1,24 @@
1
+ import {defaultKeyGenerator} from '../editor/key-generator'
2
+
3
+ export type EditorPriority = {
4
+ id: string
5
+ name?: string
6
+ reference?: {
7
+ priority: EditorPriority
8
+ importance: 'higher' | 'lower'
9
+ }
10
+ }
11
+
12
+ export function createEditorPriority(config?: {
13
+ name?: string
14
+ reference?: {
15
+ priority: EditorPriority
16
+ importance: 'higher' | 'lower'
17
+ }
18
+ }): EditorPriority {
19
+ return {
20
+ id: defaultKeyGenerator(),
21
+ name: config?.name,
22
+ reference: config?.reference,
23
+ }
24
+ }
@@ -1,7 +0,0 @@
1
- import type {BehaviorActionImplementation} from './behavior.actions'
2
-
3
- export const deleteBackwardActionImplementation: BehaviorActionImplementation<
4
- 'delete.backward'
5
- > = ({action}) => {
6
- action.editor.deleteBackward(action.unit)
7
- }
@@ -1,24 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import {toSlateRange} from '../internal-utils/ranges'
3
- import type {BehaviorActionImplementation} from './behavior.actions'
4
-
5
- export const deleteBlockActionImplementation: BehaviorActionImplementation<
6
- 'delete.block'
7
- > = ({action}) => {
8
- const range = toSlateRange(
9
- {
10
- anchor: {path: action.at, offset: 0},
11
- focus: {path: action.at, offset: 0},
12
- },
13
- action.editor,
14
- )
15
-
16
- if (!range) {
17
- console.error('Unable to find Slate range from selection points')
18
- return
19
- }
20
-
21
- Transforms.removeNodes(action.editor, {
22
- at: range,
23
- })
24
- }
@@ -1,7 +0,0 @@
1
- import type {BehaviorActionImplementation} from './behavior.actions'
2
-
3
- export const deleteForwardActionImplementation: BehaviorActionImplementation<
4
- 'delete.forward'
5
- > = ({action}) => {
6
- action.editor.deleteForward(action.unit)
7
- }
@@ -1,17 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import type {BehaviorActionImplementation} from './behavior.actions'
3
-
4
- export const insertTextActionImplementation: BehaviorActionImplementation<
5
- 'insert.text'
6
- > = ({action}) => {
7
- if (action.editor.marks) {
8
- Transforms.insertNodes(action.editor, {
9
- text: action.text,
10
- ...action.editor.marks,
11
- })
12
- } else {
13
- Transforms.insertText(action.editor, action.text)
14
- }
15
-
16
- action.editor.marks = null
17
- }
@@ -1,12 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import type {BehaviorActionImplementation} from './behavior.actions'
3
-
4
- export const moveBackwardActionImplementation: BehaviorActionImplementation<
5
- 'move.backward'
6
- > = ({action}) => {
7
- Transforms.move(action.editor, {
8
- unit: 'character',
9
- distance: action.distance,
10
- reverse: true,
11
- })
12
- }
@@ -1,16 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import {toSlatePath} from '../internal-utils/paths'
3
- import type {BehaviorActionImplementation} from './behavior.actions'
4
-
5
- export const moveBlockActionImplementation: BehaviorActionImplementation<
6
- 'move.block'
7
- > = ({action}) => {
8
- const at = [toSlatePath(action.at, action.editor)[0]]
9
- const to = [toSlatePath(action.to, action.editor)[0]]
10
-
11
- Transforms.moveNodes(action.editor, {
12
- at,
13
- to,
14
- mode: 'highest',
15
- })
16
- }
@@ -1,11 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import type {BehaviorActionImplementation} from './behavior.actions'
3
-
4
- export const moveForwardActionImplementation: BehaviorActionImplementation<
5
- 'move.forward'
6
- > = ({action}) => {
7
- Transforms.move(action.editor, {
8
- unit: 'character',
9
- distance: action.distance,
10
- })
11
- }
@@ -1,15 +0,0 @@
1
- import {Transforms} from 'slate'
2
- import {toSlateRange} from '../internal-utils/ranges'
3
- import type {BehaviorActionImplementation} from './behavior.actions'
4
-
5
- export const selectActionImplementation: BehaviorActionImplementation<
6
- 'select'
7
- > = ({action}) => {
8
- const newSelection = toSlateRange(action.at, action.editor)
9
-
10
- if (newSelection) {
11
- Transforms.select(action.editor, newSelection)
12
- } else {
13
- Transforms.deselect(action.editor)
14
- }
15
- }