feat: add renderer type to MarkdownRendererExtensionOptions

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-04-13 19:00:18 +02:00
parent 0809e01b2d
commit f12cadbbb7
5 changed files with 14 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import { useCalculateLineMarkerPosition } from '../../../markdown-renderer/hooks
import { useMarkdownExtensions } from '../../../markdown-renderer/hooks/use-markdown-extensions'
import { MarkdownToReact } from '../../../markdown-renderer/markdown-to-react/markdown-to-react'
import { useDocumentSyncScrolling } from '../../hooks/sync-scroll/use-document-sync-scrolling'
import { RendererType } from '../../window-post-message-communicator/rendering-message'
import type { CommonMarkdownRendererProps, HeightChangeRendererProps } from '../common-markdown-renderer-props'
import { DocumentTocSidebar } from './document-toc-sidebar'
import styles from './markdown-document.module.scss'
@ -67,6 +68,7 @@ export const DocumentMarkdownRenderer: React.FC<DocumentMarkdownRendererProps> =
const extensions = useMarkdownExtensions(
baseUrl,
RendererType.DOCUMENT,
useMemo(
() => [
new HeadlineAnchorsMarkdownExtension(),

View file

@ -6,6 +6,7 @@
import { cypressId } from '../../../../utils/cypress-attribute'
import { useMarkdownExtensions } from '../../../markdown-renderer/hooks/use-markdown-extensions'
import { MarkdownToReact } from '../../../markdown-renderer/markdown-to-react/markdown-to-react'
import { RendererType } from '../../window-post-message-communicator/rendering-message'
import type { CommonMarkdownRendererProps, HeightChangeRendererProps } from '../common-markdown-renderer-props'
import useResizeObserver from '@react-hook/resize-observer'
import React, { useEffect, useRef, useState } from 'react'
@ -32,7 +33,7 @@ export const SimpleMarkdownRenderer: React.FC<SimpleMarkdownRendererProps> = ({
setRendererSize(entry.contentRect)
})
useEffect(() => onHeightChange?.((rendererSize?.height ?? 0) + 1), [rendererSize, onHeightChange])
const extensions = useMarkdownExtensions(baseUrl, [])
const extensions = useMarkdownExtensions(baseUrl, RendererType.SIMPLE, [])
return (
<div className={`vh-100 bg-transparent overflow-y-hidden`}>

View file

@ -7,6 +7,7 @@ import { RevealMarkdownExtension } from '../../../markdown-renderer/extensions/r
import { useMarkdownExtensions } from '../../../markdown-renderer/hooks/use-markdown-extensions'
import { REVEAL_STATUS, useReveal } from '../../../markdown-renderer/hooks/use-reveal'
import { MarkdownToReact } from '../../../markdown-renderer/markdown-to-react/markdown-to-react'
import { RendererType } from '../../window-post-message-communicator/rendering-message'
import type { CommonMarkdownRendererProps } from '../common-markdown-renderer-props'
import { LoadingSlide } from './loading-slide'
import type { SlideOptions } from '@hedgedoc/commons'
@ -34,6 +35,7 @@ export const SlideshowMarkdownRenderer: React.FC<SlideshowMarkdownRendererProps>
const extensions = useMarkdownExtensions(
baseUrl,
RendererType.SLIDESHOW,
useMemo(() => [new RevealMarkdownExtension()], [])
)