mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-27 13:34:28 -04:00
add vega-lite diagram (#574)
added vega-lite diagrams Update CHANGELOG.md Co-authored-by: mrdrogdrog <mr.drogdrog@gmail.com>
This commit is contained in:
parent
0f6ea38140
commit
553cd3577d
9 changed files with 690 additions and 8 deletions
|
@ -0,0 +1,16 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { VegaChart } from './vega-chart'
|
||||
|
||||
export class VegaReplacer implements ComponentReplacer {
|
||||
getReplacement (codeNode: DomElement): React.ReactElement | undefined {
|
||||
if (codeNode.name !== 'code' || !codeNode.attribs || !codeNode.attribs['data-highlight-language'] || codeNode.attribs['data-highlight-language'] !== 'vega-lite' || !codeNode.children || !codeNode.children[0]) {
|
||||
return
|
||||
}
|
||||
|
||||
const code = codeNode.children[0].data as string
|
||||
|
||||
return <VegaChart code={code}/>
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue