mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
fix(frontend): migrate TOC to @hedgedoc/markdown-it-plugins
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
60db7f4931
commit
7be4ef6e70
10 changed files with 36 additions and 46 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue