mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
ts: Convert compose_textarea.js to TypeScript.
Added type definitions for `jquery-caret-plugin` third party package and converted `compose_textarea.js` to TypeScript.
This commit is contained in:
25
web/src/compose_textarea.ts
Normal file
25
web/src/compose_textarea.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import $ from "jquery";
|
||||
|
||||
// Save the compose content cursor position and restore when we
|
||||
// shift-tab back in (see hotkey.js).
|
||||
let saved_compose_cursor = 0;
|
||||
|
||||
function set_compose_textarea_handlers(): void {
|
||||
$("#compose-textarea").on("blur", function () {
|
||||
saved_compose_cursor = $(this).caret();
|
||||
});
|
||||
|
||||
// on the end of the modified-message fade in, remove the fade-in-message class.
|
||||
const animationEnd = "webkitAnimationEnd oanimationend msAnimationEnd animationend";
|
||||
$("body").on(animationEnd, ".fade-in-message", function () {
|
||||
$(this).removeClass("fade-in-message");
|
||||
});
|
||||
}
|
||||
|
||||
export function restore_compose_cursor(): void {
|
||||
$("#compose-textarea").trigger("focus").caret(saved_compose_cursor);
|
||||
}
|
||||
|
||||
export function initialize(): void {
|
||||
set_compose_textarea_handlers();
|
||||
}
|
||||
Reference in New Issue
Block a user