froala / wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
Other
5.28k stars 672 forks source link

Links in pasted text are corrupted in Safari #4515

Closed em77 closed 1 year ago

em77 commented 2 years ago
Expected behavior.

Copy/pasting text that includes links should behave the same in all browsers and should be preserved and formatted the same as from where it was copied.

Actual behavior.

The expected behavior does not occur in Safari. The links are corrupted.

Steps to reproduce the problem.

Simply make some text in an editor (like Google Docs) with a link included and copy/paste it into the demo editor on Chrome and Safari.

You can get it to work properly in Safari by including some plugins but excluding the url plugin. If you include no plugins, the problem still happens. The problem also happens if the only plugin included is the linkStyles one (example). I'm still trying to narrow down with what settings the problem occurs and when it doesn't but it seems very much related to the url plugin which is maybe being included in the background when using linkStyles which would explain it being broken using that as well? I would disable the url plugin in our app if it didn't provide such expected behavior from users (automatically turning raw urls into links to those same urls). This behavior is practically required at this point for an online text editor.

Chrome:

Screen Shot 2022-09-13 at 10 08 10 AM

Safari:

Screen Shot 2022-09-13 at 10 08 37 AM
Editor version.

4.0.14

OS.

Mac 12.5.1

Browser.

Chrome 105.0.5195.102 Safari 15.6.1

Recording.

The steps above and screenshots should adequately describe the problem and how to reproduce it.

essmahr commented 2 years ago

We are also running into this. Much like @em77, dropping the link plugin is a no-go for us.

essmahr commented 2 years ago

I've confirmed that this bug was introduced with v4.0.13, I can't reproduce with v4.0.12: https://codesandbox.io/s/froala-core-sandbox-forked-qxtnc0?file=/index.html

em77 commented 2 years ago

@essmahr Thanks for figuring that out. I requested the code for the past few versions from froala support and that helped me narrow down the problem which is a single typo on one line which I've opened a PR to fix in #4519. Not sure how long it'll take for this to get into a new release. If you're aware of an active admin on this repo, feel free to do a mention of them on the PR.

essmahr commented 2 years ago

@em77 Thanks for digging!

I've poked through the source code and plainpaste is not a typo or referring to the Froala option here, it is a custom attribute added to the editor container (l.$el[0] in the minified src). That attribute is added in the main froala package as part of the pasting process (this is new, it was not happening in v4.0.12).

It's interesting that this resolves the issue (I haven't tested yet). But I think what's actually happening in https://github.com/froala/wysiwyg-editor/pull/4519 is that some code that's supposed to run does not run, ever, because an if is always false. So, I think this still needs some attention from the Froala team.

em77 commented 2 years ago

@essmahr You are right, it doesn't seem to be referring to the option pastePlain. I've closed the PR and I'm not sure how much more I'll be able to personally dig into this issue. Hopefully it gets some attention from the froala devs.

em77 commented 2 years ago

BTW if you write into froala support they will send you the unminified source code for any versions you want to look at.

em77 commented 1 year ago

This issue is fixed in the latest release.