docs: consolidate docs (#2182)

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-07-21 22:36:46 +02:00 committed by GitHub
parent 8d46d7e39e
commit ecffebc43c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
307 changed files with 1474 additions and 487 deletions

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -8,7 +8,9 @@ import { useMemo } from 'react'
import { useApplicationState } from './use-application-state'
/**
* Returns the app title with branding if set.
* Calculates the app title with branding if set.
*
* @return The app title with branding.
*/
export const useAppTitle = (): string => {
const brandingName = useApplicationState((state) => state.config.branding.name)

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -13,6 +13,7 @@ import type { ApplicationState } from '../../redux/application-state'
*
* @param selector A selector function that extracts the needed information from the state.
* @param checkForEquality An optional custom equality function. If not provided then {@link equal equal from fast-deep-equal} will be used.
* @return The requested information
*/
export const useApplicationState = <TSelected>(
selector: (state: ApplicationState) => TSelected,

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -7,6 +7,9 @@
import { useEffect } from 'react'
import { useIsDarkModeActivated } from './use-is-dark-mode-activated'
/**
* Applies the `dark` css class to the body tag according to the dark mode state.
*/
export const useApplyDarkMode = (): void => {
const darkModeActivated = useIsDarkModeActivated()

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -7,6 +7,12 @@
import { useRouter } from 'next/router'
import { useMemo } from 'react'
/**
* Extracts the parameter from the router expected to be an array of values.
*
* @param parameter The parameter to extract
* @return An array of values extracted from the router.
*/
export const useArrayStringUrlParameter = (parameter: string): string[] => {
const router = useRouter()

View file

@ -15,7 +15,7 @@ import { useEffect } from 'react'
export const useBindPointerMovementEventOnWindow = (
onPointerMovement: (event: MouseEvent | TouchEvent) => void,
onPointerRelease: () => void
) => {
): void => {
useEffect(() => {
const pointerMovement = onPointerMovement
const pointerRelease = onPointerRelease

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -7,6 +7,11 @@
import { useRouter } from 'next/router'
import { useMemo } from 'react'
/**
* Retrieves the frontend base url either from an environment variable or from the window location itself.
*
* @return The base url of the frontend.
*/
export const useFrontendBaseUrl = (): string => {
const { asPath } = useRouter()
return useMemo(() => {

View file

@ -1,11 +1,16 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { useApplicationState } from './use-application-state'
/**
* Extracts the current state of the dark mode from the global application state.
*
* @return The current state of the dark mode.
*/
export const useIsDarkModeActivated = (): boolean => {
return useApplicationState((state) => state.darkMode.darkMode)
}

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -8,7 +8,8 @@ import { useApplicationState } from './use-application-state'
/**
* Extracts the markdown content of the current note from the global application state.
* @return the markdown content of the note
*
* @return The markdown content of the note
*/
export const useNoteMarkdownContent = (): string => {
return useApplicationState((state) => state.noteDetails.markdownContent.plain)

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -9,7 +9,9 @@ import { useApplicationState } from './use-application-state'
import { useMemo } from 'react'
/**
* Returns the title of the note or a placeholder text.
* Retrieves the title of the note or a placeholder text, if no title is set.
*
* @return The title of the note
*/
export const useNoteTitle = (): string => {
const { t } = useTranslation()

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -9,6 +9,7 @@ import { useCallback } from 'react'
/**
* Takes an input change event and sends the event value to a state setter.
*
* @param setter The setter method for the state.
* @return Hook that can be used as callback for onChange.
*/

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -7,6 +7,13 @@
import { useRouter } from 'next/router'
import { useMemo } from 'react'
/**
* Extracts the parameter from the router expected to be a single value.
*
* @param parameter The parameter to extract
* @param fallback The fallback returned if there is no value.
* @return A value extracted from the router.
*/
export const useSingleStringUrlParameter = <T>(parameter: string, fallback: T): string | T => {
const router = useRouter()

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -9,6 +9,8 @@ import { useApplicationState } from './use-application-state'
/**
* Returns the markdown content from the global application state trimmed to the maximal note length and without the frontmatter lines.
*
* @return The array of markdown content lines
*/
export const useTrimmedNoteMarkdownContentWithoutFrontmatter = (): string[] => {
const maxLength = useApplicationState((state) => state.config.maxDocumentLength)