mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
Remove TOC replacer
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
33648f1645
commit
971421925a
2 changed files with 0 additions and 19 deletions
|
@ -65,7 +65,6 @@ import { KatexReplacer } from './replace-components/katex/katex-replacer'
|
||||||
import { PdfReplacer } from './replace-components/pdf/pdf-replacer'
|
import { PdfReplacer } from './replace-components/pdf/pdf-replacer'
|
||||||
import { PossibleWiderReplacer } from './replace-components/possible-wider/possible-wider-replacer'
|
import { PossibleWiderReplacer } from './replace-components/possible-wider/possible-wider-replacer'
|
||||||
import { QuoteOptionsReplacer } from './replace-components/quote-options/quote-options-replacer'
|
import { QuoteOptionsReplacer } from './replace-components/quote-options/quote-options-replacer'
|
||||||
import { TocReplacer } from './replace-components/toc/toc-replacer'
|
|
||||||
import { VimeoReplacer } from './replace-components/vimeo/vimeo-replacer'
|
import { VimeoReplacer } from './replace-components/vimeo/vimeo-replacer'
|
||||||
import { YoutubeReplacer } from './replace-components/youtube/youtube-replacer'
|
import { YoutubeReplacer } from './replace-components/youtube/youtube-replacer'
|
||||||
|
|
||||||
|
@ -310,7 +309,6 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({ content, onM
|
||||||
new AsciinemaReplacer(),
|
new AsciinemaReplacer(),
|
||||||
new PdfReplacer(),
|
new PdfReplacer(),
|
||||||
new ImageReplacer(),
|
new ImageReplacer(),
|
||||||
new TocReplacer(),
|
|
||||||
new CsvReplacer(),
|
new CsvReplacer(),
|
||||||
new FlowchartReplacer(),
|
new FlowchartReplacer(),
|
||||||
new HighlightedCodeReplacer(),
|
new HighlightedCodeReplacer(),
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { DomElement } from 'domhandler'
|
|
||||||
import { ComponentReplacer, SubNodeConverter } from '../ComponentReplacer'
|
|
||||||
|
|
||||||
export class TocReplacer implements ComponentReplacer {
|
|
||||||
getReplacement (node: DomElement, index: number, subNodeConverter: SubNodeConverter): React.ReactElement | undefined {
|
|
||||||
if (node.name !== 'p' || node.children?.length !== 1) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const possibleTocDiv = node.children[0]
|
|
||||||
if (possibleTocDiv.name === 'div' && possibleTocDiv.attribs && possibleTocDiv.attribs.class &&
|
|
||||||
possibleTocDiv.attribs.class === 'table-of-contents' && possibleTocDiv.children && possibleTocDiv.children.length === 1) {
|
|
||||||
const listElement = possibleTocDiv.children[0]
|
|
||||||
listElement.attribs = Object.assign(listElement.attribs || {}, { class: 'table-of-contents' })
|
|
||||||
return subNodeConverter(listElement, index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue