fix(chart): convert markdown to HTML for TipTap insertion

- Convert chart markdown to <pre><code class="language-chart"> HTML format
- Fix parseHTML to store code content in node attrs
- Fix renderHTML to output actual code content instead of placeholder

This fixes charts rendering as raw markdown text instead of visual charts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Antigravity
2026-05-23 09:51:30 +00:00
parent 10e529deff
commit 835e1872bb
2 changed files with 23 additions and 6 deletions

View File

@@ -70,7 +70,12 @@ export const ChartExtension = Node.create({
// Detect chart blocks by class="language-chart"
if (codeEl && codeEl.classList.contains('language-chart')) {
return {}
// Store the code content as an attribute
const codeContent = codeEl.textContent || ''
return {
code: codeContent,
language: 'chart'
}
}
return false
@@ -79,8 +84,10 @@ export const ChartExtension = Node.create({
]
},
renderHTML({ HTMLAttributes }) {
return ['pre', { ...HTMLAttributes, class: 'language-chart' }, ['code', { class: 'language-chart' }, 0]]
renderHTML({ HTMLAttributes, node }) {
// Get the code content from node attrs
const code = node.attrs.code || ''
return ['pre', { ...HTMLAttributes, class: 'language-chart' }, ['code', { class: 'language-chart' }, code]]
},
addNodeView() {