@portabletext/editor 3.0.6 → 3.0.8
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-dts/index.d.ts +2 -2
- package/lib/_chunks-es/util.slice-blocks.js +1 -8
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.js +112 -131
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
- package/src/converters/converter.portable-text.deserialize.test.ts +0 -13
- package/src/editor/Editable.tsx +3 -11
- package/src/editor/create-editor.ts +1 -7
- package/src/editor/create-slate-editor.tsx +13 -13
- package/src/editor/plugins/createWithEditableAPI.ts +68 -75
- package/src/editor/plugins/createWithPatches.ts +20 -23
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +19 -0
- package/src/editor/range-decorations-machine.ts +1 -1
- package/src/editor/weakMaps.ts +0 -2
- package/src/history/slate-plugin.history.ts +1 -5
- package/src/internal-utils/__tests__/values.test.ts +1 -121
- package/src/internal-utils/applyPatch.ts +1 -1
- package/src/internal-utils/operation-to-patches.test.ts +31 -6
- package/src/internal-utils/operation-to-patches.ts +10 -16
- package/src/internal-utils/values.test.ts +0 -7
- package/src/internal-utils/values.ts +70 -34
- package/src/operations/behavior.operation.block.unset.ts +12 -36
- package/src/operations/behavior.operation.child.unset.ts +33 -15
- package/src/utils/parse-blocks.test.ts +0 -16
- package/src/utils/parse-blocks.ts +6 -11
|
@@ -129,8 +129,6 @@ describe(parseBlock.name, () => {
|
|
|
129
129
|
marks: [],
|
|
130
130
|
},
|
|
131
131
|
],
|
|
132
|
-
markDefs: [],
|
|
133
|
-
style: 'normal',
|
|
134
132
|
})
|
|
135
133
|
})
|
|
136
134
|
|
|
@@ -160,8 +158,6 @@ describe(parseBlock.name, () => {
|
|
|
160
158
|
marks: [],
|
|
161
159
|
},
|
|
162
160
|
],
|
|
163
|
-
markDefs: [],
|
|
164
|
-
style: 'normal',
|
|
165
161
|
})
|
|
166
162
|
})
|
|
167
163
|
|
|
@@ -271,8 +267,6 @@ describe(parseBlock.name, () => {
|
|
|
271
267
|
marks: ['em'],
|
|
272
268
|
},
|
|
273
269
|
],
|
|
274
|
-
markDefs: [],
|
|
275
|
-
style: 'normal',
|
|
276
270
|
})
|
|
277
271
|
})
|
|
278
272
|
|
|
@@ -301,9 +295,7 @@ describe(parseBlock.name, () => {
|
|
|
301
295
|
marks: [],
|
|
302
296
|
},
|
|
303
297
|
],
|
|
304
|
-
markDefs: [],
|
|
305
298
|
listItem: 'bullet',
|
|
306
|
-
style: 'normal',
|
|
307
299
|
})
|
|
308
300
|
})
|
|
309
301
|
|
|
@@ -332,8 +324,6 @@ describe(parseBlock.name, () => {
|
|
|
332
324
|
marks: [],
|
|
333
325
|
},
|
|
334
326
|
],
|
|
335
|
-
markDefs: [],
|
|
336
|
-
style: 'normal',
|
|
337
327
|
})
|
|
338
328
|
})
|
|
339
329
|
|
|
@@ -363,8 +353,6 @@ describe(parseBlock.name, () => {
|
|
|
363
353
|
marks: [],
|
|
364
354
|
},
|
|
365
355
|
],
|
|
366
|
-
markDefs: [],
|
|
367
|
-
style: 'normal',
|
|
368
356
|
})
|
|
369
357
|
})
|
|
370
358
|
|
|
@@ -398,8 +386,6 @@ describe(parseBlock.name, () => {
|
|
|
398
386
|
marks: [],
|
|
399
387
|
},
|
|
400
388
|
],
|
|
401
|
-
markDefs: [],
|
|
402
|
-
style: 'normal',
|
|
403
389
|
})
|
|
404
390
|
})
|
|
405
391
|
|
|
@@ -432,8 +418,6 @@ describe(parseBlock.name, () => {
|
|
|
432
418
|
marks: [],
|
|
433
419
|
},
|
|
434
420
|
],
|
|
435
|
-
markDefs: [],
|
|
436
|
-
style: 'normal',
|
|
437
421
|
})
|
|
438
422
|
})
|
|
439
423
|
})
|
|
@@ -249,25 +249,20 @@ export function parseTextBlock({
|
|
|
249
249
|
_type: context.schema.block.name,
|
|
250
250
|
_key,
|
|
251
251
|
children: normalizedChildren,
|
|
252
|
-
markDefs: options.removeUnusedMarkDefs
|
|
253
|
-
? markDefs.filter((markDef) => marks.includes(markDef._key))
|
|
254
|
-
: markDefs,
|
|
255
252
|
...customFields,
|
|
256
253
|
}
|
|
257
254
|
|
|
255
|
+
if (typeof block.markDefs === 'object' && block.markDefs !== null) {
|
|
256
|
+
parsedBlock.markDefs = options.removeUnusedMarkDefs
|
|
257
|
+
? markDefs.filter((markDef) => marks.includes(markDef._key))
|
|
258
|
+
: markDefs
|
|
259
|
+
}
|
|
260
|
+
|
|
258
261
|
if (
|
|
259
262
|
typeof block.style === 'string' &&
|
|
260
263
|
context.schema.styles.find((style) => style.name === block.style)
|
|
261
264
|
) {
|
|
262
265
|
parsedBlock.style = block.style
|
|
263
|
-
} else {
|
|
264
|
-
const defaultStyle = context.schema.styles.at(0)?.name
|
|
265
|
-
|
|
266
|
-
if (defaultStyle !== undefined) {
|
|
267
|
-
parsedBlock.style = defaultStyle
|
|
268
|
-
} else {
|
|
269
|
-
console.error('Expected default style')
|
|
270
|
-
}
|
|
271
266
|
}
|
|
272
267
|
|
|
273
268
|
if (
|