Excuse me, after creating a Plugin through ViewPlugin.define, how to register it to EditorView for work  

Excuse me, after creating a Plugin through ViewPlugin.define, how to register it to EditorView for work


Include it in your state’s extensions config options.

this is my test code,I also operate like this,but it didn’t work properly and it threw an error message when executed

let mentionDeco = Decoration.mark({class: "mention"})
let tagDeco = Decoration.mark({class: "hashtag"})
let highlightDeco = Decoration.mark({class: "highlight"})
let decorator = new MatchDecorator({
  regexp: /(a)|(b)|(c)/g,
  decoration: m => m[1] ? mentionDeco : m[2] ? highlightDeco : tagDeco
})

let plugin = ViewPlugin.define(view => ({
  decorations: decorator.createDeco(view),
  update(u) {
    eLogger.info(tag, "decorations update", u)
    this.decorations = decorator.updateDeco(u, this.decorations)
  },
  destroy() {
    eLogger.info(tag, "decorations destroy")
  }
}), {
  decorations: v => v.decorations
})
eLogger.info(tag, "decorations plugin", plugin)
this.editorState = EditorState.create({
  doc: this.logDoc,
  extensions: [basicSetup,plugin]
})

this is error msg

Uncaught (in promise) TypeError: Cannot read property 'extension' of undefined
    at inner (index.js?e1ea:1075)
    at inner (index.js?e1ea:1075)
    at inner (index.js?e1ea:1075)
    at inner (index.js?e1ea:1053)
    at flatten (index.js?e1ea:1078)
    at Function.resolve (index.js?e1ea:990)
    at Function.create (index.js?e1ea:1642)
    at Proxy.created (LogEditView.vue?2a2b:50)
    at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:154)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?5c40:163)

That looks like an error you’d get if you had an undefined somewhere in your extension arrays. I don’t see how that would happen with the given code though.

thanks,but my all code is here