--- a/wp/wp-includes/js/tinymce/plugins/wordpress/plugin.js Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/js/tinymce/plugins/wordpress/plugin.js Tue Dec 15 13:49:49 2020 +0100
@@ -1,6 +1,6 @@
/* global getUserSetting, setUserSetting */
( function( tinymce ) {
-// Set the minimum value for the modals z-index higher than #wpadminbar (100000)
+// Set the minimum value for the modals z-index higher than #wpadminbar (100000).
if ( ! tinymce.ui.FloatPanel.zIndex || tinymce.ui.FloatPanel.zIndex < 100100 ) {
tinymce.ui.FloatPanel.zIndex = 100100;
}
@@ -88,7 +88,7 @@
}
});
- // Hide the toolbars after loading
+ // Hide the toolbars after loading.
editor.on( 'PostRender', function() {
if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) {
toggleToolbars( 'hide' );
@@ -191,7 +191,7 @@
}
});
- // Display the tag name instead of img in element path
+ // Display the tag name instead of img in element path.
editor.on( 'ResolveName', function( event ) {
var attr;
@@ -200,7 +200,7 @@
}
});
- // Register commands
+ // Register commands.
editor.addCommand( 'WP_More', function( tag ) {
var parent, html, title,
classname = 'wp-more-tag',
@@ -215,13 +215,13 @@
html = '<img src="' + tinymce.Env.transparentSrc + '" alt="" title="' + title + '" class="' + classname + '" ' +
'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />';
- // Most common case
+ // Most common case.
if ( node === rootNode || ( node.nodeName === 'P' && node.parentNode === rootNode ) ) {
editor.insertContent( html );
return;
}
- // Get the top level parent node
+ // Get the top level parent node.
parent = dom.getParent( node, function( found ) {
if ( found.parentNode && found.parentNode === rootNode ) {
return true;
@@ -328,7 +328,7 @@
html = '<div class="wp-editor-help">';
- // Main section, default and additional shortcuts
+ // Main section, default and additional shortcuts.
html = html +
'<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' +
'<table class="wp-help-th-center fixed">' +
@@ -342,7 +342,7 @@
'</table>';
if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) {
- // Text pattern section
+ // Text pattern section.
html = html +
'<h2>' + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ) + '</h2>' +
'<table class="wp-help-th-center fixed">' +
@@ -363,7 +363,7 @@
'</table>';
}
- // Focus management section
+ // Focus management section.
html = html +
'<h2>' + __( 'Focus shortcuts:' ) + '</h2>' +
'<table class="wp-help-single">' +
@@ -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( /<p>\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 <br> added by WebKit browsers to the clipboard
+ // Remove trailing <br> added by WebKit browsers to the clipboard.
event.content = event.content.replace( /<br class="?Apple-interchange-newline"?>/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,