Co-authored-by: shikhantmaungs <shinkhantmaungs@gmail.com> Co-authored-by: Thomas Ghysels <info@thomasg.be> Co-authored-by: Kokutse Djoguenou <kokutse@Kokutses-MacBook-Pro.local> Co-authored-by: Christian Gil <47041342+ChrisGV04@users.noreply.github.com> Co-authored-by: Łukasz Rabiec <lukaszrabiec@gmail.com> Co-authored-by: Jenny <jennifer.eberlei@gmail.com> Co-authored-by: Hung Vu <hunghvu2017@gmail.com> Co-authored-by: Shin Khant Maung <101539335+shinkhantmaungs@users.noreply.github.com> Co-authored-by: Carlo Brualdi <carlo.brualdi@gmail.com> Co-authored-by: Ariel Tonglet <ariel.tonglet@gmail.com> Co-authored-by: Roman Ryzhikov <general+github@ya.ru> Co-authored-by: maekoya <maekoya@stromatolite.jp> Co-authored-by: Emilia Trollros <3m1l1a@emiliatrollros.se> Co-authored-by: Kokutse J Djoguenou <90865585+Julesdj@users.noreply.github.com> Co-authored-by: Mitch Dries <mitch.dries@gmail.com> BREAKING CHANGE: If you assigned labels to collections, globals or block names, you need to update your config! Your GraphQL schema and generated Typescript interfaces may have changed. Payload no longer uses labels for code based naming. To prevent breaking changes to your GraphQL API and typescript types in your project, you can assign the below properties to match what Payload previously generated for you from labels. On Collections Use `graphQL.singularName`, `graphQL.pluralName` for GraphQL schema names. Use `typescript.interface` for typescript generation name. On Globals Use `graphQL.name` for GraphQL Schema name. Use `typescript.interface` for typescript generation name. On Blocks (within Block fields) Use `graphQL.singularName` for graphQL schema names.
213 lines
4.3 KiB
TypeScript
213 lines
4.3 KiB
TypeScript
import type { CollectionConfig } from '../../../../src/collections/config/types';
|
|
import { Field } from '../../../../src/fields/config/types';
|
|
|
|
export const blocksFieldSeedData = [
|
|
{
|
|
blockName: 'First block',
|
|
blockType: 'text',
|
|
text: 'first block',
|
|
richText: [],
|
|
},
|
|
{
|
|
blockName: 'Second block',
|
|
blockType: 'number',
|
|
number: 342,
|
|
},
|
|
{
|
|
blockName: 'Sub-block demonstration',
|
|
blockType: 'subBlocks',
|
|
subBlocks: [
|
|
{
|
|
blockName: 'First sub block',
|
|
blockType: 'number',
|
|
number: 123,
|
|
},
|
|
{
|
|
blockName: 'Second sub block',
|
|
blockType: 'text',
|
|
text: 'second sub block',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
blockName: 'I18n Block',
|
|
blockType: 'i18n-text',
|
|
text: 'first block',
|
|
},
|
|
] as const;
|
|
|
|
export const blocksField: Field = {
|
|
name: 'blocks',
|
|
type: 'blocks',
|
|
required: true,
|
|
blocks: [
|
|
{
|
|
slug: 'text',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'richText',
|
|
type: 'richText',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'number',
|
|
fields: [
|
|
{
|
|
name: 'number',
|
|
type: 'number',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'subBlocks',
|
|
fields: [
|
|
{
|
|
type: 'collapsible',
|
|
label: 'Collapsible within Block',
|
|
fields: [
|
|
{
|
|
name: 'subBlocks',
|
|
type: 'blocks',
|
|
blocks: [
|
|
{
|
|
slug: 'text',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'number',
|
|
fields: [
|
|
{
|
|
name: 'number',
|
|
type: 'number',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'tabs',
|
|
fields: [
|
|
{
|
|
type: 'tabs',
|
|
tabs: [
|
|
{
|
|
label: 'Tab with Collapsible',
|
|
fields: [
|
|
{
|
|
type: 'collapsible',
|
|
label: 'Collapsible within Block',
|
|
fields: [
|
|
{
|
|
// collapsible
|
|
name: 'textInCollapsible',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{
|
|
// collapsible
|
|
name: 'textInRow',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
defaultValue: blocksFieldSeedData,
|
|
};
|
|
|
|
const BlockFields: CollectionConfig = {
|
|
slug: 'block-fields',
|
|
fields: [
|
|
blocksField,
|
|
{
|
|
...blocksField,
|
|
name: 'collapsedByDefaultBlocks',
|
|
localized: true,
|
|
admin: {
|
|
initCollapsed: true,
|
|
},
|
|
},
|
|
{
|
|
...blocksField,
|
|
name: 'localizedBlocks',
|
|
localized: true,
|
|
},
|
|
{
|
|
type: 'blocks',
|
|
name: 'i18nBlocks',
|
|
label: {
|
|
en: 'Block en',
|
|
es: 'Block es',
|
|
},
|
|
labels: {
|
|
singular: {
|
|
en: 'Block en',
|
|
es: 'Block es',
|
|
},
|
|
plural: {
|
|
en: 'Blocks en',
|
|
es: 'Blocks es',
|
|
},
|
|
},
|
|
blocks: [
|
|
{
|
|
slug: 'text',
|
|
graphQL: {
|
|
singularName: 'I18nText',
|
|
},
|
|
labels: {
|
|
singular: {
|
|
en: 'Text en',
|
|
es: 'Text es',
|
|
},
|
|
plural: {
|
|
en: 'Texts en',
|
|
es: 'Texts es',
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
export const blocksDoc = {
|
|
blocks: blocksFieldSeedData,
|
|
localizedBlocks: blocksFieldSeedData,
|
|
};
|
|
|
|
export default BlockFields;
|