【发布时间】:2017-10-07 20:32:29
【问题描述】:
我有以下功能
buttonToSelection(){
const editorState = this.state.editorState;
var selectionState = editorState.getSelection();
const newSelection = selectionState.merge({
anchorOffset: 1,
focusOffset: 10
})
const newEditorState = EditorState.forceSelection(editorState, newSelection);
this.editorChangeState(RichUtils.toggleInlineStyle(newEditorState,'STRIKEOUT'));
}
我想要实现的是单击按钮样式,文本范围在 1 到 10 之间并带有 STRIKEOUT。该功能目前执行此操作,但也保留文本的选择。我只是想让它改变文本的样式。
【问题讨论】:
标签: draftjs