mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
Use fira code in editor (#695)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
b3288a6666
commit
8ce344512c
19 changed files with 311 additions and 113 deletions
|
@ -11,6 +11,7 @@ import {
|
|||
EditorConfig,
|
||||
EditorConfigActionType,
|
||||
SetEditorConfigAction,
|
||||
SetEditorLigaturesAction,
|
||||
SetEditorPreferencesAction,
|
||||
SetEditorSyncScrollAction
|
||||
} from './types'
|
||||
|
@ -52,12 +53,18 @@ export const setEditorSyncScroll = (syncScroll: boolean): void => {
|
|||
store.dispatch(action)
|
||||
}
|
||||
|
||||
export const setEditorPreferences = (preferences: EditorConfiguration): void => {
|
||||
export const setEditorLigatures = (ligatures: boolean): void => {
|
||||
const action: SetEditorLigaturesAction = {
|
||||
type: EditorConfigActionType.SET_LIGATURES,
|
||||
ligatures: ligatures
|
||||
}
|
||||
store.dispatch(action);
|
||||
}
|
||||
|
||||
export const mergeEditorPreferences = (preferences: EditorConfiguration): void => {
|
||||
const action: SetEditorPreferencesAction = {
|
||||
type: EditorConfigActionType.SET_EDITOR_PREFERENCES,
|
||||
preferences: {
|
||||
...preferences
|
||||
}
|
||||
type: EditorConfigActionType.MERGE_EDITOR_PREFERENCES,
|
||||
preferences: preferences
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
|
|
@ -12,12 +12,14 @@ import {
|
|||
EditorConfigActions,
|
||||
EditorConfigActionType,
|
||||
SetEditorConfigAction,
|
||||
SetEditorLigaturesAction,
|
||||
SetEditorPreferencesAction,
|
||||
SetEditorSyncScrollAction
|
||||
} from './types'
|
||||
|
||||
const initialState: EditorConfig = {
|
||||
editorMode: EditorMode.BOTH,
|
||||
ligatures: true,
|
||||
syncScroll: true,
|
||||
preferences: {
|
||||
theme: 'one-dark',
|
||||
|
@ -28,7 +30,7 @@ const initialState: EditorConfig = {
|
|||
}
|
||||
|
||||
const getInitialState = (): EditorConfig => {
|
||||
return loadFromLocalStorage() ?? initialState
|
||||
return { ...initialState, ...loadFromLocalStorage() }
|
||||
}
|
||||
|
||||
export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (state: EditorConfig = getInitialState(), action: EditorConfigActions) => {
|
||||
|
@ -48,10 +50,19 @@ export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (
|
|||
}
|
||||
saveToLocalStorage(newState)
|
||||
return newState
|
||||
case EditorConfigActionType.SET_EDITOR_PREFERENCES:
|
||||
case EditorConfigActionType.SET_LIGATURES:
|
||||
newState = {
|
||||
...state,
|
||||
preferences: (action as SetEditorPreferencesAction).preferences
|
||||
ligatures: (action as SetEditorLigaturesAction).ligatures
|
||||
}
|
||||
saveToLocalStorage(newState)
|
||||
return newState
|
||||
case EditorConfigActionType.MERGE_EDITOR_PREFERENCES:
|
||||
newState = {
|
||||
...state,
|
||||
preferences: {
|
||||
...state.preferences, ...(action as SetEditorPreferencesAction).preferences
|
||||
}
|
||||
}
|
||||
saveToLocalStorage(newState)
|
||||
return newState
|
||||
|
|
|
@ -11,12 +11,14 @@ import { EditorMode } from '../../components/editor/app-bar/editor-view-mode'
|
|||
export enum EditorConfigActionType {
|
||||
SET_EDITOR_VIEW_MODE = 'editor/mode/set',
|
||||
SET_SYNC_SCROLL = 'editor/syncScroll/set',
|
||||
SET_EDITOR_PREFERENCES = 'editor/preferences/set'
|
||||
MERGE_EDITOR_PREFERENCES = 'editor/preferences/merge',
|
||||
SET_LIGATURES = 'editor/preferences/setLigatures'
|
||||
}
|
||||
|
||||
export interface EditorConfig {
|
||||
editorMode: EditorMode;
|
||||
syncScroll: boolean;
|
||||
ligatures: boolean
|
||||
preferences: EditorConfiguration
|
||||
}
|
||||
|
||||
|
@ -28,6 +30,10 @@ export interface SetEditorSyncScrollAction extends EditorConfigActions {
|
|||
syncScroll: boolean
|
||||
}
|
||||
|
||||
export interface SetEditorLigaturesAction extends EditorConfigActions {
|
||||
ligatures: boolean
|
||||
}
|
||||
|
||||
export interface SetEditorConfigAction extends EditorConfigActions {
|
||||
mode: EditorMode
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue