Cleanup after [29179]:

* `_WP_Editors::editor_settings()` no longer needs to load MEjs styles
* Make sure each identical shortcode with multiple instances also has an iframe sandbox for each instance
* For the time being, make audio and video shortcodes bypass the loading placeholder to avoid whiplash visually

Props avryl, wonderboymusic.
See #28905.


git-svn-id: https://develop.svn.wordpress.org/trunk@29187 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-07-16 15:39:05 +00:00
parent 09f5183276
commit 7e05c69ce2
2 changed files with 103 additions and 77 deletions

View File

@ -503,14 +503,10 @@ final class _WP_Editors {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$version = 'ver=' . $GLOBALS['wp_version'];
$dashicons = includes_url( "css/dashicons$suffix.css?$version" );
$mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" );
$wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );
// WordPress default stylesheet and dashicons
$mce_css = array(
$dashicons,
$mediaelement,
$wpmediaelement,
self::$baseurl . '/skins/wordpress/wp-content.css?' . $version
);

View File

@ -69,13 +69,29 @@ window.wp = window.wp || {};
);
},
unbind: function() {},
setContent: function( html, callback, option ) {
getNodes: function( callback ) {
var nodes = [];
_.each( tinymce.editors, function( editor ) {
var self = this;
if ( editor.plugins.wpview ) {
$( editor.getBody() )
.find( '[data-wpview-text="' + this.encodedText + '"]' )
.each( function ( i, element ) {
.each( function ( i, node ) {
if ( callback ) {
callback( editor, node );
}
nodes.push( node );
} );
}
}, this );
return nodes;
},
setContent: function( html, callback, option ) {
var self = this;
this.getNodes( function ( editor, element ) {
var contentWrap = $( element ).find( '.wpview-content' ),
wrap = element;
@ -101,18 +117,22 @@ window.wp = window.wp || {};
callback( self, editor, $( element ).find( '.wpview-content' )[0] );
}
} );
}
}, this );
},
/* jshint scripturl: true */
createIframe: function ( content ) {
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
iframe, iframeDoc, i, resize,
dom = tinymce.DOM;
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
if ( content.indexOf( '<script' ) !== -1 ) {
iframe = dom.create( 'iframe', {
this.getNodes( function ( editor, node ) {
var dom = editor.dom,
iframe, iframeDoc, i, resize;
node = $( node ).find( '.wpview-content' )[0];
node.innerHTML = '';
iframe = dom.add( node, 'iframe', {
src: tinymce.Env.ie ? 'javascript:""' : '',
frameBorder: '0',
allowTransparency: 'true',
@ -123,7 +143,6 @@ window.wp = window.wp || {};
}
} );
this.setContent( iframe );
iframeDoc = iframe.contentWindow.document;
iframeDoc.open();
@ -133,7 +152,7 @@ window.wp = window.wp || {};
'<head>' +
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' +
'</head>' +
'<body style="padding: 0; margin: 0;" class="' + dom.doc.body.className + '">' +
'<body style="padding: 0; margin: 0;" class="' + /* editor.getBody().className + */ '">' +
content +
'</body>' +
'</html>'
@ -158,6 +177,7 @@ window.wp = window.wp || {};
setTimeout( resize, i * 700 );
}
}
});
} else {
this.setContent( content );
}
@ -478,8 +498,6 @@ window.wp = window.wp || {};
* @mixin
*/
wp.mce.av = {
loaded: false,
View: {
overlay: true,
@ -537,7 +555,7 @@ window.wp = window.wp || {};
},
/**
* Pass data to the View's Underscore template and return the compiled output
* Return parsed response
*
* @returns {string}
*/
@ -639,6 +657,18 @@ window.wp = window.wp || {};
_.bindAll( this, 'createIframe', 'setNode', 'fetch' );
$( this ).on( 'ready', this.setNode );
},
/**
* Return parsed response
*
* @returns {string}
*/
getHtml: function() {
if ( ! this.parsed ) {
return '';
}
return this.parsed;
}
} ),
edit: function( node ) {