fix(richtext-lexical): defaultValue property didn't fit into field schema

This commit is contained in:
Alessio Gravili
2023-10-21 14:52:26 +02:00
parent 931f6ff519
commit b5c7bbed93
2 changed files with 28 additions and 1 deletions

View File

@@ -353,7 +353,7 @@ export const blocks = baseField.keys({
export const richText = baseField.keys({
name: joi.string().required(),
admin: baseAdminFields.default(),
defaultValue: joi.alternatives().try(joi.array().items(joi.object()), joi.func()),
defaultValue: joi.alternatives().try(joi.array().items(joi.object()), joi.func(), joi.object()),
editor: joi
.object()
.keys({

View File

@@ -75,6 +75,33 @@ const RichTextFields: CollectionConfig = {
{
name: 'richTextLexical',
type: 'richText',
admin: {
description: 'This rich text field uses the lexical editor.',
},
defaultValue: {
root: {
children: [
{
children: [
{
text: 'This is a paragraph.',
type: 'text',
},
],
direction: null,
format: '',
indent: 0,
type: 'paragraph',
version: 1,
},
],
direction: null,
format: '',
indent: 0,
type: 'root',
version: 1,
},
},
editor: lexicalEditor({
features: ({ defaultFeatures }) => [...defaultFeatures, TreeviewFeature()],
}),