mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
Add sync scroll button (#481)
* Add disable sync scroll button Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
d488c8e2ad
commit
c95a7e0fba
12 changed files with 194 additions and 34 deletions
|
@ -1,11 +1,19 @@
|
|||
import { store } from '..'
|
||||
import { EditorMode } from '../../components/editor/app-bar/editor-view-mode'
|
||||
import { EditorConfigActionType, SetEditorConfigAction } from './types'
|
||||
import { EditorConfigActionType, SetEditorConfigAction, SetEditorSyncScrollAction } from './types'
|
||||
|
||||
export const setEditorModeConfig = (editorMode: EditorMode): void => {
|
||||
export const setEditorMode = (editorMode: EditorMode): void => {
|
||||
const action: SetEditorConfigAction = {
|
||||
type: EditorConfigActionType.SET_EDITOR_VIEW_MODE,
|
||||
mode: editorMode
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
||||
export const setEditorSyncScroll = (syncScroll: boolean): void => {
|
||||
const action: SetEditorSyncScrollAction = {
|
||||
type: EditorConfigActionType.SET_SYNC_SCROLL,
|
||||
syncScroll: syncScroll
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
import { Reducer } from 'redux'
|
||||
import { EditorConfig, EditorConfigActions, EditorConfigActionType, SetEditorConfigAction } from './types'
|
||||
import {
|
||||
EditorConfig,
|
||||
EditorConfigActions,
|
||||
EditorConfigActionType,
|
||||
SetEditorConfigAction,
|
||||
SetEditorSyncScrollAction
|
||||
} from './types'
|
||||
import { EditorMode } from '../../components/editor/app-bar/editor-view-mode'
|
||||
|
||||
export const initialState: EditorConfig = {
|
||||
editorMode: EditorMode.BOTH
|
||||
editorMode: EditorMode.BOTH,
|
||||
syncScroll: true
|
||||
}
|
||||
|
||||
export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (state: EditorConfig = initialState, action: EditorConfigActions) => {
|
||||
|
@ -13,6 +20,11 @@ export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (
|
|||
...state,
|
||||
editorMode: (action as SetEditorConfigAction).mode
|
||||
}
|
||||
case EditorConfigActionType.SET_SYNC_SCROLL:
|
||||
return {
|
||||
...state,
|
||||
syncScroll: (action as SetEditorSyncScrollAction).syncScroll
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
import { Action } from 'redux'
|
||||
import { EditorMode } from '../../components/editor/app-bar/editor-view-mode';
|
||||
import { EditorMode } from '../../components/editor/app-bar/editor-view-mode'
|
||||
|
||||
export enum EditorConfigActionType {
|
||||
SET_EDITOR_VIEW_MODE = 'editor/mode/set'
|
||||
SET_EDITOR_VIEW_MODE = 'editor/mode/set',
|
||||
SET_SYNC_SCROLL = 'editor/syncScroll/set'
|
||||
}
|
||||
|
||||
export interface EditorConfig {
|
||||
editorMode: EditorMode;
|
||||
syncScroll: boolean;
|
||||
}
|
||||
|
||||
export interface EditorConfigActions extends Action<EditorConfigActionType> {
|
||||
type: EditorConfigActionType;
|
||||
}
|
||||
|
||||
export interface SetEditorConfigAction extends EditorConfigActions {
|
||||
mode: EditorMode;
|
||||
export interface SetEditorSyncScrollAction extends EditorConfigActions {
|
||||
syncScroll: boolean
|
||||
}
|
||||
|
||||
export interface SetEditorConfigAction extends EditorConfigActions {
|
||||
mode: EditorMode
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue