mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 19:25:18 -04:00
Reorganize redux and hooks (1/4) (#985)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
bdf8110676
commit
1b7abf9f27
61 changed files with 898 additions and 986 deletions
18
src/hooks/common/use-document-title-with-note-title.ts
Normal file
18
src/hooks/common/use-document-title-with-note-title.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { ApplicationState } from '../../redux'
|
||||
import { useDocumentTitle } from './use-document-title'
|
||||
|
||||
export const useDocumentTitleWithNoteTitle = (): void => {
|
||||
const { t } = useTranslation()
|
||||
const untitledNote = t('editor.untitledNote')
|
||||
const noteTitle = useSelector((state: ApplicationState) => state.noteDetails.noteTitle)
|
||||
|
||||
useDocumentTitle(noteTitle === '' ? untitledNote : noteTitle)
|
||||
}
|
12
src/hooks/common/use-note-markdown-content.ts
Normal file
12
src/hooks/common/use-note-markdown-content.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useSelector } from 'react-redux'
|
||||
import { ApplicationState } from '../../redux'
|
||||
|
||||
export const useNoteMarkdownContent = (): string => {
|
||||
return useSelector((state: ApplicationState) => state.noteDetails.markdownContent)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue