TinyMCE: 'wpdialogs' plugin, don't add the (external) UI dialogs element to the internal windows array, fix .close(). See #24067.
git-svn-id: https://develop.svn.wordpress.org/trunk@26900 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f6d42a08e9
commit
a18943fd1b
@ -8,22 +8,28 @@
|
|||||||
* For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins
|
* For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins
|
||||||
*/
|
*/
|
||||||
tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
||||||
|
if ( this.wp ) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wp = {};
|
||||||
this.parent = editor.windowManager;
|
this.parent = editor.windowManager;
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
|
|
||||||
tinymce.extend( this, this.parent );
|
tinymce.extend( this, this.parent );
|
||||||
|
|
||||||
this.open = function( args, params ) {
|
this.open = function( args, params ) {
|
||||||
var self = this, $element;
|
var $element,
|
||||||
|
self = this,
|
||||||
|
wp = this.wp;
|
||||||
|
|
||||||
if ( ! args.wpDialog ) {
|
if ( ! args.wpDialog ) {
|
||||||
return this.parent.open( args, params );
|
return this.parent.open.apply( this, arguments );
|
||||||
} else if ( ! args.id ) {
|
} else if ( ! args.id ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.element = $element = jQuery( '#' + args.id );
|
wp.$element = $element = jQuery( '#' + args.id );
|
||||||
|
|
||||||
if ( ! $element.length ) {
|
if ( ! $element.length ) {
|
||||||
return;
|
return;
|
||||||
@ -33,9 +39,8 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
|||||||
window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.');
|
window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.features = args;
|
wp.features = args;
|
||||||
self.params = params;
|
wp.params = params;
|
||||||
self.windows.push( $element );
|
|
||||||
|
|
||||||
// Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
|
// Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
|
||||||
editor.nodeChanged();
|
editor.nodeChanged();
|
||||||
@ -55,24 +60,20 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
|||||||
$element.wpdialog('open');
|
$element.wpdialog('open');
|
||||||
|
|
||||||
$element.on( 'wpdialogclose', function() {
|
$element.on( 'wpdialogclose', function() {
|
||||||
var i = self.windows.length;
|
if ( self.wp.$element ) {
|
||||||
|
self.wp = {};
|
||||||
while ( i-- && i > -1 ) {
|
|
||||||
if ( self.windows[i] === self.element ) {
|
|
||||||
self.windows.splice( i, 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function() {
|
||||||
if ( ! this.features.wpDialog ) {
|
if ( ! this.wp.features || ! this.wp.features.wpDialog ) {
|
||||||
return this.parent.close.apply( this, arguments );
|
return this.parent.close.apply( this, arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element.wpdialog('close');
|
this.wp.$element.wpdialog('close');
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
tinymce.PluginManager.add( 'wpdialogs', function( editor ) {
|
tinymce.PluginManager.add( 'wpdialogs', function( editor ) {
|
||||||
// Replace window manager
|
// Replace window manager
|
||||||
|
@ -57,7 +57,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
out = b.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
|
out = b.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
|
||||||
|
|
||||||
if ( out && out[1] ) {
|
if ( out && out[1] ) {
|
||||||
return '<p>' + out[1] + '</p>'
|
return '<p>' + out[1] + '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
Loading…
Reference in New Issue
Block a user