Skip to content
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

Defer removal of iFrames on paste until transform stage, and only rem… #19998

Closed
wants to merge 5 commits into from

Conversation

glendaviesnz
Copy link
Contributor

@glendaviesnz glendaviesnz commented Feb 2, 2020

A potential fix for #18389. Defers the removal of iFrames on paste until transform stage, and only removes if no custom transform

Description

Moves the deletion of iframes in in the paste handler to the htmlToBlocks method. This allows for users without unfilteredHTML permissions to still paste iframe code that is going to be transformed to blocks anyway.

How has this been tested?

Tested manually by pasting known and unknown iframe code into a paragraph block, and also added unit tests for the htmlToBlocks method.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.

@glendaviesnz glendaviesnz requested a review from pento February 2, 2020 21:51
…es get wrapped in a figure node by this point
@glendaviesnz glendaviesnz changed the title [WIP]: Defer removal of iFrames on paste until transform stage, and only rem… Defer removal of iFrames on paste until transform stage, and only rem… Feb 4, 2020
@glendaviesnz glendaviesnz marked this pull request as ready for review February 4, 2020 01:28
! canUserUseUnfilteredHTML &&
checkForUntransformedIframe( rawTransform, node )
) {
return undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to add an explicit undefined here to keep linting happy!

@glendaviesnz glendaviesnz self-assigned this Feb 4, 2020
@scruffian
Copy link
Contributor

I tested this on the Google Calendar block in Jetpack and it works!

@glendaviesnz
Copy link
Contributor Author

glendaviesnz commented Feb 14, 2020

@ellatrix, @youknowriad - we have two potential solutions to #18389 - this PR and @pento's one at #19086 - do either of you have any views on which one might be preferred for moving forward with, or should we be looking at just allowing iframes to be pasted and stripped later as mentioned at #19086 (comment) (I tend to agree with @pento's response to this that it gives a better experience for non admins to strip them on paste rather than having them mysteriously disappear on publish).

@ellatrix
Copy link
Member

Hi! I've replied on #18389 since this PR is older: #19086 (comment).

@ellatrix ellatrix mentioned this pull request Mar 18, 2020
6 tasks
@ellatrix
Copy link
Member

ellatrix commented Mar 19, 2020

Hi! I merged #20983. You should now be able to create a custom embed transform matching the URL. Let me know if there's any difficulties.

@ellatrix ellatrix closed this Mar 19, 2020
@ellatrix ellatrix deleted the try/defer-iframe-removal-on-paste branch March 19, 2020 09:11
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.

3 participants