TinyMCE: wpView improvements: remove the (obsolete) get/setViewText methods. Update stopping/pausing of multiple ME media players. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31548 git-svn-id: http://core.svn.wordpress.org/trunk@31529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c30c705ec3
commit
5f27c59f49
|
@ -651,7 +651,7 @@ window.wp = window.wp || {};
|
|||
var media = wp.media[ this.type ],
|
||||
frame = media.edit( text );
|
||||
|
||||
this.stopPlayers && this.stopPlayers();
|
||||
this.pausePlayers && this.pausePlayers();
|
||||
|
||||
_.each( this.state, function( state ) {
|
||||
frame.state( state ).on( 'update', function( selection ) {
|
||||
|
@ -728,7 +728,7 @@ window.wp = window.wp || {};
|
|||
self.render();
|
||||
} )
|
||||
.fail( function( response ) {
|
||||
if ( self.type === 'embedURL' ) {
|
||||
if ( self.url ) {
|
||||
self.removeMarkers();
|
||||
} else {
|
||||
self.setError( response.message || response.statusText, 'admin-media' );
|
||||
|
@ -737,19 +737,19 @@ window.wp = window.wp || {};
|
|||
|
||||
this.getEditors( function( editor ) {
|
||||
editor.on( 'wpview-selected', function() {
|
||||
self.stopPlayers();
|
||||
self.pausePlayers();
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
stopPlayers: function( remove ) {
|
||||
pausePlayers: function() {
|
||||
this.getNodes( function( editor, node, content ) {
|
||||
var win = $( 'iframe.wpview-sandbox', content ).get( 0 );
|
||||
|
||||
if ( win && ( win = win.contentWindow ) && win.mejs ) {
|
||||
_.each( win.mejs.players, function( player ) {
|
||||
try {
|
||||
player[ remove ? 'remove' : 'pause' ]();
|
||||
player.pause();
|
||||
} catch ( e ) {}
|
||||
} );
|
||||
}
|
||||
|
@ -762,10 +762,10 @@ window.wp = window.wp || {};
|
|||
|
||||
edit: function( text, update ) {
|
||||
var media = wp.media.embed,
|
||||
isURL = 'embedURL' === this.type,
|
||||
frame = media.edit( text, isURL );
|
||||
frame = media.edit( text, !! this.url ),
|
||||
self = this;
|
||||
|
||||
this.stopPlayers();
|
||||
this.pausePlayers();
|
||||
|
||||
frame.state( 'embed' ).props.on( 'change:url', function( model, url ) {
|
||||
if ( url ) {
|
||||
|
@ -774,7 +774,7 @@ window.wp = window.wp || {};
|
|||
} );
|
||||
|
||||
frame.state( 'embed' ).on( 'select', function() {
|
||||
if ( isURL ) {
|
||||
if ( self.url ) {
|
||||
update( frame.state( 'embed' ).metadata.url );
|
||||
} else {
|
||||
update( media.shortcode( frame.state( 'embed' ).metadata ).string() );
|
||||
|
@ -808,7 +808,7 @@ window.wp = window.wp || {};
|
|||
views.register( 'embedURL', _.extend( {}, embed, {
|
||||
match: function( content ) {
|
||||
var re = /(^|<p>)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi,
|
||||
match = re.exec( tinymce.trim( content ) );
|
||||
match = re.exec( content );
|
||||
|
||||
if ( match ) {
|
||||
return {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -34,37 +34,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text/shortcode string for a view.
|
||||
*
|
||||
* @param view The view wrapper's node
|
||||
* @returns string The text/shoercode string of the view
|
||||
*/
|
||||
function getViewText( view ) {
|
||||
if ( view = getView( view ) ) {
|
||||
return window.decodeURIComponent( editor.dom.getAttrib( view, 'data-wpview-text' ) || '' );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view's original text/shortcode string
|
||||
*
|
||||
* @param view The view wrapper's HTML id or node
|
||||
* @param text The text string to be set
|
||||
*/
|
||||
function setViewText( view, text ) {
|
||||
view = getView( view );
|
||||
|
||||
if ( view ) {
|
||||
editor.dom.setAttrib( view, 'data-wpview-text', window.encodeURIComponent( text || '' ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _stop( event ) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
@ -138,7 +107,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
clipboard = dom.create( 'div', {
|
||||
'class': 'wpview-clipboard',
|
||||
'contenteditable': 'true'
|
||||
}, getViewText( viewNode ) );
|
||||
}, decodeURIComponent( editor.dom.getAttrib( viewNode, 'data-wpview-text' ) ) );
|
||||
|
||||
editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard );
|
||||
|
||||
|
@ -197,8 +166,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
// Check if the `wp.mce` API exists.
|
||||
if ( typeof wp === 'undefined' || ! wp.mce ) {
|
||||
return {
|
||||
getViewText: _noop,
|
||||
setViewText: _noop,
|
||||
getView: _noop
|
||||
};
|
||||
}
|
||||
|
@ -721,8 +688,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
});
|
||||
|
||||
return {
|
||||
getViewText: getViewText,
|
||||
setViewText: setViewText,
|
||||
getView: getView
|
||||
};
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31547';
|
||||
$wp_version = '4.2-alpha-31548';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue