mirror of https://github.com/zulip/zulip.git
refactor: Extract new function `show_preview_area` for the compose box.
The code responsible for switching from edit mode to preview mode from `compose_setup.js` is now extracted into a new function in `compose.js`, to facilitate reuse. This is a prep commit for introducing a hotkey to toggle between edit and preview mode for the compose box.
This commit is contained in:
parent
a53aee714d
commit
536ab78587
|
@ -58,6 +58,26 @@ export function clear_preview_area() {
|
|||
$("#compose .preview_mode_disabled .compose_control_button").attr("tabindex", 0);
|
||||
}
|
||||
|
||||
export function show_preview_area() {
|
||||
// Disable unneeded compose_control_buttons as we don't
|
||||
// need them in preview mode.
|
||||
$("#compose").addClass("preview_mode");
|
||||
$("#compose .preview_mode_disabled .compose_control_button").attr("tabindex", -1);
|
||||
|
||||
const content = $("textarea#compose-textarea").val();
|
||||
$("textarea#compose-textarea").hide();
|
||||
$("#compose .markdown_preview").hide();
|
||||
$("#compose .undo_markdown_preview").show();
|
||||
$("#compose .undo_markdown_preview").trigger("focus");
|
||||
$("#compose .preview_message_area").show();
|
||||
|
||||
render_and_show_preview(
|
||||
$("#compose .markdown_preview_spinner"),
|
||||
$("#compose .preview_content"),
|
||||
content,
|
||||
);
|
||||
}
|
||||
|
||||
export function create_message_object() {
|
||||
// Topics are optional, and we provide a placeholder if one isn't given.
|
||||
let topic = compose_state.topic();
|
||||
|
|
|
@ -389,23 +389,7 @@ export function initialize() {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Disable unneeded compose_control_buttons as we don't
|
||||
// need them in preview mode.
|
||||
$("#compose").addClass("preview_mode");
|
||||
$("#compose .preview_mode_disabled .compose_control_button").attr("tabindex", -1);
|
||||
|
||||
const content = $("textarea#compose-textarea").val();
|
||||
$("textarea#compose-textarea").hide();
|
||||
$("#compose .markdown_preview").hide();
|
||||
$("#compose .undo_markdown_preview").show();
|
||||
$("#compose .undo_markdown_preview").trigger("focus");
|
||||
$("#compose .preview_message_area").show();
|
||||
|
||||
compose.render_and_show_preview(
|
||||
$("#compose .markdown_preview_spinner"),
|
||||
$("#compose .preview_content"),
|
||||
content,
|
||||
);
|
||||
compose.show_preview_area();
|
||||
});
|
||||
|
||||
$("#compose").on("click", ".undo_markdown_preview", (e) => {
|
||||
|
|
Loading…
Reference in New Issue