import { type TElement, createPlateEditor, deserializeHtml } from '@udecode/plate-common' import { useEffect, useState } from 'react' import { unified } from 'unified' import rehypeStringify from 'rehype-stringify' import remarkGfm from 'remark-gfm' import remarkParse from 'remark-parse' import remarkRehype from 'remark-rehype' import remarkFlexibleMarkers from 'remark-flexible-markers' import remarkSupersub from 'remark-supersub' import { plugins } from './plate/plugins' import { container } from './app.css' import { Editor } from '.' const _markdown_cheat_sheet = ` paragraph: lorem ipsum # H1 ## H2 ### H3 #### H4 ##### H5 ###### H6 **bold text** *italicized text* > blockquote 1. First item 2. Second item 3. Third item - First item - Second item - Third item \`code\` --- [title](https://www.example.com) ![image](https://placehold.co/600x400/EEE/31343C) | Syntax | Description | | ----------- | ----------- | | Header | Title | | Paragraph | Text | | Syntax | Description | Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Colssssssssssumn 8 | Cossssssssslumn 9 | Column 10 | | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | | Header | Title | Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Column 8 | Column 9 | Column 10 | | Paragraph | Text | Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Column 8 | Column 9 | Column 10 | | Paragraph | Text | Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Column 8 | Column 9 | Column 10 | \`\`\` { "firstName": "John", "lastName": "Smith", "age": 25 } \`\`\` \`\`\`js function greet(name) { return \`Hello, \${name}!\`; } \`\`\` \`\`\`html

{{ msg }}

\`\`\` ~~The world is flat.~~ I need to highlight these ==very important words==. H~2~O X^2^

Should be centered

Should be right aligned

A Blue Heading

A red paragraph.

normal

I love these hidden gems for getting logos from any domain 🔗 pic.twitter.com/uKsPnksPPB

— Pontus Abrahamsson — oss/acc (@pontusab) August 15, 2024

Frontend developers are officially cooked pic.twitter.com/gjWwCoPAB8

— WebDevCody (@webdevcody) August 19, 2024
` const _markdown_email = ` ---
Dear Dinwwwh,
Are you looking to simplify your email writing process? Introducing a revolutionary approach that allows you to create compelling emails with ease.
Transform your email communication today! Here's what you can expect: - Streamlined writing experience - Intuitive interface - Time-saving features
We're building a community of users passionate about efficient communication. Join us in shaping the future of email composition. Ready to try it out? Click here to get started: [Link](https://dinwwwh.com)
We look forward to helping you enhance your email writing experience.
Best regards, Noeditor!
--- ` .replace(//g, (_, size) => ``) const editor = createPlateEditor({ plugins }) const html = await unified() .use(remarkParse) .use(remarkGfm, { singleTilde: false }) .use(remarkFlexibleMarkers) .use(remarkSupersub) .use(remarkRehype, { allowDangerousHtml: true }) .use(rehypeStringify, { allowDangerousHtml: true }) .process(_markdown_cheat_sheet) // eslint-disable-next-line no-console console.log(html.toString()) const initialValue = deserializeHtml(editor, { element: html.toString() }) as TElement[] export function App() { const [value, setValue] = useState() useEffect(() => { // eslint-disable-next-line no-console console.log(value) }, [value]) return (
) }