Lexical tests comprise almost half of the collections in the fields suite, and are starting to become complex to manage. They are sometimes related to other auxiliary collections, so refactoring one test sometimes breaks another, seemingly unrelated one. In addition, the fields suite is very large, taking a long time to compile. This will make it faster. Some ideas for future refactorings: - 3 main collections: defaultFeatures, fully featured, and legacy. Legacy is the current one that has multiple editors and could later be migrated to the first two. - Avoid collections with more than 1 editor. - Create reseed buttons to restore the editor to certain states, to avoid a proliferation of collections and documents. - Reduce the complexity of the three auxiliary collections (text, array, upload), which are rarely or never used and have many fields designed for tests in the fields suite.
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
/**
|
|
* IMPORTANT: Do not change this style. This specific configuration is needed to reproduce this issue before it was fixed (https://github.com/payloadcms/payload/issues/4282):
|
|
* - lexicalEditor initialized on the outside and then shared between two richText fields
|
|
* - tabs field with two tabs, each with a richText field
|
|
* - each tab has a different label in each language. Needs to be a LOCALIZED label, not a single label for all languages. Only then can it be reproduced
|
|
*/
|
|
|
|
import type { GlobalConfig } from 'payload'
|
|
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
|
|
const initializedEditor = lexicalEditor()
|
|
|
|
const TabsWithRichText: GlobalConfig = {
|
|
slug: 'tabsWithRichText',
|
|
fields: [
|
|
{
|
|
type: 'tabs',
|
|
tabs: [
|
|
{
|
|
name: 'tab1',
|
|
label: {
|
|
en: 'en tab1',
|
|
es: 'es tab1',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'rt1',
|
|
type: 'richText',
|
|
editor: initializedEditor,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'tab2',
|
|
label: {
|
|
en: 'en tab2',
|
|
es: 'es tab2',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'rt2',
|
|
type: 'richText',
|
|
editor: initializedEditor,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|
|
|
|
export default TabsWithRichText
|