@portabletext/editor 1.1.1 → 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.
- package/README.md +3 -0
- package/lib/index.d.mts +1667 -0
- package/lib/index.d.ts +1667 -0
- package/lib/index.esm.js +305 -153
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +305 -154
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +305 -153
- package/lib/index.mjs.map +1 -1
- package/package.json +23 -22
- package/src/editor/Editable.tsx +30 -31
- package/src/editor/PortableTextEditor.tsx +23 -6
- package/src/editor/__tests__/PortableTextEditor.test.tsx +9 -9
- package/src/editor/__tests__/PortableTextEditorTester.tsx +2 -5
- package/src/editor/__tests__/RangeDecorations.test.tsx +2 -2
- package/src/editor/__tests__/handleClick.test.tsx +27 -7
- package/src/editor/__tests__/insert-block.test.tsx +4 -4
- package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +7 -7
- package/src/editor/__tests__/self-solving.test.tsx +176 -0
- package/src/editor/components/Leaf.tsx +28 -23
- package/src/editor/components/Synchronizer.tsx +60 -32
- package/src/editor/editor-machine.ts +195 -0
- package/src/editor/hooks/usePortableTextEditorSelection.tsx +11 -13
- package/src/editor/hooks/useSyncValue.test.tsx +9 -9
- package/src/editor/hooks/useSyncValue.ts +14 -13
- package/src/editor/plugins/__tests__/createWithInsertData.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +28 -28
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +17 -17
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +8 -8
- package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +5 -5
- package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +2 -2
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +46 -46
- package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +22 -11
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +9 -9
- package/src/editor/plugins/createWithInsertData.ts +4 -8
- package/src/editor/plugins/createWithObjectKeys.ts +7 -0
- package/src/editor/plugins/createWithPatches.ts +5 -6
- package/src/editor/plugins/createWithPortableTextBlockStyle.ts +10 -2
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +20 -4
- package/src/editor/plugins/createWithPortableTextSelections.ts +4 -5
- package/src/editor/plugins/createWithSchemaTypes.ts +9 -0
- package/src/editor/plugins/index.ts +18 -8
- package/src/index.ts +9 -3
- package/src/utils/__tests__/dmpToOperations.test.ts +1 -1
- package/src/utils/__tests__/operationToPatches.test.ts +61 -61
- package/src/utils/__tests__/patchToOperations.test.ts +39 -39
- package/src/utils/__tests__/ranges.test.ts +1 -1
- package/src/utils/__tests__/valueNormalization.test.tsx +14 -2
- package/src/utils/__tests__/values.test.ts +17 -17
- package/src/utils/validateValue.ts +0 -22
- package/src/editor/__tests__/utils.ts +0 -44
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import {isPortableTextBlock, isPortableTextSpan} from '@portabletext/toolkit'
|
|
8
8
|
import type {PortableTextObject} from '@sanity/types'
|
|
9
9
|
import {isEqual, uniq} from 'lodash'
|
|
10
|
-
import type {Subject} from 'rxjs'
|
|
11
10
|
import {
|
|
12
11
|
Editor,
|
|
13
12
|
Element,
|
|
@@ -19,7 +18,6 @@ import {
|
|
|
19
18
|
type Descendant,
|
|
20
19
|
} from 'slate'
|
|
21
20
|
import type {
|
|
22
|
-
EditorChange,
|
|
23
21
|
PortableTextMemberSchemaTypes,
|
|
24
22
|
PortableTextSlateEditor,
|
|
25
23
|
} from '../../types/editor'
|
|
@@ -27,12 +25,13 @@ import {debugWithName} from '../../utils/debug'
|
|
|
27
25
|
import {toPortableTextRange} from '../../utils/ranges'
|
|
28
26
|
import {isChangingRemotely} from '../../utils/withChanges'
|
|
29
27
|
import {isRedoing, isUndoing} from '../../utils/withUndoRedo'
|
|
28
|
+
import type {EditorActor} from '../editor-machine'
|
|
30
29
|
|
|
31
30
|
const debug = debugWithName('plugin:withPortableTextMarkModel')
|
|
32
31
|
|
|
33
32
|
export function createWithPortableTextMarkModel(
|
|
33
|
+
editorActor: EditorActor,
|
|
34
34
|
types: PortableTextMemberSchemaTypes,
|
|
35
|
-
change$: Subject<EditorChange>,
|
|
36
35
|
keyGenerator: () => string,
|
|
37
36
|
): (editor: PortableTextSlateEditor) => PortableTextSlateEditor {
|
|
38
37
|
return function withPortableTextMarkModel(editor: PortableTextSlateEditor) {
|
|
@@ -59,7 +58,7 @@ export function createWithPortableTextMarkModel(
|
|
|
59
58
|
editor.selection,
|
|
60
59
|
types,
|
|
61
60
|
)
|
|
62
|
-
|
|
61
|
+
editorActor.send({type: 'selection', selection: ptRange})
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
// Extend Slate's default normalization. Merge spans with same set of .marks when doing merge_node operations, and clean up markDefs / marks
|
|
@@ -82,10 +81,12 @@ export function createWithPortableTextMarkModel(
|
|
|
82
81
|
JSON.stringify(child, null, 2),
|
|
83
82
|
JSON.stringify(nextNode, null, 2),
|
|
84
83
|
)
|
|
84
|
+
editorActor.send({type: 'normalizing'})
|
|
85
85
|
Transforms.mergeNodes(editor, {
|
|
86
86
|
at: [childPath[0], childPath[1] + 1],
|
|
87
87
|
voids: true,
|
|
88
88
|
})
|
|
89
|
+
editorActor.send({type: 'done normalizing'})
|
|
89
90
|
return
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -96,7 +97,9 @@ export function createWithPortableTextMarkModel(
|
|
|
96
97
|
*/
|
|
97
98
|
if (editor.isTextBlock(node) && !Array.isArray(node.markDefs)) {
|
|
98
99
|
debug('Adding .markDefs to block node')
|
|
100
|
+
editorActor.send({type: 'normalizing'})
|
|
99
101
|
Transforms.setNodes(editor, {markDefs: []}, {at: path})
|
|
102
|
+
editorActor.send({type: 'done normalizing'})
|
|
100
103
|
return
|
|
101
104
|
}
|
|
102
105
|
|
|
@@ -105,7 +108,9 @@ export function createWithPortableTextMarkModel(
|
|
|
105
108
|
*/
|
|
106
109
|
if (editor.isTextSpan(node) && !Array.isArray(node.marks)) {
|
|
107
110
|
debug('Adding .marks to span node')
|
|
111
|
+
editorActor.send({type: 'normalizing'})
|
|
108
112
|
Transforms.setNodes(editor, {marks: []}, {at: path})
|
|
113
|
+
editorActor.send({type: 'done normalizing'})
|
|
109
114
|
return
|
|
110
115
|
}
|
|
111
116
|
|
|
@@ -123,11 +128,13 @@ export function createWithPortableTextMarkModel(
|
|
|
123
128
|
if (editor.isTextBlock(block)) {
|
|
124
129
|
if (node.text === '' && annotations && annotations.length > 0) {
|
|
125
130
|
debug('Removing annotations from empty span node')
|
|
131
|
+
editorActor.send({type: 'normalizing'})
|
|
126
132
|
Transforms.setNodes(
|
|
127
133
|
editor,
|
|
128
134
|
{marks: node.marks?.filter((mark) => decorators.includes(mark))},
|
|
129
135
|
{at: path},
|
|
130
136
|
)
|
|
137
|
+
editorActor.send({type: 'done normalizing'})
|
|
131
138
|
return
|
|
132
139
|
}
|
|
133
140
|
}
|
|
@@ -151,6 +158,7 @@ export function createWithPortableTextMarkModel(
|
|
|
151
158
|
|
|
152
159
|
if (orphanedAnnotations.length > 0) {
|
|
153
160
|
debug('Removing orphaned annotations from span node')
|
|
161
|
+
editorActor.send({type: 'normalizing'})
|
|
154
162
|
Transforms.setNodes(
|
|
155
163
|
editor,
|
|
156
164
|
{
|
|
@@ -160,6 +168,7 @@ export function createWithPortableTextMarkModel(
|
|
|
160
168
|
},
|
|
161
169
|
{at: childPath},
|
|
162
170
|
)
|
|
171
|
+
editorActor.send({type: 'done normalizing'})
|
|
163
172
|
return
|
|
164
173
|
}
|
|
165
174
|
}
|
|
@@ -187,6 +196,7 @@ export function createWithPortableTextMarkModel(
|
|
|
187
196
|
|
|
188
197
|
if (orphanedAnnotations.length > 0) {
|
|
189
198
|
debug('Removing orphaned annotations from span node')
|
|
199
|
+
editorActor.send({type: 'normalizing'})
|
|
190
200
|
Transforms.setNodes(
|
|
191
201
|
editor,
|
|
192
202
|
{
|
|
@@ -196,6 +206,7 @@ export function createWithPortableTextMarkModel(
|
|
|
196
206
|
},
|
|
197
207
|
{at: path},
|
|
198
208
|
)
|
|
209
|
+
editorActor.send({type: 'done normalizing'})
|
|
199
210
|
return
|
|
200
211
|
}
|
|
201
212
|
}
|
|
@@ -216,7 +227,10 @@ export function createWithPortableTextMarkModel(
|
|
|
216
227
|
|
|
217
228
|
if (markDefs.length !== newMarkDefs.length) {
|
|
218
229
|
debug('Removing duplicate markDefs')
|
|
230
|
+
editorActor.send({type: 'normalizing'})
|
|
219
231
|
Transforms.setNodes(editor, {markDefs: newMarkDefs}, {at: path})
|
|
232
|
+
editorActor.send({type: 'done normalizing'})
|
|
233
|
+
return
|
|
220
234
|
}
|
|
221
235
|
}
|
|
222
236
|
|
|
@@ -241,6 +255,7 @@ export function createWithPortableTextMarkModel(
|
|
|
241
255
|
})
|
|
242
256
|
if (node.markDefs && !isEqual(newMarkDefs, node.markDefs)) {
|
|
243
257
|
debug('Removing markDef not in use')
|
|
258
|
+
editorActor.send({type: 'normalizing'})
|
|
244
259
|
Transforms.setNodes(
|
|
245
260
|
editor,
|
|
246
261
|
{
|
|
@@ -248,6 +263,7 @@ export function createWithPortableTextMarkModel(
|
|
|
248
263
|
},
|
|
249
264
|
{at: path},
|
|
250
265
|
)
|
|
266
|
+
editorActor.send({type: 'done normalizing'})
|
|
251
267
|
return
|
|
252
268
|
}
|
|
253
269
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type {Subject} from 'rxjs'
|
|
2
1
|
import type {BaseRange} from 'slate'
|
|
3
2
|
import type {
|
|
4
|
-
EditorChange,
|
|
5
3
|
EditorSelection,
|
|
6
4
|
PortableTextMemberSchemaTypes,
|
|
7
5
|
PortableTextSlateEditor,
|
|
@@ -12,13 +10,14 @@ import {
|
|
|
12
10
|
type ObjectWithKeyAndType,
|
|
13
11
|
} from '../../utils/ranges'
|
|
14
12
|
import {SLATE_TO_PORTABLE_TEXT_RANGE} from '../../utils/weakMaps'
|
|
13
|
+
import type {EditorActor} from '../editor-machine'
|
|
15
14
|
|
|
16
15
|
const debug = debugWithName('plugin:withPortableTextSelections')
|
|
17
16
|
const debugVerbose = debug.enabled && false
|
|
18
17
|
|
|
19
18
|
// This plugin will make sure that we emit a PT selection whenever the editor has changed.
|
|
20
19
|
export function createWithPortableTextSelections(
|
|
21
|
-
|
|
20
|
+
editorActor: EditorActor,
|
|
22
21
|
types: PortableTextMemberSchemaTypes,
|
|
23
22
|
): (editor: PortableTextSlateEditor) => PortableTextSlateEditor {
|
|
24
23
|
let prevSelection: BaseRange | null = null
|
|
@@ -46,9 +45,9 @@ export function createWithPortableTextSelections(
|
|
|
46
45
|
)
|
|
47
46
|
}
|
|
48
47
|
if (ptRange) {
|
|
49
|
-
|
|
48
|
+
editorActor.send({type: 'selection', selection: ptRange})
|
|
50
49
|
} else {
|
|
51
|
-
|
|
50
|
+
editorActor.send({type: 'selection', selection: null})
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
prevSelection = editor.selection
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
PortableTextSlateEditor,
|
|
13
13
|
} from '../../types/editor'
|
|
14
14
|
import {debugWithName} from '../../utils/debug'
|
|
15
|
+
import type {EditorActor} from '../editor-machine'
|
|
15
16
|
|
|
16
17
|
const debug = debugWithName('plugin:withSchemaTypes')
|
|
17
18
|
/**
|
|
@@ -19,9 +20,11 @@ const debug = debugWithName('plugin:withSchemaTypes')
|
|
|
19
20
|
*
|
|
20
21
|
*/
|
|
21
22
|
export function createWithSchemaTypes({
|
|
23
|
+
editorActor,
|
|
22
24
|
schemaTypes,
|
|
23
25
|
keyGenerator,
|
|
24
26
|
}: {
|
|
27
|
+
editorActor: EditorActor
|
|
25
28
|
schemaTypes: PortableTextMemberSchemaTypes
|
|
26
29
|
keyGenerator: () => string
|
|
27
30
|
}) {
|
|
@@ -71,18 +74,24 @@ export function createWithSchemaTypes({
|
|
|
71
74
|
debug('Setting span type on text node without a type')
|
|
72
75
|
const span = node as PortableTextSpan
|
|
73
76
|
const key = span._key || keyGenerator()
|
|
77
|
+
editorActor.send({type: 'normalizing'})
|
|
74
78
|
Transforms.setNodes(
|
|
75
79
|
editor,
|
|
76
80
|
{...span, _type: schemaTypes.span.name, _key: key},
|
|
77
81
|
{at: path},
|
|
78
82
|
)
|
|
83
|
+
editorActor.send({type: 'done normalizing'})
|
|
84
|
+
return
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
// catches cases when the children are missing keys but excludes it when the normalize is running the node as the editor object
|
|
82
88
|
if (node._key === undefined && (path.length === 1 || path.length === 2)) {
|
|
83
89
|
debug('Setting missing key on child node without a key')
|
|
84
90
|
const key = keyGenerator()
|
|
91
|
+
editorActor.send({type: 'normalizing'})
|
|
85
92
|
Transforms.setNodes(editor, {_key: key}, {at: path})
|
|
93
|
+
editorActor.send({type: 'done normalizing'})
|
|
94
|
+
return
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
normalizeNode(entry)
|
|
@@ -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 {
|
|
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(
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
116
|
+
editorActor,
|
|
107
117
|
schemaTypes,
|
|
108
118
|
)
|
|
109
119
|
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
export type
|
|
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,4 +1,3 @@
|
|
|
1
|
-
import {describe, expect, test} from '@jest/globals'
|
|
2
1
|
import type {DiffMatchPatch} from '@portabletext/patches'
|
|
3
2
|
import {makeDiff, makePatches, stringifyPatches} from '@sanity/diff-match-patch'
|
|
4
3
|
import {
|
|
@@ -10,6 +9,7 @@ import {
|
|
|
10
9
|
type PortableTextTextBlock,
|
|
11
10
|
} from '@sanity/types'
|
|
12
11
|
import type {Descendant, Operation} from 'slate'
|
|
12
|
+
import {describe, expect, test} from 'vitest'
|
|
13
13
|
import type {PortableTextSlateEditor} from '../../types/editor'
|
|
14
14
|
import {diffMatchPatch} from '../applyPatch'
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {beforeEach, describe, expect, it} from '@jest/globals'
|
|
2
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
|
-
|
|
65
|
-
|
|
66
|
-
"items":
|
|
67
|
-
|
|
64
|
+
[
|
|
65
|
+
{
|
|
66
|
+
"items": [
|
|
67
|
+
{
|
|
68
68
|
"_key": "773866318fa8",
|
|
69
69
|
"_type": "someObject",
|
|
70
70
|
"title": "The Object",
|
|
71
71
|
},
|
|
72
72
|
],
|
|
73
|
-
"path":
|
|
74
|
-
|
|
73
|
+
"path": [
|
|
74
|
+
{
|
|
75
75
|
"_key": "1f2e64b47787",
|
|
76
76
|
},
|
|
77
77
|
"children",
|
|
78
|
-
|
|
78
|
+
{
|
|
79
79
|
"_key": "c130395c640c",
|
|
80
80
|
},
|
|
81
81
|
],
|
|
82
82
|
"position": "after",
|
|
83
83
|
"type": "insert",
|
|
84
84
|
},
|
|
85
|
-
|
|
86
|
-
"path":
|
|
87
|
-
|
|
85
|
+
{
|
|
86
|
+
"path": [
|
|
87
|
+
{
|
|
88
88
|
"_key": "1f2e64b47787",
|
|
89
89
|
},
|
|
90
90
|
"children",
|
|
91
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
"items":
|
|
124
|
-
|
|
121
|
+
[
|
|
122
|
+
{
|
|
123
|
+
"items": [
|
|
124
|
+
{
|
|
125
125
|
"_key": "c130395c640c",
|
|
126
126
|
"_type": "someObject",
|
|
127
127
|
"title": "The Object",
|
|
128
128
|
},
|
|
129
129
|
],
|
|
130
|
-
"path":
|
|
131
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
"path":
|
|
163
|
+
[
|
|
164
|
+
{
|
|
165
|
+
"path": [],
|
|
166
166
|
"type": "setIfMissing",
|
|
167
|
-
"value":
|
|
167
|
+
"value": [],
|
|
168
168
|
},
|
|
169
|
-
|
|
170
|
-
"items":
|
|
171
|
-
|
|
169
|
+
{
|
|
170
|
+
"items": [
|
|
171
|
+
{
|
|
172
172
|
"_key": "c130395c640c",
|
|
173
173
|
"_type": "someObject",
|
|
174
174
|
},
|
|
175
175
|
],
|
|
176
|
-
"path":
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
"items":
|
|
208
|
-
|
|
205
|
+
[
|
|
206
|
+
{
|
|
207
|
+
"items": [
|
|
208
|
+
{
|
|
209
209
|
"_key": "c130395c640c",
|
|
210
210
|
"_type": "someObject",
|
|
211
211
|
"title": "The Object",
|
|
212
212
|
},
|
|
213
213
|
],
|
|
214
|
-
"path":
|
|
215
|
-
|
|
214
|
+
"path": [
|
|
215
|
+
{
|
|
216
216
|
"_key": "1f2e64b47787",
|
|
217
217
|
},
|
|
218
218
|
"children",
|
|
219
|
-
|
|
219
|
+
{
|
|
220
220
|
"_key": "fd9b4a4e6c0b",
|
|
221
221
|
},
|
|
222
222
|
],
|
|
@@ -243,14 +243,14 @@ describe('operationToPatches', () => {
|
|
|
243
243
|
createDefaultValue(),
|
|
244
244
|
),
|
|
245
245
|
).toMatchInlineSnapshot(`
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
"path":
|
|
249
|
-
|
|
246
|
+
[
|
|
247
|
+
{
|
|
248
|
+
"path": [
|
|
249
|
+
{
|
|
250
250
|
"_key": "1f2e64b47787",
|
|
251
251
|
},
|
|
252
252
|
"children",
|
|
253
|
-
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
"path":
|
|
286
|
-
|
|
283
|
+
[
|
|
284
|
+
{
|
|
285
|
+
"path": [
|
|
286
|
+
{
|
|
287
287
|
"_key": "1f2e64b47787",
|
|
288
288
|
},
|
|
289
289
|
"children",
|
|
290
|
-
|
|
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
|
-
|
|
324
|
-
|
|
325
|
-
"path":
|
|
326
|
-
|
|
323
|
+
[
|
|
324
|
+
{
|
|
325
|
+
"path": [
|
|
326
|
+
{
|
|
327
327
|
"_key": "1f2e64b47787",
|
|
328
328
|
},
|
|
329
329
|
"children",
|
|
330
|
-
|
|
330
|
+
{
|
|
331
331
|
"_key": "773866318fa8",
|
|
332
332
|
},
|
|
333
333
|
],
|
|
@@ -351,10 +351,10 @@ describe('operationToPatches', () => {
|
|
|
351
351
|
val,
|
|
352
352
|
),
|
|
353
353
|
).toMatchInlineSnapshot(`
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
"path":
|
|
357
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
"path":
|
|
395
|
-
|
|
392
|
+
[
|
|
393
|
+
{
|
|
394
|
+
"path": [
|
|
395
|
+
{
|
|
396
396
|
"_key": "1f2e64b47787",
|
|
397
397
|
},
|
|
398
398
|
"children",
|
|
399
|
-
|
|
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
|
-
|
|
408
|
-
"path":
|
|
409
|
-
|
|
407
|
+
{
|
|
408
|
+
"path": [
|
|
409
|
+
{
|
|
410
410
|
"_key": "1f2e64b47787",
|
|
411
411
|
},
|
|
412
412
|
"children",
|
|
413
|
-
|
|
413
|
+
{
|
|
414
414
|
"_key": "r4wr323432",
|
|
415
415
|
},
|
|
416
416
|
],
|