fix(frontend): migrate TOC to @hedgedoc/markdown-it-plugins

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-12-02 19:50:55 +01:00
parent 60db7f4931
commit 7be4ef6e70
10 changed files with 36 additions and 46 deletions

View file

@ -5,10 +5,10 @@
*/
import { tocSlugify } from '../../editor-page/table-of-contents/toc-slugify'
import { MarkdownRendererExtension } from './base/markdown-renderer-extension'
import type { TocAst } from '@hedgedoc/markdown-it-plugins'
import { toc } from '@hedgedoc/markdown-it-plugins'
import equal from 'fast-deep-equal'
import type MarkdownIt from 'markdown-it'
import type { TocAst } from 'markdown-it-toc-done-right'
import toc from 'markdown-it-toc-done-right'
/**
* Adds table of content to the markdown rendering.
@ -19,10 +19,9 @@ export class TableOfContentsMarkdownExtension extends MarkdownRendererExtension
public configureMarkdownIt(markdownIt: MarkdownIt): void {
toc(markdownIt, {
placeholder: '(\\[TOC\\]|\\[toc\\])',
listType: 'ul',
level: [1, 2, 3],
callback: (code: string, ast: TocAst): void => {
callback: (ast: TocAst): void => {
if (equal(ast, this.lastAst)) {
return
}