add command for adding images

This commit is contained in:
Philipp Kühn
2018-09-29 22:49:38 +02:00
parent 8f66c19c7e
commit efdf45de4c
3 changed files with 34 additions and 0 deletions

View File

@@ -34,6 +34,16 @@ export default class ImageNode extends Node {
}
}
command({ type, attrs }) {
return (state, dispatch) => {
const { selection } = state
const position = selection.$cursor ? selection.$cursor.pos : selection.$to.pos
const node = type.create(attrs)
const transaction = state.tr.insert(position, node)
dispatch(transaction)
}
}
get plugins() {
return [
new Plugin({