52
53
sideSortablesHeight: 0
55
$textEditorClone.insertAfter( $textEditor );
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'
65
56
function getHeights() {
66
57
var windowWidth = $window.width();
87
function textEditorKeyup( event ) {
88
var VK = jQuery.ui.keyCode,
90
range = document.createRange(),
91
selStart = $textEditor[0].selectionStart,
92
selEnd = $textEditor[0].selectionEnd,
93
textNode = $textEditorClone[0].firstChild,
95
offset, cursorTop, cursorBottom, editorTop, editorBottom;
97
if ( selStart && selEnd && selStart !== selEnd ) {
101
// These are not TinyMCE ranges.
103
range.setStart( textNode, selStart );
104
range.setEnd( textNode, selEnd + 1 );
107
offset = range.getBoundingClientRect();
109
if ( ! offset.height ) {
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;
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 );
125
78
function textEditorResize() {
126
if ( ( mceEditor && ! mceEditor.isHidden() ) || ( ! mceEditor && initialMode === 'tinymce' ) ) {
130
var textEditorHeight = $textEditor.height(),
133
$textEditorClone.width( $textEditor.width() - 22 );
134
$textEditorClone.text( $textEditor.val() + ' ' );
136
hiddenHeight = $textEditorClone.height();
138
if ( hiddenHeight < autoresizeMinHeight ) {
139
hiddenHeight = autoresizeMinHeight;
142
if ( hiddenHeight === textEditorHeight ) {
146
$textEditor.height( hiddenHeight );
79
if ( mceEditor && ! mceEditor.isHidden() ) {
83
if ( ! mceEditor && initialMode === 'tinymce' ) {
87
var length = textEditor.value.length;
88
var height = parseInt( textEditor.style.height, 10 );
89
var top = window.scrollTop;
91
if ( length < oldTextLength ) {
92
// textEditor.scrollHeight is not adjusted until the next line.
93
textEditor.style.height = 'auto';
95
if ( textEditor.scrollHeight > autoresizeMinHeight ) {
96
textEditor.style.height = textEditor.scrollHeight + 'px';
98
textEditor.style.height = autoresizeMinHeight + 'px';
101
// Prevent scroll-jumping in Firefox and IE.
102
window.scrollTop = top;
104
if ( textEditor.scrollHeight < height ) {
107
} else if ( height < textEditor.scrollHeight ) {
108
textEditor.style.height = textEditor.scrollHeight + 'px';
112
oldTextLength = length;
151
115
// We need to wait for TinyMCE to initialize.
643
605
// Adjust when collapsing the menu, changing the columns, changing the body class.
644
606
$document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust )
645
.on( 'postbox-toggled.editor-expand', function() {
607
.on( 'postbox-toggled.editor-expand postbox-moved.editor-expand', function() {
646
608
if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > pinnedToolsTop ) {
647
609
fixedSideBottom = true;
648
610
window.scrollBy( 0, -1 );