make current replaceText command compatible with the previous one
This commit is contained in:
@@ -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) => {
|
return (state, dispatch) => {
|
||||||
const { $from, $to } = state.selection
|
const { $from, $to } = state.selection
|
||||||
const index = $from.index()
|
const index = $from.index()
|
||||||
@@ -10,7 +12,7 @@ export default function (range = null, type, content = []) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dispatch) {
|
if (dispatch) {
|
||||||
dispatch(state.tr.replaceWith(from, to, content))
|
dispatch(state.tr.replaceWith(from, to, type.create(attrs, fragment)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ export default class Mention extends Node {
|
|||||||
|
|
||||||
insertMention(range, attrs, schema) {
|
insertMention(range, attrs, schema) {
|
||||||
const nodeType = schema.nodes[this.name]
|
const nodeType = schema.nodes[this.name]
|
||||||
const content = nodeType.create(attrs, this.createFragment(schema, attrs.label))
|
const nodeFragment = this.createFragment(schema, attrs.label)
|
||||||
return replaceText(range, nodeType, content)
|
return replaceText(range, nodeType, attrs, nodeFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
get schema() {
|
get schema() {
|
||||||
|
|||||||
Reference in New Issue
Block a user