-
Notifications
You must be signed in to change notification settings - Fork 3k
-
In our situation we have this richText field
export const introductionField = (config: Config): Field => {
return {
name: 'introduction',
type: 'richText',
localized: true,
required: config.required,
admin: { description: 'Introduction text for the page' },
editor: richTextEditorConfig(),
};
};
Coming along this custom LexicalEditor
import type { LexicalEditorProps } from '@payloadcms/richtext-lexical';
import {
BlocksFeature,
FixedToolbarFeature,
InlineToolbarFeature,
lexicalEditor,
LinkFeature,
RelationshipFeature,
} from '@payloadcms/richtext-lexical';
import { ALL_PAGE_COLLECTIONS } from '~/fields/pageType/pageType';
import { getTranslatedLabel } from '~/utilities/getTranslatedLabel';
export const richTextEditorConfig = (config?: Partial<LexicalEditorProps>) =>
lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
LinkFeature({
enabledCollections: ALL_PAGE_COLLECTIONS,
fields: ({ defaultFields }) => defaultFields,
}),
RelationshipFeature({
enabledCollections: ALL_PAGE_COLLECTIONS,
}),
BlocksFeature({
blocks: [
{
slug: 'code',
interfaceName: 'CodeBlock',
labels: {
singular: getTranslatedLabel('fieldLabels:codeBlock'),
plural: getTranslatedLabel('fieldLabels:codeBlocks'),
},
fields: [
{
name: 'code',
type: 'code',
label: getTranslatedLabel('fieldLabels:code'),
required: true,
admin: {
language: 'javascript',
},
},
{
name: 'language',
type: 'select',
label: getTranslatedLabel('fieldLabels:language'),
defaultValue: 'html',
options: [
{ label: 'HTML', value: 'html' },
{ label: 'JavaScript', value: 'javascript' },
{ label: 'TypeScript', value: 'typescript' },
{ label: 'CSS', value: 'css' },
{ label: 'JSON', value: 'json' },
{ label: 'Python', value: 'python' },
{ label: 'SQL', value: 'sql' },
{ label: 'Shell', value: 'shell' },
{ label: 'Plain Text', value: 'plaintext' },
],
},
],
},
],
}),
FixedToolbarFeature(),
InlineToolbarFeature(),
],
...config,
});
Problem that we are facing is that whenever we click on "Publish in English" it throws an error "Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object."
obraz obrazThis error does not happen when:
- we save collection as
draft - we publish it to all locales
Another thing is that even the fact that error is displayed, we are still having an value as object in API (which is something that we want). Question is - how can we prevent displaying this error, we are expecting the value to be an object and not to perform a lot of API calls based on value being an ID.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment