Editor: autoresize fixes for text
* Resize on backspace. * Don't make it smaller than the minimum height. Props azaozz, iseulde. See #36482. Built from https://develop.svn.wordpress.org/trunk@37603 git-svn-id: http://core.svn.wordpress.org/trunk@37571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6d583100d1
commit
6b4662ab96
|
@ -1 +1 @@
|
||||||
(function(a,b,c,d){function e(a,c){if("undefined"!=typeof c){var d=b.createElement("input");d.name=a,d.value=c,d.type="hidden",p.appendChild(d)}}var f,g,h,i,j,k,l,m,n,o=a.encodeURIComponent,p=b.createElement("form"),q=b.getElementsByTagName("head")[0],r="_press_this_app",s=!0;if(d){if(!c.match(/^https?:/))return void(top.location.href=d);if(d+="&u="+o(c),c.match(/^https:/)&&d.match(/^http:/)&&(s=!1),a.getSelection?h=a.getSelection()+"":b.getSelection?h=b.getSelection()+"":b.selection&&(h=b.selection.createRange().text||""),d+="&buster="+(new Date).getTime(),s||(b.title&&(d+="&t="+o(b.title.substr(0,256))),h&&(d+="&s="+o(h.substr(0,512)))),f=a.outerWidth||b.documentElement.clientWidth||600,g=a.outerHeight||b.documentElement.clientHeight||700,f=800>f||f>5e3?600:.7*f,g=800>g||g>3e3?700:.9*g,!s)return void a.open(d,r,"location,resizable,scrollbars,width="+f+",height="+g);i=q.getElementsByTagName("meta")||[];for(var t=0;t<i.length&&!(t>200);t++){var u=i[t],v=u.getAttribute("name"),w=u.getAttribute("property"),x=u.getAttribute("content");x&&(v?e("_meta["+v+"]",x):w&&e("_meta["+w+"]",x))}j=q.getElementsByTagName("link")||[];for(var y=0;y<j.length&&!(y>=50);y++){var z=j[y],A=z.getAttribute("rel");("canonical"===A||"icon"===A||"shortlink"===A)&&e("_links["+A+"]",z.getAttribute("href"))}b.body.getElementsByClassName&&(k=b.body.getElementsByClassName("hfeed")[0]),k=b.getElementById("content")||k||b.body,l=k.getElementsByTagName("img")||[];for(var B=0;B<l.length&&!(B>=100);B++)n=l[B],n.src.indexOf("avatar")>-1||n.className.indexOf("avatar")>-1||n.width&&n.width<256||n.height&&n.height<128||e("_images[]",n.src);m=b.body.getElementsByTagName("iframe")||[];for(var C=0;C<m.length&&!(C>=50);C++)e("_embeds[]",m[C].src);b.title&&e("t",b.title),h&&e("s",h),p.setAttribute("method","POST"),p.setAttribute("action",d),p.setAttribute("target",r),p.setAttribute("style","display: none;"),a.open("about:blank",r,"location,resizable,scrollbars,width="+f+",height="+g),b.body.appendChild(p),p.submit()}})(window,document,top.location.href,window.pt_url);
|
(function(a,b,c,d){function e(a,c){if("undefined"!=typeof c){var d=b.createElement("input");d.name=a,d.value=c,d.type="hidden",p.appendChild(d)}}var f,g,h,i,j,k,l,m,n,o=a.encodeURIComponent,p=b.createElement("form"),q=b.getElementsByTagName("head")[0],r="_press_this_app",s=!0;if(d){if(!c.match(/^https?:/))return void(top.location.href=d);if(d+="&u="+o(c),c.match(/^https:/)&&d.match(/^http:/)&&(s=!1),a.getSelection?h=a.getSelection()+"":b.getSelection?h=b.getSelection()+"":b.selection&&(h=b.selection.createRange().text||""),d+="&buster="+(new Date).getTime(),s||(b.title&&(d+="&t="+o(b.title.substr(0,256))),h&&(d+="&s="+o(h.substr(0,512)))),f=a.outerWidth||b.documentElement.clientWidth||600,g=a.outerHeight||b.documentElement.clientHeight||700,f=800>f||f>5e3?600:.7*f,g=800>g||g>3e3?700:.9*g,!s)return void a.open(d,r,"location,resizable,scrollbars,width="+f+",height="+g);i=q.getElementsByTagName("meta")||[];for(var t=0;t<i.length&&!(t>200);t++){var u=i[t],v=u.getAttribute("name"),w=u.getAttribute("property"),x=u.getAttribute("content");x&&(v?e("_meta["+v+"]",x):w&&e("_meta["+w+"]",x))}j=q.getElementsByTagName("link")||[];for(var y=0;y<j.length&&!(y>=50);y++){var z=j[y],A=z.getAttribute("rel");"canonical"!==A&&"icon"!==A&&"shortlink"!==A||e("_links["+A+"]",z.getAttribute("href"))}b.body.getElementsByClassName&&(k=b.body.getElementsByClassName("hfeed")[0]),k=b.getElementById("content")||k||b.body,l=k.getElementsByTagName("img")||[];for(var B=0;B<l.length&&!(B>=100);B++)n=l[B],n.src.indexOf("avatar")>-1||n.className.indexOf("avatar")>-1||n.width&&n.width<256||n.height&&n.height<128||e("_images[]",n.src);m=b.body.getElementsByTagName("iframe")||[];for(var C=0;C<m.length&&!(C>=50);C++)e("_embeds[]",m[C].src);b.title&&e("t",b.title),h&&e("s",h),p.setAttribute("method","POST"),p.setAttribute("action",d),p.setAttribute("target",r),p.setAttribute("style","display: none;"),a.open("about:blank",r,"location,resizable,scrollbars,width="+f+",height="+g),b.body.appendChild(p),p.submit()}})(window,document,top.location.href,window.pt_url);
|
|
@ -16,7 +16,7 @@
|
||||||
$textTop = $( '#ed_toolbar' ),
|
$textTop = $( '#ed_toolbar' ),
|
||||||
$textEditor = $( '#content' ),
|
$textEditor = $( '#content' ),
|
||||||
textEditor = $textEditor[0],
|
textEditor = $textEditor[0],
|
||||||
textEditorLength = 0,
|
oldTextLength = 0,
|
||||||
$bottom = $( '#post-status-info' ),
|
$bottom = $( '#post-status-info' ),
|
||||||
$menuBar = $(),
|
$menuBar = $(),
|
||||||
$statusBar = $(),
|
$statusBar = $(),
|
||||||
|
@ -76,8 +76,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function textEditorResize() {
|
function textEditorResize() {
|
||||||
var reduce, scrollHeight;
|
|
||||||
|
|
||||||
if ( mceEditor && ! mceEditor.isHidden() ) {
|
if ( mceEditor && ! mceEditor.isHidden() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -86,17 +84,28 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reduce = textEditorLength > ( textEditorLength = textEditor.value.length );
|
var length = textEditor.value.length;
|
||||||
scrollHeight = textEditor.scrollHeight;
|
var height = parseInt( textEditor.style.height, 10 );
|
||||||
|
|
||||||
if ( reduce ) {
|
if ( length < oldTextLength ) {
|
||||||
|
// textEditor.scrollHeight is not adjusted until the next line.
|
||||||
textEditor.style.height = 'auto';
|
textEditor.style.height = 'auto';
|
||||||
textEditor.style.height = scrollHeight + 'px';
|
|
||||||
adjust();
|
if ( textEditor.scrollHeight >= autoresizeMinHeight ) {
|
||||||
} else if ( parseInt( textEditor.style.height, 10 ) < scrollHeight ) {
|
textEditor.style.height = textEditor.scrollHeight + 'px';
|
||||||
textEditor.style.height = scrollHeight + 'px';
|
} else {
|
||||||
|
textEditor.style.height = autoresizeMinHeight + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( textEditor.scrollHeight < height ) {
|
||||||
adjust();
|
adjust();
|
||||||
}
|
}
|
||||||
|
} else if ( height < textEditor.scrollHeight ) {
|
||||||
|
textEditor.style.height = textEditor.scrollHeight + 'px';
|
||||||
|
adjust();
|
||||||
|
}
|
||||||
|
|
||||||
|
oldTextLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to wait for TinyMCE to initialize.
|
// We need to wait for TinyMCE to initialize.
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.6-alpha-37602';
|
$wp_version = '4.6-alpha-37603';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue