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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user