@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.js
CHANGED
|
@@ -8588,6 +8588,45 @@ function legacySchemaToEditorSchema(schema) {
|
|
|
8588
8588
|
}))
|
|
8589
8589
|
};
|
|
8590
8590
|
}
|
|
8591
|
+
function compileSchemaDefinition(definition) {
|
|
8592
|
+
const styles = (definition.styles ?? []).map((style) => ({
|
|
8593
|
+
...style,
|
|
8594
|
+
value: style.name
|
|
8595
|
+
}));
|
|
8596
|
+
return {
|
|
8597
|
+
block: {
|
|
8598
|
+
name: "block"
|
|
8599
|
+
},
|
|
8600
|
+
span: {
|
|
8601
|
+
name: "span"
|
|
8602
|
+
},
|
|
8603
|
+
styles: styles.some((style) => style.value === "normal") ? styles : [{
|
|
8604
|
+
value: "normal",
|
|
8605
|
+
name: "normal",
|
|
8606
|
+
title: "Normal"
|
|
8607
|
+
}, ...styles],
|
|
8608
|
+
lists: (definition.lists ?? []).map((list) => ({
|
|
8609
|
+
...list,
|
|
8610
|
+
value: list.name
|
|
8611
|
+
})),
|
|
8612
|
+
decorators: (definition.decorators ?? []).map((decorator) => ({
|
|
8613
|
+
...decorator,
|
|
8614
|
+
value: decorator.name
|
|
8615
|
+
})),
|
|
8616
|
+
annotations: (definition.annotations ?? []).map((annotation) => ({
|
|
8617
|
+
...annotation,
|
|
8618
|
+
fields: annotation.fields ?? []
|
|
8619
|
+
})),
|
|
8620
|
+
blockObjects: (definition.blockObjects ?? []).map((blockObject) => ({
|
|
8621
|
+
...blockObject,
|
|
8622
|
+
fields: blockObject.fields ?? []
|
|
8623
|
+
})),
|
|
8624
|
+
inlineObjects: (definition.inlineObjects ?? []).map((inlineObject) => ({
|
|
8625
|
+
...inlineObject,
|
|
8626
|
+
fields: inlineObject.fields ?? []
|
|
8627
|
+
}))
|
|
8628
|
+
};
|
|
8629
|
+
}
|
|
8591
8630
|
function compileSchemaDefinitionToLegacySchema(definition) {
|
|
8592
8631
|
const blockObjects = definition?.blockObjects?.map((blockObject) => defineType({
|
|
8593
8632
|
type: "object",
|
|
@@ -10310,7 +10349,7 @@ function editorConfigToMachineInput(config) {
|
|
|
10310
10349
|
};
|
|
10311
10350
|
}
|
|
10312
10351
|
function compileSchemasFromEditorConfig(config) {
|
|
10313
|
-
const legacySchema = config.schemaDefinition ? compileSchemaDefinitionToLegacySchema(config.schemaDefinition) : createLegacySchema(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)), schema = legacySchemaToEditorSchema(legacySchema);
|
|
10352
|
+
const legacySchema = config.schemaDefinition ? compileSchemaDefinitionToLegacySchema(config.schemaDefinition) : createLegacySchema(config.schema.hasOwnProperty("jsonType") ? config.schema : compileType(config.schema)), schema = config.schemaDefinition ? compileSchemaDefinition(config.schemaDefinition) : legacySchemaToEditorSchema(legacySchema);
|
|
10314
10353
|
return {
|
|
10315
10354
|
legacySchema,
|
|
10316
10355
|
schema
|