make current replaceText command compatible with the previous one

This commit is contained in:
Priestch
2020-10-20 23:49:19 +08:00
committed by Hans Pagel
parent a6da24a75d
commit 38ea4e6c66
2 changed files with 6 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
export default function (range = null, type, content = []) {
import { Fragment } from 'prosemirror-model'
export default function (range = null, type, attrs = {}, fragment = Fragment.empty) {
return (state, dispatch) => {
const { $from, $to } = state.selection
const index = $from.index()
@@ -10,7 +12,7 @@ export default function (range = null, type, content = []) {
}
if (dispatch) {
dispatch(state.tr.replaceWith(from, to, content))
dispatch(state.tr.replaceWith(from, to, type.create(attrs, fragment)))
}
return true