-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add URL handling to raw handler #3326
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3326 +/- ##
==========================================
- Coverage 34.65% 34.61% -0.04%
==========================================
Files 260 260
Lines 6741 6757 +16
Branches 1220 1226 +6
==========================================
+ Hits 2336 2339 +3
- Misses 3719 3728 +9
- Partials 686 690 +4
Continue to review full report at Codecov.
|
This seems normal to me. I agree we shouldn't try to have extra rules in Paragraph to ignore URLs. As with any parsable system, expressions will match multiple constructs and precedence rules will be needed. Take basic algebra and precedence rules for |
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.
As for the PR, LGTM! Soon we should work on documentation for the whole paste / patterns / transforms stack.
abd8156
to
a58d720
Compare
Is this in 1.9.1? I have a blocks that has:
And YouTube iframe embed code gets deleted upon "Convert to blocks". |
@vedranmiletic, do you mean classic (pre-Gutenberg) content? If so, I've logged issue #4125. |
Description
This PR changes several things regarding the pasting of URLs.
Instead of using TinyMCE's link-over-word paste, add it to Gutenberg, and add the behaviour of core which ignores whitespace and empty/wrapping HTML tags.
https://github.com/WordPress/WordPress/blob/06fa4161aa74619239cf27017d124081c825684a/wp-includes/js/tinymce/plugins/wplink/plugin.js#L320-L336
Remove the 'paste' transformation type from the patterns plugin, and instead use the raw handler. This will allow URLs to be embedded from paste and raw handling in general, not just pasting a URL on an empty line. The paste transform was kind of an odd hack in the patterns plugin.
One thing that is a bit awkward is that the order of registration matters. This is similar to the
<pre>
and<pre><code>
tags. I'm not sure what the best solution is other than ensuring the right order (also register plugins first), or adding a condition to the paragraph block to ignore ones with a URL (bad imo).How Has This Been Tested?
Checklist: