mirror of https://github.com/zulip/zulip.git
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:
parent
a527d196d7
commit
66d7e711b2
|
@ -467,7 +467,7 @@ export function quote_and_reply(opts) {
|
||||||
const fence = fenced_code.get_unused_fence(message.raw_content);
|
const fence = fenced_code.get_unused_fence(message.raw_content);
|
||||||
content += `${fence}quote\n${message.raw_content}\n${fence}`;
|
content += `${fence}quote\n${message.raw_content}\n${fence}`;
|
||||||
compose_ui.replace_syntax("[Quoting…]", content, textarea);
|
compose_ui.replace_syntax("[Quoting…]", content, textarea);
|
||||||
autosize.update($("#compose-textarea"));
|
compose_ui.autosize_textarea($("#compose-textarea"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message && message.raw_content) {
|
if (message && message.raw_content) {
|
||||||
|
|
|
@ -51,9 +51,7 @@ export function smart_insert(textarea, syntax) {
|
||||||
textarea.caret(syntax);
|
textarea.caret(syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should just call exports.autosize_textarea, but it's a bit
|
autosize_textarea(textarea);
|
||||||
// annoying for the unit tests, so we don't do that.
|
|
||||||
autosize.update(textarea);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function insert_syntax_and_focus(syntax, textarea = $("#compose-textarea")) {
|
export function insert_syntax_and_focus(syntax, textarea = $("#compose-textarea")) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import autosize from "autosize";
|
|
||||||
import {formatISO} from "date-fns";
|
import {formatISO} from "date-fns";
|
||||||
import ConfirmDatePlugin from "flatpickr/dist/plugins/confirmDate/confirmDate";
|
import ConfirmDatePlugin from "flatpickr/dist/plugins/confirmDate/confirmDate";
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
@ -176,7 +175,7 @@ export function handle_enter(textarea, e) {
|
||||||
// Now add the newline, remembering to resize the
|
// Now add the newline, remembering to resize the
|
||||||
// textarea if needed.
|
// textarea if needed.
|
||||||
textarea.caret("\n");
|
textarea.caret("\n");
|
||||||
autosize.update(textarea);
|
compose_ui.autosize_textarea(textarea);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue