';
- // Main section, default and additional shortcuts
+ // Main section, default and additional shortcuts.
html = html +
'
';
if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) {
- // Text pattern section
+ // Text pattern section.
html = html +
'
';
}
- // Focus management section
+ // Focus management section.
html = html +
'
' +
@@ -413,7 +413,7 @@
}
});
- // Register buttons
+ // Register buttons.
editor.addButton( 'wp_more', {
tooltip: 'Insert Read More tag',
onclick: function() {
@@ -439,7 +439,7 @@
stateSelector: 'code'
});
- // Insert->Add Media
+ // Insert->Add Media.
if ( wp && wp.media && wp.media.editor ) {
editor.addButton( 'wp_add_media', {
tooltip: 'Add Media',
@@ -455,7 +455,7 @@
});
}
- // Insert "Read More..."
+ // Insert "Read More...".
editor.addMenuItem( 'wp_more', {
text: 'Insert Read More tag',
icon: 'wp_more',
@@ -465,7 +465,7 @@
}
});
- // Insert "Next Page"
+ // Insert "Next Page".
editor.addMenuItem( 'wp_page', {
text: 'Page break',
icon: 'wp_page',
@@ -496,7 +496,7 @@
editor.on( 'init', function() {
var env = tinymce.Env,
- bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
+ bodyClass = ['mceContentBody'], // Back-compat for themes that use this in editor-style.css...
doc = editor.getDoc(),
dom = editor.dom;
@@ -531,7 +531,7 @@
}
});
- // Remove invalid parent paragraphs when inserting HTML
+ // Remove invalid parent paragraphs when inserting HTML.
editor.on( 'BeforeSetContent', function( event ) {
if ( event.content ) {
event.content = event.content.replace( /\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' )
@@ -554,21 +554,21 @@
if ( editor.getParam( 'wp_paste_filters', true ) ) {
editor.on( 'PastePreProcess', function( event ) {
- // Remove trailing
added by WebKit browsers to the clipboard
+ // Remove trailing
added by WebKit browsers to the clipboard.
event.content = event.content.replace( /
/gi, '' );
- // In WebKit this is handled by removeWebKitStyles()
+ // In WebKit this is handled by removeWebKitStyles().
if ( ! tinymce.Env.webkit ) {
- // Remove all inline styles
+ // Remove all inline styles.
event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' );
- // Put back the internal styles
+ // Put back the internal styles.
event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' );
}
});
editor.on( 'PastePostProcess', function( event ) {
- // Remove empty paragraphs
+ // Remove empty paragraphs.
editor.$( 'p', event.node ).each( function( i, node ) {
if ( dom.isEmpty( node ) ) {
dom.remove( node );
@@ -585,7 +585,7 @@
});
editor.on( 'SaveContent', function( event ) {
- // If editor is hidden, we just want the textarea's value to be saved
+ // If editor is hidden, we just want the textarea's value to be saved.
if ( ! editor.inline && editor.isHidden() ) {
event.content = event.element.value;
return;
@@ -638,12 +638,12 @@
}
} );
- // Alt+Shift+Z removes a block in the Block Editor, don't add it to the Classic Block.
+ // Alt+Shift+Z removes a block in the block editor, don't add it to the Classic block.
if ( ! editor.settings.classic_block_editor ) {
editor.addShortcut( 'access+z', '', 'WP_Adv' );
}
- // Workaround for not triggering the global help modal in the Block Editor by the Classic Block shortcut.
+ // Workaround for not triggering the global help modal in the block editor by the Classic block shortcut.
editor.on( 'keydown', function( event ) {
var match;
@@ -700,7 +700,7 @@
wpTooltips = {};
- // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325
+ // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325.
if ( tinymce.Env.mac ) {
access = '\u2303\u2325';
meta = '\u2318';
@@ -761,7 +761,7 @@
}
function addShortcutsToListbox() {
- // listbox for the "blocks" drop-down
+ // listbox for the "blocks" drop-down.
each( editor.theme.panel.find( 'listbox' ), function( listbox ) {
if ( listbox && listbox.settings.text === 'Paragraph' ) {
each( listbox.settings.values, function( item ) {
@@ -789,7 +789,7 @@
mceToolbar,
mceStatusbar,
wpStatusbar,
- isChromeRtl = ( editor.rtl && /Chrome/.test( navigator.userAgent ) );
+ cachedWinSize;
if ( container ) {
mceToolbar = tinymce.$( '.mce-toolbar-grp', container )[0];
@@ -1040,16 +1040,6 @@
toolbar.on( 'show', function() {
this.reposition();
-
- if ( isChromeRtl ) {
- tinymce.$( '.mce-widget.mce-tooltip' ).addClass( 'wp-hide-mce-tooltip' );
- }
- } );
-
- toolbar.on( 'hide', function() {
- if ( isChromeRtl ) {
- tinymce.$( '.mce-widget.mce-tooltip' ).removeClass( 'wp-hide-mce-tooltip' );
- }
} );
toolbar.on( 'keydown', function( event ) {
@@ -1115,6 +1105,9 @@
} );
function hide( event ) {
+ var win;
+ var size;
+
if ( activeToolbar ) {
if ( activeToolbar.tempHide || event.type === 'hide' || event.type === 'blur' ) {
activeToolbar.hide();
@@ -1125,6 +1118,36 @@
event.type === 'resize' ||
event.type === 'scroll'
) && ! activeToolbar.blockHide ) {
+ /*
+ * Showing a tooltip may trigger a `resize` event in Chromium browsers.
+ * That results in a flicketing inline menu; tooltips are shown on hovering over a button,
+ * which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again.
+ */
+ if ( event.type === 'resize' || event.type === 'resizewindow' ) {
+ win = editor.getWin();
+ size = win.innerHeight + win.innerWidth;
+
+ // Reset old cached size.
+ if ( cachedWinSize && ( new Date() ).getTime() - cachedWinSize.timestamp > 2000 ) {
+ cachedWinSize = null;
+ }
+
+ if ( cachedWinSize ) {
+ if ( size && Math.abs( size - cachedWinSize.size ) < 2 ) {
+ // `resize` fired but the window hasn't been resized. Bail.
+ return;
+ }
+ } else {
+ // First of a new series of `resize` events. Store the cached size and bail.
+ cachedWinSize = {
+ timestamp: ( new Date() ).getTime(),
+ size: size,
+ };
+
+ return;
+ }
+ }
+
clearTimeout( timeout );
timeout = setTimeout( function() {
@@ -1140,15 +1163,15 @@
}
}
- editor.dom.bind( editor.getWin(), 'resize', hide );
+ if ( editor.inline ) {
+ editor.on( 'resizewindow', hide );
- if ( editor.inline ) {
// Enable `capture` for the event.
// This will hide/reposition the toolbar on any scrolling in the document.
document.addEventListener( 'scroll', hide, true );
} else {
- editor.dom.bind( editor.getWin(), 'scroll', hide );
- // For full height iframe editor.
+ // Bind to the editor iframe and to the parent window.
+ editor.dom.bind( editor.getWin(), 'resize scroll', hide );
editor.on( 'resizewindow scrollwindow', hide );
}
@@ -1166,7 +1189,7 @@
function noop() {}
- // Expose some functions (back-compat)
+ // Expose some functions (back-compat).
return {
_showButtons: noop,
_hideButtons: noop,