mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00

* Merge documentContent and markdownContent Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add hook for markdown content without frontmatter Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Use hook for export Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Let subcomponent handle the markdown content Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
20 lines
828 B
TypeScript
20 lines
828 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { useNoteMarkdownContent } from './use-note-markdown-content'
|
|
import { useApplicationState } from './use-application-state'
|
|
import { useMemo } from 'react'
|
|
|
|
/**
|
|
* Extracts the markdown content of the current note from the global application state and removes the frontmatter.
|
|
* @return the markdown content of the note without frontmatter
|
|
*/
|
|
export const useNoteMarkdownContentWithoutFrontmatter = (): string => {
|
|
const markdownContent = useNoteMarkdownContent()
|
|
const offsetLines = useApplicationState((state) => state.noteDetails.frontmatterRendererInfo.offsetLines)
|
|
|
|
return useMemo(() => markdownContent.split('\n').slice(offsetLines).join('\n'), [markdownContent, offsetLines])
|
|
}
|