]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wordpress/plugin.js
WordPress 4.5
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wordpress / plugin.js
index 8e4d5b6a7407d965edb8e358ec3f984a7b61f9ae..968ebd9a6b2e9943ab4c2c6affd32e303757f3a4 100644 (file)
@@ -117,7 +117,15 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                        }
 
                        // Remove spaces from empty paragraphs.
-                       event.content = event.content.replace( /<p>(?:&nbsp;|\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 ( /^(&nbsp;|\s|\u00a0|\ufeff)+$/i.test( text ) ) {
+                                       return '<p><br /></p>';
+                               }
+
+                               return tag;
+                       });
                }
        });
 
@@ -254,43 +262,42 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                // 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' }) +
@@ -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();
                                }
                        }
                }