Skip to content

Commit 6205531

Browse files
author
Ben Briggs
committed
add showButtons prop to Editor and pass prop to differentiate the buttons within the Editor
1 parent 7915fda commit 6205531

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/components/Editor.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const propTypes = {
2727
onTab: PropTypes.func,
2828
onUpArrow: PropTypes.func,
2929
onDownArrow: PropTypes.func,
30-
readOnly: PropTypes.bool
30+
readOnly: PropTypes.bool,
31+
showButtons: PropTypes.bool
3132
};
3233

3334
const EditorWrapper = React.createClass({
@@ -54,7 +55,8 @@ const EditorWrapper = React.createClass({
5455
blockRendererFn: () => {},
5556
blockStyleFn: () => {},
5657
keyBindingFn: () => {},
57-
readOnly: false
58+
readOnly: false,
59+
showButtons: true
5860
};
5961
},
6062

@@ -166,16 +168,22 @@ const EditorWrapper = React.createClass({
166168
const {
167169
onChange,
168170
addKeyCommandListener,
169-
removeKeyCommandListener
171+
removeKeyCommandListener,
172+
showButtons
170173
} = this.props;
171174

175+
if (showButtons === false) {
176+
return null;
177+
}
178+
172179
const decoratedState = this.getDecoratedState();
173180

174181
return this.props.buttons.map((Button, index) => {
175182
return (
176183
<Button
177184
{...this.getOtherProps()}
178185
key={`button-${index}`}
186+
attachedToEditor={true}
179187
editorState={decoratedState}
180188
onChange={onChange}
181189
addKeyCommandListener={addKeyCommandListener}

0 commit comments

Comments
 (0)