BREAKING: requires user to install @payloacms-richtext-slate and specify a `config.editor` property * chore: move slate stuff into packages/richtext-slate * chore: fieldTypes stuff * chore: fix richtext-slate tsconfig * chore: add clean:unix command * chore: fix up things * chore: undo subpath imports being hoisted up * chore: fix incorrect imports * chore: improve AdapterArguments type * chore: remove unused richTextToHTML and stringifyRichText files * fix: core-dev scss imports * chore: fix publishConfig exports for richtext-slate * chore: adjust joi schema for richtext field * chore: various fixes * chore: handle afterRead population in richText adapter * chore: handle more after-read promise stuff * chore: fix joi validation * chore: add richtext adapter to tests * chore: merge adapter props with field props * chore: index.tsx => index.ts * chore: rename `adapter` to `editor` * chore: fix e2e tests not running due to importing a constant from a file (`Tabs`) which imports createSlate. This fails because createSlate imports React components. * chore: remove unnecessary import * chore: improve various typings * chore: improve typings for List view Cell components * feat: richText adapter cell component * chore: add missing types packages for packages/richtext-slate * chore: add new adapter interface properties to joi schema * chore: withMergedProps utility which replaces getSlateCellComponent and getSlateFieldComponent * feat: added config.defaultEditor property which is now required. field.editor is no longer required and overrides config.defaultEditor * docs: mention editor and defaultEditor property in the docs * chore: fix incorrectly formatted JSX in docs files breaking mdx parser * chore: fix various errors * chore: auto-generated pointer files
384 lines
7.7 KiB
TypeScript
384 lines
7.7 KiB
TypeScript
import path from 'path'
|
|
|
|
import { mapAsync } from '../../packages/payload/src/utilities/mapAsync'
|
|
import { createSlate } from '../../packages/richtext-slate/src'
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults'
|
|
import { devUser } from '../credentials'
|
|
import AfterDashboard from './components/AfterDashboard'
|
|
import AfterNavLinks from './components/AfterNavLinks'
|
|
import BeforeLogin from './components/BeforeLogin'
|
|
import DemoUIFieldCell from './components/DemoUIField/Cell'
|
|
import DemoUIFieldField from './components/DemoUIField/Field'
|
|
import Logout from './components/Logout'
|
|
import CustomDefaultRoute from './components/routes/CustomDefault'
|
|
import CustomMinimalRoute from './components/routes/CustomMinimal'
|
|
import CustomDefaultView from './components/views/CustomDefault'
|
|
import CustomEditView from './components/views/CustomEdit'
|
|
import CustomVersionsView from './components/views/CustomVersions'
|
|
import CustomView from './components/views/CustomView'
|
|
import { globalSlug, slug } from './shared'
|
|
|
|
export interface Post {
|
|
createdAt: Date
|
|
description: string
|
|
id: string
|
|
title: string
|
|
updatedAt: Date
|
|
}
|
|
|
|
export default buildConfigWithDefaults({
|
|
admin: {
|
|
css: path.resolve(__dirname, 'styles.scss'),
|
|
components: {
|
|
// providers: [CustomProvider, CustomProvider],
|
|
routes: [
|
|
{
|
|
path: '/custom-minimal-route',
|
|
Component: CustomMinimalRoute,
|
|
},
|
|
{
|
|
path: '/custom-default-route',
|
|
Component: CustomDefaultRoute,
|
|
},
|
|
],
|
|
afterDashboard: [AfterDashboard],
|
|
beforeLogin: [BeforeLogin],
|
|
logout: {
|
|
Button: Logout,
|
|
},
|
|
afterNavLinks: [AfterNavLinks],
|
|
views: {
|
|
// Dashboard: CustomDashboardView,
|
|
// Account: CustomAccountView,
|
|
},
|
|
},
|
|
},
|
|
i18n: {
|
|
resources: {
|
|
en: {
|
|
general: {
|
|
dashboard: 'Home',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
localization: {
|
|
locales: ['en', 'es'],
|
|
},
|
|
collections: [
|
|
{
|
|
slug: 'users',
|
|
auth: true,
|
|
admin: {
|
|
useAsTitle: 'email',
|
|
},
|
|
fields: [],
|
|
},
|
|
{
|
|
slug: 'hidden-collection',
|
|
admin: {
|
|
hidden: () => true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug,
|
|
admin: {
|
|
description: 'Description',
|
|
listSearchableFields: ['title', 'description', 'number'],
|
|
group: 'One',
|
|
useAsTitle: 'title',
|
|
defaultColumns: ['id', 'number', 'title', 'description', 'demoUIField'],
|
|
preview: () => 'https://payloadcms.com',
|
|
},
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'description',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'number',
|
|
type: 'number',
|
|
},
|
|
{
|
|
name: 'richText',
|
|
type: 'richText',
|
|
editor: createSlate({
|
|
admin: {
|
|
elements: ['relationship'],
|
|
},
|
|
}),
|
|
},
|
|
{
|
|
type: 'ui',
|
|
name: 'demoUIField',
|
|
label: 'Demo UI Field',
|
|
admin: {
|
|
components: {
|
|
Field: DemoUIFieldField,
|
|
Cell: DemoUIFieldCell,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'custom-views-one',
|
|
versions: true,
|
|
admin: {
|
|
components: {
|
|
views: {
|
|
// This will override the entire Edit view including all nested views, i.e. `/edit/:id/*`
|
|
// To override one specific nested view, use the nested view's slug as the key
|
|
Edit: CustomEditView,
|
|
},
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'custom-views-two',
|
|
versions: true,
|
|
admin: {
|
|
components: {
|
|
views: {
|
|
Edit: {
|
|
// This will override one specific nested view within the `/edit/:id` route, i.e. `/edit/:id/versions`
|
|
Default: CustomDefaultView,
|
|
Versions: CustomVersionsView,
|
|
MyCustomView: {
|
|
path: '/custom',
|
|
Component: CustomView,
|
|
label: 'Custom',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'group-one-collection-ones',
|
|
admin: {
|
|
group: 'One',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'group-one-collection-twos',
|
|
admin: {
|
|
group: 'One',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'group-two-collection-ones',
|
|
admin: {
|
|
group: 'Two',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'group-two-collection-twos',
|
|
admin: {
|
|
group: 'Two',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'geo',
|
|
fields: [
|
|
{
|
|
name: 'point',
|
|
type: 'point',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
globals: [
|
|
{
|
|
slug: 'hidden-global',
|
|
admin: {
|
|
hidden: () => true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: globalSlug,
|
|
admin: {
|
|
group: 'Group',
|
|
},
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
|
|
{
|
|
slug: 'custom-global-views-one',
|
|
versions: true,
|
|
admin: {
|
|
components: {
|
|
views: {
|
|
Edit: CustomEditView,
|
|
},
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'custom-global-views-two',
|
|
versions: true,
|
|
admin: {
|
|
components: {
|
|
views: {
|
|
Edit: {
|
|
Default: CustomDefaultView,
|
|
Versions: CustomVersionsView,
|
|
MyCustomView: {
|
|
path: '/custom',
|
|
Component: CustomView,
|
|
label: 'Custom',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'group-globals-one',
|
|
admin: {
|
|
group: 'Group',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
slug: 'group-globals-two',
|
|
admin: {
|
|
group: 'Group',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
onInit: async (payload) => {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
|
|
await mapAsync([...Array(11)], async () => {
|
|
await payload.create({
|
|
collection: slug,
|
|
data: {
|
|
title: 'title',
|
|
description: 'description',
|
|
},
|
|
})
|
|
})
|
|
|
|
await payload.create({
|
|
collection: 'custom-views-one',
|
|
data: {
|
|
title: 'title',
|
|
},
|
|
})
|
|
|
|
await payload.create({
|
|
collection: 'custom-views-two',
|
|
data: {
|
|
title: 'title',
|
|
},
|
|
})
|
|
|
|
await payload.create({
|
|
collection: 'geo',
|
|
data: {
|
|
point: [7, -7],
|
|
},
|
|
})
|
|
|
|
await payload.create({
|
|
collection: 'geo',
|
|
data: {
|
|
point: [5, -5],
|
|
},
|
|
})
|
|
},
|
|
})
|