Javascript 多个插件中的SlateJs RenderMark

Javascript 多个插件中的SlateJs RenderMark,javascript,reactjs,slatejs,Javascript,Reactjs,Slatejs,我在多个插件中使用了renderMark,但只调用了插件堆栈中的顶级插件,其余的插件被忽略 //第一个插件 function MarkHotkey(options) { const { type, key, RenderTag, icon } = options return { onKeyDown(event, editor, next) { if (!event.ctrlKey || event.key != key) return next();

我在多个插件中使用了renderMark,但只调用了插件堆栈中的顶级插件,其余的插件被忽略

//第一个插件

function MarkHotkey(options) {
  const { type, key, RenderTag, icon } = options

  return {
    onKeyDown(event, editor, next) {
      if (!event.ctrlKey || event.key != key) return next();
      event.preventDefault();
      editor.toggleMark(type)
    },
    renderMark(props, editor, next){
      const { children, mark, attributes } = props;
      if(type === mark.type){
       return <u {...attributes}>{children}</u>
     }
      next();
    }
//带有插件的渲染编辑器

class App extends React.Component {
  state = {
    value: Value.fromJSON(initialValue), // editor initialisation
  }

  onChange = ({ value }) => {
    this.setState({ value })
  }

  render() {
    return <Editor 
    value={this.state.value} 
    onChange={this.onChange}
    plugins={plugins}
    />
  }

}

export default App;
类应用程序扩展了React.Component{
状态={
value:value.fromJSON(initialValue),//编辑器初始化
}
onChange=({value})=>{
this.setState({value})
}
render(){
返回
}
}
导出默认应用程序;
当我按下ctrl+I时,它按预期工作,而ctrl+u不工作。

您必须返回
next()
,而不仅仅是调用它。之后,插件应该按照它们列出的顺序启动,并继续向下传递事件,直到其中一个不返回
next()


希望这有帮助

很乐意帮忙!这对我来说很明显,因为我做了很多次!
const plugins = [
  MarkHotkey1({ key: 'i', type: 'italic' ,RenderTag : 'em',icon :''}),
  MarkHotkey({ key: 'u', type: 'underline' ,RenderTag : 'u',icon :''}),
]
class App extends React.Component {
  state = {
    value: Value.fromJSON(initialValue), // editor initialisation
  }

  onChange = ({ value }) => {
    this.setState({ value })
  }

  render() {
    return <Editor 
    value={this.state.value} 
    onChange={this.onChange}
    plugins={plugins}
    />
  }

}

export default App;