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:
Philip Molares 2023-03-26 12:30:16 +02:00 committed by Tilman Vatteroth
parent 8bd7fd1be8
commit 8e57188ab5
7 changed files with 14 additions and 8 deletions

View file

@ -5,6 +5,7 @@
*/
import { MissingTrailingSlashError, WrongProtocolError } from './errors.js'
import { parseUrl } from './parse-url.js'
import { describe, expect, it } from '@jest/globals'
describe('validate url', () => {
it("doesn't accept non-urls", () => {

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
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 { ShowIf } from '../../common/show-if/show-if'
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 { ReadOnlyModeButton } from './read-only-mode-button'
import { SlideModeButton } from './slide-mode-button'
import { NoteType } from '@hedgedoc/commons'
import React from 'react'
import { Nav, Navbar } from 'react-bootstrap'

View file

@ -5,11 +5,11 @@
*/
import { useApplicationState } from '../../../../hooks/common/use-application-state'
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 type { ModalVisibilityProps } from '../../../common/modals/common-modal'
import { CommonModal } from '../../../common/modals/common-modal'
import { ShowIf } from '../../../common/show-if/show-if'
import { NoteType } from '@hedgedoc/commons'
import React from 'react'
import { Modal } from 'react-bootstrap'
import { Trans, useTranslation } from 'react-i18next'

View file

@ -5,13 +5,13 @@
*/
import { useApplicationState } from '../../../hooks/common/use-application-state'
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 { RendererType } from '../../render-page/window-post-message-communicator/rendering-message'
import type { RenderIframeProps } from '../renderer-pane/render-iframe'
import { RenderIframe } from '../renderer-pane/render-iframe'
import { useOnScrollWithLineOffset } from './hooks/use-on-scroll-with-line-offset'
import { useScrollStateWithoutLineOffset } from './hooks/use-scroll-state-without-line-offset'
import { NoteType } from '@hedgedoc/commons'
import React from 'react'
export type EditorDocumentRendererProps = Omit<

View file

@ -7,10 +7,10 @@ import type { Config } from '../api/config/types'
import type { HistoryEntryWithOrigin } from '../api/history/types'
import type { DarkModeConfig } from './dark-mode/types'
import type { EditorConfig } from './editor/types'
import type { NoteDetails } from './note-details/types/note-details'
import type { RealtimeStatus } from './realtime/types'
import type { RendererStatus } from './renderer-status/types'
import type { OptionalUserState } from './user/types'
import type { NoteDetails } from '@hedgedoc/commons'
export interface ApplicationState {
user: OptionalUserState

View file

@ -7,9 +7,14 @@ import { initialState } from '../initial-state'
import { buildStateFromFirstHeadingUpdate } from './build-state-from-first-heading-update'
// noinspection JSUnusedGlobalSymbols
jest.mock('../generate-note-title', () => ({
jest.mock(
'@hedgedoc/commons',
() =>
({
...jest.requireActual('@hedgedoc/commons'),
generateNoteTitle: () => 'generated title'
}))
} as Record<string, unknown>)
)
describe('build state from first heading update', () => {
it('generates a new state with the given first heading', () => {

View file

@ -7,8 +7,8 @@ import type { Note } from '../../../api/notes/types'
import * as buildStateFromUpdatedMarkdownContentModule from '../build-state-from-updated-markdown-content'
import { initialSlideOptions } from '../initial-state'
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 { NoteTextDirection, NoteType } from '@hedgedoc/commons'
import { DateTime } from 'luxon'
import { Mock } from 'ts-mockery'