mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
Feature/sequence diagram (#538)
This commit is contained in:
parent
119c9512e7
commit
63b24fa5bf
7 changed files with 59 additions and 5 deletions
|
@ -0,0 +1,20 @@
|
|||
import { DomElement } from 'domhandler'
|
||||
import React, { Fragment } from 'react'
|
||||
import { ComponentReplacer } from '../ComponentReplacer'
|
||||
import { MermaidChart } from '../mermaid/mermaid-chart'
|
||||
import { DeprecationWarning } from './deprecation-warning'
|
||||
|
||||
export class SequenceDiagramReplacer implements ComponentReplacer {
|
||||
getReplacement (codeNode: DomElement, index: number): React.ReactElement | undefined {
|
||||
if (codeNode.name !== 'code' || !codeNode.attribs || !codeNode.attribs['data-highlight-language'] || codeNode.attribs['data-highlight-language'] !== 'sequence' || !codeNode.children || !codeNode.children[0]) {
|
||||
return
|
||||
}
|
||||
|
||||
const code = codeNode.children[0].data as string
|
||||
|
||||
return <Fragment key={index} >
|
||||
<DeprecationWarning/>
|
||||
<MermaidChart code={'sequenceDiagram\n' + code}/>
|
||||
</Fragment>
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue