From 78bb2a4c9b33a47927f33464a12fddeace41b035 Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Tue, 23 Jul 2024 02:11:49 +0000 Subject: [PATCH] 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. --- web/src/click_handlers.js | 13 +------------ web/src/message_edit.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/web/src/click_handlers.js b/web/src/click_handlers.js index 96ecd62eaa..621cc14e71 100644 --- a/web/src/click_handlers.js +++ b/web/src/click_handlers.js @@ -367,18 +367,7 @@ export function initialize() { $("body").on("click", ".message_edit_form .undo_markdown_preview", (e) => { e.preventDefault(); - const $row = rows.get_closest_row(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(); + message_edit.clear_preview_area(e.target); }); // RESOLVED TOPICS diff --git a/web/src/message_edit.js b/web/src/message_edit.js index 5cb68556e9..c044f1f44e 100644 --- a/web/src/message_edit.js +++ b/web/src/message_edit.js @@ -1442,3 +1442,18 @@ export function show_preview_area($element) { 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(); +}