Skip to content

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

Merged
merged 3 commits into from
May 9, 2019

Conversation

mariux
Copy link
Contributor

@mariux mariux commented May 6, 2019

fixes markPasteRules and markInputRules for italic and bold marks.. fixes #284

@philippkuehn
Copy link
Contributor

This will break bold inputrules :(
May-07-2019 07-48-03

@mariux
Copy link
Contributor Author

mariux commented May 7, 2019

true true... i will come up with something new..

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@mariux mariux force-pushed the fix-italic-rules branch from ed044c1 to b0c28da Compare May 7, 2019 15:15
@mariux mariux changed the title fix pasteRules and inputRules for italic mark fix pasteRules for italic mark May 7, 2019
@mariux
Copy link
Contributor Author

mariux commented May 7, 2019

removed the input rule from the pull request so only fixes this on paste for now

@mariux mariux force-pushed the fix-italic-rules branch from 6cc32e1 to 0a675a5 Compare May 7, 2019 17:12
@mariux
Copy link
Contributor Author

mariux commented May 7, 2019

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

@mariux mariux force-pushed the fix-italic-rules branch from 0a675a5 to 6d130a9 Compare May 7, 2019 17:24
@mariux mariux changed the title fix pasteRules for italic mark WIP fix pasteRules for italic mark May 7, 2019
@mariux mariux force-pushed the fix-italic-rules branch 2 times, most recently from 1bdc331 to 4f3696a Compare May 7, 2019 18:26
@mariux mariux changed the title WIP fix pasteRules for italic mark fix pasteRules for italic mark May 7, 2019
@mariux
Copy link
Contributor Author

mariux commented May 7, 2019

should be fine now even for all edge cases i had think of.. ;)

@philippkuehn
Copy link
Contributor

Sorry 😅
May-07-2019 22-26-46

@mariux
Copy link
Contributor Author

mariux commented May 7, 2019

;) sneaky ;)

tr.delete(textEnd, end)
if (match[m]) {
const matchStart = start + match[0].indexOf(match[m - 1])
const matchEnd = matchStart + match[m - 1].length
Copy link
Contributor Author

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....

Copy link
Contributor Author

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...

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
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
@mariux mariux force-pushed the fix-italic-rules branch from 4f3696a to 98cf0e4 Compare May 7, 2019 21:12
@mariux
Copy link
Contributor Author

mariux commented May 7, 2019

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
@Alecyrus
Copy link
Contributor

Alecyrus commented May 8, 2019

It seems work now. deploy preview

@mariux mariux changed the title fix pasteRules for italic mark fix pasteRules and InputRules for italic mark May 8, 2019
@philippkuehn philippkuehn merged commit 4c6ec7a into ueberdosis:master May 9, 2019
@mariux mariux deleted the fix-italic-rules branch June 3, 2020 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transformation <em> when pasting or typing has unexpected results
3 participants