@portabletext/editor 3.0.0 → 3.0.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/lib/_chunks-es/util.slice-blocks.js +68 -29
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.js +42 -21
- package/lib/index.js.map +1 -1
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/behaviors/behavior.abstract.split.ts +1 -0
- package/src/converters/converter.portable-text.ts +1 -0
- package/src/converters/converter.text-html.ts +1 -0
- package/src/converters/converter.text-plain.ts +1 -0
- package/src/editor/Editable.tsx +1 -0
- package/src/editor/plugins/create-with-event-listeners.ts +30 -2
- package/src/internal-utils/operation-to-patches.test.ts +23 -25
- package/src/internal-utils/operation-to-patches.ts +31 -22
- package/src/internal-utils/selection-text.test.ts +3 -0
- package/src/internal-utils/selection-text.ts +5 -2
- package/src/internal-utils/values.ts +23 -11
- package/src/operations/behavior.operation.block.set.ts +1 -0
- package/src/operations/behavior.operation.block.unset.ts +2 -0
- package/src/operations/behavior.operation.insert.block.ts +1 -0
- package/src/test/vitest/step-definitions.tsx +2 -0
- package/src/utils/parse-blocks.test.ts +333 -16
- package/src/utils/parse-blocks.ts +101 -27
- package/src/utils/util.merge-text-blocks.ts +5 -1
- package/src/utils/util.slice-blocks.ts +24 -10
|
@@ -17,7 +17,9 @@ export function sliceBlocks({
|
|
|
17
17
|
context,
|
|
18
18
|
blocks,
|
|
19
19
|
}: {
|
|
20
|
-
context: Pick<EditorContext, 'schema' | 'selection'>
|
|
20
|
+
context: Pick<EditorContext, 'schema' | 'selection'> & {
|
|
21
|
+
keyGenerator?: () => string
|
|
22
|
+
}
|
|
21
23
|
blocks: Array<PortableTextBlock>
|
|
22
24
|
}): Array<PortableTextBlock> {
|
|
23
25
|
const slice: Array<PortableTextBlock> = []
|
|
@@ -167,11 +169,15 @@ export function sliceBlocks({
|
|
|
167
169
|
middleBlocks.push(
|
|
168
170
|
parseBlock({
|
|
169
171
|
context: {
|
|
170
|
-
|
|
171
|
-
keyGenerator: defaultKeyGenerator,
|
|
172
|
+
schema: context.schema,
|
|
173
|
+
keyGenerator: context.keyGenerator ?? defaultKeyGenerator,
|
|
172
174
|
},
|
|
173
175
|
block,
|
|
174
|
-
options: {
|
|
176
|
+
options: {
|
|
177
|
+
normalize: false,
|
|
178
|
+
removeUnusedMarkDefs: true,
|
|
179
|
+
validateFields: false,
|
|
180
|
+
},
|
|
175
181
|
}) ?? block,
|
|
176
182
|
)
|
|
177
183
|
}
|
|
@@ -180,22 +186,30 @@ export function sliceBlocks({
|
|
|
180
186
|
const parsedStartBlock = startBlock
|
|
181
187
|
? parseBlock({
|
|
182
188
|
context: {
|
|
183
|
-
|
|
184
|
-
keyGenerator: defaultKeyGenerator,
|
|
189
|
+
schema: context.schema,
|
|
190
|
+
keyGenerator: context.keyGenerator ?? defaultKeyGenerator,
|
|
185
191
|
},
|
|
186
192
|
block: startBlock,
|
|
187
|
-
options: {
|
|
193
|
+
options: {
|
|
194
|
+
normalize: false,
|
|
195
|
+
removeUnusedMarkDefs: true,
|
|
196
|
+
validateFields: false,
|
|
197
|
+
},
|
|
188
198
|
})
|
|
189
199
|
: undefined
|
|
190
200
|
|
|
191
201
|
const parsedEndBlock = endBlock
|
|
192
202
|
? parseBlock({
|
|
193
203
|
context: {
|
|
194
|
-
|
|
195
|
-
keyGenerator: defaultKeyGenerator,
|
|
204
|
+
schema: context.schema,
|
|
205
|
+
keyGenerator: context.keyGenerator ?? defaultKeyGenerator,
|
|
196
206
|
},
|
|
197
207
|
block: endBlock,
|
|
198
|
-
options: {
|
|
208
|
+
options: {
|
|
209
|
+
normalize: false,
|
|
210
|
+
removeUnusedMarkDefs: true,
|
|
211
|
+
validateFields: false,
|
|
212
|
+
},
|
|
199
213
|
})
|
|
200
214
|
: undefined
|
|
201
215
|
|