X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..refs/tags/wordpress-4.5.2-scripts:/wp-includes/js/tinymce/plugins/wordpress/plugin.js diff --git a/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/wp-includes/js/tinymce/plugins/wordpress/plugin.js index 8e4d5b6a..968ebd9a 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -117,7 +117,15 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } // Remove spaces from empty paragraphs. - event.content = event.content.replace( /

(?: |\u00a0|\uFEFF|\s)+<\/p>/gi, '


' ); + // Avoid backtracking, can freeze the editor. See #35890. + // (This is also quite faster than using only one regex.) + event.content = event.content.replace( /

([^<>]+)<\/p>/gi, function( tag, text ) { + if ( /^( |\s|\u00a0|\ufeff)+$/i.test( text ) ) { + return '


'; + } + + return tag; + }); } }); @@ -254,43 +262,42 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { // Main section, default and additional shortcuts html = html + '

' + __( 'Default shortcuts,' ) + ' ' + meta + '

' + - '' + + '
' + header + table1.join('') + '
' + '

' + __( 'Additional shortcuts,' ) + ' ' + access + '

' + - '' + + '
' + header + table2.join('') + '
'; - if ( editor.plugins.wptextpattern ) { + if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) { // Text pattern section html = html + '

' + __( '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.' ) + '

' + - '' + - tr({ '*': 'Bullet list' }) + - tr({ '-': 'Bullet list' }) + - tr({ '1.': 'Numbered list' }) + - tr({ '1)': 'Numbered list' }) + + '
' + + tr({ '*': 'Bullet list', '1.': 'Numbered list' }) + + tr({ '-': 'Bullet list', '1)': 'Numbered list' }) + '
'; html = html + '

' + __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ) + '

' + - '' + + '
' + tr({ '>': 'Blockquote' }) + tr({ '##': 'Heading 2' }) + tr({ '###': 'Heading 3' }) + tr({ '####': 'Heading 4' }) + tr({ '#####': 'Heading 5' }) + tr({ '######': 'Heading 6' }) + + tr({ '---': 'Horizontal line' }) + '
'; } // Focus management section html = html + '

' + __( 'Focus shortcuts:' ) + '

' + - '' + + '
' + 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' }) + @@ -550,8 +557,23 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { 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. @@ -744,7 +766,10 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { 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. @@ -850,13 +875,17 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { 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; } @@ -870,18 +899,21 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { 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(); } } }