๐Ÿ“ฆ payloadcms / payload

๐Ÿ“„ TabsWithRichText.ts ยท 54 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54/**
 * 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