From 6542947472c8b85c6eca7365a9481cd504634eca Mon Sep 17 00:00:00 2001 From: Dan Roundhill Date: Mon, 5 Feb 2018 13:28:36 -0800 Subject: [PATCH] Moving the markdown toggle to a 'preview' icon in the toolbar. Removed the old segmented control that took up vertical space in the editor. (#699) --- lib/icons/preview-stop.jsx | 15 ++++++++++++ lib/icons/preview.jsx | 15 ++++++++++++ lib/note-editor.jsx | 47 +++----------------------------------- lib/note-toolbar.jsx | 26 ++++++++++++++++++++- scss/editor.scss | 17 -------------- scss/print.scss | 1 - 6 files changed, 58 insertions(+), 63 deletions(-) create mode 100644 lib/icons/preview-stop.jsx create mode 100644 lib/icons/preview.jsx diff --git a/lib/icons/preview-stop.jsx b/lib/icons/preview-stop.jsx new file mode 100644 index 000000000..96c0e492a --- /dev/null +++ b/lib/icons/preview-stop.jsx @@ -0,0 +1,15 @@ +import React from 'react'; + +export default function PreviewStopIcon() { + return ( + + + + ); +} diff --git a/lib/icons/preview.jsx b/lib/icons/preview.jsx new file mode 100644 index 000000000..118210564 --- /dev/null +++ b/lib/icons/preview.jsx @@ -0,0 +1,15 @@ +import React from 'react'; + +export default function PreviewIcon() { + return ( + + + + ); +} diff --git a/lib/note-editor.jsx b/lib/note-editor.jsx index 870cd45c4..0e0e4e3bb 100644 --- a/lib/note-editor.jsx +++ b/lib/note-editor.jsx @@ -143,16 +143,6 @@ export const NoteEditor = React.createClass({ this.setIsViewingRevisions(false); }, - setEditorMode(event) { - const editorMode = get(event, 'target.dataset.editorMode'); - - if (!editorMode) { - return; - } - - this.props.onSetEditorMode(editorMode); - }, - setIsViewingRevisions: function(isViewing) { this.setState({ isViewingRevisions: isViewing }); }, @@ -239,10 +229,12 @@ export const NoteEditor = React.createClass({ setIsViewingRevisions={this.setIsViewingRevisions} onCloseNote={this.props.onCloseNote} onNoteInfo={this.props.onNoteInfo} + onSetEditorMode={this.props.onSetEditorMode} + editorMode={editorMode} + markdownEnabled={markdownEnabled} />
- {!!markdownEnabled && this.renderModeBar()}
); }, - - renderModeBar() { - const { editorMode } = this.props; - - const isPreviewing = editorMode === 'markdown'; - - return ( -
- - -
- ); - }, }); const mapStateToProps = ({ appState: state, settings }) => ({ diff --git a/lib/note-toolbar.jsx b/lib/note-toolbar.jsx index 87a93b2f9..968abc60b 100644 --- a/lib/note-toolbar.jsx +++ b/lib/note-toolbar.jsx @@ -1,6 +1,8 @@ import React, { PropTypes } from 'react'; import BackIcon from './icons/back'; import InfoIcon from './icons/info'; +import PreviewIcon from './icons/preview'; +import PreviewStopIcon from './icons/preview-stop'; import RevisionsIcon from './icons/revisions'; import TrashIcon from './icons/trash'; import ShareIcon from './icons/share'; @@ -16,6 +18,9 @@ export default React.createClass({ onCloseNote: PropTypes.func.isRequired, onNoteInfo: PropTypes.func.isRequired, setIsViewingRevisions: PropTypes.func.isRequired, + onSetEditorMode: PropTypes.func.isRequired, + editorMode: PropTypes.string.isRequred, + markdownEnabled: PropTypes.bool.isRequred, }, showRevisions: function() { @@ -30,8 +35,15 @@ export default React.createClass({ return isTrashed ? this.renderTrashed() : this.renderNormal(); }, + setEditorMode() { + const { editorMode } = this.props; + + this.props.onSetEditorMode(editorMode === 'markdown' ? 'edit' : 'markdown'); + }, + renderNormal() { - const { note } = this.props; + const { note, editorMode, markdownEnabled } = this.props; + const isPreviewing = editorMode === 'markdown'; return (
@@ -45,6 +57,18 @@ export default React.createClass({
+ {markdownEnabled && ( +
+ +
+ )}