Supports bi-directional import/export between MDX <=> Lexical. JSX will be mapped to lexical blocks back and forth. This will allow editing our mdx docs in payload while keeping mdx as the source of truth --------- Co-authored-by: Germán Jabloñski <43938777+GermanJablo@users.noreply.github.com>
33 lines
703 B
TypeScript
33 lines
703 B
TypeScript
import type { Block } from 'payload'
|
|
|
|
import { languages } from '../../../collections/Posts/shared.js'
|
|
import { codeConverter } from './converter.js'
|
|
|
|
export const CodeBlock: Block = {
|
|
slug: 'Code',
|
|
admin: {
|
|
jsx: './mdx/jsxBlocks/code/converterClient.js#codeConverterClient',
|
|
},
|
|
jsx: codeConverter,
|
|
fields: [
|
|
{
|
|
type: 'select',
|
|
name: 'language',
|
|
options: Object.entries(languages).map(([key, value]) => ({
|
|
label: value,
|
|
value: key,
|
|
})),
|
|
defaultValue: 'ts',
|
|
},
|
|
{
|
|
admin: {
|
|
components: {
|
|
Field: './collections/Posts/CodeFields.js#Code',
|
|
},
|
|
},
|
|
name: 'code',
|
|
type: 'code',
|
|
},
|
|
],
|
|
}
|