我有一个围绕Draft.js提供的编辑器的包装器,并且我希望能够使UL和OL在按下tab / shift-tab键时正常工作。我定义了以下方法:
_onChange(editorState) {
this.setState({editorState});
if (this.props.onChange) {
this.props.onChange(
new CustomEvent('chimpeditor_update',
{
detail: stateToHTML(editorState.getCurrentContent())
})
);
}
}
_onTab(event) {
console.log('onTab');
this._onChange(RichUtils.onTab(event, this.state.editorState, 6));
}
这里有一个方法叫做_onTab
,它与Editor.onTab
相连。在这个方法中,我调用了RichUtil.onTab()
,我认为它会返回更新后的EditorState
,然后我将其传递给一个通用方法来更新EditorState
并调用一些回调函数。但是,当我按下tab键或shift+tab键时,什么都没有发生。
console.log
输出吗?如果没有,那么你没有正确绑定调用。让我知道文件看起来如何。 - kaushik94