refractor: Replace manual autosize of textarea with compose_ui autosize.

This commit make compose_ui.autosize_textarea handle most of the autosize
logic of the textarea. It audits for any logic that is trying to do
autosize manually and replace it with compose_ui.autosize_textarea.
This allows to have better check for when the textarea is autosized.

Mainly done this so that we can have a check on #compose-textarea when
to autosize and when not to, thus helping to have all the logic in only
one function.
This commit is contained in:
Signior-X 2021-03-31 17:10:26 +05:30 committed by Tim Abbott
parent a527d196d7
commit 66d7e711b2
3 changed files with 3 additions and 6 deletions

View File

@ -467,7 +467,7 @@ export function quote_and_reply(opts) {
const fence = fenced_code.get_unused_fence(message.raw_content);
content += `${fence}quote\n${message.raw_content}\n${fence}`;
compose_ui.replace_syntax("[Quoting…]", content, textarea);
autosize.update($("#compose-textarea"));
compose_ui.autosize_textarea($("#compose-textarea"));
}
if (message && message.raw_content) {

View File

@ -51,9 +51,7 @@ export function smart_insert(textarea, syntax) {
textarea.caret(syntax);
}
// This should just call exports.autosize_textarea, but it's a bit
// annoying for the unit tests, so we don't do that.
autosize.update(textarea);
autosize_textarea(textarea);
}
export function insert_syntax_and_focus(syntax, textarea = $("#compose-textarea")) {

View File

@ -1,4 +1,3 @@
import autosize from "autosize";
import {formatISO} from "date-fns";
import ConfirmDatePlugin from "flatpickr/dist/plugins/confirmDate/confirmDate";
import $ from "jquery";
@ -176,7 +175,7 @@ export function handle_enter(textarea, e) {
// Now add the newline, remembering to resize the
// textarea if needed.
textarea.caret("\n");
autosize.update(textarea);
compose_ui.autosize_textarea(textarea);
e.preventDefault();
return;
}