Ticket #33301: 33301.3.patch
File 33301.3.patch, 8.5 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
1477 1477 1478 1478 $args = array(); 1479 1479 1480 if ( isset( $_POST['search'] ) ) 1480 if ( isset( $_POST['search'] ) ) { 1481 1481 $args['s'] = wp_unslash( $_POST['search'] ); 1482 } 1483 1484 if ( isset( $_POST['term'] ) ) { 1485 $args['s'] = wp_unslash( $_POST['term'] ); 1486 } 1487 1482 1488 $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; 1483 1489 1484 1490 require(ABSPATH . WPINC . '/class-wp-editor.php'); -
src/wp-includes/class-wp-editor.php
779 779 780 780 if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) { 781 781 wp_enqueue_script('wplink'); 782 wp_enqueue_script( 'jquery-ui-autocomplete' ); 782 783 } 783 784 784 785 if ( self::$old_dfw_compat ) { -
src/wp-includes/css/editor.css
1709 1709 } 1710 1710 } 1711 1711 1712 div.wp-link-preview input { 1713 width: 300px; 1714 } 1715 1712 1716 /* =Overlay Body 1713 1717 -------------------------------------------------------------- */ 1714 1718 -
src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
744 744 top, left; 745 745 746 746 if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) { 747 return this.hide(); 747 this.scrolling = true; 748 this.hide(); 749 this.scrolling = false; 750 return this; 748 751 } 749 752 750 753 // Add offset in iOS to move the menu over the image, out of the way of the default iOS menu. … … 850 853 851 854 currentSelection = args.selection || args.element; 852 855 853 if ( activeToolbar ) {856 if ( activeToolbar && activeToolbar !== args.toolbar ) { 854 857 activeToolbar.hide(); 855 858 } 856 859 857 860 if ( args.toolbar ) { 858 activeToolbar = args.toolbar; 859 activeToolbar.show(); 861 if ( activeToolbar !== args.toolbar ) { 862 activeToolbar = args.toolbar; 863 activeToolbar.show(); 864 } else { 865 activeToolbar.reposition(); 866 } 860 867 } else { 861 868 activeToolbar = false; 862 869 } … … 870 877 871 878 function hide( event ) { 872 879 if ( activeToolbar ) { 873 activeToolbar.hide();874 875 880 if ( event.type === 'hide' ) { 881 activeToolbar.hide(); 876 882 activeToolbar = false; 877 883 } else if ( event.type === 'resize' || event.type === 'scroll' ) { 878 884 clearTimeout( timeout ); 879 885 880 886 timeout = setTimeout( function() { 881 887 if ( activeToolbar && typeof activeToolbar.show === 'function' ) { 888 activeToolbar.scrolling = false; 882 889 activeToolbar.show(); 883 890 } 884 891 }, 250 ); 892 893 activeToolbar.scrolling = true; 894 activeToolbar.hide(); 885 895 } 886 896 } 887 897 } -
src/wp-includes/js/tinymce/plugins/wplink/plugin.js
47 47 } 48 48 } ); 49 49 50 tinymce.ui.WPLinkInput = tinymce.ui.Control.extend( { 51 renderHtml: function() { 52 return ( 53 '<div id="' + this._id + '" class="wp-link-preview">' + 54 '<input type="text" value="" tabindex="-1" />' + 55 '</div>' 56 ); 57 }, 58 setURL: function( url ) { 59 this.getEl().firstChild.value = url; 60 } 61 } ); 62 50 63 tinymce.PluginManager.add( 'wplink', function( editor ) { 51 var toolbar; 64 var toolbar, editToolbar; 65 66 editor.on( 'preinit', function() { 67 if ( editor.wp && editor.wp._createToolbar ) { 68 toolbar = editor.wp._createToolbar( [ 69 'wp_link_preview', 70 'wp_link_edit', 71 'wp_link_remove' 72 ], true ); 73 74 editToolbar = editor.wp._createToolbar( [ 75 'wp_link_input' 76 ], true ); 77 } 78 } ); 52 79 53 80 editor.addCommand( 'WP_Link', function() { 54 window.wpLink && window.wpLink.open( editor.id ); 81 var a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 82 83 if ( a ) { 84 editor.dom.setAttribs( a, { 'data-wp-edit': true } ); 85 } else { 86 editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); 87 } 88 89 editor.nodeChanged(); 55 90 }); 56 91 57 92 // WP default shortcut … … 99 134 } 100 135 } ); 101 136 137 var previewInstance, inputInstance; 138 102 139 editor.addButton( 'wp_link_preview', { 103 140 type: 'WPLinkPreview', 104 141 onPostRender: function() { 105 var self = this; 142 previewInstance = this; 143 } 144 } ); 145 146 editor.addButton( 'wp_link_input', { 147 type: 'WPLinkInput', 148 onPostRender: function() { 149 var input = this.getEl().firstChild; 150 var cache; 151 var last; 152 153 inputInstance = this; 154 155 jQuery( input ).autocomplete( { 156 source: function( request, response ) { 157 if ( last === request.term ) { 158 response( cache ); 159 return; 160 } 161 162 if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) { 163 return response(); 164 } 165 166 jQuery.post( ajaxurl, { 167 action: 'wp-link-ajax', 168 page: 1, 169 search: request.term, 170 _ajax_linking_nonce: jQuery( '#_ajax_linking_nonce' ).val() 171 }, function( data ) { 172 cache = data; 173 response( data ); 174 }, 'json' ); 175 176 last = request.term; 177 }, 178 select: function( event, ui ) { 179 jQuery( input ).val( ui.item.permalink ); 180 return false; 181 }, 182 minLength: 2 183 } ).autocomplete( 'instance' )._renderItem = function( ul, item ) { 184 return jQuery( '<li>' ) 185 .append( '<span>' + item.title + '</span><span>' + item.info + '</span>' ) 186 .appendTo( ul ); 187 }; 188 189 jQuery( input ).on( 'focus', function() { 190 jQuery( input ).autocomplete( 'search' ); 191 } ); 106 192 107 editor.on( 'wptoolbar', function( event ) { 108 var anchor = editor.dom.getParent( event.element, 'a' ), 109 $anchor, 110 href; 111 112 if ( anchor ) { 113 $anchor = editor.$( anchor ); 114 href = $anchor.attr( 'href' ); 115 116 if ( href && ! $anchor.find( 'img' ).length ) { 117 self.setURL( href ); 118 event.element = anchor; 119 event.toolbar = toolbar; 193 editor.on( 'init', function() { 194 var a; 195 196 tinymce.$( input ).on( 'keydown', function( event ) { 197 event.keyCode === 13 && editToolbar.hide(); 198 } ); 199 200 editToolbar.on( 'show', function() { 201 a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 202 node = editToolbar.find( 'toolbar' )[0]; 203 node && node.focus( true ); 204 } ); 205 206 editToolbar.on( 'hide', function(event) { 207 if ( editToolbar.scrolling ) { 208 return; 209 } 210 211 href = tinymce.trim( input.value ); 212 213 if ( href && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) ) { 214 href = 'http://' + href; 120 215 } 121 } 216 217 if ( ! href ) { 218 editor.dom.remove( a, true ); 219 return; 220 } 221 222 if ( a ) { 223 editor.dom.setAttribs( a, { href: href, 'data-wp-edit': null } ); 224 } 225 226 a = false; 227 228 editor.nodeChanged(); 229 editor.focus(); 230 } ); 122 231 } ); 123 232 } 124 233 } ); 125 234 235 editor.on( 'wptoolbar', function( event ) { 236 var anchor = editor.dom.getParent( event.element, 'a' ), 237 $anchor, 238 href, edit, node; 239 240 if ( anchor ) { 241 $anchor = editor.$( anchor ); 242 href = $anchor.attr( 'href' ); 243 edit = $anchor.attr( 'data-wp-edit' ); 244 245 if ( href === '_wp_link_placeholder' || edit ) { 246 inputInstance.setURL( edit ? href : '' ); 247 event.element = anchor; 248 event.toolbar = editToolbar; 249 } else if ( href && ! $anchor.find( 'img' ).length ) { 250 previewInstance.setURL( href ); 251 event.element = anchor; 252 event.toolbar = toolbar; 253 } 254 } 255 } ); 256 126 257 editor.addButton( 'wp_link_edit', { 127 258 tooltip: 'Edit ', // trailing space is needed, used for context 128 259 icon: 'dashicon dashicons-edit', … … 134 265 icon: 'dashicon dashicons-no', 135 266 cmd: 'unlink' 136 267 } ); 137 138 editor.on( 'preinit', function() {139 if ( editor.wp && editor.wp._createToolbar ) {140 toolbar = editor.wp._createToolbar( [141 'wp_link_preview',142 'wp_link_edit',143 'wp_link_remove'144 ], true );145 }146 } );147 268 } ); 148 269 } )( window.tinymce );