-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #816 from WordPress/update/embed-block
Enhance the embed block to support all WP_oEmbed embeds
- Loading branch information
Showing
10 changed files
with
161 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ | |
} | ||
}, | ||
"globals": { | ||
"wp": true | ||
"wp": true, | ||
"wpApiSettings": true | ||
}, | ||
"plugins": [ | ||
"react", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<!-- wp:core/embed url="https://www.youtube.com/watch?v=Nl6U7UotA-M" --> | ||
<figure><iframe src="//www.youtube.com/embed/Nl6U7UotA-M" frameborder="0" allowfullscreen></iframe><figcaption>State of the Word 2016</figcaption></figure> | ||
<!-- /wp:core/embed --> | ||
<figure>https://www.youtube.com/embed/Nl6U7UotA-M"<figcaption>State of the Word 2016</figcaption></figure> | ||
<!-- /wp:core/embed --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
blocks/test/fixtures/core-embed-youtube-caption.serialized.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// When embedding HTML from the WP oEmbed proxy, we need to insert it | ||
// into a div and make sure any scripts get run. This component takes | ||
// HTML and puts it into a div element, and creates and adds new script | ||
// elements so all scripts get run as expected. | ||
|
||
export default class HtmlEmbed extends wp.element.Component { | ||
|
||
componentDidMount() { | ||
const body = this.node; | ||
const { html = '' } = this.props; | ||
|
||
body.innerHTML = html; | ||
|
||
const scripts = body.getElementsByTagName( 'script' ); | ||
const newScripts = Array.from( scripts ).map( ( script ) => { | ||
const newScript = document.createElement( 'script' ); | ||
if ( script.src ) { | ||
newScript.src = script.src; | ||
} else { | ||
newScript.innerHTML = script.innerHTML; | ||
} | ||
return newScript; | ||
} ); | ||
|
||
newScripts.forEach( ( script ) => body.appendChild( script ) ); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div ref={ ( node ) => this.node = node } /> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters