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

Replace injected html with sandboxing iframe #1392

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

notnownikki
Copy link
Member

@notnownikki notnownikki requested a review from aduth June 23, 2017 13:14
@jasmussen
Copy link
Contributor

Meta note. That was a damn good "tall tweet".

This works pretty amazingly well. Tweets, tumblr worked superbly.

Not necessary but "would be nice" — can we inject the following style into the iframe?

body {
margin: 0;
}

The first time I embedded the cloudup image, it didn't work. The second time it worked fine.

The video wasn't responsive like they are in master currently, but if we can inject a little CSS into this I can fix it in a separate PR. Unlike the embed previously, this one responds to my width/height changes in the inspector! 🎉

To summarize:

  • can we inject a little CSS into the iframe? If yes, then I volunteer to write the CSS necessary, in a separate PR.
  • The cloudup thing, was that a bug on my end or a race condition?

Overall stellar work 💓

@notnownikki
Copy link
Member Author

Sounds like there's still a race condition on cloudup there... (well, on all photo embeds, but I now know how to fix this properly, seems like we have to go to a three stage render like Calypso after all...)

Yeah, we can inject CSS, JavaScript, anything we like into the iframe!

Should we work on the race condition and CSS in separate PRs? I'm quite keen to get this merged, as I really dislike the current "inject it all into the main editor context" solution we have now, and I'm not sure how long the work to properly fix the race condition will take.

@jasmussen
Copy link
Contributor

Should we work on the race condition and CSS in separate PRs? I'm quite keen to get this merged, as I really dislike the current "inject it all into the main editor context" solution we have now, and I'm not sure how long the work to properly fix the race condition will take.

That's fine with me, especially if we can open tickets so we don't forget.

aduth is on vacation, so if you need a code review I'd recommend @youknowriad or @iseulde

@notnownikki
Copy link
Member Author

Reviews requested from @youknowriad and @iseulde :)

// Make sure that we don't miss very quick loading documents here that the observer
// doesn't see load, but haven't completely loaded when we call sendResize for the
// first time.
setTimeout( sendResize, 1000 );
Copy link
Member Author

Choose a reason for hiding this comment

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

This works... most of the time. There's still something going on though that stops some embeds sending a resize when they load.

I'm going to tackle that specific problem in another PR. I have a good idea of how to solve it from looking at the embed code in Calypso, but I don't want to delay this and have this branch fall out of sync too much, as I'm not sure how long it will take to fully solve this.

@@ -0,0 +1,173 @@
/**
* Imported from Calypso, with some lint fixes and gutenburg specific changes.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should keep this comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷‍♀️ I mean, it's a direct copy, but with some react changes for how it handles the references, and lint fixes.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I couldn't test all the embeds, but code looks good

@notnownikki notnownikki merged commit a65909d into master Jun 28, 2017
@mtias mtias deleted the update/sandboxing-resizing-iframes branch June 29, 2017 16:59
@@ -158,6 +161,7 @@ function getEmbedBlockSettings( { title, icon, category = 'embed' } ) {

const parsedUrl = parse( url );
const cannotPreview = includes( HOSTS_NO_PREVIEWS, parsedUrl.host.replace( /^www\./, '' ) );
const iframeTitle = 'Embedded content from ' + parsedUrl.host;
Copy link
Member

Choose a reason for hiding this comment

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

Should this have been localized?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, see #1635

export { default as ResponsiveWrapper } from './responsive-wrapper';
export { default as SandBox } from './sandbox';
Copy link
Member

Choose a reason for hiding this comment

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

"Sandbox" is a single word, shouldn't need the PascalCase-ing here.

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.

4 participants