add command for mentions

This commit is contained in:
Philipp Kühn
2018-09-25 07:43:21 +02:00
parent b2e73fc0a4
commit a511704f49
4 changed files with 60 additions and 7 deletions

View File

@@ -0,0 +1,16 @@
export default function (type, attrs = {}) {
return (state, dispatch) => {
const { $from } = state.selection
const index = $from.index()
if (!$from.parent.canReplaceWith(index, index, type)) {
return false
}
if (dispatch) {
dispatch(state.tr.replaceSelectionWith(type.create(attrs)))
}
return true
}
}