TinyMCE: initialize the floating toolbars on preinit so we can attach other events on init.
Props iseulde. Fixes #30619. git-svn-id: https://develop.svn.wordpress.org/trunk@31732 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
976e548ef7
commit
1c1e5f377f
|
@ -1,6 +1,6 @@
|
||||||
/* global tinymce */
|
/* global tinymce */
|
||||||
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||||
var floatingToolbar, serializer,
|
var toolbar, serializer,
|
||||||
each = tinymce.each,
|
each = tinymce.each,
|
||||||
iOS = tinymce.Env.iOS;
|
iOS = tinymce.Env.iOS;
|
||||||
|
|
||||||
|
@ -59,9 +59,20 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
editor.once( 'preinit', function() {
|
||||||
|
toolbar = editor.wp._createToolbar( [
|
||||||
|
'wp_img_alignleft',
|
||||||
|
'wp_img_aligncenter',
|
||||||
|
'wp_img_alignright',
|
||||||
|
'wp_img_alignnone',
|
||||||
|
'wp_img_edit',
|
||||||
|
'wp_img_remove'
|
||||||
|
] );
|
||||||
|
} );
|
||||||
|
|
||||||
editor.on( 'wptoolbar', function( event ) {
|
editor.on( 'wptoolbar', function( event ) {
|
||||||
if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) {
|
if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) {
|
||||||
event.toolbar = floatingToolbar;
|
event.toolbar = toolbar;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -77,7 +88,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||||
editor.nodeChanged();
|
editor.nodeChanged();
|
||||||
}, 200 );
|
}, 200 );
|
||||||
} else {
|
} else {
|
||||||
floatingToolbar.hide();
|
toolbar.hide();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -544,17 +555,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||||
|
|
||||||
dom.addClass( editor.getBody(), captionClass );
|
dom.addClass( editor.getBody(), captionClass );
|
||||||
|
|
||||||
if ( editor.wp._createToolbar ) {
|
|
||||||
floatingToolbar = editor.wp._createToolbar( [
|
|
||||||
'wp_img_alignleft',
|
|
||||||
'wp_img_aligncenter',
|
|
||||||
'wp_img_alignright',
|
|
||||||
'wp_img_alignnone',
|
|
||||||
'wp_img_edit',
|
|
||||||
'wp_img_remove'
|
|
||||||
] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add caption field to the default image dialog
|
// Add caption field to the default image dialog
|
||||||
editor.on( 'wpLoadImageForm', function( event ) {
|
editor.on( 'wpLoadImageForm', function( event ) {
|
||||||
if ( editor.getParam( 'wpeditimage_disable_captions' ) ) {
|
if ( editor.getParam( 'wpeditimage_disable_captions' ) ) {
|
||||||
|
@ -867,8 +867,8 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||||
editor.nodeChanged();
|
editor.nodeChanged();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if ( floatingToolbar ) {
|
if ( toolbar ) {
|
||||||
floatingToolbar.reposition();
|
toolbar.reposition();
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.fire( 'ExecCommand', {
|
editor.fire( 'ExecCommand', {
|
||||||
|
|
|
@ -240,11 +240,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||||
selection = editor.selection,
|
selection = editor.selection,
|
||||||
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||||
|
|
||||||
toolbar = editor.wp._createToolbar( [
|
|
||||||
'wp_view_edit',
|
|
||||||
'wp_view_remove'
|
|
||||||
] );
|
|
||||||
|
|
||||||
// When a view is selected, ensure content that is being pasted
|
// When a view is selected, ensure content that is being pasted
|
||||||
// or inserted is added to a text node (instead of the view).
|
// or inserted is added to a text node (instead of the view).
|
||||||
editor.on( 'BeforeSetContent', function() {
|
editor.on( 'BeforeSetContent', function() {
|
||||||
|
@ -673,6 +668,13 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
editor.once( 'preinit', function() {
|
||||||
|
toolbar = editor.wp._createToolbar( [
|
||||||
|
'wp_view_edit',
|
||||||
|
'wp_view_remove'
|
||||||
|
] );
|
||||||
|
} );
|
||||||
|
|
||||||
editor.on( 'wptoolbar', function( event ) {
|
editor.on( 'wptoolbar', function( event ) {
|
||||||
if ( selected ) {
|
if ( selected ) {
|
||||||
event.element = selected;
|
event.element = selected;
|
||||||
|
|
Loading…
Reference in New Issue