Previously the value of new tab checkbox in the link feature was not able to be set to true by default because we were passing `false` as a default value. This fixes that and adds test coverage for customising that link drawer.
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import type { CheckboxField, CollectionConfig } from 'payload'
|
|
|
|
import {
|
|
FixedToolbarFeature,
|
|
lexicalEditor,
|
|
LinkFeature,
|
|
TreeViewFeature,
|
|
} from '@payloadcms/richtext-lexical'
|
|
|
|
import { lexicalLinkFeatureSlug } from '../../slugs.js'
|
|
|
|
export const LexicalLinkFeature: CollectionConfig = {
|
|
slug: lexicalLinkFeatureSlug,
|
|
labels: {
|
|
singular: 'Lexical Link Feature',
|
|
plural: 'Lexical Link Feature',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'richText',
|
|
type: 'richText',
|
|
editor: lexicalEditor({
|
|
features: ({ defaultFeatures }) => [
|
|
...defaultFeatures,
|
|
TreeViewFeature(),
|
|
LinkFeature({
|
|
fields: ({ defaultFields }) => {
|
|
const modifiedFields = defaultFields.map((field) => {
|
|
if (field.name === 'newTab') {
|
|
return { ...field, defaultValue: true } as CheckboxField
|
|
}
|
|
|
|
return field
|
|
})
|
|
|
|
return [...modifiedFields, { type: 'text', name: 'someText' }]
|
|
},
|
|
}),
|
|
FixedToolbarFeature(),
|
|
],
|
|
}),
|
|
},
|
|
],
|
|
}
|