小编森田昌*_*田昌宏的帖子

Draft.js 的 RichUtils.toggleInlineStyle 不起作用

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>);
   }
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery reactjs semantic-ui draftjs

4
推荐指数
1
解决办法
2054
查看次数

标签 统计

draftjs ×1

javascript ×1

jquery ×1

reactjs ×1

semantic-ui ×1