<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29279] trunk/src: Editor scrolling:</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/29279">29279</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2014-07-24 01:32:29 +0000 (Thu, 24 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Editor scrolling:
- Improve TinyMCE resizing when a floated block is at the end of the content.
- Improve setting the padding/margin under the toolbar on loading.
- Add custom event on TinyMCE resizing and use it to adjust the pinning (if needed).
Part props avryl, see <a href="http://core.trac.wordpress.org/ticket/28328">#28328</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsseditcss">trunk/src/wp-admin/css/edit.css</a></li>
<li><a href="#trunksrcwpadminjseditorexpandjs">trunk/src/wp-admin/js/editor-expand.js</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswpautoresizepluginjs">trunk/src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsseditcss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/edit.css (29278 => 29279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/edit.css  2014-07-23 22:08:17 UTC (rev 29278)
+++ trunk/src/wp-admin/css/edit.css     2014-07-24 01:32:29 UTC (rev 29279)
</span><span class="lines">@@ -378,6 +378,24 @@
</span><span class="cx">  overflow: hidden;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.wp-fullscreen-wrap #content-textarea-clone {
+       display: none;
+}
+
+/* editor-expand.js override */
+.wp-fullscreen-wrap {
+       padding-top: 0 !important;
+}
+
+.wp-fullscreen-wrap .wp-editor-area {
+       margin-top: 0 !important;
+}
+
+.wp-fullscreen-wrap .mce-edit-area {
+       padding-top: 0 !important;
+}
+/* end editor-expand.js override */
+
</ins><span class="cx"> #timestampdiv select {
</span><span class="cx">  height: 21px;
</span><span class="cx">  line-height: 14px;
</span></span></pre></div>
<a id="trunksrcwpadminjseditorexpandjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/editor-expand.js (29278 => 29279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/editor-expand.js   2014-07-23 22:08:17 UTC (rev 29278)
+++ trunk/src/wp-admin/js/editor-expand.js      2014-07-24 01:32:29 UTC (rev 29279)
</span><span class="lines">@@ -41,20 +41,26 @@
</span><span class="cx">          textEditorResize();
</span><span class="cx">  } );
</span><span class="cx"> 
</span><del>-       $textEditor.on( 'keyup', function() {
-               var range = document.createRange(),
-                       start = $textEditor[0].selectionStart,
-                       end = $textEditor[0].selectionEnd,
</del><ins>+        $textEditor.on( 'keyup', function( event ) {
+               var VK = jQuery.ui.keyCode,
+                       key = event.keyCode,
+                       range = document.createRange(),
+                       selStart = $textEditor[0].selectionStart,
+                       selEnd = $textEditor[0].selectionEnd,
</ins><span class="cx">                   textNode = $textEditorClone[0].firstChild,
</span><span class="cx">                  windowHeight = $window.height(),
</span><ins>+                       buffer = 10,
</ins><span class="cx">                   offset, cursorTop, cursorBottom, editorTop, editorBottom;
</span><span class="cx"> 
</span><del>-               if ( start && end && start !== end ) {
</del><ins>+                if ( selStart && selEnd && selStart !== selEnd ) {
</ins><span class="cx">                   return;
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               range.setStart( textNode, start );
-               range.setEnd( textNode, end + 1 );
</del><ins>+                // These are not TinyMCE ranges.
+               try {
+                       range.setStart( textNode, selStart );
+                       range.setEnd( textNode, selEnd + 1 );
+               } catch ( ex ) {}
</ins><span class="cx"> 
</span><span class="cx">          offset = range.getBoundingClientRect();
</span><span class="cx"> 
</span><span class="lines">@@ -62,13 +68,15 @@
</span><span class="cx">                  return;
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               cursorTop = offset.top;
-               cursorBottom = cursorTop + offset.height;
-               editorTop = $adminBar.outerHeight() + $textTop.outerHeight();
</del><ins>+                cursorTop = offset.top - buffer;
+               cursorBottom = cursorTop + offset.height + buffer;
+               editorTop = $adminBar.outerHeight() + $tools.outerHeight() + $textTop.outerHeight();
</ins><span class="cx">           editorBottom = windowHeight - $bottom.outerHeight();
</span><span class="cx"> 
</span><del>-               if ( cursorTop < editorTop || cursorBottom > editorBottom ) {
-                       window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - windowHeight / 2 );
</del><ins>+                if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
+                       window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
+               } else if ( cursorBottom > editorBottom ) {
+                       window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
</ins><span class="cx">           }
</span><span class="cx">  } );
</span><span class="cx"> 
</span><span class="lines">@@ -77,9 +85,14 @@
</span><span class="cx">                  return;
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               var hiddenHeight = $textEditorClone.width( $textEditor.width() ).text( $textEditor.val() + '&nbsp;' ).height(),
-                       textEditorHeight = $textEditor.height();
</del><ins>+                var textEditorHeight = $textEditor.height(),
+                       hiddenHeight;
</ins><span class="cx"> 
</span><ins>+               $textEditorClone.width( $textEditor.width() );
+               $textEditorClone.text( $textEditor.val() + '&nbsp;' );
+
+               hiddenHeight = $textEditorClone.height();
+
</ins><span class="cx">           if ( hiddenHeight < 300 ) {
</span><span class="cx">                  hiddenHeight = 300;
</span><span class="cx">          }
</span><span class="lines">@@ -90,7 +103,7 @@
</span><span class="cx"> 
</span><span class="cx">          $textEditor.height( hiddenHeight );
</span><span class="cx"> 
</span><del>-               adjust( 'resize' );
</del><ins>+                adjust();
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  // We need to wait for TinyMCE to initialize.
</span><span class="lines">@@ -103,9 +116,6 @@
</span><span class="cx">          // Copy the editor instance.
</span><span class="cx">          editorInstance = editor;
</span><span class="cx"> 
</span><del>-               // Resizing will be handled by the autoresize plugin.
-               editor.theme.resizeTo = function() {};
-
</del><span class="cx">           // Set the minimum height to the initial viewport height.
</span><span class="cx">          editor.settings.autoresize_min_height = 300;
</span><span class="cx"> 
</span><span class="lines">@@ -118,8 +128,8 @@
</span><span class="cx">          editor.on( 'show', function() {
</span><span class="cx">                  setTimeout( function() {
</span><span class="cx">                          editor.execCommand( 'wpAutoResize' );
</span><del>-                               adjust( 'resize' );
-                       }, 200 );
</del><ins>+                                adjust();
+                       }, 300 );
</ins><span class="cx">           } );
</span><span class="cx"> 
</span><span class="cx">          // Make sure the cursor is always visible.
</span><span class="lines">@@ -195,58 +205,21 @@
</span><span class="cx"> 
</span><span class="cx">          editor.on( 'hide', function() {
</span><span class="cx">                  textEditorResize();
</span><del>-                       adjust( 'resize' );
</del><ins>+                        adjust();
</ins><span class="cx">           } );
</span><span class="cx"> 
</span><span class="cx">          // Adjust when the editor resizes.
</span><del>-               editor.on( 'nodechange setcontent keyup FullscreenStateChanged', function() {
-                       adjust( 'resize' );
</del><ins>+                editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', function() {
+                       adjust();
</ins><span class="cx">           } );
</span><span class="cx"> 
</span><del>-               editor.on( 'wp-toolbar-toggle', function() {
-                       $visualEditor.css( {
-                               paddingTop: $visualTop.outerHeight()
-                       } );
-               } );
-
</del><span class="cx">           // And adjust "immediately".
</span><span class="cx">          // Allow some time to load CSS etc.
</span><del>-               setTimeout( function() {
-                       $visualEditor.css( {
-                               paddingTop: $visualTop.outerHeight()
-                       } );
-
-                       adjust( 'resize' );
-               }, 500 );
</del><ins>+                initialResize( adjust );
</ins><span class="cx">   } );
</span><span class="cx"> 
</span><del>-       // Adjust when the window is scrolled or resized.
-       $window.on( 'scroll resize', function( event ) {
-               adjust( event.type );
-       } );
-
-       // Adjust when exiting fullscreen mode.
-       fullscreen && fullscreen.pubsub.subscribe( 'hidden', function() {
-               adjust( 'resize' );
-       } );
-
-       // Adjust when collapsing the menu.
-       $document.on( 'wp-collapse-menu.editor-expand', function() {
-               adjust( 'resize' );
-       } )
-
-       // Adjust when changing the columns.
-       .on( 'postboxes-columnchange.editor-expand', function() {
-               adjust( 'resize' );
-       } )
-
-       // Adjust when changing the body class.
-       .on( 'editor-classchange.editor-expand', function() {
-               adjust( 'resize' );
-       } );
-
</del><span class="cx">   // Adjust the toolbars based on the active editor mode.
</span><del>-       function adjust( eventType ) {
</del><ins>+        function adjust( type ) {
</ins><span class="cx">           // Make sure we're not in fullscreen mode.
</span><span class="cx">          if ( fullscreen && fullscreen.settings.visible ) {
</span><span class="cx">                  return;
</span><span class="lines">@@ -257,22 +230,14 @@
</span><span class="cx">                  windowHeight = $window.height(),
</span><span class="cx">                  windowWidth = $window.width(),
</span><span class="cx">                  adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0,
</span><del>-                       $top, $editor, visual,
</del><ins>+                        resize = type !== 'scroll',
+                       visual = ( editorInstance && ! editorInstance.isHidden() ),
+                       $top, $editor,
</ins><span class="cx">                   toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight;
</span><span class="cx"> 
</span><del>-               // Visual editor.
-               if ( editorInstance && ! editorInstance.isHidden() ) {
</del><ins>+                if ( visual ) {
</ins><span class="cx">                   $top = $visualTop;
</span><span class="cx">                  $editor = $visualEditor;
</span><del>-                       visual = true;
-
-                       // Doesn't hide the panel of 'styleselect'. :(
-                       tinymce.each( editorInstance.controlManager.buttons, function( button ) {
-                               if ( button._active && ( button.type === 'colorbutton' || button.type === 'panelbutton' || button.type === 'menubutton' ) ) {
-                                       button.hidePanel();
-                               }
-                       } );
-               // Text editor.
</del><span class="cx">           } else {
</span><span class="cx">                  $top = $textTop;
</span><span class="cx">                  $editor = $textEditor;
</span><span class="lines">@@ -287,7 +252,7 @@
</span><span class="cx">          statusBarHeight = visual ? $statusBar.outerHeight() : 0;
</span><span class="cx"> 
</span><span class="cx">          // Maybe pin the top.
</span><del>-               if ( ( ! fixedTop || eventType === 'resize' ) &&
</del><ins>+                if ( ( ! fixedTop || resize ) &&
</ins><span class="cx">                           // Handle scrolling down.
</span><span class="cx">                          ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) &&
</span><span class="cx">                          // Handle scrolling up.
</span><span class="lines">@@ -307,7 +272,7 @@
</span><span class="cx">                          width: editorWidth + 2
</span><span class="cx">                  } );
</span><span class="cx">          // Maybe unpin the top.
</span><del>-               } else if ( fixedTop || eventType === 'resize' ) {
</del><ins>+                } else if ( fixedTop || resize ) {
</ins><span class="cx">                   // Handle scrolling up.
</span><span class="cx">                  if ( windowPos <= ( topPos - toolsHeight -  adminBarHeight ) ) {
</span><span class="cx">                          fixedTop = false;
</span><span class="lines">@@ -342,7 +307,7 @@
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          // Maybe adjust the bottom bar.
</span><del>-               if ( ( ! fixedBottom || eventType === 'resize' ) &&
</del><ins>+                if ( ( ! fixedBottom || resize ) &&
</ins><span class="cx">                           // + 1 for the border around the .wp-editor-container.
</span><span class="cx">                          ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1 ) ) {
</span><span class="cx">                  fixedBottom = true;
</span><span class="lines">@@ -353,7 +318,7 @@
</span><span class="cx">                          width: editorWidth + 2,
</span><span class="cx">                          borderTop: '1px solid #dedede'
</span><span class="cx">                  } );
</span><del>-               } else if ( fixedBottom &&
</del><ins>+                } else if ( ( fixedBottom || resize ) &&
</ins><span class="cx">                           ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1 ) ) {
</span><span class="cx">                  fixedBottom = false;
</span><span class="cx"> 
</span><span class="lines">@@ -364,24 +329,50 @@
</span><span class="cx">                          borderTop: 'none'
</span><span class="cx">                  } );
</span><span class="cx">          }
</span><ins>+
+               if ( resize ) {
+                       $contentWrap.css( {
+                               paddingTop: $tools.outerHeight()
+                       } );
+
+                       if ( visual ) {
+                               $visualEditor.css( {
+                                       paddingTop: $visualTop.outerHeight()
+                               } );
+                       } else {
+                               $textEditor.css( {
+                                       marginTop: $textTop.outerHeight()
+                               } );
+                               $textEditorClone.width( $textEditor.width() );
+                       }
+               }
</ins><span class="cx">   }
</span><span class="cx"> 
</span><del>-       textEditorResize();
</del><ins>+        function initialResize( callback ) {
+               for ( var i = 1; i < 6; i++ ) {
+                       setTimeout( callback, 500 * i );
+               }
+       }
</ins><span class="cx"> 
</span><del>-       $tools.css( {
-               position: 'absolute',
-               top: 0,
-               width: $contentWrap.width()
</del><ins>+        // Adjust when the window is scrolled or resized.
+       $window.on( 'scroll.editor-expand resize.editor-expand', function( event ) {
+               adjust( event.type );
</ins><span class="cx">   } );
</span><span class="cx"> 
</span><del>-       $contentWrap.css( {
-               paddingTop: $tools.outerHeight()
</del><ins>+        // Adjust when entering/exiting fullscreen mode.
+       fullscreen && fullscreen.pubsub.subscribe( 'hidden', function() {
+               textEditorResize();
+               adjust();
</ins><span class="cx">   } );
</span><span class="cx"> 
</span><del>-       // This needs to execute after quicktags is ready or a button is added...
-       setTimeout( function() {
-               $textEditor.css( {
-                       paddingTop: $textTop.outerHeight() + parseInt( $textEditor.css( 'padding-top' ), 10 )
</del><ins>+        // Adjust when collapsing the menu, changing the columns, changing the body class.
+       $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust );
+
+       // Ideally we need to resize just after CSS has fully loaded and QuickTags is ready.
+       if ( $contentWrap.hasClass( 'html-active' ) ) {
+               initialResize( function() {
+                       adjust();
+                       textEditorResize();
</ins><span class="cx">           } );
</span><del>-       }, 500 );
</del><ins>+        }
</ins><span class="cx"> });
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswpautoresizepluginjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js (29278 => 29279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js  2014-07-23 22:08:17 UTC (rev 29278)
+++ trunk/src/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js     2014-07-24 01:32:29 UTC (rev 29279)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx">                  return;
</span><span class="cx">          }
</span><span class="cx"> 
</span><ins>+               e = e || {};
</ins><span class="cx">           body = doc.body;
</span><span class="cx">          docElm = doc.documentElement;
</span><span class="cx">          resizeHeight = settings.autoresize_min_height;
</span><span class="lines">@@ -60,6 +61,11 @@
</span><span class="cx">          marginBottom = editor.dom.getStyle( body, 'margin-bottom', true );
</span><span class="cx">          myHeight = body.offsetHeight + parseInt( marginTop, 10 ) + parseInt( marginBottom, 10 );
</span><span class="cx"> 
</span><ins>+               // IE < 11, other?
+               if ( myHeight && myHeight < docElm.offsetHeight ) {
+                       myHeight = docElm.offsetHeight;
+               }
+
</ins><span class="cx">           // Make sure we have a valid height
</span><span class="cx">          if ( isNaN( myHeight ) || myHeight <= 0 ) {
</span><span class="cx">                  // Get height differently depending on the browser used
</span><span class="lines">@@ -93,6 +99,8 @@
</span><span class="cx">                  if ( tinymce.isWebKit && deltaSize < 0 ) {
</span><span class="cx">                          resize( e );
</span><span class="cx">                  }
</span><ins>+
+                       editor.fire( 'wp-autoresize', { height: resizeHeight } );
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -102,7 +110,7 @@
</span><span class="cx">   */
</span><span class="cx">  function wait( times, interval, callback ) {
</span><span class="cx">          setTimeout( function() {
</span><del>-                       resize({});
</del><ins>+                        resize();
</ins><span class="cx"> 
</span><span class="cx">                  if ( times-- ) {
</span><span class="cx">                          wait( times, interval, callback );
</span><span class="lines">@@ -123,14 +131,20 @@
</span><span class="cx">                  editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
</span><span class="cx">                  // Add appropriate listeners for resizing the content area
</span><span class="cx">                  editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
</span><ins>+                       resize();
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  function off() {
</span><ins>+               var doc;
+
</ins><span class="cx">           // Don't turn off if the setting is 'on'
</span><span class="cx">          if ( ! settings.wp_autoresize_on ) {
</span><ins>+                       doc = editor.getDoc();
</ins><span class="cx">                   editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
</span><span class="cx">                  editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
</span><ins>+                       doc.body.style.overflowY = 'auto';
+                       doc.documentElement.style.overflowY = 'auto'; // Old IE
</ins><span class="cx">                   oldSize = 0;
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="lines">@@ -158,6 +172,11 @@
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><ins>+       // Reset the stored size
+       editor.on( 'show', function() {
+               oldSize = 0;
+       });
+
</ins><span class="cx">   // Register the command
</span><span class="cx">  editor.addCommand( 'wpAutoResize', resize );
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>