Files
payload/test/lexical-mdx/mdx/jsxBlocks/code/code.ts
Alessio Gravili d4f1add2ab feat(richtext-lexical): mdx support (#9160)
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>
2024-11-17 15:03:45 -07:00

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',
},
],
}