fix em input rule

This commit is contained in:
Philipp Kühn
2018-08-27 21:53:12 +02:00
parent 7d60a084a4
commit 1de45acef5
2 changed files with 9 additions and 4 deletions

View File

@@ -6,11 +6,16 @@ export default function (regexp, markType, getAttrs) {
let tr = state.tr
if (match[1]) {
const startSpaces = match[0].search(/\S/)
let textStart = start + match[0].indexOf(match[1])
let textEnd = textStart + match[1].length
if (textEnd < end) tr.delete(textEnd, end)
if (textStart > start) tr.delete(start, textStart)
end = start + match[1].length
if (textEnd < end) {
tr.delete(textEnd, end)
}
if (textStart > start) {
tr.delete(start + startSpaces, textStart)
}
end = start + startSpaces + match[1].length
}
tr.addMark(start, end, markType.create(attrs))