mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-31 23:28:34 -04:00
Add note loading boundary (#2040)
* Remove redundant equal value Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add NoteLoadingBoundary to fetch note from API before rendering Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Improve debug message for setHandler Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add test for boundary Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Use common error page for note loading errors Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix tests Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Format code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add missing snapshot Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Reformat code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
0419113d36
commit
880e542351
19 changed files with 282 additions and 166 deletions
|
@ -6,20 +6,16 @@
|
|||
|
||||
import { useMemo } from 'react'
|
||||
import { useApplicationState } from './use-application-state'
|
||||
import equal from 'fast-deep-equal'
|
||||
|
||||
/**
|
||||
* Returns the markdown content from the global application state trimmed to the maximal note length and without the frontmatter lines.
|
||||
*/
|
||||
export const useTrimmedNoteMarkdownContentWithoutFrontmatter = (): string[] => {
|
||||
const maxLength = useApplicationState((state) => state.config.maxDocumentLength)
|
||||
const markdownContent = useApplicationState(
|
||||
(state) => ({
|
||||
lines: state.noteDetails.markdownContent.lines,
|
||||
content: state.noteDetails.markdownContent.plain
|
||||
}),
|
||||
equal
|
||||
)
|
||||
const markdownContent = useApplicationState((state) => ({
|
||||
lines: state.noteDetails.markdownContent.lines,
|
||||
content: state.noteDetails.markdownContent.plain
|
||||
}))
|
||||
const lineOffset = useApplicationState((state) => state.noteDetails.frontmatterRendererInfo.lineOffset)
|
||||
|
||||
const trimmedLines = useMemo(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue