Change registerPlugin to add plugin after Extensions plugins

This commit changes `registerPlugin` by 1. adding the new plugin to `this.plugins` and 2. updating `this.plugins` within `this.state.plugins` by splicing with the new `this.plugins` length. Previously, new plugins were simply added to the end of `this.state.plugins` and were not appended to `this.plugins`. 

By placing new plugins at this new location within `this.state.plugins`, we prioritize registered plugins over default ProseMirror plugins such as `keymap(baseKeymap)`. This will allow new plugins to have precedence over props such as `handleKeyDown`.
This commit is contained in:
BrianHung 2020-04-08 03:17:59 -07:00 committed by GitHub
parent 441af1a6ce
commit 90f0498265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -492,9 +492,9 @@ export default class Editor extends Emitter {
return
}
const newState = this.state.reconfigure({
plugins: this.state.plugins.concat([plugin]),
})
this.plugins.push(plugin);
this.state.plugins.splice(this.plugins.length, 0, plugin);
const newState = this.state.reconfigure({plugins: this.state.plugins});
this.view.updateState(newState)
}