fix em input rule
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -30,7 +30,7 @@ export default class ItalicMark extends Mark {
|
||||
|
||||
inputRules({ type }) {
|
||||
return [
|
||||
markInputRule(/(?:\*|_)([^\*_]+)(?:\*|_)$/, type),
|
||||
markInputRule(/(?:^|[^\*_])(?:\*|_)([^\*_]+)(?:\*|_)$/, type),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user