allow for returning an array of multiple commands

This commit is contained in:
Philipp Kühn
2018-09-23 08:04:02 +02:00
parent e51141eb5e
commit 92515e2ee4
3 changed files with 12 additions and 8 deletions

View File

@@ -94,11 +94,15 @@ export default class ExtensionManager {
...commands,
[name]: attrs => {
view.focus()
command({
const provider = command({
type: schema[`${type}s`][name],
attrs,
schema,
})(view.state, view.dispatch, view)
})
const callbacks = Array.isArray(provider) ? provider : [provider]
callbacks.forEach(callback => callback(view.state, view.dispatch, view))
},
}), {})
}