From eccdad4ca70d0e899b2a89f8b2b559b1877dd5e2 Mon Sep 17 00:00:00 2001 From: Jinksi Date: Sat, 14 Oct 2017 14:06:14 +1000 Subject: [PATCH 1/3] Add ScrollSync Button --- src/components/EntryEditor/EntryEditor.css | 10 ++++--- src/components/EntryEditor/EntryEditor.js | 33 ++++++++++++++++++---- src/components/ScrollSync/ScrollSync.js | 2 ++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/components/EntryEditor/EntryEditor.css b/src/components/EntryEditor/EntryEditor.css index d4d0a665986a..5dc51cd4e25d 100644 --- a/src/components/EntryEditor/EntryEditor.css +++ b/src/components/EntryEditor/EntryEditor.css @@ -3,16 +3,18 @@ height: 100%; } -.nc-entryEditor-previewToggle { +.nc-entryEditor-toggleButtons { position: absolute; top: 8px; - right: 40px; + right: 20px; z-index: 1000; opacity: 0.8; + display: flex; + justify-content: flex-end; } -.nc-entryEditor-previewToggleShow { - right: 60px; +.nc-entryEditor-toggleButtons > * + * { + margin-left: 10px; } .nc-entryEditor-controlPane { diff --git a/src/components/EntryEditor/EntryEditor.js b/src/components/EntryEditor/EntryEditor.js index 0accd4f7867c..6b94f6b65df5 100644 --- a/src/components/EntryEditor/EntryEditor.js +++ b/src/components/EntryEditor/EntryEditor.js @@ -11,11 +11,13 @@ import Toolbar from './EntryEditorToolbar'; import { StickyContext } from '../UI/Sticky/Sticky'; const PREVIEW_VISIBLE = 'cms.preview-visible'; +const SCROLL_SYNC_ENABLED = 'cms.scroll-sync-enabled'; class EntryEditor extends Component { state = { showEventBlocker: false, previewVisible: localStorage.getItem(PREVIEW_VISIBLE) !== "false", + scrollSyncEnabled: localStorage.getItem(SCROLL_SYNC_ENABLED) !== "false", }; handleSplitPaneDragStart = () => { @@ -37,6 +39,12 @@ class EntryEditor extends Component { localStorage.setItem(PREVIEW_VISIBLE, newPreviewVisible); }; + handleToggleScrollSync = () => { + const newScrollSyncEnabled = !this.state.scrollSyncEnabled; + this.setState({ scrollSyncEnabled: newScrollSyncEnabled }); + localStorage.setItem(SCROLL_SYNC_ENABLED, newScrollSyncEnabled); + }; + render() { const { collection, @@ -55,13 +63,13 @@ class EntryEditor extends Component { onCancelEdit, } = this.props; - const { previewVisible, showEventBlocker } = this.state; + const { previewVisible, scrollSyncEnabled, showEventBlocker } = this.state; const collectionPreviewEnabled = collection.getIn(['editor', 'preview'], true); - const togglePreviewButton = ( + const TogglePreviewButton = () => (