diff --git a/src/react-contenteditable.tsx b/src/react-contenteditable.tsx index 030e4ba..e3ad89f 100644 --- a/src/react-contenteditable.tsx +++ b/src/react-contenteditable.tsx @@ -46,6 +46,14 @@ export default class ContentEditable extends React.Component { render() { const { tagName, html, innerRef, ...props } = this.props; + let contentEditable = this.props.contentEditable === undefined + ? true + : this.props.contentEditable; + + if (this.props.disabled === true) { + contentEditable = false; + } + return React.createElement( tagName || 'div', { @@ -58,7 +66,7 @@ export default class ContentEditable extends React.Component { onBlur: this.props.onBlur || this.emitChange, onKeyUp: this.props.onKeyUp || this.emitChange, onKeyDown: this.props.onKeyDown || this.emitChange, - contentEditable: !this.props.disabled, + contentEditable, dangerouslySetInnerHTML: { __html: html } }, this.props.children); @@ -120,6 +128,14 @@ export default class ContentEditable extends React.Component { } static propTypes = { + contentEditable: PropTypes.oneOf([ + "events", + "caret", + "typing", + "plaintext-only", + true, + false + ]), html: PropTypes.string.isRequired, onChange: PropTypes.func, disabled: PropTypes.bool,