add command for mentions
This commit is contained in:
16
packages/tiptap-commands/src/commands/setInlineBlockType.js
Normal file
16
packages/tiptap-commands/src/commands/setInlineBlockType.js
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user