message_edit: Extract clear_preview_area from click_handlers.

We want to able to use the clear_preview_area in other places than
click_handlers and that's why it has been moved to message_edit.js.
The name was chosen to be consistent with a similar function in
compose.js.
This commit is contained in:
Shubham Padia 2024-07-23 02:11:49 +00:00 committed by Tim Abbott
parent f4704f0419
commit 78bb2a4c9b
2 changed files with 16 additions and 12 deletions

View File

@ -367,18 +367,7 @@ export function initialize() {
$("body").on("click", ".message_edit_form .undo_markdown_preview", (e) => { $("body").on("click", ".message_edit_form .undo_markdown_preview", (e) => {
e.preventDefault(); e.preventDefault();
const $row = rows.get_closest_row(e.target); message_edit.clear_preview_area(e.target);
// While in preview mode we disable unneeded compose_control_buttons,
// so here we are re-enabling those compose_control_buttons
$row.removeClass("preview_mode");
$row.find(".preview_mode_disabled .compose_control_button").attr("tabindex", 0);
$row.find(".message_edit_content").show();
$row.find(".undo_markdown_preview").hide();
$row.find(".preview_message_area").hide();
$row.find(".preview_content").empty();
$row.find(".markdown_preview").show();
}); });
// RESOLVED TOPICS // RESOLVED TOPICS

View File

@ -1442,3 +1442,18 @@ export function show_preview_area($element) {
content, content,
); );
} }
export function clear_preview_area($element) {
const $row = rows.get_closest_row($element);
// While in preview mode we disable unneeded compose_control_buttons,
// so here we are re-enabling those compose_control_buttons
$row.removeClass("preview_mode");
$row.find(".preview_mode_disabled .compose_control_button").attr("tabindex", 0);
$row.find(".message_edit_content").show();
$row.find(".undo_markdown_preview").hide();
$row.find(".preview_message_area").hide();
$row.find(".preview_content").empty();
$row.find(".markdown_preview").show();
}