@portabletext/editor 1.1.0 → 1.1.2

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 (79) hide show
  1. package/README.md +3 -0
  2. package/lib/index.d.mts +1680 -12
  3. package/lib/index.d.ts +1680 -12
  4. package/lib/index.esm.js +310 -162
  5. package/lib/index.esm.js.map +1 -1
  6. package/lib/index.js +310 -163
  7. package/lib/index.js.map +1 -1
  8. package/lib/index.mjs +310 -162
  9. package/lib/index.mjs.map +1 -1
  10. package/package.json +25 -38
  11. package/src/editor/Editable.tsx +51 -50
  12. package/src/editor/PortableTextEditor.tsx +42 -26
  13. package/src/editor/__tests__/PortableTextEditor.test.tsx +11 -12
  14. package/src/editor/__tests__/PortableTextEditorTester.tsx +2 -5
  15. package/src/editor/__tests__/RangeDecorations.test.tsx +6 -7
  16. package/src/editor/__tests__/handleClick.test.tsx +27 -7
  17. package/src/editor/__tests__/insert-block.test.tsx +6 -6
  18. package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +8 -8
  19. package/src/editor/__tests__/self-solving.test.tsx +176 -0
  20. package/src/editor/components/Element.tsx +15 -17
  21. package/src/editor/components/Leaf.tsx +40 -35
  22. package/src/editor/components/SlateContainer.tsx +2 -2
  23. package/src/editor/components/Synchronizer.tsx +62 -34
  24. package/src/editor/editor-machine.ts +195 -0
  25. package/src/editor/hooks/usePortableTextEditor.ts +1 -1
  26. package/src/editor/hooks/usePortableTextEditorSelection.tsx +12 -14
  27. package/src/editor/hooks/useSyncValue.test.tsx +9 -9
  28. package/src/editor/hooks/useSyncValue.ts +16 -19
  29. package/src/editor/nodes/DefaultAnnotation.tsx +1 -2
  30. package/src/editor/nodes/DefaultObject.tsx +1 -1
  31. package/src/editor/plugins/__tests__/createWithInsertData.test.tsx +2 -5
  32. package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +28 -28
  33. package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +17 -17
  34. package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +8 -8
  35. package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +6 -6
  36. package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +2 -2
  37. package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +47 -49
  38. package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +22 -11
  39. package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +9 -9
  40. package/src/editor/plugins/createWithEditableAPI.ts +8 -8
  41. package/src/editor/plugins/createWithHotKeys.ts +8 -12
  42. package/src/editor/plugins/createWithInsertBreak.ts +4 -4
  43. package/src/editor/plugins/createWithInsertData.ts +11 -16
  44. package/src/editor/plugins/createWithMaxBlocks.ts +1 -1
  45. package/src/editor/plugins/createWithObjectKeys.ts +10 -3
  46. package/src/editor/plugins/createWithPatches.ts +9 -12
  47. package/src/editor/plugins/createWithPlaceholderBlock.ts +2 -2
  48. package/src/editor/plugins/createWithPortableTextBlockStyle.ts +13 -5
  49. package/src/editor/plugins/createWithPortableTextLists.ts +3 -4
  50. package/src/editor/plugins/createWithPortableTextMarkModel.ts +24 -10
  51. package/src/editor/plugins/createWithPortableTextSelections.ts +9 -10
  52. package/src/editor/plugins/createWithSchemaTypes.ts +13 -4
  53. package/src/editor/plugins/createWithUndoRedo.ts +3 -7
  54. package/src/editor/plugins/createWithUtils.ts +6 -6
  55. package/src/editor/plugins/index.ts +21 -11
  56. package/src/index.ts +9 -3
  57. package/src/types/editor.ts +33 -33
  58. package/src/types/options.ts +3 -3
  59. package/src/types/slate.ts +4 -4
  60. package/src/utils/__tests__/dmpToOperations.test.ts +4 -4
  61. package/src/utils/__tests__/operationToPatches.test.ts +62 -62
  62. package/src/utils/__tests__/patchToOperations.test.ts +40 -40
  63. package/src/utils/__tests__/ranges.test.ts +2 -2
  64. package/src/utils/__tests__/valueNormalization.test.tsx +14 -2
  65. package/src/utils/__tests__/values.test.ts +17 -17
  66. package/src/utils/applyPatch.ts +10 -12
  67. package/src/utils/getPortableTextMemberSchemaTypes.ts +8 -8
  68. package/src/utils/operationToPatches.ts +5 -9
  69. package/src/utils/paths.ts +5 -5
  70. package/src/utils/ranges.ts +4 -5
  71. package/src/utils/selection.ts +2 -2
  72. package/src/utils/ucs2Indices.ts +2 -2
  73. package/src/utils/validateValue.ts +3 -25
  74. package/src/utils/values.ts +7 -8
  75. package/src/utils/weakMaps.ts +2 -2
  76. package/src/utils/withChanges.ts +1 -1
  77. package/src/utils/withUndoRedo.ts +1 -1
  78. package/src/utils/withoutPatching.ts +1 -1
  79. package/src/editor/__tests__/utils.ts +0 -45
@@ -1,7 +1,7 @@
1
1
  import {noop} from 'lodash'
2
- import {type BaseOperation, type Editor, type Node, type NodeEntry} from 'slate'
3
- import {type PortableTextSlateEditor} from '../../types/editor'
4
- import {type createEditorOptions} from '../../types/options'
2
+ import type {BaseOperation, Editor, Node, NodeEntry} from 'slate'
3
+ import type {PortableTextSlateEditor} from '../../types/editor'
4
+ import type {createEditorOptions} from '../../types/options'
5
5
  import {createOperationToPatches} from '../../utils/operationToPatches'
6
6
  import {createWithEditableAPI} from './createWithEditableAPI'
7
7
  import {createWithInsertBreak} from './createWithInsertBreak'
@@ -49,7 +49,7 @@ export const withPlugins = <T extends Editor>(
49
49
  const e = editor as T & PortableTextSlateEditor
50
50
  const {keyGenerator, portableTextEditor, patches$, readOnly, maxBlocks} =
51
51
  options
52
- const {schemaTypes, change$} = portableTextEditor
52
+ const {editorActor, schemaTypes} = portableTextEditor
53
53
  e.subscriptions = []
54
54
  if (e.destroy) {
55
55
  e.destroy()
@@ -63,15 +63,23 @@ export const withPlugins = <T extends Editor>(
63
63
  })
64
64
  }
65
65
  const operationToPatches = createOperationToPatches(schemaTypes)
66
- const withObjectKeys = createWithObjectKeys(schemaTypes, keyGenerator)
67
- const withSchemaTypes = createWithSchemaTypes({schemaTypes, keyGenerator})
66
+ const withObjectKeys = createWithObjectKeys(
67
+ editorActor,
68
+ schemaTypes,
69
+ keyGenerator,
70
+ )
71
+ const withSchemaTypes = createWithSchemaTypes({
72
+ editorActor,
73
+ schemaTypes,
74
+ keyGenerator,
75
+ })
68
76
  const withEditableAPI = createWithEditableAPI(
69
77
  portableTextEditor,
70
78
  schemaTypes,
71
79
  keyGenerator,
72
80
  )
73
81
  const withPatches = createWithPatches({
74
- change$,
82
+ editorActor,
75
83
  keyGenerator,
76
84
  patches$,
77
85
  patchFunctions: operationToPatches,
@@ -86,12 +94,14 @@ export const withPlugins = <T extends Editor>(
86
94
  blockSchemaType: schemaTypes.block,
87
95
  })
88
96
  const withPortableTextMarkModel = createWithPortableTextMarkModel(
97
+ editorActor,
89
98
  schemaTypes,
90
- change$,
91
99
  keyGenerator,
92
100
  )
93
- const withPortableTextBlockStyle =
94
- createWithPortableTextBlockStyle(schemaTypes)
101
+ const withPortableTextBlockStyle = createWithPortableTextBlockStyle(
102
+ editorActor,
103
+ schemaTypes,
104
+ )
95
105
 
96
106
  const withPlaceholderBlock = createWithPlaceholderBlock()
97
107
 
@@ -103,7 +113,7 @@ export const withPlugins = <T extends Editor>(
103
113
  portableTextEditor,
104
114
  })
105
115
  const withPortableTextSelections = createWithPortableTextSelections(
106
- change$,
116
+ editorActor,
107
117
  schemaTypes,
108
118
  )
109
119
 
package/src/index.ts CHANGED
@@ -1,10 +1,16 @@
1
- export type {PortableTextEditableProps} from './editor/Editable'
1
+ export {type Patch} from '@portabletext/patches'
2
2
  export {PortableTextEditable} from './editor/Editable'
3
+ export type {PortableTextEditableProps} from './editor/Editable'
4
+ export {
5
+ editorMachine,
6
+ type EditorActor,
7
+ type MutationEvent,
8
+ type PatchEvent,
9
+ } from './editor/editor-machine'
3
10
  export {usePortableTextEditor} from './editor/hooks/usePortableTextEditor'
4
11
  export {defaultKeyGenerator as keyGenerator} from './editor/hooks/usePortableTextEditorKeyGenerator'
5
12
  export {usePortableTextEditorSelection} from './editor/hooks/usePortableTextEditorSelection'
6
- export type {PortableTextEditorProps} from './editor/PortableTextEditor'
7
13
  export {PortableTextEditor} from './editor/PortableTextEditor'
14
+ export type {PortableTextEditorProps} from './editor/PortableTextEditor'
8
15
  export * from './types/editor'
9
16
  export * from './types/options'
10
- export {type Patch} from '@portabletext/patches'
@@ -1,39 +1,39 @@
1
- import {type Patch} from '@portabletext/patches'
2
- import {
3
- type ArraySchemaType,
4
- type BlockDecoratorDefinition,
5
- type BlockListDefinition,
6
- type BlockSchemaType,
7
- type BlockStyleDefinition,
8
- type ObjectSchemaType,
9
- type Path,
10
- type PortableTextBlock,
11
- type PortableTextChild,
12
- type PortableTextListBlock,
13
- type PortableTextObject,
14
- type PortableTextSpan,
15
- type PortableTextTextBlock,
16
- type SpanSchemaType,
17
- type TypedObject,
1
+ import type {Patch} from '@portabletext/patches'
2
+ import type {
3
+ ArraySchemaType,
4
+ BlockDecoratorDefinition,
5
+ BlockListDefinition,
6
+ BlockSchemaType,
7
+ BlockStyleDefinition,
8
+ ObjectSchemaType,
9
+ Path,
10
+ PortableTextBlock,
11
+ PortableTextChild,
12
+ PortableTextListBlock,
13
+ PortableTextObject,
14
+ PortableTextSpan,
15
+ PortableTextTextBlock,
16
+ SpanSchemaType,
17
+ TypedObject,
18
18
  } from '@sanity/types'
19
- import {
20
- type ClipboardEvent,
21
- type FocusEvent,
22
- type KeyboardEvent,
23
- type PropsWithChildren,
24
- type ReactElement,
25
- type RefObject,
19
+ import type {
20
+ ClipboardEvent,
21
+ FocusEvent,
22
+ KeyboardEvent,
23
+ PropsWithChildren,
24
+ ReactElement,
25
+ RefObject,
26
26
  } from 'react'
27
- import {type Observable, type Subject} from 'rxjs'
28
- import {
29
- type Descendant,
30
- type Node as SlateNode,
31
- type Operation as SlateOperation,
27
+ import type {Observable, Subject} from 'rxjs'
28
+ import type {
29
+ Descendant,
30
+ Node as SlateNode,
31
+ Operation as SlateOperation,
32
32
  } from 'slate'
33
- import {type ReactEditor} from 'slate-react'
34
- import {type DOMNode} from 'slate-react/dist/utils/dom'
35
- import {type PortableTextEditableProps} from '../editor/Editable'
36
- import {type PortableTextEditor} from '../editor/PortableTextEditor'
33
+ import type {ReactEditor} from 'slate-react'
34
+ import type {DOMNode} from 'slate-react/dist/utils/dom'
35
+ import type {PortableTextEditableProps} from '../editor/Editable'
36
+ import type {PortableTextEditor} from '../editor/PortableTextEditor'
37
37
 
38
38
  /** @beta */
39
39
  export interface EditableAPIDeleteOptions {
@@ -1,6 +1,6 @@
1
- import {type BaseSyntheticEvent} from 'react'
2
- import {type PortableTextEditor} from '../editor/PortableTextEditor'
3
- import {type PatchObservable} from './editor'
1
+ import type {BaseSyntheticEvent} from 'react'
2
+ import type {PortableTextEditor} from '../editor/PortableTextEditor'
3
+ import type {PatchObservable} from './editor'
4
4
 
5
5
  /**
6
6
  * @internal
@@ -1,7 +1,7 @@
1
- import {type PortableTextSpan, type PortableTextTextBlock} from '@sanity/types'
2
- import {type BaseEditor, type Descendant} from 'slate'
3
- import {type ReactEditor} from 'slate-react'
4
- import {type PortableTextSlateEditor} from '..'
1
+ import type {PortableTextSpan, PortableTextTextBlock} from '@sanity/types'
2
+ import type {BaseEditor, Descendant} from 'slate'
3
+ import type {ReactEditor} from 'slate-react'
4
+ import type {PortableTextSlateEditor} from '..'
5
5
 
6
6
  export interface VoidElement {
7
7
  _type: string
@@ -1,5 +1,4 @@
1
- import {describe, expect, test} from '@jest/globals'
2
- import {type DiffMatchPatch} from '@portabletext/patches'
1
+ import type {DiffMatchPatch} from '@portabletext/patches'
3
2
  import {makeDiff, makePatches, stringifyPatches} from '@sanity/diff-match-patch'
4
3
  import {
5
4
  isPortableTextSpan,
@@ -9,8 +8,9 @@ import {
9
8
  type PortableTextSpan,
10
9
  type PortableTextTextBlock,
11
10
  } from '@sanity/types'
12
- import {type Descendant, type Operation} from 'slate'
13
- import {type PortableTextSlateEditor} from '../../types/editor'
11
+ import type {Descendant, Operation} from 'slate'
12
+ import {describe, expect, test} from 'vitest'
13
+ import type {PortableTextSlateEditor} from '../../types/editor'
14
14
  import {diffMatchPatch} from '../applyPatch'
15
15
 
16
16
  describe('operationToPatches: diffMatchPatch', () => {
@@ -1,6 +1,6 @@
1
- import {beforeEach, describe, expect, it} from '@jest/globals'
2
- import {type PortableTextTextBlock} from '@sanity/types'
1
+ import type {PortableTextTextBlock} from '@sanity/types'
3
2
  import {createEditor, type Descendant} from 'slate'
3
+ import {beforeEach, describe, expect, it} from 'vitest'
4
4
  import {PortableTextEditor, type PortableTextEditorProps} from '../..'
5
5
  import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
6
6
  import {defaultKeyGenerator} from '../../editor/hooks/usePortableTextEditorKeyGenerator'
@@ -61,34 +61,34 @@ describe('operationToPatches', () => {
61
61
  createDefaultValue(),
62
62
  ),
63
63
  ).toMatchInlineSnapshot(`
64
- Array [
65
- Object {
66
- "items": Array [
67
- Object {
64
+ [
65
+ {
66
+ "items": [
67
+ {
68
68
  "_key": "773866318fa8",
69
69
  "_type": "someObject",
70
70
  "title": "The Object",
71
71
  },
72
72
  ],
73
- "path": Array [
74
- Object {
73
+ "path": [
74
+ {
75
75
  "_key": "1f2e64b47787",
76
76
  },
77
77
  "children",
78
- Object {
78
+ {
79
79
  "_key": "c130395c640c",
80
80
  },
81
81
  ],
82
82
  "position": "after",
83
83
  "type": "insert",
84
84
  },
85
- Object {
86
- "path": Array [
87
- Object {
85
+ {
86
+ "path": [
87
+ {
88
88
  "_key": "1f2e64b47787",
89
89
  },
90
90
  "children",
91
- Object {
91
+ {
92
92
  "_key": "c130395c640c",
93
93
  },
94
94
  "text",
@@ -118,17 +118,17 @@ describe('operationToPatches', () => {
118
118
  createDefaultValue(),
119
119
  ),
120
120
  ).toMatchInlineSnapshot(`
121
- Array [
122
- Object {
123
- "items": Array [
124
- Object {
121
+ [
122
+ {
123
+ "items": [
124
+ {
125
125
  "_key": "c130395c640c",
126
126
  "_type": "someObject",
127
127
  "title": "The Object",
128
128
  },
129
129
  ],
130
- "path": Array [
131
- Object {
130
+ "path": [
131
+ {
132
132
  "_key": "1f2e64b47787",
133
133
  },
134
134
  ],
@@ -160,20 +160,20 @@ describe('operationToPatches', () => {
160
160
  [],
161
161
  ),
162
162
  ).toMatchInlineSnapshot(`
163
- Array [
164
- Object {
165
- "path": Array [],
163
+ [
164
+ {
165
+ "path": [],
166
166
  "type": "setIfMissing",
167
- "value": Array [],
167
+ "value": [],
168
168
  },
169
- Object {
170
- "items": Array [
171
- Object {
169
+ {
170
+ "items": [
171
+ {
172
172
  "_key": "c130395c640c",
173
173
  "_type": "someObject",
174
174
  },
175
175
  ],
176
- "path": Array [
176
+ "path": [
177
177
  0,
178
178
  ],
179
179
  "position": "before",
@@ -202,21 +202,21 @@ describe('operationToPatches', () => {
202
202
  createDefaultValue(),
203
203
  ),
204
204
  ).toMatchInlineSnapshot(`
205
- Array [
206
- Object {
207
- "items": Array [
208
- Object {
205
+ [
206
+ {
207
+ "items": [
208
+ {
209
209
  "_key": "c130395c640c",
210
210
  "_type": "someObject",
211
211
  "title": "The Object",
212
212
  },
213
213
  ],
214
- "path": Array [
215
- Object {
214
+ "path": [
215
+ {
216
216
  "_key": "1f2e64b47787",
217
217
  },
218
218
  "children",
219
- Object {
219
+ {
220
220
  "_key": "fd9b4a4e6c0b",
221
221
  },
222
222
  ],
@@ -243,14 +243,14 @@ describe('operationToPatches', () => {
243
243
  createDefaultValue(),
244
244
  ),
245
245
  ).toMatchInlineSnapshot(`
246
- Array [
247
- Object {
248
- "path": Array [
249
- Object {
246
+ [
247
+ {
248
+ "path": [
249
+ {
250
250
  "_key": "1f2e64b47787",
251
251
  },
252
252
  "children",
253
- Object {
253
+ {
254
254
  "_key": "fd9b4a4e6c0b",
255
255
  },
256
256
  "text",
@@ -280,14 +280,14 @@ describe('operationToPatches', () => {
280
280
  before,
281
281
  ),
282
282
  ).toMatchInlineSnapshot(`
283
- Array [
284
- Object {
285
- "path": Array [
286
- Object {
283
+ [
284
+ {
285
+ "path": [
286
+ {
287
287
  "_key": "1f2e64b47787",
288
288
  },
289
289
  "children",
290
- Object {
290
+ {
291
291
  "_key": "fd9b4a4e6c0b",
292
292
  },
293
293
  "text",
@@ -320,14 +320,14 @@ describe('operationToPatches', () => {
320
320
  createDefaultValue(),
321
321
  ),
322
322
  ).toMatchInlineSnapshot(`
323
- Array [
324
- Object {
325
- "path": Array [
326
- Object {
323
+ [
324
+ {
325
+ "path": [
326
+ {
327
327
  "_key": "1f2e64b47787",
328
328
  },
329
329
  "children",
330
- Object {
330
+ {
331
331
  "_key": "773866318fa8",
332
332
  },
333
333
  ],
@@ -351,10 +351,10 @@ describe('operationToPatches', () => {
351
351
  val,
352
352
  ),
353
353
  ).toMatchInlineSnapshot(`
354
- Array [
355
- Object {
356
- "path": Array [
357
- Object {
354
+ [
355
+ {
356
+ "path": [
357
+ {
358
358
  "_key": "1f2e64b47787",
359
359
  },
360
360
  ],
@@ -389,14 +389,14 @@ describe('operationToPatches', () => {
389
389
  val,
390
390
  ),
391
391
  ).toMatchInlineSnapshot(`
392
- Array [
393
- Object {
394
- "path": Array [
395
- Object {
392
+ [
393
+ {
394
+ "path": [
395
+ {
396
396
  "_key": "1f2e64b47787",
397
397
  },
398
398
  "children",
399
- Object {
399
+ {
400
400
  "_key": "fd9b4a4e6c0b",
401
401
  },
402
402
  "text",
@@ -404,13 +404,13 @@ describe('operationToPatches', () => {
404
404
  "type": "set",
405
405
  "value": "1234",
406
406
  },
407
- Object {
408
- "path": Array [
409
- Object {
407
+ {
408
+ "path": [
409
+ {
410
410
  "_key": "1f2e64b47787",
411
411
  },
412
412
  "children",
413
- Object {
413
+ {
414
414
  "_key": "r4wr323432",
415
415
  },
416
416
  ],
@@ -1,7 +1,7 @@
1
- import {beforeEach, describe, expect, it} from '@jest/globals'
2
- import {type Patch} from '@portabletext/patches'
1
+ import type {Patch} from '@portabletext/patches'
3
2
  import {noop} from 'lodash'
4
3
  import {createEditor, type Descendant} from 'slate'
4
+ import {beforeEach, describe, expect, it} from 'vitest'
5
5
  import {keyGenerator, PortableTextEditor} from '../..'
6
6
  import {schemaType} from '../../editor/__tests__/PortableTextEditorTester'
7
7
  import {withPlugins} from '../../editor/plugins'
@@ -70,21 +70,21 @@ describe('operationToPatches', () => {
70
70
  patchToOperations(editor, p)
71
71
  })
72
72
  expect(editor.children).toMatchInlineSnapshot(`
73
- Array [
74
- Object {
73
+ [
74
+ {
75
75
  "__inline": false,
76
76
  "_key": "c01739b0d03b",
77
77
  "_type": "image",
78
- "children": Array [
79
- Object {
78
+ "children": [
79
+ {
80
80
  "_key": "${VOID_CHILD_KEY}",
81
81
  "_type": "span",
82
- "marks": Array [],
82
+ "marks": [],
83
83
  "text": "",
84
84
  },
85
85
  ],
86
- "value": Object {
87
- "asset": Object {
86
+ "value": {
87
+ "asset": {
88
88
  "_ref": "image-f52f71bc1df46e080dabe43a8effe8ccfb5f21de-4032x3024-png",
89
89
  "_type": "reference",
90
90
  },
@@ -93,7 +93,7 @@ describe('operationToPatches', () => {
93
93
  ]
94
94
  `)
95
95
  })
96
- it('will not create operations for insertion inside object blocks', () => {
96
+ it('will not create operations for insertion inside blocks', () => {
97
97
  editor.children = [
98
98
  {
99
99
  _type: 'someType',
@@ -127,31 +127,31 @@ describe('operationToPatches', () => {
127
127
  patchToOperations(editor, p)
128
128
  })
129
129
  expect(editor.children).toMatchInlineSnapshot(`
130
- Array [
131
- Object {
130
+ [
131
+ {
132
132
  "__inline": false,
133
133
  "_key": "c01739b0d03b",
134
134
  "_type": "someType",
135
- "children": Array [
136
- Object {
135
+ "children": [
136
+ {
137
137
  "_key": "${VOID_CHILD_KEY}",
138
138
  "_type": "span",
139
- "marks": Array [],
139
+ "marks": [],
140
140
  "text": "",
141
141
  },
142
142
  ],
143
- "value": Object {
144
- "asset": Object {
143
+ "value": {
144
+ "asset": {
145
145
  "_ref": "image-f52f71bc1df46e080dabe43a8effe8ccfb5f21de-4032x3024-png",
146
146
  "_type": "reference",
147
147
  },
148
- "nestedArray": Array [],
148
+ "nestedArray": [],
149
149
  },
150
150
  },
151
151
  ]
152
152
  `)
153
153
  })
154
- it('will not create operations for removal inside object blocks', () => {
154
+ it('will not create operations for removal inside blocks', () => {
155
155
  editor.children = [
156
156
  {
157
157
  _type: 'someType',
@@ -190,26 +190,26 @@ describe('operationToPatches', () => {
190
190
  patchToOperations(editor, p)
191
191
  })
192
192
  expect(editor.children).toMatchInlineSnapshot(`
193
- Array [
194
- Object {
193
+ [
194
+ {
195
195
  "__inline": false,
196
196
  "_key": "c01739b0d03b",
197
197
  "_type": "someType",
198
- "children": Array [
199
- Object {
198
+ "children": [
199
+ {
200
200
  "_key": "${VOID_CHILD_KEY}",
201
201
  "_type": "span",
202
- "marks": Array [],
202
+ "marks": [],
203
203
  "text": "",
204
204
  },
205
205
  ],
206
- "value": Object {
207
- "asset": Object {
206
+ "value": {
207
+ "asset": {
208
208
  "_ref": "image-f52f71bc1df46e080dabe43a8effe8ccfb5f21de-4032x3024-png",
209
209
  "_type": "reference",
210
210
  },
211
- "nestedArray": Array [
212
- Object {
211
+ "nestedArray": [
212
+ {
213
213
  "_key": "foo",
214
214
  "_type": "nestedValue",
215
215
  },
@@ -219,7 +219,7 @@ describe('operationToPatches', () => {
219
219
  ]
220
220
  `)
221
221
  })
222
- it('will not create operations for setting data inside object blocks', () => {
222
+ it('will not create operations for setting data inside blocks', () => {
223
223
  editor.children = [
224
224
  {
225
225
  _key: '1335959d4d03',
@@ -265,34 +265,34 @@ describe('operationToPatches', () => {
265
265
  patchToOperations(editor, p)
266
266
  })
267
267
  expect(editor.children).toMatchInlineSnapshot(`
268
- Array [
269
- Object {
268
+ [
269
+ {
270
270
  "_key": "1335959d4d03",
271
271
  "_type": "block",
272
- "children": Array [
273
- Object {
272
+ "children": [
273
+ {
274
274
  "_key": "9bd868adcd6b",
275
275
  "_type": "span",
276
- "marks": Array [],
276
+ "marks": [],
277
277
  "text": "1 ",
278
278
  },
279
- Object {
279
+ {
280
280
  "_key": "6f75d593f3fc",
281
281
  "_type": "span",
282
- "marks": Array [
282
+ "marks": [
283
283
  "11de7fcea659",
284
284
  ],
285
285
  "text": "2",
286
286
  },
287
- Object {
287
+ {
288
288
  "_key": "033618a7f081",
289
289
  "_type": "span",
290
- "marks": Array [],
290
+ "marks": [],
291
291
  "text": " 3",
292
292
  },
293
293
  ],
294
- "markDefs": Array [
295
- Object {
294
+ "markDefs": [
295
+ {
296
296
  "_key": "11de7fcea659",
297
297
  "_type": "link",
298
298
  },
@@ -1,5 +1,5 @@
1
- import {describe, expect, it} from '@jest/globals'
2
- import {type InsertTextOperation, type Range} from 'slate'
1
+ import type {InsertTextOperation, Range} from 'slate'
2
+ import {describe, expect, it} from 'vitest'
3
3
  import {moveRangeByOperation} from '../ranges'
4
4
 
5
5
  describe('moveRangeByOperation', () => {