]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wordpress/plugin.js
Wordpress 4.6-scripts
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wordpress / plugin.js
index 3ea329c608248ecd8be31afb7d8537d8e957b9a7..b930e921f209f8208a7d1e6004fb2ed71eb43215 100644 (file)
@@ -90,7 +90,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
         window.wpActiveEditor = editor.id;
     });
 
-       // Replace Read More/Next Page tags with images
        editor.on( 'BeforeSetContent', function( event ) {
                var title;
 
@@ -116,6 +115,21 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                                event.content = wp.editor.autop( event.content );
                        }
 
+                       if ( event.content.indexOf( '<script' ) !== -1 || event.content.indexOf( '<style' ) !== -1 ) {
+                               event.content = event.content.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match, tag ) {
+                                       return '<img ' +
+                                               'src="' + tinymce.Env.transparentSrc + '" ' +
+                                               'data-wp-preserve="' + encodeURIComponent( match ) + '" ' +
+                                               'data-mce-resize="false" ' +
+                                               'data-mce-placeholder="1" '+
+                                               'class="mce-object" ' +
+                                               'width="20" height="20" '+
+                                               'alt="&lt;' + tag + '&gt;" ' +
+                                               'title="&lt;' + tag + '&gt;" ' +
+                                       '/>';
+                               } );
+                       }
+
                        // Remove spaces from empty paragraphs.
                        // Avoid backtracking, can freeze the editor. See #35890.
                        // (This is also quite faster than using only one regex.)
@@ -129,23 +143,28 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                }
        });
 
-       // Replace images with tags
-       editor.on( 'PostProcess', function( e ) {
-               if ( e.get ) {
-                       e.content = e.content.replace(/<img[^>]+>/g, function( image ) {
-                               var match, moretext = '';
+       editor.on( 'PostProcess', function( event ) {
+               if ( event.get ) {
+                       event.content = event.content.replace(/<img[^>]+>/g, function( image ) {
+                               var match,
+                                       string,
+                                       moretext = '';
 
                                if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) {
                                        if ( match = image.match( /data-wp-more-text="([^"]+)"/ ) ) {
                                                moretext = match[1];
                                        }
 
-                                       image = '<!--more' + moretext + '-->';
+                                       string = '<!--more' + moretext + '-->';
                                } else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) {
-                                       image = '<!--nextpage-->';
+                                       string = '<!--nextpage-->';
+                               } else if ( image.indexOf( 'data-wp-preserve' ) !== -1 ) {
+                                       if ( match = image.match( / data-wp-preserve="([^"]+)"/ ) ) {
+                                               string = decodeURIComponent( match[1] );
+                                       }
                                }
 
-                               return image;
+                               return string || image;
                        });
                }
        });
@@ -540,7 +559,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                        q: 'mceBlockQuote',
                        u: 'InsertUnorderedList',
                        o: 'InsertOrderedList',
-                       s: 'unlink',
                        m: 'WP_Medialib',
                        z: 'WP_Adv',
                        t: 'WP_More',
@@ -561,6 +579,11 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                if ( window.getUserSetting( 'editor_plain_text_paste_warning' ) > 1 ) {
                        editor.settings.paste_plaintext_inform = false;
                }
+
+               // Change the editor iframe title on MacOS, add the correct help shortcut.
+               if ( tinymce.Env.mac ) {
+                       tinymce.$( editor.iframeElement ).attr( 'title', __( 'Rich Text Area. Press Control-Option-H for help.' ) );
+               }
        } );
 
        editor.on( 'PastePlainTextToggle', function( event ) {
@@ -745,12 +768,11 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                                        },
                                        toolbar = this.getEl(),
                                        toolbarWidth = toolbar.offsetWidth,
-                                       toolbarHeight = toolbar.offsetHeight,
+                                       toolbarHeight = toolbar.clientHeight,
                                        selection = currentSelection.getBoundingClientRect(),
                                        selectionMiddle = ( selection.left + selection.right ) / 2,
                                        buffer = 5,
-                                       margin = 8,
-                                       spaceNeeded = toolbarHeight + margin + buffer,
+                                       spaceNeeded = toolbarHeight + buffer,
                                        wpAdminbarBottom = wpAdminbar ? wpAdminbar.getBoundingClientRect().bottom : 0,
                                        mceToolbarBottom = mceToolbar ? mceToolbar.getBoundingClientRect().bottom : 0,
                                        mceStatusbarTop = mceStatusbar ? windowHeight - mceStatusbar.getBoundingClientRect().top : 0,
@@ -784,12 +806,12 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
                                                top = selection.bottom + iframeRect.top + scrollY - iosOffsetBottom;
                                        } else if ( spaceTop >= spaceNeeded ) {
                                                className = ' mce-arrow-down';
-                                               top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin + iosOffsetTop;
+                                               top = selection.top + iframeRect.top + scrollY - toolbarHeight + iosOffsetTop;
                                        }
                                } else {
                                        if ( spaceTop >= spaceNeeded ) {
                                                className = ' mce-arrow-down';
-                                               top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin + iosOffsetTop;
+                                               top = selection.top + iframeRect.top + scrollY - toolbarHeight + iosOffsetTop;
                                        } else if ( spaceBottom >= spaceNeeded && editorHeight / 2 > selection.bottom + iframeRect.top - blockedTop ) {
                                                className = ' mce-arrow-up';
                                                top = selection.bottom + iframeRect.top + scrollY - iosOffsetBottom;