mirror of https://github.com/zulip/zulip.git
compose: Disable unneeded control buttons in preview mode while editing.
This is a follow up to #26728, which disables buttons in preview mode for any message being edited. Care is taken to pass the correct preview state (compose vs the message row being edited) to the popover menu so the buttons in it too can be disabled as needed.
This commit is contained in:
parent
64d5547f26
commit
54b399ce96
|
@ -361,6 +361,12 @@ export function initialize() {
|
|||
const $row = rows.get_closest_row(e.target);
|
||||
const $msg_edit_content = $row.find(".message_edit_content");
|
||||
const content = $msg_edit_content.val();
|
||||
|
||||
// Disable unneeded compose_control_buttons as we don't
|
||||
// need them in preview mode.
|
||||
$row.addClass("preview_mode");
|
||||
$row.find(".preview_mode_disabled .compose_control_button").attr("tabindex", -1);
|
||||
|
||||
$msg_edit_content.hide();
|
||||
$row.find(".markdown_preview").hide();
|
||||
$row.find(".undo_markdown_preview").show();
|
||||
|
@ -376,6 +382,12 @@ 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();
|
||||
|
|
|
@ -125,7 +125,7 @@ export function clear_preview_area() {
|
|||
autosize.update($("#compose-textarea"));
|
||||
|
||||
// While in preview mode we disable unneeded compose_control_buttons,
|
||||
// so here we are re-enabling that compose_control_buttons
|
||||
// so here we are re-enabling those compose_control_buttons
|
||||
$("#compose").removeClass("preview_mode");
|
||||
$("#compose .preview_mode_disabled .compose_control_button").attr("tabindex", 0);
|
||||
}
|
||||
|
|
|
@ -511,11 +511,20 @@ export function initialize() {
|
|||
register_popover_menu(".compose_control_menu_wrapper", {
|
||||
placement: "top",
|
||||
onShow(instance) {
|
||||
const parent_row = rows.get_closest_row(instance.reference);
|
||||
let preview_mode_on;
|
||||
// If the popover is opened from a message edit form, we want to
|
||||
// infer the preview mode from that row, else from the compose box.
|
||||
if (parent_row.length) {
|
||||
preview_mode_on = parent_row.hasClass("preview_mode");
|
||||
} else {
|
||||
preview_mode_on = $("#compose").hasClass("preview_mode");
|
||||
}
|
||||
instance.setContent(
|
||||
parse_html(
|
||||
render_compose_control_buttons_popover({
|
||||
giphy_enabled: giphy.is_giphy_enabled(),
|
||||
preview_mode_on: $("#compose").hasClass("preview_mode"),
|
||||
preview_mode_on,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue