I've just set up a simple
richTextfield with no additional configuration, and the attached screenshot is what I see.
My config uses the preset
@/fields/defaultLexicaleditor, which should render as a proper WYSIWYG, but what I see is a single line with the ability to click one of the plus icons to add a paragraph.
What has gone wrong here?
Hey
@321395600824467466
Yeah this is intentional, the default functionality is included there. If you type
/you will see a list of elements you can add. If you highlight some text, a floating menu should appear with more options
Looks like the only element I can add is a paragraph, and there are no additional UI elements on selection.
The default config looks like it should at least have some basic formatting available, unless I'm misunderstanding how Lexical is set up?
https://payloadcms.com/docs/rich-text/overview#features-overviewAlso, thanks for the quick response,
@654031862146007055!
Is this the website template?
Yep!
Can you share the collection config of the field this is in?
Sure, let me grab that.
So this should be grabbing the lexical config you have set up in your root payload config - want to double check that your root config uses the defaultLexical object
You can also try passing the editor directly into the field via
description.editor{
name: 'description',
type: 'richText',
editor: defaultLexical,
},I've tried that as well, but I'm having the same result. I'll give it another go. It flashes for a moment on initial render, then shrinks down. Let me try explicitly passing it real quick.
Nope, passing it results in the same thing.
This one's a headscratcher. I haven't added any packages to my knowledge, either. This is a vanilla set up.
I've had a handful of little issues along the way and quite a few ones that have nearly been blocking. Hopefully this one doesn't end up too tough to solve, I'm determined to keep using Payload for this project.
Oh, you're missing a bunch of stuff here, seems like the default lexical helper object was updated to be super minimal
One sec, I'll whip up a copy & paste solution here for ya
That'd do it lol. Thanks!
import type { TextFieldSingleValidation } from 'payload'
import {
LinkFeature,
lexicalEditor,
type LinkFields,
} from '@payloadcms/richtext-lexical'
export const defaultLexical = lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
LinkFeature({
enabledCollections: ['pages', 'posts'],
fields: ({ defaultFields }) => {
const defaultFieldsWithoutUrl = defaultFields.filter((field) => {
if ('name' in field && field.name === 'url') return false
return true
})
return [
...defaultFieldsWithoutUrl,
{
name: 'url',
type: 'text',
admin: {
condition: (_data, siblingData) => siblingData?.linkType !== 'internal',
},
label: ({ t }) => t('fields:enterURL'),
required: true,
validate: ((value, options) => {
if ((options?.siblingData as LinkFields)?.linkType === 'internal') {
return true // no validation needed, as no url should exist for internal links
}
return value ? true : 'URL is required'
}) as TextFieldSingleValidation,
},
]
},
}),
]
})This doesn't include the
FixedToolbarFeatureor the
BlocksFeaturefyi
That looks like it does it! Thanks a ton. Should I just override the file itself for now?
Should I just override the file itself for now?
Up to you honestly
Got it 👍
Would you mind one more hopefully quick question while I've got you? My other blocking issue that hasn't had any traction.
The key here is the defaultFeatures being included now
Go for it
Sweet, thank ya. Let me grab the summary from my other question
Or if you made a community help thread, you can just copy the link
Oh, didn't know I could copy the link. That makes it easier.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.