mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-02-17 20:51:04 +00:00
fix(frontend): first heading will be cleared
If all headings are deleted the note title will be deleted and not be kept to the last value. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
02a5f62d27
commit
1609f3e01f
2 changed files with 2 additions and 13 deletions
|
@ -19,13 +19,10 @@ import type { CommonMarkdownRendererProps, HeightChangeRendererProps } from '../
|
||||||
import { DocumentTocSidebar } from './document-toc-sidebar'
|
import { DocumentTocSidebar } from './document-toc-sidebar'
|
||||||
import styles from './markdown-document.module.scss'
|
import styles from './markdown-document.module.scss'
|
||||||
import useResizeObserver from '@react-hook/resize-observer'
|
import useResizeObserver from '@react-hook/resize-observer'
|
||||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
import React, { useMemo, useRef, useState } from 'react'
|
||||||
import { Logger } from '../../../../utils/logger'
|
|
||||||
|
|
||||||
export type DocumentMarkdownRendererProps = CommonMarkdownRendererProps & ScrollProps & HeightChangeRendererProps
|
export type DocumentMarkdownRendererProps = CommonMarkdownRendererProps & ScrollProps & HeightChangeRendererProps
|
||||||
|
|
||||||
const logger = new Logger('DocumentMarkdownRenderer')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a Markdown document and handles scrolling, yaml metadata and a floating table of contents.
|
* Renders a Markdown document and handles scrolling, yaml metadata and a floating table of contents.
|
||||||
*
|
*
|
||||||
|
@ -67,11 +64,6 @@ export const DocumentMarkdownRenderer: React.FC<DocumentMarkdownRendererProps> =
|
||||||
const markdownBodyRef = useRef<HTMLDivElement>(null)
|
const markdownBodyRef = useRef<HTMLDivElement>(null)
|
||||||
const currentLineMarkers = useRef<LineMarkers[]>()
|
const currentLineMarkers = useRef<LineMarkers[]>()
|
||||||
|
|
||||||
// ToDo: Remove this
|
|
||||||
useEffect(() => {
|
|
||||||
logger.debug(markdownContentLines)
|
|
||||||
}, [markdownContentLines])
|
|
||||||
|
|
||||||
const extensions = useMarkdownExtensions(
|
const extensions = useMarkdownExtensions(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
RendererType.DOCUMENT,
|
RendererType.DOCUMENT,
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
import { NodeProcessor } from '../../../components/markdown-renderer/node-preprocessors/node-processor'
|
import { NodeProcessor } from '../../../components/markdown-renderer/node-preprocessors/node-processor'
|
||||||
import { extractFirstHeading } from '@hedgedoc/commons'
|
import { extractFirstHeading } from '@hedgedoc/commons'
|
||||||
import { Optional } from '@mrdrogdrog/optional'
|
|
||||||
import type { Document } from 'domhandler'
|
import type { Document } from 'domhandler'
|
||||||
import type { EventEmitter2 } from 'eventemitter2'
|
import type { EventEmitter2 } from 'eventemitter2'
|
||||||
|
|
||||||
|
@ -20,9 +19,7 @@ export class ExtractFirstHeadlineNodeProcessor extends NodeProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
process(nodes: Document): Document {
|
process(nodes: Document): Document {
|
||||||
Optional.ofNullable(extractFirstHeading(nodes))
|
this.eventEmitter.emit(ExtractFirstHeadlineNodeProcessor.EVENT_NAME, extractFirstHeading(nodes))
|
||||||
.filter((text) => text !== '')
|
|
||||||
.ifPresent((text) => this.eventEmitter.emit(ExtractFirstHeadlineNodeProcessor.EVENT_NAME, text))
|
|
||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue