mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-06 19:38:08 +08:00
add comment clarifying why match index hast to be length -1
i verified that the actual transaction does not contain the last matching char tr.doc.textBetween(start, end+1) will miss the triggering char at the end
This commit is contained in:
parent
98cf0e425a
commit
5bac4a1e33
@ -10,6 +10,8 @@ export default function (regexp, markType, getAttrs) {
|
|||||||
|
|
||||||
if (match[m]) {
|
if (match[m]) {
|
||||||
const matchStart = start + match[0].indexOf(match[m - 1])
|
const matchStart = start + match[0].indexOf(match[m - 1])
|
||||||
|
// matchEnd index is -1 because the last matching char is not yet member of transaction
|
||||||
|
// and actually never will be because it triggered the inputrule and vanishes ;)
|
||||||
const matchEnd = matchStart + match[m - 1].length - 1
|
const matchEnd = matchStart + match[m - 1].length - 1
|
||||||
const textStart = matchStart + match[m - 1].lastIndexOf(match[m])
|
const textStart = matchStart + match[m - 1].lastIndexOf(match[m])
|
||||||
const textEnd = textStart + match[m].length
|
const textEnd = textStart + match[m].length
|
||||||
|
Loading…
Reference in New Issue
Block a user