-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix pasteRules and InputRules for italic mark #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
true true... i will come up with something new.. |
removed the input rule from the pull request so only fixes this on paste for now |
improved markInputRule to support 2nd match group so we can simulate a lookbehind behaviour which will be supported out of the box by browsers in the future anyway |
1bdc331
to
4f3696a
Compare
should be fine now even for all edge cases i had think of.. ;) |
;) sneaky ;) |
tr.delete(textEnd, end) | ||
if (match[m]) { | ||
const matchStart = start + match[0].indexOf(match[m - 1]) | ||
const matchEnd = matchStart + match[m - 1].length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philippkuehn actually the issue is here. but i don't get why... because if you add -1 (which i actually had before) when deleting the prefix it is range 4,6 (three positions) and when deleting the suffix it is 8,9 (just two positions) which is weird in my eyes but maybe you can come up with an explanation i will just force push the -1 again which also had no side effects for my tests....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay... the match seems to be handled before the last input character actually reaches the transaction thats why there is this index weirdness at the end of the input...
add another layer of matching by introducing support for second match group since javascript (at least in current browsers) still lacks lookbehind in regex so now supports /nomatch(markstart(text)markend)nomatch/ and still supports the /markstart(text)markend/ syntax all `nomatch` will be kept as is so kindof simulating lookbehinds
shoudl be fixed by removing 1 char less at the end... see comments in code - the rule is triggered before the last printed char enters the transaction (at least this seems to be the only explanation and also finds some proof in the code..) ... please test again... |
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
It seems work now. deploy preview |
fixes markPasteRules and markInputRules for italic and bold marks.. fixes #284