@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.
@@ -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
- ...context,
171
- keyGenerator: defaultKeyGenerator,
172
+ schema: context.schema,
173
+ keyGenerator: context.keyGenerator ?? defaultKeyGenerator,
172
174
  },
173
175
  block,
174
- options: {removeUnusedMarkDefs: true, validateFields: false},
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
- ...context,
184
- keyGenerator: defaultKeyGenerator,
189
+ schema: context.schema,
190
+ keyGenerator: context.keyGenerator ?? defaultKeyGenerator,
185
191
  },
186
192
  block: startBlock,
187
- options: {removeUnusedMarkDefs: true, validateFields: false},
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
- ...context,
195
- keyGenerator: defaultKeyGenerator,
204
+ schema: context.schema,
205
+ keyGenerator: context.keyGenerator ?? defaultKeyGenerator,
196
206
  },
197
207
  block: endBlock,
198
- options: {removeUnusedMarkDefs: true, validateFields: false},
208
+ options: {
209
+ normalize: false,
210
+ removeUnusedMarkDefs: true,
211
+ validateFields: false,
212
+ },
199
213
  })
200
214
  : undefined
201
215