Changeset 37596
- Timestamp:
- 05/30/2016 08:31:57 PM (10 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 2 edited
-
css/edit.css (modified) (1 diff)
-
js/editor-expand.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/edit.css
r37439 r37596 376 376 #wp-content-editor-container { 377 377 position: relative; 378 }379 380 #content-textarea-clone {381 z-index: -1;382 position: absolute;383 top: 0;384 visibility: hidden;385 overflow: hidden;386 max-width: 100%;387 border: 1px solid transparent;388 378 } 389 379 -
trunk/src/wp-admin/js/editor-expand.js
r37003 r37596 16 16 $textTop = $( '#ed_toolbar' ), 17 17 $textEditor = $( '#content' ), 18 $textEditorClone = $( '<div id="content-textarea-clone" class="wp-exclude-emoji"></div>' ), 18 textEditor = $textEditor[0], 19 textEditorLength = 0, 19 20 $bottom = $( '#post-status-info' ), 20 21 $menuBar = $(), … … 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(); … … 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 ) { 78 function textEditorResize() { 79 var reduce, scrollHeight; 80 81 if ( mceEditor && ! mceEditor.isHidden() ) { 98 82 return; 99 83 } 100 84 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 ) { 85 if ( ! mceEditor && initialMode === 'tinymce' ) { 110 86 return; 111 87 } 112 88 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 function textEditorResize() { 126 if ( ( mceEditor && ! mceEditor.isHidden() ) || ( ! mceEditor && initialMode === 'tinymce' ) ) { 127 return; 128 } 129 130 var textEditorHeight = $textEditor.height(), 131 hiddenHeight; 132 133 $textEditorClone.width( $textEditor.width() - 22 ); 134 $textEditorClone.text( $textEditor.val() + ' ' ); 135 136 hiddenHeight = $textEditorClone.height(); 137 138 if ( hiddenHeight < autoresizeMinHeight ) { 139 hiddenHeight = autoresizeMinHeight; 140 } 141 142 if ( hiddenHeight === textEditorHeight ) { 143 return; 144 } 145 146 $textEditor.height( hiddenHeight ); 147 148 adjust(); 89 reduce = textEditorLength > ( textEditorLength = textEditor.value.length ); 90 scrollHeight = textEditor.scrollHeight; 91 92 if ( reduce ) { 93 textEditor.style.height = 'auto'; 94 textEditor.style.height = scrollHeight + 'px'; 95 adjust(); 96 } else if ( parseInt( textEditor.style.height, 10 ) < scrollHeight ) { 97 textEditor.style.height = scrollHeight + 'px'; 98 adjust(); 99 } 149 100 } 150 101 … … 475 426 if ( event && event.deltaHeight > 0 && event.deltaHeight < 100 ) { 476 427 window.scrollBy( 0, event.deltaHeight ); 477 } else if ( advanced ) {428 } else if ( visual && advanced ) { 478 429 fixedBottom = true; 479 430 … … 604 555 marginTop: heights.textTopHeight 605 556 } ); 606 607 $textEditorClone.width( contentWrapWidth - 20 - ( borderWidth * 2 ) );608 557 } 609 558 } … … 661 610 662 611 $textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); 663 $textEditor.on( 'keyup.editor-expand', textEditorKeyup );664 612 mceBind(); 665 613
Note: See TracChangeset
for help on using the changeset viewer.