Move frontmatter extraction from renderer to redux (#1413)

This commit is contained in:
Erik Michelson 2021-09-02 11:15:31 +02:00 committed by GitHub
parent 7fb7c55877
commit 04e16d8880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 680 additions and 589 deletions

View file

@ -11,8 +11,7 @@ import { useDocumentTitleWithNoteTitle } from '../../hooks/common/use-document-t
import { useNoteMarkdownContent } from '../../hooks/common/use-note-markdown-content'
import {
setCheckboxInMarkdownContent,
setNoteFrontmatter,
setNoteMarkdownContent,
setNoteContent,
updateNoteTitleByFirstHeading
} from '../../redux/note-details/methods'
import { MotdBanner } from '../common/motd-banner/motd-banner'
@ -50,6 +49,7 @@ export const EditorPage: React.FC = () => {
const markdownContent = useNoteMarkdownContent()
const scrollSource = useRef<ScrollSource>(ScrollSource.EDITOR)
const documentContent = useApplicationState((state) => state.noteDetails.documentContent)
const editorMode: EditorMode = useApplicationState((state) => state.editorConfig.editorMode)
const editorSyncScroll: boolean = useApplicationState((state) => state.editorConfig.syncScroll)
@ -98,14 +98,14 @@ export const EditorPage: React.FC = () => {
const leftPane = useMemo(
() => (
<EditorPane
onContentChange={setNoteMarkdownContent}
content={markdownContent}
onContentChange={setNoteContent}
content={documentContent}
scrollState={scrollState.editorScrollState}
onScroll={onEditorScroll}
onMakeScrollSource={setEditorToScrollSource}
/>
),
[markdownContent, onEditorScroll, scrollState.editorScrollState, setEditorToScrollSource]
[documentContent, onEditorScroll, scrollState.editorScrollState, setEditorToScrollSource]
)
const rightPane = useMemo(
@ -116,7 +116,6 @@ export const EditorPage: React.FC = () => {
onMakeScrollSource={setRendererToScrollSource}
onFirstHeadingChange={updateNoteTitleByFirstHeading}
onTaskCheckedChange={setCheckboxInMarkdownContent}
onFrontmatterChange={setNoteFrontmatter}
onScroll={onMarkdownRendererScroll}
scrollState={scrollState.rendererScrollState}
rendererType={RendererType.DOCUMENT}