Changeset 29302
- Timestamp:
- 07/26/2014 12:07:55 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/editor-expand.js
r29279 r29302 125 125 $statusBar = $contentWrap.find( '.mce-statusbar' ).filter( ':visible' ); 126 126 127 // Adjust when switching editor modes. 128 editor.on( 'show', function() { 129 setTimeout( function() { 130 editor.execCommand( 'wpAutoResize' ); 131 adjust(); 132 }, 300 ); 133 } ); 127 function getCursorOffset() { 128 var node = editor.selection.getNode(), 129 view, offset; 130 131 if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) { 132 offset = view.getBoundingClientRect(); 133 } else { 134 offset = node.getBoundingClientRect(); 135 } 136 137 return offset.height ? offset : false; 138 } 134 139 135 140 // Make sure the cursor is always visible. … … 151 156 } 152 157 153 cursorTop = offset.top + editor.getContentAreaContainer(). getElementsByTagName( 'iframe' )[0].getBoundingClientRect().top;158 cursorTop = offset.top + editor.getContentAreaContainer().firstChild.getBoundingClientRect().top; 154 159 cursorBottom = cursorTop + offset.height; 155 160 cursorTop = cursorTop - buffer; … … 158 163 editorBottom = windowHeight - $bottom.outerHeight(); 159 164 165 // Don't scroll if the node is taller than the visible part of the editor 166 if ( editorBottom - editorTop < offset.height ) { 167 return; 168 } 169 160 170 if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) { 161 171 window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop ); … … 165 175 } ); 166 176 167 function getCursorOffset() { 168 var selection = editor.selection, 169 node = selection.getNode(), 170 range = selection.getRng(), 171 view, clone, offset; 172 173 if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) { 174 return; 175 } 176 177 if ( editor.plugins.wpview && ( view = editor.plugins.wpview.getView( node ) ) ) { 178 offset = view.getBoundingClientRect(); 179 } else if ( selection.isCollapsed() ) { 180 clone = range.cloneRange(); 181 182 if ( clone.startContainer.length > 1 ) { 183 if ( clone.startContainer.length > clone.endOffset ) { 184 clone.setEnd( clone.startContainer, clone.endOffset + 1 ); 185 } else { 186 clone.setStart( clone.startContainer, clone.endOffset - 1 ); 187 } 188 189 selection.setRng( clone ); 190 offset = selection.getRng().getBoundingClientRect(); 191 selection.setRng( range ); 192 } else { 193 offset = node.getBoundingClientRect(); 194 } 195 } else { 196 offset = range.getBoundingClientRect(); 197 } 198 199 if ( ! offset.height ) { 200 return; 201 } 202 203 return offset; 204 } 177 // Adjust when switching editor modes. 178 editor.on( 'show', function() { 179 setTimeout( function() { 180 editor.execCommand( 'wpAutoResize' ); 181 adjust(); 182 }, 300 ); 183 } ); 205 184 206 185 editor.on( 'hide', function() { -
trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js
r29298 r29302 287 287 288 288 editor.dom.bind( editor.getBody().parentNode, 'mousedown mouseup click', function( event ) { 289 var view = getView( event.target ), 290 deselectEventType; 289 var view = getView( event.target ); 291 290 292 291 firstFocus = false;
Note: See TracChangeset
for help on using the changeset viewer.