fix: make outputSchema optional on richtext config (#4230)
This commit is contained in:
@@ -31,7 +31,7 @@ export type RichTextAdapter<
|
||||
siblingDoc: Record<string, unknown>
|
||||
}) => Promise<void> | null
|
||||
|
||||
outputSchema: ({
|
||||
outputSchema?: ({
|
||||
field,
|
||||
isRequired,
|
||||
}: {
|
||||
|
||||
@@ -97,7 +97,7 @@ export default joi.object({
|
||||
CellComponent: component.required(),
|
||||
FieldComponent: component.required(),
|
||||
afterReadPromise: joi.func().optional(),
|
||||
outputSchema: joi.func().required(),
|
||||
outputSchema: joi.func().optional(),
|
||||
populationPromise: joi.func().optional(),
|
||||
validate: joi.func().required(),
|
||||
})
|
||||
|
||||
@@ -434,7 +434,7 @@ export const richText = baseField.keys({
|
||||
CellComponent: componentSchema.required(),
|
||||
FieldComponent: componentSchema.required(),
|
||||
afterReadPromise: joi.func().optional(),
|
||||
outputSchema: joi.func().required(),
|
||||
outputSchema: joi.func().optional(),
|
||||
populationPromise: joi.func().optional(),
|
||||
validate: joi.func().required(),
|
||||
})
|
||||
|
||||
@@ -132,10 +132,20 @@ function fieldsToJSONSchema(
|
||||
}
|
||||
|
||||
case 'richText': {
|
||||
fieldSchema = field.editor.outputSchema({
|
||||
field,
|
||||
isRequired,
|
||||
})
|
||||
if (field.editor.outputSchema) {
|
||||
fieldSchema = field.editor.outputSchema({
|
||||
field,
|
||||
isRequired,
|
||||
})
|
||||
} else {
|
||||
// Maintain backwards compatibility with existing rich text editors
|
||||
fieldSchema = {
|
||||
items: {
|
||||
type: 'object',
|
||||
},
|
||||
type: withNullableJSONSchemaType('array', isRequired),
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user