mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-02 16:09:59 -04:00
* Added editor-preferences to redux store * Add local-storage saving and retrieval of EditorConfig * Change import to be in a single line * Add equality check to redux-selector (as suggested by @mrdrogdrog) * Save and load editor-config to/from localStorage
This commit is contained in:
parent
a86d4cbc58
commit
f636e5ec10
6 changed files with 90 additions and 29 deletions
|
@ -20,6 +20,7 @@ import 'codemirror/keymap/emacs'
|
|||
import 'codemirror/keymap/sublime'
|
||||
import 'codemirror/keymap/vim'
|
||||
import 'codemirror/mode/gfm/gfm'
|
||||
import equal from 'fast-deep-equal'
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Controlled as ControlledCodeMirror } from 'react-codemirror2'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
@ -60,12 +61,7 @@ export const EditorPane: React.FC<EditorPaneProps & ScrollProps> = ({ onContentC
|
|||
const maxLengthWarningAlreadyShown = useRef(false)
|
||||
const [editor, setEditor] = useState<Editor>()
|
||||
const [statusBarInfo, setStatusBarInfo] = useState<StatusBarInfo>(defaultState)
|
||||
const [editorPreferences, setEditorPreferences] = useState<EditorConfiguration>({
|
||||
theme: 'one-dark',
|
||||
keyMap: 'sublime',
|
||||
indentUnit: 4,
|
||||
indentWithTabs: false
|
||||
})
|
||||
const editorPreferences = useSelector((state: ApplicationState) => state.editorConfig.preferences, equal)
|
||||
|
||||
const lastScrollPosition = useRef<number>()
|
||||
const [editorScroll, setEditorScroll] = useState<ScrollInfo>()
|
||||
|
@ -158,8 +154,6 @@ export const EditorPane: React.FC<EditorPaneProps & ScrollProps> = ({ onContentC
|
|||
<MaxLengthWarningModal show={showMaxLengthWarning} onHide={() => setShowMaxLengthWarning(false)} maxLength={maxLength}/>
|
||||
<ToolBar
|
||||
editor={editor}
|
||||
onPreferencesChange={config => setEditorPreferences(config)}
|
||||
editorPreferences={editorPreferences}
|
||||
/>
|
||||
<ControlledCodeMirror
|
||||
className="overflow-hidden w-100 flex-fill"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue