sstur / draft-js-utils

DraftJS: import/export ContentState to and from HTML/Markdown
ISC License
883 stars 234 forks source link

Update to italic parsing breaks Safari 15.5 #255

Open just-another-jxliu opened 2 years ago

just-another-jxliu commented 2 years ago

Update to italic parsing breaks Safari 15.5: em: /^_([\s\S]+?)(?<!\\)_|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/ SyntaxError: Invalid regular expression: invalid group specifier name

https://github.com/sstur/draft-js-utils/pull/254

sstur commented 2 years ago

Hey @just-another-jxliu, thanks for reporting this!

I'm going to roll back the latest release until we get this solved.

@msglifeIberia and or @MSGInsurIt, would you be interested in revisiting PR #254 to see if we could make it work with Safari?

sstur commented 2 years ago

For context, the issue is that the RegEx above uses a Negative lookbehind assertion which is the (?<! part. Safari doesn't support this.

Here's a minimum reproducible test case:

let regEx = /(?<!y)x/
image
MSGInsurIt commented 2 years ago

Hi,

We are not finding a quick solution for this issue without Negative lookbehind support without doing considerable code changes. For now, we would like to propose keeping the fix for the browsers that support it and having a fallback mechanism for those that don't support.

MSGInsurIt commented 2 years ago

FYI @just-another-jxliu , The solution might also come from the browser. https://bugs.webkit.org/show_bug.cgi?id=174931

MSGInsurIt commented 1 year ago

Hi @sstur,

The issue with the RegExp lookbehind assertions was finally implemented in the safari browser as mentioned in the following link: https://bugs.webkit.org/show_bug.cgi?id=174931

It would make sense to re-apply the merge https://github.com/sstur/draft-js-utils/pull/254 to the latest version.

Will you merge the code again?

MSGInsurIt commented 1 year ago

Negative lookbehind assertion It's working now in Release 161 of Safari Technology Preview, downloads are here: [https://developer.apple.com/safari/resources/]

Although it didn't make the cut for the release notes!