Ticket #33301: 33301.7.patch
File 33301.7.patch, 11.5 KB (added by , 7 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
451 451 width: 20px; 452 452 } 453 453 454 .mce-toolbar .mce-btn-group .mce-btn.mce-primary { 455 min-width: auto; 456 457 background: #0085ba; 458 border-color: #0073aa #006799 #006799; 459 -webkit-box-shadow: 0 1px 0 #006799; 460 box-shadow: 0 1px 0 #006799; 461 color: #fff; 462 text-decoration: none; 463 text-shadow: 0 -1px 1px #006799, 464 1px 0 1px #006799, 465 0 1px 1px #006799, 466 -1px 0 1px #006799; 467 } 468 469 .mce-toolbar .mce-btn-group .mce-btn.mce-primary .mce-ico { 470 color: #fff; 471 } 472 473 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:hover, 474 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { 475 background: #008ec2; 476 border-color: #006799; 477 color: #fff; 478 } 479 480 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { 481 -webkit-box-shadow: 0 1px 0 #0073aa, 482 0 0 2px 1px #33b3db; 483 box-shadow: 0 1px 0 #0073aa, 484 0 0 2px 1px #33b3db; 485 } 486 487 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:active { 488 background: #0073aa; 489 border-color: #006799; 490 -webkit-box-shadow: inset 0 2px 0 #006799; 491 box-shadow: inset 0 2px 0 #006799; 492 vertical-align: top; 493 } 494 454 495 /* mce listbox */ 455 496 .mce-toolbar .mce-btn-group .mce-btn.mce-listbox { 456 497 -webkit-border-radius: 0; … … 1709 1750 } 1710 1751 } 1711 1752 1753 div.wp-link-input { 1754 float: left; 1755 margin: 2px; 1756 max-width: 694px; 1757 } 1758 1759 div.wp-link-input input { 1760 width: 300px; 1761 padding: 3px; 1762 -webkit-box-sizing: border-box; 1763 -moz-box-sizing: border-box; 1764 box-sizing: border-box; 1765 } 1766 1767 @media screen and ( max-width: 400px ) { 1768 div.wp-link-input { 1769 min-width: auto; 1770 max-width: 70%; 1771 max-width: -webkit-calc(100% - 80px); 1772 max-width: calc(100% - 80px); 1773 } 1774 1775 div.wp-link-input input { 1776 width: 100%; 1777 font-size: 16px; 1778 padding: 4px; 1779 } 1780 } 1781 1782 .ui-autocomplete.mce-wp-autocomplete { 1783 z-index: 100100; 1784 margin-top: 10px; 1785 max-height: 200px; 1786 overflow-y: auto; 1787 } 1788 1712 1789 /* =Overlay Body 1713 1790 -------------------------------------------------------------- */ 1714 1791 -
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 } else if ( event.type === 'resize' || event.type === 'scroll') {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-input">' + 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 ) { 64 var a; 51 65 var toolbar; 66 var editToolbar; 67 var previewInstance; 68 var inputInstance; 69 var $ = window.jQuery; 70 71 editor.on( 'preinit', function() { 72 if ( editor.wp && editor.wp._createToolbar ) { 73 toolbar = editor.wp._createToolbar( [ 74 'wp_link_preview', 75 'wp_link_edit', 76 'wp_link_remove' 77 ], true ); 78 79 editToolbar = editor.wp._createToolbar( [ 80 'wp_link_input', 81 'wp_link_apply', 82 'wp_link_advanced' 83 ], true ); 84 85 editToolbar.on( 'show', function() { 86 var node = editToolbar.find( 'toolbar' )[0]; 87 node && node.focus( true ); 88 a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 89 } ); 90 91 editToolbar.on( 'hide', function() { 92 editToolbar.scrolling || editor.execCommand( 'wp_link_cancel' ); 93 } ); 94 } 95 } ); 52 96 53 97 editor.addCommand( 'WP_Link', function() { 54 window.wpLink && window.wpLink.open( editor.id ); 55 }); 98 var a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 99 100 if ( a ) { 101 editor.dom.setAttribs( a, { 'data-wp-edit': true } ); 102 } else { 103 editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); 104 } 105 106 editor.nodeChanged(); 107 } ); 108 109 editor.addCommand( 'wp_link_apply', function() { 110 if ( editToolbar.scrolling ) { 111 return; 112 } 113 114 var href = tinymce.trim( inputInstance.getEl().firstChild.value ); 115 116 if ( href && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) ) { 117 href = 'http://' + href; 118 } 119 120 if ( ! href ) { 121 editor.dom.remove( a, true ); 122 return; 123 } 124 125 if ( a ) { 126 editor.dom.setAttribs( a, { href: href, 'data-wp-edit': null } ); 127 } 128 129 a = false; 130 131 editor.nodeChanged(); 132 editor.focus(); 133 } ); 134 135 editor.addCommand( 'wp_link_cancel', function() { 136 if ( a ) { 137 if ( editor.$( a ).attr( 'href' ) === '_wp_link_placeholder' ) { 138 editor.dom.remove( a, true ); 139 } else { 140 editor.dom.setAttribs( a, { 'data-wp-edit': null } ); 141 } 142 } 143 144 a = false; 145 146 editor.nodeChanged(); 147 editor.focus(); 148 } ); 56 149 57 150 // WP default shortcut 58 151 editor.addShortcut( 'access+a', '', 'WP_Link' ); … … 102 195 editor.addButton( 'wp_link_preview', { 103 196 type: 'WPLinkPreview', 104 197 onPostRender: function() { 105 var self = this; 198 previewInstance = this; 199 } 200 } ); 201 202 editor.addButton( 'wp_link_input', { 203 type: 'WPLinkInput', 204 onPostRender: function() { 205 var input = this.getEl().firstChild; 206 var cache; 207 var last; 208 209 inputInstance = this; 210 211 if ( $ ) { 212 $( input ).autocomplete( { 213 source: function( request, response ) { 214 if ( last === request.term ) { 215 response( cache ); 216 return; 217 } 218 219 if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) { 220 return response(); 221 } 222 223 $.post( window.ajaxurl, { 224 action: 'wp-link-ajax', 225 page: 1, 226 search: request.term, 227 _ajax_linking_nonce: $( '#_ajax_linking_nonce' ).val() 228 }, function( data ) { 229 cache = data; 230 response( data ); 231 }, 'json' ); 232 233 last = request.term; 234 }, 235 select: function( event, ui ) { 236 $( input ).val( ui.item.permalink ); 237 return false; 238 }, 239 minLength: 2, 240 position: { 241 my: 'left top+5' 242 } 243 } ).autocomplete( 'instance' )._renderItem = function( ul, item ) { 244 $( ul ).addClass( 'mce-wp-autocomplete' ); 106 245 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; 246 return $( '<li>' ) 247 .append( '<span>' + item.title + '</span> <span class="alignright">' + item.info + '</span>' ) 248 .appendTo( ul ); 249 }; 250 251 $( input ).autocomplete( 'widget' ).hover( 252 function() { 253 $( document.body ).addClass( 'modal-open' ); 254 }, 255 function() { 256 $( document.body ).removeClass( 'modal-open' ); 120 257 } 121 } 258 ); 259 260 $( input ).on( 'focus', function() { 261 $( input ).autocomplete( 'search' ); 262 } ); 263 } 264 265 tinymce.$( input ).on( 'keydown', function( event ) { 266 event.keyCode === 13 && editor.execCommand( 'wp_link_apply' ); 122 267 } ); 123 268 } 124 269 } ); 125 270 271 editor.on( 'wptoolbar', function( event ) { 272 var anchor = editor.dom.getParent( event.element, 'a' ), 273 $anchor, 274 href, edit; 275 276 if ( anchor ) { 277 $anchor = editor.$( anchor ); 278 href = $anchor.attr( 'href' ); 279 edit = $anchor.attr( 'data-wp-edit' ); 280 281 if ( href === '_wp_link_placeholder' || edit ) { 282 inputInstance.setURL( edit ? href : '' ); 283 event.element = anchor; 284 event.toolbar = editToolbar; 285 } else if ( href && ! $anchor.find( 'img' ).length ) { 286 previewInstance.setURL( href ); 287 event.element = anchor; 288 event.toolbar = toolbar; 289 } 290 } 291 } ); 292 126 293 editor.addButton( 'wp_link_edit', { 127 294 tooltip: 'Edit ', // trailing space is needed, used for context 128 295 icon: 'dashicon dashicons-edit', … … 135 302 cmd: 'unlink' 136 303 } ); 137 304 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);305 // Advanced, more, options? 306 editor.addButton( 'wp_link_advanced', { 307 tooltip: 'Advanced', 308 icon: 'dashicon dashicons-admin-generic', 309 onclick: function() { 310 editor.execCommand( 'wp_link_apply' ); 311 window.wpLink && window.wpLink.open( editor.id ); 145 312 } 146 313 } ); 314 315 editor.addButton( 'wp_link_apply', { 316 tooltip: 'Apply', 317 icon: 'dashicon dashicons-editor-break', 318 cmd: 'wp_link_apply', 319 classes: 'widget btn primary' 320 } ); 147 321 } ); 148 322 } )( window.tinymce );