mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 23:54:42 -04:00
Feature/d3 graphviz (#564)
added graphviz diagrams via d3-graphviz added craco and webpack-copy-plugin to copy wasm files Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
e6ee1aff50
commit
5972932d33
8 changed files with 448 additions and 49 deletions
|
@ -0,0 +1,16 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React from 'react'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { GraphvizFrame } from './graphviz-frame'
|
||||
|
||||
export class GraphvizReplacer implements ComponentReplacer {
|
||||
getReplacement (codeNode: DomElement): React.ReactElement | undefined {
|
||||
if (codeNode.name !== 'code' || !codeNode.attribs || !codeNode.attribs['data-highlight-language'] || codeNode.attribs['data-highlight-language'] !== 'graphviz' || !codeNode.children || !codeNode.children[0]) {
|
||||
return
|
||||
}
|
||||
|
||||
const code = codeNode.children[0].data as string
|
||||
|
||||
return <GraphvizFrame code={code}/>
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue