mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00

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>
16 lines
642 B
TypeScript
16 lines
642 B
TypeScript
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}/>
|
|
}
|
|
}
|