mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00

* Adjust editor config Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
26 lines
934 B
TypeScript
26 lines
934 B
TypeScript
/*
|
|
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
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): 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>
|
|
<DeprecationWarning/>
|
|
<MermaidChart code={ 'sequenceDiagram\n' + code }/>
|
|
</Fragment>
|
|
}
|
|
}
|