Files
payloadcms/test/lexical/baseConfig.ts
German Jablonski 207caa570c fix(richtext-lexical): prevent disallowed headings to be pasted (#13765)
Fixes #13705

With this PR, if the editor detects a disallowed heading in
`HeadingFeature`, it automatically converts it to the lowest allowed
heading.

I've also verified that disallowed headings aren't introduced when
pasting from the clipboard if the HeadingFeature isn't registered at
all. The reason this works is because the LexicalEditor doesn't have the
HeadingNode in that case.
2025-09-19 11:02:18 -07:00

85 lines
2.8 KiB
TypeScript

import { fileURLToPath } from 'node:url'
import path from 'path'
import { type Config } from 'payload'
import { LexicalFullyFeatured } from './collections/_LexicalFullyFeatured/index.js'
import ArrayFields from './collections/Array/index.js'
import {
getLexicalFieldsCollection,
lexicalBlocks,
lexicalInlineBlocks,
} from './collections/Lexical/index.js'
import { LexicalAccessControl } from './collections/LexicalAccessControl/index.js'
import { LexicalHeadingFeature } from './collections/LexicalHeadingFeature/index.js'
import { LexicalInBlock } from './collections/LexicalInBlock/index.js'
import { LexicalJSXConverter } from './collections/LexicalJSXConverter/index.js'
import { LexicalLinkFeature } from './collections/LexicalLinkFeature/index.js'
import { LexicalLocalizedFields } from './collections/LexicalLocalized/index.js'
import { LexicalMigrateFields } from './collections/LexicalMigrate/index.js'
import { LexicalObjectReferenceBugCollection } from './collections/LexicalObjectReferenceBug/index.js'
import { LexicalRelationshipsFields } from './collections/LexicalRelationships/index.js'
import { OnDemandForm } from './collections/OnDemandForm/index.js'
import { OnDemandOutsideForm } from './collections/OnDemandOutsideForm/index.js'
import RichTextFields from './collections/RichText/index.js'
import TextFields from './collections/Text/index.js'
import Uploads from './collections/Upload/index.js'
import TabsWithRichText from './globals/TabsWithRichText.js'
import { seed } from './seed.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export const baseConfig: Partial<Config> = {
// ...extend config here
collections: [
LexicalFullyFeatured,
LexicalLinkFeature,
LexicalHeadingFeature,
LexicalJSXConverter,
getLexicalFieldsCollection({
blocks: lexicalBlocks,
inlineBlocks: lexicalInlineBlocks,
}),
LexicalMigrateFields,
LexicalLocalizedFields,
LexicalObjectReferenceBugCollection,
LexicalInBlock,
LexicalAccessControl,
LexicalRelationshipsFields,
RichTextFields,
TextFields,
Uploads,
ArrayFields,
OnDemandForm,
OnDemandOutsideForm,
],
globals: [TabsWithRichText],
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
components: {
beforeDashboard: [
{
path: './components/CollectionsExplained.tsx#CollectionsExplained',
},
],
},
},
onInit: async (payload) => {
// IMPORTANT: This should only seed, not clear the database.
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
await seed(payload)
}
},
localization: {
defaultLocale: 'en',
fallback: true,
locales: ['en', 'es'],
},
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
}