From 33fe2b820c6bcb2c67201c4acde3a28b5be9f89f Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Fri, 17 Mar 2017 23:17:14 -0400 Subject: [PATCH] add active state to rich text raw toggle --- src/components/UI/theme.css | 1 + src/components/Widgets/MarkdownControl.js | 13 +++---------- .../MarkdownControlElements/RawEditor/index.js | 4 +++- .../Widgets/MarkdownControlElements/Toolbar.css | 7 +++++-- .../Widgets/MarkdownControlElements/Toolbar.js | 11 +++++++---- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/components/UI/theme.css b/src/components/UI/theme.css index 63519df1..4aed59be 100644 --- a/src/components/UI/theme.css +++ b/src/components/UI/theme.css @@ -21,6 +21,7 @@ --textFieldBorderColor: #e7e7e7; --highlightFGColor: #fff; --highlightBGColor: #3ab7a5; + --highlightFGAltColor: #eee; --controlLabelColor: var(--textColor); --controlBGColor: #fff; --backgroundTertiaryColor: #f2f5f4; diff --git a/src/components/Widgets/MarkdownControl.js b/src/components/Widgets/MarkdownControl.js index d37796a8..820c4c5d 100644 --- a/src/components/Widgets/MarkdownControl.js +++ b/src/components/Widgets/MarkdownControl.js @@ -3,18 +3,15 @@ import registry from '../../lib/registry'; import RawEditor from './MarkdownControlElements/RawEditor'; import VisualEditor from './MarkdownControlElements/VisualEditor'; import { processEditorPlugins } from './richText'; -import { connect } from 'react-redux'; -import { switchVisualMode } from '../../actions/editor'; const MODE_STORAGE_KEY = 'cms.md-mode'; -class MarkdownControl extends React.Component { +export default class MarkdownControl extends React.Component { static propTypes = { - editor: PropTypes.object.isRequired, onChange: PropTypes.func.isRequired, onAddAsset: PropTypes.func.isRequired, + onRemoveAsset: PropTypes.func.isRequired, getAsset: PropTypes.func.isRequired, - switchVisualMode: PropTypes.func.isRequired, value: PropTypes.node, }; @@ -57,6 +54,7 @@ class MarkdownControl extends React.Component { onAddAsset={onAddAsset} onRemoveAsset={onRemoveAsset} onMode={this.handleMode} + rawMode getAsset={getAsset} value={value} /> @@ -64,8 +62,3 @@ class MarkdownControl extends React.Component { ); } } - -export default connect( - state => ({ editor: state.editor }), - { switchVisualMode } -)(MarkdownControl); diff --git a/src/components/Widgets/MarkdownControlElements/RawEditor/index.js b/src/components/Widgets/MarkdownControlElements/RawEditor/index.js index fc06192b..b94b9358 100644 --- a/src/components/Widgets/MarkdownControlElements/RawEditor/index.js +++ b/src/components/Widgets/MarkdownControlElements/RawEditor/index.js @@ -305,7 +305,7 @@ export default class RawEditor extends React.Component { }; render() { - const { onAddAsset, onRemoveAsset, getAsset } = this.props; + const { onAddAsset, onRemoveAsset, getAsset, rawMode } = this.props; const { plugins, selectionPosition, dragging } = this.state; const classNames = [styles.root]; if (dragging) { @@ -328,6 +328,7 @@ export default class RawEditor extends React.Component { onItalic={this.handleItalic} onLink={this.handleLink} onToggleMode={this.handleToggle} + rawMode={rawMode} /> +function button(label, icon, action, active) { + const classNames = List([styles.Button]); + return (
  • @@ -11,7 +13,7 @@ function button(label, icon, action) { } function Toolbar(props) { - const { onH1, onH2, onBold, onItalic, onLink, onToggleMode } = props; + const { onH1, onH2, onBold, onItalic, onLink, onToggleMode, rawMode } = props; return (
      {button('Header 1', 'h1', onH1)} @@ -19,7 +21,7 @@ function Toolbar(props) { {button('Bold', 'bold', onBold)} {button('Italic', 'italic', onItalic)} {button('Link', 'link', onLink)} - {button('View Code', 'code', onToggleMode)} + {button('View Code', 'code', onToggleMode, rawMode)}
    ); } @@ -31,6 +33,7 @@ Toolbar.propTypes = { onItalic: PropTypes.func.isRequired, onLink: PropTypes.func.isRequired, onToggleMode: PropTypes.func.isRequired, + rawMode: PropTypes.bool, }; export default Toolbar;