}
// Remove spaces from empty paragraphs.
- event.content = event.content.replace( /<p>(?: |\u00a0|\uFEFF|\s)+<\/p>/gi, '<p><br /></p>' );
+ // Avoid backtracking, can freeze the editor. See #35890.
+ // (This is also quite faster than using only one regex.)
+ event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) {
+ if ( /^( |\s|\u00a0|\ufeff)+$/i.test( text ) ) {
+ return '<p><br /></p>';
+ }
+
+ return tag;
+ });
}
});
// Main section, default and additional shortcuts
html = html +
'<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' +
- '<table class="wp-help-th-center">' +
+ '<table class="wp-help-th-center fixed">' +
header +
table1.join('') +
'</table>' +
'<h2>' + __( 'Additional shortcuts,' ) + ' ' + access + '</h2>' +
- '<table class="wp-help-th-center">' +
+ '<table class="wp-help-th-center fixed">' +
header +
table2.join('') +
'</table>';
- if ( editor.plugins.wptextpattern ) {
+ if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) {
// 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>' +
- tr({ '*': 'Bullet list' }) +
- tr({ '-': 'Bullet list' }) +
- tr({ '1.': 'Numbered list' }) +
- tr({ '1)': 'Numbered list' }) +
+ '<table class="wp-help-th-center fixed">' +
+ tr({ '*': 'Bullet list', '1.': 'Numbered list' }) +
+ tr({ '-': 'Bullet list', '1)': 'Numbered list' }) +
'</table>';
html = html +
'<h2>' + __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ) + '</h2>' +
- '<table>' +
+ '<table class="wp-help-single">' +
tr({ '>': 'Blockquote' }) +
tr({ '##': 'Heading 2' }) +
tr({ '###': 'Heading 3' }) +
tr({ '####': 'Heading 4' }) +
tr({ '#####': 'Heading 5' }) +
tr({ '######': 'Heading 6' }) +
+ tr({ '---': 'Horizontal line' }) +
'</table>';
}
// Focus management section
html = html +
'<h2>' + __( 'Focus shortcuts:' ) + '</h2>' +
- '<table>' +
+ '<table class="wp-help-single">' +
tr({ 'Alt + F8': 'Inline toolbar (when an image, link or preview is selected)' }) +
tr({ 'Alt + F9': 'Editor menu (when enabled)' }) +
tr({ 'Alt + F10': 'Editor toolbar' }) +
wp.autosave.server.triggerSave();
}
} );
+
+ if ( window.getUserSetting( 'editor_plain_text_paste_warning' ) > 1 ) {
+ editor.settings.paste_plaintext_inform = false;
+ }
} );
+ editor.on( 'PastePlainTextToggle', function( event ) {
+ // Warn twice, then stop.
+ if ( event.state === true ) {
+ var times = parseInt( window.getUserSetting( 'editor_plain_text_paste_warning' ), 10 ) || 0;
+
+ if ( times < 2 ) {
+ window.setUserSetting( 'editor_plain_text_paste_warning', ++times );
+ }
+ }
+ });
+
/**
* Experimental: create a floating toolbar.
* This functionality will change in the next releases. Not recommended for use by plugins.
top, left;
if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) {
- return this.hide();
+ this.scrolling = true;
+ this.hide();
+ this.scrolling = false;
+ return this;
}
// Add offset in iOS to move the menu over the image, out of the way of the default iOS menu.
currentSelection = args.selection || args.element;
- if ( activeToolbar ) {
+ if ( activeToolbar && activeToolbar !== args.toolbar ) {
activeToolbar.hide();
}
if ( args.toolbar ) {
- activeToolbar = args.toolbar;
- activeToolbar.show();
+ if ( activeToolbar !== args.toolbar ) {
+ activeToolbar = args.toolbar;
+ activeToolbar.show();
+ } else {
+ activeToolbar.reposition();
+ }
} else {
activeToolbar = false;
}
function hide( event ) {
if ( activeToolbar ) {
- activeToolbar.hide();
-
- if ( event.type === 'hide' ) {
+ if ( activeToolbar.tempHide || event.type === 'hide' ) {
+ activeToolbar.hide();
activeToolbar = false;
- } else if ( event.type === 'resize' || event.type === 'scroll' ) {
+ } else if ( ( event.type === 'resize' || event.type === 'scroll' ) && ! activeToolbar.blockHide ) {
clearTimeout( timeout );
timeout = setTimeout( function() {
if ( activeToolbar && typeof activeToolbar.show === 'function' ) {
+ activeToolbar.scrolling = false;
activeToolbar.show();
}
}, 250 );
+
+ activeToolbar.scrolling = true;
+ activeToolbar.hide();
}
}
}