mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
refactor(common): extract frontmatter code into commons
Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
8bd7fd1be8
commit
8e57188ab5
7 changed files with 14 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import { MissingTrailingSlashError, WrongProtocolError } from './errors.js'
|
import { MissingTrailingSlashError, WrongProtocolError } from './errors.js'
|
||||||
import { parseUrl } from './parse-url.js'
|
import { parseUrl } from './parse-url.js'
|
||||||
|
import { describe, expect, it } from '@jest/globals'
|
||||||
|
|
||||||
describe('validate url', () => {
|
describe('validate url', () => {
|
||||||
it("doesn't accept non-urls", () => {
|
it("doesn't accept non-urls", () => {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||||
import { NoteType } from '../../../redux/note-details/types/note-details'
|
|
||||||
import { NewNoteButton } from '../../common/new-note-button/new-note-button'
|
import { NewNoteButton } from '../../common/new-note-button/new-note-button'
|
||||||
import { ShowIf } from '../../common/show-if/show-if'
|
import { ShowIf } from '../../common/show-if/show-if'
|
||||||
import { SignInButton } from '../../landing-layout/navigation/sign-in-button'
|
import { SignInButton } from '../../landing-layout/navigation/sign-in-button'
|
||||||
|
@ -15,6 +14,7 @@ import { HelpButton } from './help-button/help-button'
|
||||||
import { NavbarBranding } from './navbar-branding'
|
import { NavbarBranding } from './navbar-branding'
|
||||||
import { ReadOnlyModeButton } from './read-only-mode-button'
|
import { ReadOnlyModeButton } from './read-only-mode-button'
|
||||||
import { SlideModeButton } from './slide-mode-button'
|
import { SlideModeButton } from './slide-mode-button'
|
||||||
|
import { NoteType } from '@hedgedoc/commons'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Nav, Navbar } from 'react-bootstrap'
|
import { Nav, Navbar } from 'react-bootstrap'
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
*/
|
*/
|
||||||
import { useApplicationState } from '../../../../hooks/common/use-application-state'
|
import { useApplicationState } from '../../../../hooks/common/use-application-state'
|
||||||
import { useBaseUrl } from '../../../../hooks/common/use-base-url'
|
import { useBaseUrl } from '../../../../hooks/common/use-base-url'
|
||||||
import { NoteType } from '../../../../redux/note-details/types/note-details'
|
|
||||||
import { CopyableField } from '../../../common/copyable/copyable-field/copyable-field'
|
import { CopyableField } from '../../../common/copyable/copyable-field/copyable-field'
|
||||||
import type { ModalVisibilityProps } from '../../../common/modals/common-modal'
|
import type { ModalVisibilityProps } from '../../../common/modals/common-modal'
|
||||||
import { CommonModal } from '../../../common/modals/common-modal'
|
import { CommonModal } from '../../../common/modals/common-modal'
|
||||||
import { ShowIf } from '../../../common/show-if/show-if'
|
import { ShowIf } from '../../../common/show-if/show-if'
|
||||||
|
import { NoteType } from '@hedgedoc/commons'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Modal } from 'react-bootstrap'
|
import { Modal } from 'react-bootstrap'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
*/
|
*/
|
||||||
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
import { useApplicationState } from '../../../hooks/common/use-application-state'
|
||||||
import { useTrimmedNoteMarkdownContentWithoutFrontmatter } from '../../../hooks/common/use-trimmed-note-markdown-content-without-frontmatter'
|
import { useTrimmedNoteMarkdownContentWithoutFrontmatter } from '../../../hooks/common/use-trimmed-note-markdown-content-without-frontmatter'
|
||||||
import { NoteType } from '../../../redux/note-details/types/note-details'
|
|
||||||
import { setRendererStatus } from '../../../redux/renderer-status/methods'
|
import { setRendererStatus } from '../../../redux/renderer-status/methods'
|
||||||
import { RendererType } from '../../render-page/window-post-message-communicator/rendering-message'
|
import { RendererType } from '../../render-page/window-post-message-communicator/rendering-message'
|
||||||
import type { RenderIframeProps } from '../renderer-pane/render-iframe'
|
import type { RenderIframeProps } from '../renderer-pane/render-iframe'
|
||||||
import { RenderIframe } from '../renderer-pane/render-iframe'
|
import { RenderIframe } from '../renderer-pane/render-iframe'
|
||||||
import { useOnScrollWithLineOffset } from './hooks/use-on-scroll-with-line-offset'
|
import { useOnScrollWithLineOffset } from './hooks/use-on-scroll-with-line-offset'
|
||||||
import { useScrollStateWithoutLineOffset } from './hooks/use-scroll-state-without-line-offset'
|
import { useScrollStateWithoutLineOffset } from './hooks/use-scroll-state-without-line-offset'
|
||||||
|
import { NoteType } from '@hedgedoc/commons'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export type EditorDocumentRendererProps = Omit<
|
export type EditorDocumentRendererProps = Omit<
|
||||||
|
|
2
frontend/src/redux/application-state.d.ts
vendored
2
frontend/src/redux/application-state.d.ts
vendored
|
@ -7,10 +7,10 @@ import type { Config } from '../api/config/types'
|
||||||
import type { HistoryEntryWithOrigin } from '../api/history/types'
|
import type { HistoryEntryWithOrigin } from '../api/history/types'
|
||||||
import type { DarkModeConfig } from './dark-mode/types'
|
import type { DarkModeConfig } from './dark-mode/types'
|
||||||
import type { EditorConfig } from './editor/types'
|
import type { EditorConfig } from './editor/types'
|
||||||
|
import type { NoteDetails } from './note-details/types/note-details'
|
||||||
import type { RealtimeStatus } from './realtime/types'
|
import type { RealtimeStatus } from './realtime/types'
|
||||||
import type { RendererStatus } from './renderer-status/types'
|
import type { RendererStatus } from './renderer-status/types'
|
||||||
import type { OptionalUserState } from './user/types'
|
import type { OptionalUserState } from './user/types'
|
||||||
import type { NoteDetails } from '@hedgedoc/commons'
|
|
||||||
|
|
||||||
export interface ApplicationState {
|
export interface ApplicationState {
|
||||||
user: OptionalUserState
|
user: OptionalUserState
|
||||||
|
|
|
@ -7,9 +7,14 @@ import { initialState } from '../initial-state'
|
||||||
import { buildStateFromFirstHeadingUpdate } from './build-state-from-first-heading-update'
|
import { buildStateFromFirstHeadingUpdate } from './build-state-from-first-heading-update'
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
jest.mock('../generate-note-title', () => ({
|
jest.mock(
|
||||||
|
'@hedgedoc/commons',
|
||||||
|
() =>
|
||||||
|
({
|
||||||
|
...jest.requireActual('@hedgedoc/commons'),
|
||||||
generateNoteTitle: () => 'generated title'
|
generateNoteTitle: () => 'generated title'
|
||||||
}))
|
} as Record<string, unknown>)
|
||||||
|
)
|
||||||
|
|
||||||
describe('build state from first heading update', () => {
|
describe('build state from first heading update', () => {
|
||||||
it('generates a new state with the given first heading', () => {
|
it('generates a new state with the given first heading', () => {
|
||||||
|
|
|
@ -7,8 +7,8 @@ import type { Note } from '../../../api/notes/types'
|
||||||
import * as buildStateFromUpdatedMarkdownContentModule from '../build-state-from-updated-markdown-content'
|
import * as buildStateFromUpdatedMarkdownContentModule from '../build-state-from-updated-markdown-content'
|
||||||
import { initialSlideOptions } from '../initial-state'
|
import { initialSlideOptions } from '../initial-state'
|
||||||
import type { NoteDetails } from '../types/note-details'
|
import type { NoteDetails } from '../types/note-details'
|
||||||
import { NoteTextDirection, NoteType } from '../types/note-details'
|
|
||||||
import { buildStateFromServerDto } from './build-state-from-set-note-data-from-server'
|
import { buildStateFromServerDto } from './build-state-from-set-note-data-from-server'
|
||||||
|
import { NoteTextDirection, NoteType } from '@hedgedoc/commons'
|
||||||
import { DateTime } from 'luxon'
|
import { DateTime } from 'luxon'
|
||||||
import { Mock } from 'ts-mockery'
|
import { Mock } from 'ts-mockery'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue