mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 18:55:19 -04:00
Post toc after rendering and not during it
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
56e8de5d44
commit
7e1f774867
1 changed files with 6 additions and 12 deletions
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { MutableRefObject } from 'react'
|
import type { MutableRefObject } from 'react'
|
||||||
import { useMemo } from 'react'
|
import { useMemo, useRef } from 'react'
|
||||||
import { TableOfContentsMarkdownExtension } from '../markdown-extension/table-of-contents-markdown-extension'
|
import { TableOfContentsMarkdownExtension } from '../markdown-extension/table-of-contents-markdown-extension'
|
||||||
import { VegaLiteMarkdownExtension } from '../markdown-extension/vega-lite/vega-lite-markdown-extension'
|
import { VegaLiteMarkdownExtension } from '../markdown-extension/vega-lite/vega-lite-markdown-extension'
|
||||||
//TODO: fix dependency issues in markmap
|
//TODO: fix dependency issues in markmap
|
||||||
|
@ -42,6 +42,7 @@ import type { MarkdownExtension } from '../markdown-extension/markdown-extension
|
||||||
import { IframeCapsuleMarkdownExtension } from '../markdown-extension/iframe-capsule/iframe-capsule-markdown-extension'
|
import { IframeCapsuleMarkdownExtension } from '../markdown-extension/iframe-capsule/iframe-capsule-markdown-extension'
|
||||||
import { ImagePlaceholderMarkdownExtension } from '../markdown-extension/image-placeholder/image-placeholder-markdown-extension'
|
import { ImagePlaceholderMarkdownExtension } from '../markdown-extension/image-placeholder/image-placeholder-markdown-extension'
|
||||||
import { UploadIndicatingImageFrameMarkdownExtension } from '../markdown-extension/upload-indicating-image-frame/upload-indicating-image-frame-markdown-extension'
|
import { UploadIndicatingImageFrameMarkdownExtension } from '../markdown-extension/upload-indicating-image-frame/upload-indicating-image-frame-markdown-extension'
|
||||||
|
import { useOnRefChange } from './use-on-ref-change'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a list of {@link MarkdownExtension markdown extensions} that is a combination of the common extensions and the given additional.
|
* Provides a list of {@link MarkdownExtension markdown extensions} that is a combination of the common extensions and the given additional.
|
||||||
|
@ -65,10 +66,12 @@ export const useMarkdownExtensions = (
|
||||||
onTocChange?: (ast?: TocAst) => void
|
onTocChange?: (ast?: TocAst) => void
|
||||||
): MarkdownExtension[] => {
|
): MarkdownExtension[] => {
|
||||||
const plantumlServer = useApplicationState((state) => state.config.plantumlServer)
|
const plantumlServer = useApplicationState((state) => state.config.plantumlServer)
|
||||||
|
const toc = useRef<TocAst | undefined>(undefined)
|
||||||
|
useOnRefChange(toc, onTocChange)
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
return [
|
return [
|
||||||
new TableOfContentsMarkdownExtension(onTocChange),
|
new TableOfContentsMarkdownExtension((ast?: TocAst) => (toc.current = ast)),
|
||||||
...additionalExtensions,
|
...additionalExtensions,
|
||||||
new VegaLiteMarkdownExtension(),
|
new VegaLiteMarkdownExtension(),
|
||||||
// new MarkmapMarkdownExtension(),
|
// new MarkmapMarkdownExtension(),
|
||||||
|
@ -103,14 +106,5 @@ export const useMarkdownExtensions = (
|
||||||
new HighlightedCodeMarkdownExtension(),
|
new HighlightedCodeMarkdownExtension(),
|
||||||
new DebuggerMarkdownExtension()
|
new DebuggerMarkdownExtension()
|
||||||
]
|
]
|
||||||
}, [
|
}, [additionalExtensions, baseUrl, currentLineMarkers, lineOffset, onImageClick, onTaskCheckedChange, plantumlServer])
|
||||||
additionalExtensions,
|
|
||||||
baseUrl,
|
|
||||||
currentLineMarkers,
|
|
||||||
lineOffset,
|
|
||||||
onImageClick,
|
|
||||||
onTaskCheckedChange,
|
|
||||||
onTocChange,
|
|
||||||
plantumlServer
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue