mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-01-13 06:11:54 +00:00
feat(renderer): Add flag to enable auto height for render iframe
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
2817740c94
commit
579919f142
2 changed files with 12 additions and 3 deletions
|
@ -32,6 +32,7 @@ export interface RenderIframeProps extends RendererProps {
|
|||
forcedDarkMode?: boolean
|
||||
frameClasses?: string
|
||||
onRendererStatusChange?: undefined | ((rendererReady: boolean) => void)
|
||||
adaptFrameHeightToContent?: boolean
|
||||
}
|
||||
|
||||
const log = new Logger('RenderIframe')
|
||||
|
@ -50,6 +51,7 @@ const log = new Logger('RenderIframe')
|
|||
* @param frameClasses CSS classes that should be applied to the iframe
|
||||
* @param rendererType The {@link RendererType type} of the renderer to use.
|
||||
* @param forcedDarkMode If set, the dark mode will be set to the given value. Otherwise, the dark mode won't be changed.
|
||||
* @param adaptFrameHeightToContent If set, the iframe height will be adjusted to the content height
|
||||
* @param onRendererStatusChange Callback that is fired when the renderer in the iframe is ready
|
||||
*/
|
||||
export const RenderIframe: React.FC<RenderIframeProps> = ({
|
||||
|
@ -62,6 +64,7 @@ export const RenderIframe: React.FC<RenderIframeProps> = ({
|
|||
frameClasses,
|
||||
rendererType,
|
||||
forcedDarkMode,
|
||||
adaptFrameHeightToContent,
|
||||
onRendererStatusChange
|
||||
}) => {
|
||||
const [rendererReady, setRendererReady] = useState<boolean>(false)
|
||||
|
@ -113,9 +116,14 @@ export const RenderIframe: React.FC<RenderIframeProps> = ({
|
|||
|
||||
useEditorReceiveHandler(
|
||||
CommunicationMessageType.ON_HEIGHT_CHANGE,
|
||||
useCallback((values: OnHeightChangeMessage) => {
|
||||
setFrameHeight?.(values.height)
|
||||
}, [])
|
||||
useCallback(
|
||||
(values: OnHeightChangeMessage) => {
|
||||
if (adaptFrameHeightToContent) {
|
||||
setFrameHeight?.(values.height)
|
||||
}
|
||||
},
|
||||
[adaptFrameHeightToContent]
|
||||
)
|
||||
)
|
||||
|
||||
useEditorReceiveHandler(
|
||||
|
|
|
@ -32,6 +32,7 @@ export const IntroCustomContent: React.FC = () => {
|
|||
markdownContentLines={content}
|
||||
rendererType={RendererType.INTRO}
|
||||
forcedDarkMode={true}
|
||||
adaptFrameHeightToContent={true}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue