Ticket #32197: 32197.4.patch
File 32197.4.patch, 4.3 KB (added by , 10 years ago) |
---|
-
src/wp-admin/css/edit.css
380 380 position: relative; 381 381 } 382 382 383 #content-textarea-clone {384 z-index: -1;385 position: absolute;386 top: 0;387 visibility: hidden;388 overflow: hidden;389 max-width: 100%;390 border: 1px solid transparent;391 }392 393 .wp-fullscreen-wrap #content-textarea-clone {394 display: none;395 }396 397 383 /* editor-expand.js override */ 398 384 .wp-fullscreen-wrap { 399 385 padding-top: 0 !important; -
src/wp-admin/js/editor-expand.js
15 15 $visualEditor = $(), 16 16 $textTop = $( '#ed_toolbar' ), 17 17 $textEditor = $( '#content' ), 18 $textEditorClone = $( '<div id="content-textarea-clone"></div>' ), 18 textEditor = $textEditor[0], 19 textEditorLength = 0, 19 20 $bottom = $( '#post-status-info' ), 20 21 $menuBar = $(), 21 22 $statusBar = $(), … … 52 53 sideSortablesHeight: 0 53 54 }; 54 55 55 $textEditorClone.insertAfter( $textEditor );56 57 $textEditorClone.css( {58 'font-family': $textEditor.css( 'font-family' ),59 'font-size': $textEditor.css( 'font-size' ),60 'line-height': $textEditor.css( 'line-height' ),61 'white-space': 'pre-wrap',62 'word-wrap': 'break-word'63 } );64 65 56 function getHeights() { 66 57 var windowWidth = $window.width(); 67 58 … … 84 75 } 85 76 } 86 77 87 function textEditorKeyup( event ) {88 var VK = jQuery.ui.keyCode,89 key = event.keyCode,90 range = document.createRange(),91 selStart = $textEditor[0].selectionStart,92 selEnd = $textEditor[0].selectionEnd,93 textNode = $textEditorClone[0].firstChild,94 buffer = 10,95 offset, cursorTop, cursorBottom, editorTop, editorBottom;96 97 if ( selStart && selEnd && selStart !== selEnd ) {98 return;99 }100 101 // These are not TinyMCE ranges.102 try {103 range.setStart( textNode, selStart );104 range.setEnd( textNode, selEnd + 1 );105 } catch ( ex ) {}106 107 offset = range.getBoundingClientRect();108 109 if ( ! offset.height ) {110 return;111 }112 113 cursorTop = offset.top - buffer;114 cursorBottom = cursorTop + offset.height + buffer;115 editorTop = heights.adminBarHeight + heights.toolsHeight + heights.textTopHeight;116 editorBottom = heights.windowHeight - heights.bottomHeight;117 118 if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {119 window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );120 } else if ( cursorBottom > editorBottom ) {121 window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );122 }123 }124 125 78 function textEditorResize() { 79 var length, pageYOffset; 80 126 81 if ( ( mceEditor && ! mceEditor.isHidden() ) || ( ! mceEditor && initialMode === 'tinymce' ) ) { 127 82 return; 128 83 } 129 84 130 var textEditorHeight = $textEditor.height(), 131 hiddenHeight; 85 length = textEditor.value.length; 132 86 133 $textEditorClone.width( $textEditor.width() - 22 ); 134 $textEditorClone.text( $textEditor.val() + ' ' ); 87 if ( length !== textEditorLength ) { 88 if ( length < textEditorLength ) { 89 pageYOffset = window.pageYOffset; 90 textEditor.style.height = 'auto'; 91 } 135 92 136 hiddenHeight = $textEditorClone.height();93 textEditor.style.height = textEditor.scrollHeight + 'px'; 137 94 138 if ( hiddenHeight < autoresizeMinHeight) {139 hiddenHeight = autoresizeMinHeight;140 }95 if ( length < textEditorLength ) { 96 window.scrollTo( window.pageXOffset, pageYOffset ); 97 } 141 98 142 if ( hiddenHeight === textEditorHeight ) { 143 return; 99 adjust(); 144 100 } 145 101 146 $textEditor.height( hiddenHeight ); 147 148 adjust(); 102 textEditorLength = length; 149 103 } 150 104 151 105 // We need to wait for TinyMCE to initialize. … … 603 557 $textEditor.css( { 604 558 marginTop: heights.textTopHeight 605 559 } ); 606 607 $textEditorClone.width( contentWrapWidth - 20 - ( borderWidth * 2 ) );608 560 } 609 561 } 610 562 } … … 660 612 }); 661 613 662 614 $textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); 663 $textEditor.on( 'keyup.editor-expand', textEditorKeyup );664 615 mceBind(); 665 616 666 617 // Adjust when entering/exiting fullscreen mode.