Fixes #885 | Fix editor.on paste function and enhance REGEX_URL #886
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prelude
The issue was introduce by the following commit:
"Adds a way to correct paste behavior of an URL"
32040b8
Issue
Pasting text from the clipboard which contains url(s) the first url is automatically moving to the beginning of the paragraph replacing with an anchor link. The other urls stay untached.
The issue is only reproducable when copying text from the clipboard
which has url(s)
and not contains new lines
and the text is not copied from the editor itself.
When typeing text in the editor the url(s) are replacing with anchor links correctly.
Solution
The original solution was wrong: only replaced the first url in the text and placed the anchor link to the beginning of the text.
I changed the REGEX_URL to find all the url occurrence in the text and i rewrited the paste function to replace all the urls in place with the anchor links. I also added the functionality to replace the valid emails with anchor links too.
https://issues.liferay.com/browse/LPS-85659