~canonical-sysadmins/wordpress/4.8

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/wordpress/plugin.js

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
        window.wpActiveEditor = editor.id;
91
91
    });
92
92
 
93
 
        // Replace Read More/Next Page tags with images
94
93
        editor.on( 'BeforeSetContent', function( event ) {
95
94
                var title;
96
95
 
116
115
                                event.content = wp.editor.autop( event.content );
117
116
                        }
118
117
 
 
118
                        if ( event.content.indexOf( '<script' ) !== -1 || event.content.indexOf( '<style' ) !== -1 ) {
 
119
                                event.content = event.content.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match, tag ) {
 
120
                                        return '<img ' +
 
121
                                                'src="' + tinymce.Env.transparentSrc + '" ' +
 
122
                                                'data-wp-preserve="' + encodeURIComponent( match ) + '" ' +
 
123
                                                'data-mce-resize="false" ' +
 
124
                                                'data-mce-placeholder="1" '+
 
125
                                                'class="mce-object" ' +
 
126
                                                'width="20" height="20" '+
 
127
                                                'alt="&lt;' + tag + '&gt;" ' +
 
128
                                                'title="&lt;' + tag + '&gt;" ' +
 
129
                                        '/>';
 
130
                                } );
 
131
                        }
 
132
 
119
133
                        // Remove spaces from empty paragraphs.
120
134
                        // Avoid backtracking, can freeze the editor. See #35890.
121
135
                        // (This is also quite faster than using only one regex.)
129
143
                }
130
144
        });
131
145
 
132
 
        // Replace images with tags
133
 
        editor.on( 'PostProcess', function( e ) {
134
 
                if ( e.get ) {
135
 
                        e.content = e.content.replace(/<img[^>]+>/g, function( image ) {
136
 
                                var match, moretext = '';
 
146
        editor.on( 'PostProcess', function( event ) {
 
147
                if ( event.get ) {
 
148
                        event.content = event.content.replace(/<img[^>]+>/g, function( image ) {
 
149
                                var match,
 
150
                                        string,
 
151
                                        moretext = '';
137
152
 
138
153
                                if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) {
139
154
                                        if ( match = image.match( /data-wp-more-text="([^"]+)"/ ) ) {
140
155
                                                moretext = match[1];
141
156
                                        }
142
157
 
143
 
                                        image = '<!--more' + moretext + '-->';
 
158
                                        string = '<!--more' + moretext + '-->';
144
159
                                } else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) {
145
 
                                        image = '<!--nextpage-->';
 
160
                                        string = '<!--nextpage-->';
 
161
                                } else if ( image.indexOf( 'data-wp-preserve' ) !== -1 ) {
 
162
                                        if ( match = image.match( / data-wp-preserve="([^"]+)"/ ) ) {
 
163
                                                string = decodeURIComponent( match[1] );
 
164
                                        }
146
165
                                }
147
166
 
148
 
                                return image;
 
167
                                return string || image;
149
168
                        });
150
169
                }
151
170
        });
540
559
                        q: 'mceBlockQuote',
541
560
                        u: 'InsertUnorderedList',
542
561
                        o: 'InsertOrderedList',
543
 
                        s: 'unlink',
544
562
                        m: 'WP_Medialib',
545
563
                        z: 'WP_Adv',
546
564
                        t: 'WP_More',
561
579
                if ( window.getUserSetting( 'editor_plain_text_paste_warning' ) > 1 ) {
562
580
                        editor.settings.paste_plaintext_inform = false;
563
581
                }
 
582
 
 
583
                // Change the editor iframe title on MacOS, add the correct help shortcut.
 
584
                if ( tinymce.Env.mac ) {
 
585
                        tinymce.$( editor.iframeElement ).attr( 'title', __( 'Rich Text Area. Press Control-Option-H for help.' ) );
 
586
                }
564
587
        } );
565
588
 
566
589
        editor.on( 'PastePlainTextToggle', function( event ) {
745
768
                                        },
746
769
                                        toolbar = this.getEl(),
747
770
                                        toolbarWidth = toolbar.offsetWidth,
748
 
                                        toolbarHeight = toolbar.offsetHeight,
 
771
                                        toolbarHeight = toolbar.clientHeight,
749
772
                                        selection = currentSelection.getBoundingClientRect(),
750
773
                                        selectionMiddle = ( selection.left + selection.right ) / 2,
751
774
                                        buffer = 5,
752
 
                                        margin = 8,
753
 
                                        spaceNeeded = toolbarHeight + margin + buffer,
 
775
                                        spaceNeeded = toolbarHeight + buffer,
754
776
                                        wpAdminbarBottom = wpAdminbar ? wpAdminbar.getBoundingClientRect().bottom : 0,
755
777
                                        mceToolbarBottom = mceToolbar ? mceToolbar.getBoundingClientRect().bottom : 0,
756
778
                                        mceStatusbarTop = mceStatusbar ? windowHeight - mceStatusbar.getBoundingClientRect().top : 0,
784
806
                                                top = selection.bottom + iframeRect.top + scrollY - iosOffsetBottom;
785
807
                                        } else if ( spaceTop >= spaceNeeded ) {
786
808
                                                className = ' mce-arrow-down';
787
 
                                                top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin + iosOffsetTop;
 
809
                                                top = selection.top + iframeRect.top + scrollY - toolbarHeight + iosOffsetTop;
788
810
                                        }
789
811
                                } else {
790
812
                                        if ( spaceTop >= spaceNeeded ) {
791
813
                                                className = ' mce-arrow-down';
792
 
                                                top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin + iosOffsetTop;
 
814
                                                top = selection.top + iframeRect.top + scrollY - toolbarHeight + iosOffsetTop;
793
815
                                        } else if ( spaceBottom >= spaceNeeded && editorHeight / 2 > selection.bottom + iframeRect.top - blockedTop ) {
794
816
                                                className = ' mce-arrow-up';
795
817
                                                top = selection.bottom + iframeRect.top + scrollY - iosOffsetBottom;