@portabletext/editor 2.3.1 → 2.3.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-dts/behavior.types.action.d.cts +51 -51
- package/lib/_chunks-dts/behavior.types.action.d.ts +122 -122
- package/lib/index.cjs +40 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +40 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.cts +2 -2
- package/lib/utils/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/converters/converter.text-plain.test.ts +7 -5
- package/src/editor/__tests__/PortableTextEditor.test.tsx +5 -14
- package/src/editor/__tests__/PortableTextEditorTester.tsx +23 -77
- package/src/editor/__tests__/RangeDecorations.test.tsx +2 -9
- package/src/editor/__tests__/insert-block.test.tsx +7 -28
- package/src/editor/__tests__/self-solving.test.tsx +5 -17
- package/src/editor/create-editor.ts +4 -1
- package/src/editor/editor-schema.ts +36 -3
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +8 -15
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +7 -11
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +81 -63
- package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +2 -9
- package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +3 -7
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +17 -27
- package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +3 -7
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +4 -9
- package/src/internal-utils/__tests__/valueNormalization.test.tsx +3 -7
- package/src/internal-utils/__tests__/values.test.ts +5 -6
- package/src/internal-utils/operation-to-patches.test.ts +17 -12
- package/src/plugins/plugin.internal.portable-text-editor-ref.tsx +16 -0
- package/src/editor/__tests__/sync-value.test.tsx +0 -154
package/lib/index.cjs
CHANGED
|
@@ -8559,6 +8559,45 @@ function legacySchemaToEditorSchema(schema2) {
|
|
|
8559
8559
|
}))
|
|
8560
8560
|
};
|
|
8561
8561
|
}
|
|
8562
|
+
function compileSchemaDefinition(definition) {
|
|
8563
|
+
const styles = (definition.styles ?? []).map((style) => ({
|
|
8564
|
+
...style,
|
|
8565
|
+
value: style.name
|
|
8566
|
+
}));
|
|
8567
|
+
return {
|
|
8568
|
+
block: {
|
|
8569
|
+
name: "block"
|
|
8570
|
+
},
|
|
8571
|
+
span: {
|
|
8572
|
+
name: "span"
|
|
8573
|
+
},
|
|
8574
|
+
styles: styles.some((style) => style.value === "normal") ? styles : [{
|
|
8575
|
+
value: "normal",
|
|
8576
|
+
name: "normal",
|
|
8577
|
+
title: "Normal"
|
|
8578
|
+
}, ...styles],
|
|
8579
|
+
lists: (definition.lists ?? []).map((list) => ({
|
|
8580
|
+
...list,
|
|
8581
|
+
value: list.name
|
|
8582
|
+
})),
|
|
8583
|
+
decorators: (definition.decorators ?? []).map((decorator) => ({
|
|
8584
|
+
...decorator,
|
|
8585
|
+
value: decorator.name
|
|
8586
|
+
})),
|
|
8587
|
+
annotations: (definition.annotations ?? []).map((annotation) => ({
|
|
8588
|
+
...annotation,
|
|
8589
|
+
fields: annotation.fields ?? []
|
|
8590
|
+
})),
|
|
8591
|
+
blockObjects: (definition.blockObjects ?? []).map((blockObject) => ({
|
|
8592
|
+
...blockObject,
|
|
8593
|
+
fields: blockObject.fields ?? []
|
|
8594
|
+
})),
|
|
8595
|
+
inlineObjects: (definition.inlineObjects ?? []).map((inlineObject) => ({
|
|
8596
|
+
...inlineObject,
|
|
8597
|
+
fields: inlineObject.fields ?? []
|
|
8598
|
+
}))
|
|
8599
|
+
};
|
|
8600
|
+
}
|
|
8562
8601
|
function compileSchemaDefinitionToLegacySchema(definition) {
|
|
8563
8602
|
const blockObjects = definition?.blockObjects?.map((blockObject) => types.defineType({
|
|
8564
8603
|
type: "object",
|
|
@@ -10281,7 +10320,7 @@ function editorConfigToMachineInput(config) {
|
|
|
10281
10320
|
};
|
|
10282
10321
|
}
|
|
10283
10322
|
function compileSchemasFromEditorConfig(config) {
|
|
10284
|
-
const legacySchema = config.schemaDefinition ? compileSchemaDefinitionToLegacySchema(config.schemaDefinition) : createLegacySchema(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)), schema2 = legacySchemaToEditorSchema(legacySchema);
|
|
10323
|
+
const legacySchema = config.schemaDefinition ? compileSchemaDefinitionToLegacySchema(config.schemaDefinition) : createLegacySchema(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)), schema2 = config.schemaDefinition ? compileSchemaDefinition(config.schemaDefinition) : legacySchemaToEditorSchema(legacySchema);
|
|
10285
10324
|
return {
|
|
10286
10325
|
legacySchema,
|
|
10287
10326
|
schema: schema2
|