This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021import { convertMarkdownToLexical, editorConfigFactory, type SanitizedServerEditorConfig,} from '@payloadcms/richtext-lexical'import type { Payload, SanitizedConfig } from 'payload'import { bodyEditor } from '@/lib/lexical-editor'
let cachedEditorConfig: SanitizedServerEditorConfig | null = null
export async function getBodyEditorConfig(config: SanitizedConfig) { if (cachedEditorConfig) return cachedEditorConfig cachedEditorConfig = await editorConfigFactory.fromEditor({ config, editor: bodyEditor }) return cachedEditorConfig}
export async function markdownToLexical(payload: Payload, source: string) { const editorConfig = await getBodyEditorConfig(payload.config) return convertMarkdownToLexical({ editorConfig, markdown: source })}