mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 02:36:31 -05: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 styles from './markdown-document.module.scss'
|
||||
import useResizeObserver from '@react-hook/resize-observer'
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Logger } from '../../../../utils/logger'
|
||||
import React, { useMemo, useRef, useState } from 'react'
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -67,11 +64,6 @@ export const DocumentMarkdownRenderer: React.FC<DocumentMarkdownRendererProps> =
|
|||
const markdownBodyRef = useRef<HTMLDivElement>(null)
|
||||
const currentLineMarkers = useRef<LineMarkers[]>()
|
||||
|
||||
// ToDo: Remove this
|
||||
useEffect(() => {
|
||||
logger.debug(markdownContentLines)
|
||||
}, [markdownContentLines])
|
||||
|
||||
const extensions = useMarkdownExtensions(
|
||||
baseUrl,
|
||||
RendererType.DOCUMENT,
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
import { NodeProcessor } from '../../../components/markdown-renderer/node-preprocessors/node-processor'
|
||||
import { extractFirstHeading } from '@hedgedoc/commons'
|
||||
import { Optional } from '@mrdrogdrog/optional'
|
||||
import type { Document } from 'domhandler'
|
||||
import type { EventEmitter2 } from 'eventemitter2'
|
||||
|
||||
|
@ -20,9 +19,7 @@ export class ExtractFirstHeadlineNodeProcessor extends NodeProcessor {
|
|||
}
|
||||
|
||||
process(nodes: Document): Document {
|
||||
Optional.ofNullable(extractFirstHeading(nodes))
|
||||
.filter((text) => text !== '')
|
||||
.ifPresent((text) => this.eventEmitter.emit(ExtractFirstHeadlineNodeProcessor.EVENT_NAME, text))
|
||||
this.eventEmitter.emit(ExtractFirstHeadlineNodeProcessor.EVENT_NAME, extractFirstHeading(nodes))
|
||||
return nodes
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue