mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
Replace react-html-parser with html-to-react (#1327)
* Replace react-html-parser with html-to-react Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
b13c1ce8a0
commit
82472227f9
31 changed files with 329 additions and 167 deletions
|
@ -4,13 +4,16 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { DomElement } from 'domhandler'
|
||||
import { Element } 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 {
|
||||
/**
|
||||
* Detects code blocks with "graphviz" as language and renders them as graphviz graph.
|
||||
*/
|
||||
export class GraphvizReplacer extends ComponentReplacer {
|
||||
getReplacement(codeNode: Element): React.ReactElement | undefined {
|
||||
if (
|
||||
codeNode.name !== 'code' ||
|
||||
!codeNode.attribs ||
|
||||
|
@ -22,7 +25,7 @@ export class GraphvizReplacer implements ComponentReplacer {
|
|||
return
|
||||
}
|
||||
|
||||
const code = codeNode.children[0].data as string
|
||||
const code = ComponentReplacer.extractTextChildContent(codeNode)
|
||||
|
||||
return <GraphvizFrame code={code} />
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue