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.
149 lines
2.7 KiB
TypeScript
149 lines
2.7 KiB
TypeScript
import { loremIpsum } from './loremIpsum.js'
|
|
|
|
export function generateSlateRichText() {
|
|
return [
|
|
{
|
|
children: [
|
|
{
|
|
text: "Hello, I'm a rich text field.",
|
|
},
|
|
],
|
|
type: 'h1',
|
|
textAlign: 'center',
|
|
},
|
|
{
|
|
children: [
|
|
{
|
|
text: 'I can do all kinds of fun stuff like ',
|
|
},
|
|
{
|
|
type: 'link',
|
|
url: 'https://payloadcms.com',
|
|
newTab: true,
|
|
children: [
|
|
{
|
|
text: 'render links',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
text: ', ',
|
|
},
|
|
{
|
|
type: 'link',
|
|
linkType: 'internal',
|
|
doc: {
|
|
value: '{{ARRAY_DOC_ID}}',
|
|
relationTo: 'array-fields',
|
|
},
|
|
fields: {},
|
|
children: [
|
|
{
|
|
text: 'link to relationships',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
text: ', and store nested relationship fields:',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
children: [
|
|
{
|
|
text: '',
|
|
},
|
|
],
|
|
type: 'relationship',
|
|
value: {
|
|
id: '{{TEXT_DOC_ID}}',
|
|
},
|
|
relationTo: 'text-fields',
|
|
},
|
|
{
|
|
children: [
|
|
{
|
|
text: 'You can build your own elements, too.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'ul',
|
|
children: [
|
|
{
|
|
children: [
|
|
{
|
|
text: "It's built with SlateJS",
|
|
},
|
|
],
|
|
type: 'li',
|
|
},
|
|
{
|
|
type: 'li',
|
|
children: [
|
|
{
|
|
text: 'It stores content as JSON so you can use it wherever you need',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'li',
|
|
children: [
|
|
{
|
|
text: "It's got a great editing experience for non-technical users",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
children: [
|
|
{
|
|
text: 'And a whole lot more.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
children: [
|
|
{
|
|
text: '',
|
|
},
|
|
],
|
|
type: 'upload',
|
|
value: {
|
|
id: '{{UPLOAD_DOC_ID}}',
|
|
},
|
|
relationTo: 'uploads',
|
|
fields: {
|
|
caption: [
|
|
...[...Array(4)].map(() => {
|
|
return {
|
|
children: [
|
|
{
|
|
text: loremIpsum,
|
|
},
|
|
],
|
|
}
|
|
}),
|
|
],
|
|
},
|
|
},
|
|
{
|
|
children: [
|
|
{
|
|
text: '',
|
|
},
|
|
],
|
|
},
|
|
...[...Array(2)].map(() => {
|
|
return {
|
|
children: [
|
|
{
|
|
text: loremIpsum,
|
|
},
|
|
],
|
|
}
|
|
}),
|
|
]
|
|
}
|