From 2e072affb50b4c119af4de20fa7cdb7081df73f8 Mon Sep 17 00:00:00 2001 From: Baptiste Gelez Date: Tue, 30 Oct 2018 18:16:24 +0100 Subject: [PATCH] Fix editor auto-expansion (#293) --- static/js/autoExpand.js | 14 ++++++-------- templates/posts/details.html.tera | 4 ++-- templates/posts/new.html.tera | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/static/js/autoExpand.js b/static/js/autoExpand.js index fbc25e82..e9b42b5e 100644 --- a/static/js/autoExpand.js +++ b/static/js/autoExpand.js @@ -1,9 +1,7 @@ -function autosize () { - const el = this - el.style.height = 'auto' - el.style.height = `${el.scrollHeight}px` -} +const articleContent = document.querySelector('#plume-editor') +const offset = articleContent.offsetHeight - articleContent.clientHeight -const articleContent = document.querySelector('#content') -autosize.bind(articleContent)() -articleContent.addEventListener('keyup', autosize) +articleContent.addEventListener('keydown', () => { + articleContent.style.height = 'auto' + articleContent.style.height = `${articleContent.scrollHeight - offset}px` +}) diff --git a/templates/posts/details.html.tera b/templates/posts/details.html.tera index aa7b16f8..0a96869e 100644 --- a/templates/posts/details.html.tera +++ b/templates/posts/details.html.tera @@ -104,12 +104,12 @@ {% if account %}
- + {% if previous %} {% endif %} {# Ugly, but we don't have the choice if we don't want weird paddings #} - +
{% endif %} diff --git a/templates/posts/new.html.tera b/templates/posts/new.html.tera index e8b4d701..6589de87 100644 --- a/templates/posts/new.html.tera +++ b/templates/posts/new.html.tera @@ -27,8 +27,8 @@ {% endfor %} {% endif %} - - + + {{ macros::input(name="tags", label="Tags, separated by commas", errors=errors, form=form, optional=true) }}