mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
feat: add setting for line wrapping
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4790c7cd1b
commit
e368203e16
8 changed files with 74 additions and 4 deletions
|
@ -8,6 +8,7 @@ import { Logger } from '../../utils/logger'
|
|||
import type {
|
||||
EditorConfig,
|
||||
SetEditorLigaturesAction,
|
||||
SetEditorLineWrappingAction,
|
||||
SetEditorSmartPasteAction,
|
||||
SetEditorSyncScrollAction
|
||||
} from './types'
|
||||
|
@ -44,6 +45,14 @@ export const setEditorSyncScroll = (syncScroll: boolean): void => {
|
|||
store.dispatch(action)
|
||||
}
|
||||
|
||||
export const setEditorLineWrapping = (lineWrapping: boolean): void => {
|
||||
const action: SetEditorLineWrappingAction = {
|
||||
type: EditorConfigActionType.SET_LINE_WRAPPING,
|
||||
lineWrapping
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
||||
export const setEditorLigatures = (ligatures: boolean): void => {
|
||||
const action: SetEditorLigaturesAction = {
|
||||
type: EditorConfigActionType.SET_LIGATURES,
|
||||
|
|
|
@ -12,7 +12,8 @@ const initialState: EditorConfig = {
|
|||
ligatures: true,
|
||||
syncScroll: true,
|
||||
smartPaste: true,
|
||||
spellCheck: false
|
||||
spellCheck: false,
|
||||
lineWrapping: true
|
||||
}
|
||||
|
||||
const getInitialState = (): EditorConfig => {
|
||||
|
@ -53,6 +54,13 @@ export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (
|
|||
}
|
||||
saveToLocalStorage(newState)
|
||||
return newState
|
||||
case EditorConfigActionType.SET_LINE_WRAPPING:
|
||||
newState = {
|
||||
...state,
|
||||
lineWrapping: action.lineWrapping
|
||||
}
|
||||
saveToLocalStorage(newState)
|
||||
return newState
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ export enum EditorConfigActionType {
|
|||
SET_EDITOR_VIEW_MODE = 'editor/view-mode/set',
|
||||
SET_SYNC_SCROLL = 'editor/syncScroll/set',
|
||||
SET_LIGATURES = 'editor/preferences/setLigatures',
|
||||
SET_LINE_WRAPPING = 'editor/preferences/setLineWrapping',
|
||||
SET_SMART_PASTE = 'editor/preferences/setSmartPaste',
|
||||
SET_SPELL_CHECK = 'editor/preferences/setSpellCheck'
|
||||
}
|
||||
|
@ -18,14 +19,21 @@ export interface EditorConfig {
|
|||
ligatures: boolean
|
||||
smartPaste: boolean
|
||||
spellCheck: boolean
|
||||
lineWrapping: boolean
|
||||
}
|
||||
|
||||
export type EditorConfigActions =
|
||||
| SetEditorSyncScrollAction
|
||||
| SetEditorLigaturesAction
|
||||
| SetEditorSmartPasteAction
|
||||
| SetEditorLineWrappingAction
|
||||
| SetSpellCheckAction
|
||||
|
||||
export interface SetEditorLineWrappingAction extends Action<EditorConfigActionType> {
|
||||
type: EditorConfigActionType.SET_LINE_WRAPPING
|
||||
lineWrapping: boolean
|
||||
}
|
||||
|
||||
export interface SetEditorSyncScrollAction extends Action<EditorConfigActionType> {
|
||||
type: EditorConfigActionType.SET_SYNC_SCROLL
|
||||
syncScroll: boolean
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue