TinyMCE: improve adding of custom UI to the MCE Factory.

Props iseulde.
Fixes #40690.

git-svn-id: https://develop.svn.wordpress.org/trunk@40587 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2017-05-09 01:39:49 +00:00
parent 6e868eed6e
commit 3d2137f1b4
2 changed files with 5 additions and 19 deletions

View File

@ -682,7 +682,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
mceIframe = document.getElementById( editor.id + '_ifr' ),
mceToolbar,
mceStatusbar,
namesAdded,
wpStatusbar;
if ( container ) {
@ -700,7 +699,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
buttonGroup;
each( buttons, function( item ) {
var itemName, ui, name;
var itemName;
function bindSelectorChanged() {
var selection = editor.selection;
@ -768,19 +767,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
buttonGroup = null;
} else {
// Add the new WP* types to the factory
if ( ! namesAdded ) {
ui = tinymce.ui;
for ( name in ui ) {
if ( name.toLowerCase().indexOf( 'wp' ) === 0 ) {
Factory.add( name, ui[name] );
}
}
namesAdded = true;
}
if ( ! buttonGroup ) {
buttonGroup = {
type: 'buttongroup',

View File

@ -1,5 +1,5 @@
( function( tinymce ) {
tinymce.ui.WPLinkPreview = tinymce.ui.Control.extend( {
tinymce.ui.Factory.add( 'WPLinkPreview', tinymce.ui.Control.extend( {
url: '#',
renderHtml: function() {
return (
@ -50,9 +50,9 @@
tinymce.$( this.getEl().firstChild ).attr( 'href', this.url ).text( url );
}
}
} );
} ) );
tinymce.ui.WPLinkInput = tinymce.ui.Control.extend( {
tinymce.ui.Factory.add( 'WPLinkInput', tinymce.ui.Control.extend( {
renderHtml: function() {
return (
'<div id="' + this._id + '" class="wp-link-input">' +
@ -82,7 +82,7 @@
urlInput.value = '';
urlInput.nextSibling.value = '';
}
} );
} ) );
tinymce.PluginManager.add( 'wplink', function( editor ) {
var toolbar;