Draft.js 的 RichUtils.toggleInlineStyle 无法正常工作。请帮忙!我的代码在JSfiddle上。
有什么误解吗?
var TextArea = React.createClass({
...
toggleBlockStyle: function(blockType) {
this.onChange(RichUtils.toggleBlockType(this.state.editorState, blockType)); // don't work!
},
toggleInlineStyle: function(inlineStyle) {
this.onChange(RichUtils.toggleInlineStyle(this.state.editorState, inlineStyle)); // don't work!
},
handleClear: function() {
this.onChange(EditorState.push(this.state.editorState,
ContentState.createFromText(''), 'remove-range')); // don't work!
},
...
render: function() {
return (
<div onClick={this.onFocus}>
{this.renderButtons()}
<Editor editorState={this.state.editorState}
className={this.props.className}
name={this.props.name} ref="editor"
placeholder={this.props.placeholder}
handleKeyCommand={this.handleKeyCommand}
onChange={this.onChange}
spellCheck={true}
stripPastedStyles={true}
customStyleMap={myStyleMap}/>
</div>);
}
}