mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
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 ],
|
var media = wp.media[ this.type ],
|
||||||
frame = media.edit( text );
|
frame = media.edit( text );
|
||||||
|
|
||||||
this.stopPlayers && this.stopPlayers();
|
this.pausePlayers && this.pausePlayers();
|
||||||
|
|
||||||
_.each( this.state, function( state ) {
|
_.each( this.state, function( state ) {
|
||||||
frame.state( state ).on( 'update', function( selection ) {
|
frame.state( state ).on( 'update', function( selection ) {
|
||||||
@ -728,7 +728,7 @@ window.wp = window.wp || {};
|
|||||||
self.render();
|
self.render();
|
||||||
} )
|
} )
|
||||||
.fail( function( response ) {
|
.fail( function( response ) {
|
||||||
if ( self.type === 'embedURL' ) {
|
if ( self.url ) {
|
||||||
self.removeMarkers();
|
self.removeMarkers();
|
||||||
} else {
|
} else {
|
||||||
self.setError( response.message || response.statusText, 'admin-media' );
|
self.setError( response.message || response.statusText, 'admin-media' );
|
||||||
@ -737,19 +737,19 @@ window.wp = window.wp || {};
|
|||||||
|
|
||||||
this.getEditors( function( editor ) {
|
this.getEditors( function( editor ) {
|
||||||
editor.on( 'wpview-selected', function() {
|
editor.on( 'wpview-selected', function() {
|
||||||
self.stopPlayers();
|
self.pausePlayers();
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
stopPlayers: function( remove ) {
|
pausePlayers: function() {
|
||||||
this.getNodes( function( editor, node, content ) {
|
this.getNodes( function( editor, node, content ) {
|
||||||
var win = $( 'iframe.wpview-sandbox', content ).get( 0 );
|
var win = $( 'iframe.wpview-sandbox', content ).get( 0 );
|
||||||
|
|
||||||
if ( win && ( win = win.contentWindow ) && win.mejs ) {
|
if ( win && ( win = win.contentWindow ) && win.mejs ) {
|
||||||
_.each( win.mejs.players, function( player ) {
|
_.each( win.mejs.players, function( player ) {
|
||||||
try {
|
try {
|
||||||
player[ remove ? 'remove' : 'pause' ]();
|
player.pause();
|
||||||
} catch ( e ) {}
|
} catch ( e ) {}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -762,10 +762,10 @@ window.wp = window.wp || {};
|
|||||||
|
|
||||||
edit: function( text, update ) {
|
edit: function( text, update ) {
|
||||||
var media = wp.media.embed,
|
var media = wp.media.embed,
|
||||||
isURL = 'embedURL' === this.type,
|
frame = media.edit( text, !! this.url ),
|
||||||
frame = media.edit( text, isURL );
|
self = this;
|
||||||
|
|
||||||
this.stopPlayers();
|
this.pausePlayers();
|
||||||
|
|
||||||
frame.state( 'embed' ).props.on( 'change:url', function( model, url ) {
|
frame.state( 'embed' ).props.on( 'change:url', function( model, url ) {
|
||||||
if ( url ) {
|
if ( url ) {
|
||||||
@ -774,7 +774,7 @@ window.wp = window.wp || {};
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
frame.state( 'embed' ).on( 'select', function() {
|
frame.state( 'embed' ).on( 'select', function() {
|
||||||
if ( isURL ) {
|
if ( self.url ) {
|
||||||
update( frame.state( 'embed' ).metadata.url );
|
update( frame.state( 'embed' ).metadata.url );
|
||||||
} else {
|
} else {
|
||||||
update( media.shortcode( frame.state( 'embed' ).metadata ).string() );
|
update( media.shortcode( frame.state( 'embed' ).metadata ).string() );
|
||||||
@ -808,7 +808,7 @@ window.wp = window.wp || {};
|
|||||||
views.register( 'embedURL', _.extend( {}, embed, {
|
views.register( 'embedURL', _.extend( {}, embed, {
|
||||||
match: function( content ) {
|
match: function( content ) {
|
||||||
var re = /(^|<p>)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi,
|
var re = /(^|<p>)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi,
|
||||||
match = re.exec( tinymce.trim( content ) );
|
match = re.exec( content );
|
||||||
|
|
||||||
if ( match ) {
|
if ( match ) {
|
||||||
return {
|
return {
|
||||||
|
2
wp-includes/js/mce-view.min.js
vendored
2
wp-includes/js/mce-view.min.js
vendored
File diff suppressed because one or more lines are too long
@ -34,37 +34,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
return false;
|
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 ) {
|
function _stop( event ) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
@ -138,7 +107,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
clipboard = dom.create( 'div', {
|
clipboard = dom.create( 'div', {
|
||||||
'class': 'wpview-clipboard',
|
'class': 'wpview-clipboard',
|
||||||
'contenteditable': 'true'
|
'contenteditable': 'true'
|
||||||
}, getViewText( viewNode ) );
|
}, decodeURIComponent( editor.dom.getAttrib( viewNode, 'data-wpview-text' ) ) );
|
||||||
|
|
||||||
editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard );
|
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.
|
// Check if the `wp.mce` API exists.
|
||||||
if ( typeof wp === 'undefined' || ! wp.mce ) {
|
if ( typeof wp === 'undefined' || ! wp.mce ) {
|
||||||
return {
|
return {
|
||||||
getViewText: _noop,
|
|
||||||
setViewText: _noop,
|
|
||||||
getView: _noop
|
getView: _noop
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -721,8 +688,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getViewText: getViewText,
|
|
||||||
setViewText: setViewText,
|
|
||||||
getView: getView
|
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
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user