chore(richtext-lexical): updated lexical incoming config API

This commit is contained in:
Alessio Gravili
2023-10-07 00:22:13 +02:00
parent b6de427f04
commit acfda5d8d4
4 changed files with 109 additions and 83 deletions

View File

@@ -24,7 +24,7 @@ export const UploadAndRichTextBlock: Block = {
{
name: 'richText',
type: 'richText',
editor: lexicalEditor({}),
editor: lexicalEditor(),
},
],
slug: 'uploadAndRichText',

View File

@@ -31,59 +31,48 @@ const RichTextFields: CollectionConfig = {
type: 'richText',
required: true,
editor: lexicalEditor({
userConfig(defaultEditorConfig) {
defaultEditorConfig.features.push(TreeviewFeature())
defaultEditorConfig.features.push(
LinkFeature({
fields: [
{
name: 'rel',
label: 'Rel Attribute',
type: 'select',
hasMany: true,
options: ['noopener', 'noreferrer', 'nofollow'],
admin: {
description:
'The rel attribute defines the relationship between a linked resource and the current document. This is a custom link field.',
},
},
],
}),
)
defaultEditorConfig.features.push(
UploadFeature({
collections: {
uploads: {
fields: [
{
name: 'caption',
type: 'richText',
editor: lexicalEditor({}),
},
],
features: ({ defaultFeatures }) => [
...defaultFeatures,
TreeviewFeature(),
LinkFeature({
fields: [
{
name: 'rel',
label: 'Rel Attribute',
type: 'select',
hasMany: true,
options: ['noopener', 'noreferrer', 'nofollow'],
admin: {
description:
'The rel attribute defines the relationship between a linked resource and the current document. This is a custom link field.',
},
},
}),
)
defaultEditorConfig.features.push(
BlocksFeature({
blocks: [TextBlock, UploadAndRichTextBlock],
}),
)
return defaultEditorConfig
},
],
}),
UploadFeature({
collections: {
uploads: {
fields: [
{
name: 'caption',
type: 'richText',
editor: lexicalEditor(),
},
],
},
},
}),
BlocksFeature({
blocks: [TextBlock, UploadAndRichTextBlock],
}),
],
}),
},
{
name: 'richTextLexical',
type: 'richText',
editor: lexicalEditor({
userConfig(defaultEditorConfig) {
defaultEditorConfig.features.push(TreeviewFeature())
return defaultEditorConfig
},
features: ({ defaultFeatures }) => [...defaultFeatures, TreeviewFeature()],
}),
},
{