admin: post editing: automatically set textarea height
This commit is contained in:
parent
3e3c14ce59
commit
dbca0698bf
@ -6,6 +6,7 @@ function AdminWriteEditForm(opts) {
|
||||
this.form = document.forms[this.isPage() ? 'pageForm' : 'postForm'];
|
||||
this.previewTimeout = null;
|
||||
this.previewRequest = null;
|
||||
this.firstPreviewShowDone = false;
|
||||
this.tocByLang = {};
|
||||
|
||||
if (!this.isEditing() && this.isPost()) {
|
||||
@ -91,7 +92,17 @@ extend(AdminWriteEditForm.prototype, {
|
||||
if (err)
|
||||
return console.error(err);
|
||||
ge('preview_html').innerHTML = response.html;
|
||||
});
|
||||
if (!this.firstPreviewShowDone && this.isEditing() && this.isPost()) {
|
||||
window.requestAnimationFrame(function() {
|
||||
var taHeight = this.form.text.getBoundingClientRect().height;
|
||||
var blogPostHeight = ge('blog_post').getBoundingClientRect().height - 70;
|
||||
if (blogPostHeight > taHeight) {
|
||||
setStyle(this.form.text, {height: blogPostHeight + 'px'});
|
||||
}
|
||||
}.bind(this))
|
||||
this.firstPreviewShowDone = true;
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
showError: function(code, message) {
|
||||
|
@ -424,8 +424,7 @@ HTML;
|
||||
|
||||
function markdownPreview($ctx, $unsafe_html, $title) {
|
||||
return <<<HTML
|
||||
<div class="blog-post">
|
||||
<div class="blog-post">
|
||||
<div class="blog-post" id="blog_post">
|
||||
{$ctx->if_true($title, '<div class="blog-post-title"><h1>'.$title.'</h1></div>')}
|
||||
<div class="blog-post-text">{$unsafe_html}</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user