mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-04 00:48:51 -04:00
Remove document content (#1470)
* 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>
This commit is contained in:
parent
bb0dd4d935
commit
7ec956e5c3
10 changed files with 77 additions and 48 deletions
|
@ -10,15 +10,15 @@ import { store } from '../../../redux'
|
|||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { download } from '../../common/download/download'
|
||||
import { SidebarButton } from './sidebar-button'
|
||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||
import { useNoteMarkdownContent } from '../../../hooks/common/use-note-markdown-content'
|
||||
|
||||
export const ExportMarkdownSidebarEntry: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const documentContent = useApplicationState((state) => state.noteDetails.documentContent)
|
||||
const markdownContent = useNoteMarkdownContent()
|
||||
const onClick = useCallback(() => {
|
||||
const sanitized = sanitize(store.getState().noteDetails.noteTitle)
|
||||
download(documentContent, `${sanitized !== '' ? sanitized : t('editor.untitledNote')}.md`, 'text/markdown')
|
||||
}, [documentContent, t])
|
||||
download(markdownContent, `${sanitized !== '' ? sanitized : t('editor.untitledNote')}.md`, 'text/markdown')
|
||||
}, [markdownContent, t])
|
||||
|
||||
return (
|
||||
<SidebarButton data-cy={'menu-export-markdown'} onClick={onClick} icon={'file-text'}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue