Ticket #28322: 28322.patch
File 28322.patch, 2.7 KB (added by , 9 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
86 86 } 87 87 88 88 function select( viewNode ) { 89 var clipboard, 90 dom = editor.dom; 89 var clipboard; 91 90 92 91 if ( ! viewNode ) { 93 92 return; … … 94 93 } 95 94 96 95 if ( viewNode !== selected ) { 97 // Make sure that the editor is focused.98 // It is possible that the editor is not focused when the mouse event fires99 // without focus, the selection will not work properly.100 editor.getBody().focus();101 102 96 deselect(); 103 97 selected = viewNode; 104 dom.setAttrib( viewNode,'data-mce-selected', 1 );98 $( viewNode ).attr( 'data-mce-selected', 1 ); 105 99 106 clipboard = dom.create( 'div', {100 clipboard = editor.dom.create( 'div', { 107 101 'class': 'wpview-clipboard', 108 102 'contenteditable': 'true' 109 103 }, wp.mce.views.getText( viewNode ) ); 110 104 111 editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard );105 $( '.wpview-body', viewNode ).append( clipboard ); 112 106 113 107 // Both of the following are necessary to prevent manipulating the selection/focus 114 dom.bind( clipboard,'beforedeactivate focusin focusout', _stop );115 dom.bind( selected,'beforedeactivate focusin focusout', _stop );108 $( clipboard ).on( 'beforedeactivate focusin focusout', _stop ); 109 $( selected ).on( 'beforedeactivate focusin focusout', _stop ); 116 110 117 // select the hidden div 111 // Make sure that the editor is focused. 112 // It is possible that the editor is not focused when the mouse event fires 113 // without focus, the selection will not work properly. 114 // Need to select the (visible) wpView wrap node first to prevent Chrome from jumping to the top. 115 editor.selection.select( viewNode ); 116 editor.focus(); 117 118 // Select the hidden clipboard div so when the users try to copy the selection, 119 // they will copy the string used to create the wpView. 118 120 if ( isios ) { 119 121 editor.selection.select( clipboard ); 120 122 } else { … … 130 132 * Deselect a selected view and remove clipboard 131 133 */ 132 134 function deselect() { 133 var clipboard,134 dom = editor.dom;135 136 135 if ( selected ) { 137 clipboard = editor.dom.select( '.wpview-clipboard', selected )[0]; 138 dom.unbind( clipboard ); 139 dom.remove( clipboard ); 140 141 dom.unbind( selected, 'beforedeactivate focusin focusout click mouseup', _stop ); 142 dom.setAttrib( selected, 'data-mce-selected', null ); 136 $( selected ).off( 'beforedeactivate focusin focusout click mouseup', _stop ) 137 .removeAttr( 'data-mce-selected' ) 138 .find( '.wpview-clipboard' ).off().remove(); 143 139 } 144 140 145 141 selected = null;