add active state to rich text raw toggle
This commit is contained in:
@ -21,6 +21,7 @@
|
|||||||
--textFieldBorderColor: #e7e7e7;
|
--textFieldBorderColor: #e7e7e7;
|
||||||
--highlightFGColor: #fff;
|
--highlightFGColor: #fff;
|
||||||
--highlightBGColor: #3ab7a5;
|
--highlightBGColor: #3ab7a5;
|
||||||
|
--highlightFGAltColor: #eee;
|
||||||
--controlLabelColor: var(--textColor);
|
--controlLabelColor: var(--textColor);
|
||||||
--controlBGColor: #fff;
|
--controlBGColor: #fff;
|
||||||
--backgroundTertiaryColor: #f2f5f4;
|
--backgroundTertiaryColor: #f2f5f4;
|
||||||
|
@ -3,18 +3,15 @@ import registry from '../../lib/registry';
|
|||||||
import RawEditor from './MarkdownControlElements/RawEditor';
|
import RawEditor from './MarkdownControlElements/RawEditor';
|
||||||
import VisualEditor from './MarkdownControlElements/VisualEditor';
|
import VisualEditor from './MarkdownControlElements/VisualEditor';
|
||||||
import { processEditorPlugins } from './richText';
|
import { processEditorPlugins } from './richText';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { switchVisualMode } from '../../actions/editor';
|
|
||||||
|
|
||||||
const MODE_STORAGE_KEY = 'cms.md-mode';
|
const MODE_STORAGE_KEY = 'cms.md-mode';
|
||||||
|
|
||||||
class MarkdownControl extends React.Component {
|
export default class MarkdownControl extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
editor: PropTypes.object.isRequired,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
onAddAsset: PropTypes.func.isRequired,
|
onAddAsset: PropTypes.func.isRequired,
|
||||||
|
onRemoveAsset: PropTypes.func.isRequired,
|
||||||
getAsset: PropTypes.func.isRequired,
|
getAsset: PropTypes.func.isRequired,
|
||||||
switchVisualMode: PropTypes.func.isRequired,
|
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,6 +54,7 @@ class MarkdownControl extends React.Component {
|
|||||||
onAddAsset={onAddAsset}
|
onAddAsset={onAddAsset}
|
||||||
onRemoveAsset={onRemoveAsset}
|
onRemoveAsset={onRemoveAsset}
|
||||||
onMode={this.handleMode}
|
onMode={this.handleMode}
|
||||||
|
rawMode
|
||||||
getAsset={getAsset}
|
getAsset={getAsset}
|
||||||
value={value}
|
value={value}
|
||||||
/>
|
/>
|
||||||
@ -64,8 +62,3 @@ class MarkdownControl extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
|
||||||
state => ({ editor: state.editor }),
|
|
||||||
{ switchVisualMode }
|
|
||||||
)(MarkdownControl);
|
|
||||||
|
@ -305,7 +305,7 @@ export default class RawEditor extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { onAddAsset, onRemoveAsset, getAsset } = this.props;
|
const { onAddAsset, onRemoveAsset, getAsset, rawMode } = this.props;
|
||||||
const { plugins, selectionPosition, dragging } = this.state;
|
const { plugins, selectionPosition, dragging } = this.state;
|
||||||
const classNames = [styles.root];
|
const classNames = [styles.root];
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
@ -328,6 +328,7 @@ export default class RawEditor extends React.Component {
|
|||||||
onItalic={this.handleItalic}
|
onItalic={this.handleItalic}
|
||||||
onLink={this.handleLink}
|
onLink={this.handleLink}
|
||||||
onToggleMode={this.handleToggle}
|
onToggleMode={this.handleToggle}
|
||||||
|
rawMode={rawMode}
|
||||||
/>
|
/>
|
||||||
<ToolbarPlugins
|
<ToolbarPlugins
|
||||||
selectionPosition={selectionPosition}
|
selectionPosition={selectionPosition}
|
||||||
@ -357,5 +358,6 @@ RawEditor.propTypes = {
|
|||||||
getAsset: PropTypes.func.isRequired,
|
getAsset: PropTypes.func.isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
onMode: PropTypes.func.isRequired,
|
onMode: PropTypes.func.isRequired,
|
||||||
|
rawMode: PropTypes.bool,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@import "../../UI/theme";
|
||||||
|
|
||||||
.Toolbar {
|
.Toolbar {
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
@ -13,8 +15,9 @@
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
@nest .ButtonActive& {
|
||||||
background-color: #eee;
|
background-color: var(--highlightFGAltColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
|
import { List } from 'immutable';
|
||||||
import { Icon } from '../../UI';
|
import { Icon } from '../../UI';
|
||||||
import styles from './Toolbar.css';
|
import styles from './Toolbar.css';
|
||||||
|
|
||||||
function button(label, icon, action) {
|
function button(label, icon, action, active) {
|
||||||
return (<li className={styles.Button}>
|
const classNames = List([styles.Button]);
|
||||||
|
return (<li className={(active ? classNames.push(styles.ButtonActive) : classNames).join(' ')}>
|
||||||
<button className={styles[label]} onClick={action} title={label}>
|
<button className={styles[label]} onClick={action} title={label}>
|
||||||
<Icon type={icon} />
|
<Icon type={icon} />
|
||||||
</button>
|
</button>
|
||||||
@ -11,7 +13,7 @@ function button(label, icon, action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Toolbar(props) {
|
function Toolbar(props) {
|
||||||
const { onH1, onH2, onBold, onItalic, onLink, onToggleMode } = props;
|
const { onH1, onH2, onBold, onItalic, onLink, onToggleMode, rawMode } = props;
|
||||||
return (
|
return (
|
||||||
<ul className={styles.Toolbar}>
|
<ul className={styles.Toolbar}>
|
||||||
{button('Header 1', 'h1', onH1)}
|
{button('Header 1', 'h1', onH1)}
|
||||||
@ -19,7 +21,7 @@ function Toolbar(props) {
|
|||||||
{button('Bold', 'bold', onBold)}
|
{button('Bold', 'bold', onBold)}
|
||||||
{button('Italic', 'italic', onItalic)}
|
{button('Italic', 'italic', onItalic)}
|
||||||
{button('Link', 'link', onLink)}
|
{button('Link', 'link', onLink)}
|
||||||
{button('View Code', 'code', onToggleMode)}
|
{button('View Code', 'code', onToggleMode, rawMode)}
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -31,6 +33,7 @@ Toolbar.propTypes = {
|
|||||||
onItalic: PropTypes.func.isRequired,
|
onItalic: PropTypes.func.isRequired,
|
||||||
onLink: PropTypes.func.isRequired,
|
onLink: PropTypes.func.isRequired,
|
||||||
onToggleMode: PropTypes.func.isRequired,
|
onToggleMode: PropTypes.func.isRequired,
|
||||||
|
rawMode: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Toolbar;
|
export default Toolbar;
|
||||||
|
Reference in New Issue
Block a user