|
16 | 16 | $textTop = $( '#ed_toolbar' ),
|
17 | 17 | $textEditor = $( '#content' ),
|
18 | 18 | textEditor = $textEditor[0],
|
19 |
| - textEditorLength = 0, |
| 19 | + oldTextLength = 0, |
20 | 20 | $bottom = $( '#post-status-info' ),
|
21 | 21 | $menuBar = $(),
|
22 | 22 | $statusBar = $(),
|
|
76 | 76 | }
|
77 | 77 |
|
78 | 78 | function textEditorResize() {
|
79 |
| - var reduce, scrollHeight; |
80 |
| - |
81 | 79 | if ( mceEditor && ! mceEditor.isHidden() ) {
|
82 | 80 | return;
|
83 | 81 | }
|
|
86 | 84 | return;
|
87 | 85 | }
|
88 | 86 |
|
89 |
| - reduce = textEditorLength > ( textEditorLength = textEditor.value.length ); |
90 |
| - scrollHeight = textEditor.scrollHeight; |
| 87 | + var length = textEditor.value.length; |
| 88 | + var height = parseInt( textEditor.style.height, 10 ); |
91 | 89 |
|
92 |
| - if ( reduce ) { |
| 90 | + if ( length < oldTextLength ) { |
| 91 | + // textEditor.scrollHeight is not adjusted until the next line. |
93 | 92 | 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'; |
| 93 | + |
| 94 | + if ( textEditor.scrollHeight >= autoresizeMinHeight ) { |
| 95 | + textEditor.style.height = textEditor.scrollHeight + 'px'; |
| 96 | + } else { |
| 97 | + textEditor.style.height = autoresizeMinHeight + 'px'; |
| 98 | + } |
| 99 | + |
| 100 | + if ( textEditor.scrollHeight < height ) { |
| 101 | + adjust(); |
| 102 | + } |
| 103 | + } else if ( height < textEditor.scrollHeight ) { |
| 104 | + textEditor.style.height = textEditor.scrollHeight + 'px'; |
98 | 105 | adjust();
|
99 | 106 | }
|
| 107 | + |
| 108 | + oldTextLength = length; |
100 | 109 | }
|
101 | 110 |
|
102 | 111 | // We need to wait for TinyMCE to initialize.
|
|
0 commit comments