mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 00:18:12 +00:00
js: Convert static/js/compose_actions.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e74598da17
commit
0e90f3be6d
@@ -127,7 +127,6 @@
|
|||||||
"globals": {
|
"globals": {
|
||||||
"$": false,
|
"$": false,
|
||||||
"blueslip": false,
|
"blueslip": false,
|
||||||
"compose_actions": false,
|
|
||||||
"composebox_typeahead": false,
|
"composebox_typeahead": false,
|
||||||
"csrf_token": false,
|
"csrf_token": false,
|
||||||
"current_msg_list": true,
|
"current_msg_list": true,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ set_global("DOMParser", new JSDOM().window.DOMParser);
|
|||||||
let compose_actions_start_checked;
|
let compose_actions_start_checked;
|
||||||
let compose_actions_expected_opts;
|
let compose_actions_expected_opts;
|
||||||
|
|
||||||
set_global("compose_actions", {
|
rewiremock("../../static/js/compose_actions").with({
|
||||||
update_placeholder_text: noop,
|
update_placeholder_text: noop,
|
||||||
start(msg_type, opts) {
|
start(msg_type, opts) {
|
||||||
assert.equal(msg_type, "stream");
|
assert.equal(msg_type, "stream");
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ const compose_state = zrequire("compose_state");
|
|||||||
const compose_actions = zrequire("compose_actions");
|
const compose_actions = zrequire("compose_actions");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
|
|
||||||
compose_actions.update_placeholder_text = noop;
|
compose_actions.__Rewire__("update_placeholder_text", noop);
|
||||||
|
|
||||||
const start = compose_actions.start;
|
const start = compose_actions.start;
|
||||||
const cancel = compose_actions.cancel;
|
const cancel = compose_actions.cancel;
|
||||||
@@ -128,12 +128,12 @@ run_test("initial_state", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
run_test("start", (override) => {
|
run_test("start", (override) => {
|
||||||
compose_actions.autosize_message_content = noop;
|
compose_actions.__Rewire__("autosize_message_content", noop);
|
||||||
compose_actions.expand_compose_box = noop;
|
compose_actions.__Rewire__("expand_compose_box", noop);
|
||||||
compose_actions.set_focus = noop;
|
compose_actions.__Rewire__("set_focus", noop);
|
||||||
compose_actions.complete_starting_tasks = noop;
|
compose_actions.__Rewire__("complete_starting_tasks", noop);
|
||||||
compose_actions.blur_compose_inputs = noop;
|
compose_actions.__Rewire__("blur_compose_inputs", noop);
|
||||||
compose_actions.clear_textarea = noop;
|
compose_actions.__Rewire__("clear_textarea", noop);
|
||||||
|
|
||||||
let compose_defaults;
|
let compose_defaults;
|
||||||
override(narrow_state, "set_compose_defaults", () => compose_defaults);
|
override(narrow_state, "set_compose_defaults", () => compose_defaults);
|
||||||
@@ -445,18 +445,18 @@ run_test("on_narrow", (override) => {
|
|||||||
override(compose_state, "has_message_content", () => has_message_content);
|
override(compose_state, "has_message_content", () => has_message_content);
|
||||||
|
|
||||||
let cancel_called = false;
|
let cancel_called = false;
|
||||||
compose_actions.cancel = () => {
|
compose_actions.__Rewire__("cancel", () => {
|
||||||
cancel_called = true;
|
cancel_called = true;
|
||||||
};
|
});
|
||||||
compose_actions.on_narrow({
|
compose_actions.on_narrow({
|
||||||
force_close: true,
|
force_close: true,
|
||||||
});
|
});
|
||||||
assert(cancel_called);
|
assert(cancel_called);
|
||||||
|
|
||||||
let on_topic_narrow_called = false;
|
let on_topic_narrow_called = false;
|
||||||
compose_actions.on_topic_narrow = () => {
|
compose_actions.__Rewire__("on_topic_narrow", () => {
|
||||||
on_topic_narrow_called = true;
|
on_topic_narrow_called = true;
|
||||||
};
|
});
|
||||||
narrowed_by_topic_reply = true;
|
narrowed_by_topic_reply = true;
|
||||||
compose_actions.on_narrow({
|
compose_actions.on_narrow({
|
||||||
force_close: false,
|
force_close: false,
|
||||||
@@ -476,9 +476,9 @@ run_test("on_narrow", (override) => {
|
|||||||
|
|
||||||
has_message_content = false;
|
has_message_content = false;
|
||||||
let start_called = false;
|
let start_called = false;
|
||||||
compose_actions.start = () => {
|
compose_actions.__Rewire__("start", () => {
|
||||||
start_called = true;
|
start_called = true;
|
||||||
};
|
});
|
||||||
narrowed_by_pm_reply = true;
|
narrowed_by_pm_reply = true;
|
||||||
compose_actions.on_narrow({
|
compose_actions.on_narrow({
|
||||||
force_close: false,
|
force_close: false,
|
||||||
|
|||||||
@@ -2,15 +2,21 @@
|
|||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
const rewiremock = require("rewiremock/node");
|
||||||
|
|
||||||
|
const {zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const $ = require("../zjsunit/zjquery");
|
const $ = require("../zjsunit/zjquery");
|
||||||
|
|
||||||
|
rewiremock.enable();
|
||||||
|
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
|
|
||||||
const compose_pm_pill = zrequire("compose_pm_pill");
|
const compose_pm_pill = zrequire("compose_pm_pill");
|
||||||
const input_pill = zrequire("input_pill");
|
const input_pill = zrequire("input_pill");
|
||||||
const compose_actions = set_global("compose_actions", {});
|
const compose_actions = {__esModule: true};
|
||||||
|
|
||||||
|
rewiremock("../../static/js/compose_actions").with(compose_actions);
|
||||||
|
|
||||||
let pills = {
|
let pills = {
|
||||||
pill: {},
|
pill: {},
|
||||||
@@ -193,3 +199,4 @@ run_test("has_unconverted_data", () => {
|
|||||||
// we have some unconverted data.
|
// we have some unconverted data.
|
||||||
assert.equal(compose_pm_pill.has_unconverted_data(), true);
|
assert.equal(compose_pm_pill.has_unconverted_data(), true);
|
||||||
});
|
});
|
||||||
|
rewiremock.disable();
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ const page_params = set_global("page_params", {});
|
|||||||
// jQuery stuff should go away if we make an initialize() method.
|
// jQuery stuff should go away if we make an initialize() method.
|
||||||
set_global("document", "document-stub");
|
set_global("document", "document-stub");
|
||||||
|
|
||||||
const compose_actions = set_global("compose_actions", {});
|
const compose_actions = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/compose_actions").with(compose_actions);
|
||||||
const condense = {__esModule: true};
|
const condense = {__esModule: true};
|
||||||
rewiremock("../../static/js/condense").with(condense);
|
rewiremock("../../static/js/condense").with(condense);
|
||||||
const drafts = {__esModule: true};
|
const drafts = {__esModule: true};
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const channel = {__esModule: true};
|
|||||||
rewiremock("../../static/js/channel").with(channel);
|
rewiremock("../../static/js/channel").with(channel);
|
||||||
const compose = {__esModule: true};
|
const compose = {__esModule: true};
|
||||||
rewiremock("../../static/js/compose").with(compose);
|
rewiremock("../../static/js/compose").with(compose);
|
||||||
const compose_actions = set_global("compose_actions", {});
|
const compose_actions = {__esModule: true};
|
||||||
|
rewiremock("../../static/js/compose_actions").with(compose_actions);
|
||||||
set_global("current_msg_list", {});
|
set_global("current_msg_list", {});
|
||||||
const hashchange = {__esModule: true};
|
const hashchange = {__esModule: true};
|
||||||
rewiremock("../../static/js/hashchange").with(hashchange);
|
rewiremock("../../static/js/hashchange").with(hashchange);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ rewiremock("../../static/js/top_left_corner").with({
|
|||||||
rewiremock("../../static/js/stream_list").with({
|
rewiremock("../../static/js/stream_list").with({
|
||||||
handle_narrow_deactivated: noop,
|
handle_narrow_deactivated: noop,
|
||||||
});
|
});
|
||||||
set_global("compose_actions", {
|
rewiremock("../../static/js/compose_actions").with({
|
||||||
cancel: noop,
|
cancel: noop,
|
||||||
});
|
});
|
||||||
rewiremock("../../static/js/narrow").with({
|
rewiremock("../../static/js/narrow").with({
|
||||||
|
|||||||
@@ -509,9 +509,9 @@ run_test("uppy_events", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
let compose_actions_start_called = false;
|
let compose_actions_start_called = false;
|
||||||
compose_actions.start = () => {
|
compose_actions.__Rewire__("start", () => {
|
||||||
compose_actions_start_called = true;
|
compose_actions_start_called = true;
|
||||||
};
|
});
|
||||||
let compose_ui_replace_syntax_called = false;
|
let compose_ui_replace_syntax_called = false;
|
||||||
compose_ui.__Rewire__("replace_syntax", (old_syntax, new_syntax, textarea) => {
|
compose_ui.__Rewire__("replace_syntax", (old_syntax, new_syntax, textarea) => {
|
||||||
compose_ui_replace_syntax_called = true;
|
compose_ui_replace_syntax_called = true;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import "../fold_dict";
|
|||||||
import "../setup";
|
import "../setup";
|
||||||
import "../message_list";
|
import "../message_list";
|
||||||
import "../reload";
|
import "../reload";
|
||||||
import "../compose_actions";
|
|
||||||
import "../subs";
|
import "../subs";
|
||||||
import "../ui";
|
import "../ui";
|
||||||
import "../composebox_typeahead";
|
import "../composebox_typeahead";
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import * as activity from "./activity";
|
|||||||
import * as buddy_data from "./buddy_data";
|
import * as buddy_data from "./buddy_data";
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as emoji_picker from "./emoji_picker";
|
import * as emoji_picker from "./emoji_picker";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import render_compose_private_stream_alert from "../templates/compose_private_st
|
|||||||
|
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as common from "./common";
|
import * as common from "./common";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_fade from "./compose_fade";
|
import * as compose_fade from "./compose_fade";
|
||||||
import * as compose_pm_pill from "./compose_pm_pill";
|
import * as compose_pm_pill from "./compose_pm_pill";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
|
|||||||
@@ -1,33 +1,31 @@
|
|||||||
"use strict";
|
import autosize from "autosize";
|
||||||
|
|
||||||
const autosize = require("autosize");
|
import * as fenced_code from "../shared/js/fenced_code";
|
||||||
|
|
||||||
const fenced_code = require("../shared/js/fenced_code");
|
import * as channel from "./channel";
|
||||||
|
import * as common from "./common";
|
||||||
|
import * as compose from "./compose";
|
||||||
|
import * as compose_fade from "./compose_fade";
|
||||||
|
import * as compose_pm_pill from "./compose_pm_pill";
|
||||||
|
import * as compose_state from "./compose_state";
|
||||||
|
import * as compose_ui from "./compose_ui";
|
||||||
|
import * as drafts from "./drafts";
|
||||||
|
import * as hash_util from "./hash_util";
|
||||||
|
import * as message_viewport from "./message_viewport";
|
||||||
|
import * as narrow_state from "./narrow_state";
|
||||||
|
import * as notifications from "./notifications";
|
||||||
|
import * as people from "./people";
|
||||||
|
import * as reload_state from "./reload_state";
|
||||||
|
import * as stream_data from "./stream_data";
|
||||||
|
import * as ui_util from "./ui_util";
|
||||||
|
import * as unread_ops from "./unread_ops";
|
||||||
|
|
||||||
const channel = require("./channel");
|
export function blur_compose_inputs() {
|
||||||
const common = require("./common");
|
|
||||||
const compose = require("./compose");
|
|
||||||
const compose_fade = require("./compose_fade");
|
|
||||||
const compose_pm_pill = require("./compose_pm_pill");
|
|
||||||
const compose_state = require("./compose_state");
|
|
||||||
const compose_ui = require("./compose_ui");
|
|
||||||
const drafts = require("./drafts");
|
|
||||||
const hash_util = require("./hash_util");
|
|
||||||
const message_viewport = require("./message_viewport");
|
|
||||||
const narrow_state = require("./narrow_state");
|
|
||||||
const notifications = require("./notifications");
|
|
||||||
const people = require("./people");
|
|
||||||
const reload_state = require("./reload_state");
|
|
||||||
const stream_data = require("./stream_data");
|
|
||||||
const ui_util = require("./ui_util");
|
|
||||||
const unread_ops = require("./unread_ops");
|
|
||||||
|
|
||||||
exports.blur_compose_inputs = function () {
|
|
||||||
$(".message_comp").find("input, textarea, button, #private_message_recipient").trigger("blur");
|
$(".message_comp").find("input, textarea, button, #private_message_recipient").trigger("blur");
|
||||||
};
|
}
|
||||||
|
|
||||||
function hide_box() {
|
function hide_box() {
|
||||||
exports.blur_compose_inputs();
|
blur_compose_inputs();
|
||||||
$("#stream-message").hide();
|
$("#stream-message").hide();
|
||||||
$("#private-message").hide();
|
$("#private-message").hide();
|
||||||
$(".new_message_textarea").css("min-height", "");
|
$(".new_message_textarea").css("min-height", "");
|
||||||
@@ -56,10 +54,11 @@ function get_focus_area(msg_type, opts) {
|
|||||||
}
|
}
|
||||||
return "#private_message_recipient";
|
return "#private_message_recipient";
|
||||||
}
|
}
|
||||||
// Export for testing
|
|
||||||
exports._get_focus_area = get_focus_area;
|
|
||||||
|
|
||||||
exports.set_focus = function (msg_type, opts) {
|
// Export for testing
|
||||||
|
export const _get_focus_area = get_focus_area;
|
||||||
|
|
||||||
|
export function set_focus(msg_type, opts) {
|
||||||
const focus_area = get_focus_area(msg_type, opts);
|
const focus_area = get_focus_area(msg_type, opts);
|
||||||
if (focus_area === undefined) {
|
if (focus_area === undefined) {
|
||||||
return;
|
return;
|
||||||
@@ -69,7 +68,7 @@ exports.set_focus = function (msg_type, opts) {
|
|||||||
const elt = $(focus_area);
|
const elt = $(focus_area);
|
||||||
elt.trigger("focus").trigger("select");
|
elt.trigger("focus").trigger("select");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// Show the compose box.
|
// Show the compose box.
|
||||||
function show_box(msg_type, opts) {
|
function show_box(msg_type, opts) {
|
||||||
@@ -89,12 +88,12 @@ function show_box(msg_type, opts) {
|
|||||||
// When changing this, edit the 42px in _maybe_autoscroll
|
// When changing this, edit the 42px in _maybe_autoscroll
|
||||||
$(".new_message_textarea").css("min-height", "3em");
|
$(".new_message_textarea").css("min-height", "3em");
|
||||||
|
|
||||||
exports.set_focus(msg_type, opts);
|
set_focus(msg_type, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.clear_textarea = function () {
|
export function clear_textarea() {
|
||||||
$("#compose").find("input[type=text], textarea").val("");
|
$("#compose").find("input[type=text], textarea").val("");
|
||||||
};
|
}
|
||||||
|
|
||||||
function clear_box() {
|
function clear_box() {
|
||||||
compose.clear_invites();
|
compose.clear_invites();
|
||||||
@@ -106,40 +105,40 @@ function clear_box() {
|
|||||||
compose.reset_user_acknowledged_all_everyone_flag();
|
compose.reset_user_acknowledged_all_everyone_flag();
|
||||||
compose.reset_user_acknowledged_announce_flag();
|
compose.reset_user_acknowledged_announce_flag();
|
||||||
|
|
||||||
exports.clear_textarea();
|
clear_textarea();
|
||||||
$("#compose-textarea").removeData("draft-id");
|
$("#compose-textarea").removeData("draft-id");
|
||||||
compose_ui.autosize_textarea($("#compose-textarea"));
|
compose_ui.autosize_textarea($("#compose-textarea"));
|
||||||
$("#compose-send-status").hide(0);
|
$("#compose-send-status").hide(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.autosize_message_content = function () {
|
export function autosize_message_content() {
|
||||||
autosize($("#compose-textarea"), {
|
autosize($("#compose-textarea"), {
|
||||||
callback() {
|
callback() {
|
||||||
exports.maybe_scroll_up_selected_message();
|
maybe_scroll_up_selected_message();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.expand_compose_box = function () {
|
export function expand_compose_box() {
|
||||||
$("#compose_close").show();
|
$("#compose_close").show();
|
||||||
$("#compose_controls").hide();
|
$("#compose_controls").hide();
|
||||||
$(".message_comp").show();
|
$(".message_comp").show();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.complete_starting_tasks = function (msg_type, opts) {
|
export function complete_starting_tasks(msg_type, opts) {
|
||||||
// This is sort of a kitchen sink function, and it's called only
|
// This is sort of a kitchen sink function, and it's called only
|
||||||
// by compose.start() for now. Having this as a separate function
|
// by compose.start() for now. Having this as a separate function
|
||||||
// makes testing a bit easier.
|
// makes testing a bit easier.
|
||||||
|
|
||||||
exports.maybe_scroll_up_selected_message();
|
maybe_scroll_up_selected_message();
|
||||||
ui_util.change_tab_to("#message_feed_container");
|
ui_util.change_tab_to("#message_feed_container");
|
||||||
compose_fade.start_compose(msg_type);
|
compose_fade.start_compose(msg_type);
|
||||||
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"), true);
|
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"), true);
|
||||||
$(document).trigger(new $.Event("compose_started.zulip", opts));
|
$(document).trigger(new $.Event("compose_started.zulip", opts));
|
||||||
exports.update_placeholder_text();
|
update_placeholder_text();
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.maybe_scroll_up_selected_message = function () {
|
export function maybe_scroll_up_selected_message() {
|
||||||
// If the compose box is obscuring the currently selected message,
|
// If the compose box is obscuring the currently selected message,
|
||||||
// scroll up until the message is no longer occluded.
|
// scroll up until the message is no longer occluded.
|
||||||
if (current_msg_list.selected_id() === -1) {
|
if (current_msg_list.selected_id() === -1) {
|
||||||
@@ -161,7 +160,7 @@ exports.maybe_scroll_up_selected_message = function () {
|
|||||||
if (cover > 0) {
|
if (cover > 0) {
|
||||||
message_viewport.user_initiated_animate_scroll(cover + 20);
|
message_viewport.user_initiated_animate_scroll(cover + 20);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
|
function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
|
||||||
return {
|
return {
|
||||||
@@ -189,7 +188,7 @@ function same_recipient_as_before(msg_type, opts) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update_placeholder_text = function () {
|
export function update_placeholder_text() {
|
||||||
// Change compose placeholder text only if compose box is open.
|
// Change compose placeholder text only if compose box is open.
|
||||||
if (!$("#compose-textarea").is(":visible")) {
|
if (!$("#compose-textarea").is(":visible")) {
|
||||||
return;
|
return;
|
||||||
@@ -203,16 +202,16 @@ exports.update_placeholder_text = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$("#compose-textarea").attr("placeholder", compose_ui.compute_placeholder_text(opts));
|
$("#compose-textarea").attr("placeholder", compose_ui.compute_placeholder_text(opts));
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.start = function (msg_type, opts) {
|
export function start(msg_type, opts) {
|
||||||
exports.autosize_message_content();
|
autosize_message_content();
|
||||||
|
|
||||||
if (reload_state.is_in_progress()) {
|
if (reload_state.is_in_progress()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
notifications.clear_compose_notifications();
|
notifications.clear_compose_notifications();
|
||||||
exports.expand_compose_box();
|
expand_compose_box();
|
||||||
|
|
||||||
opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
||||||
// If we are invoked by a compose hotkey (c or x) or new topic
|
// If we are invoked by a compose hotkey (c or x) or new topic
|
||||||
@@ -261,10 +260,10 @@ exports.start = function (msg_type, opts) {
|
|||||||
// Show either stream/topic fields or "You and" field.
|
// Show either stream/topic fields or "You and" field.
|
||||||
show_box(msg_type, opts);
|
show_box(msg_type, opts);
|
||||||
|
|
||||||
exports.complete_starting_tasks(msg_type, opts);
|
complete_starting_tasks(msg_type, opts);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.cancel = function () {
|
export function cancel() {
|
||||||
$("#compose-textarea").height(40 + "px");
|
$("#compose-textarea").height(40 + "px");
|
||||||
|
|
||||||
if (page_params.narrow !== undefined) {
|
if (page_params.narrow !== undefined) {
|
||||||
@@ -287,9 +286,9 @@ exports.cancel = function () {
|
|||||||
compose_state.set_message_type(false);
|
compose_state.set_message_type(false);
|
||||||
compose_pm_pill.clear();
|
compose_pm_pill.clear();
|
||||||
$(document).trigger("compose_canceled.zulip");
|
$(document).trigger("compose_canceled.zulip");
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.respond_to_message = function (opts) {
|
export function respond_to_message(opts) {
|
||||||
let msg_type;
|
let msg_type;
|
||||||
// Before initiating a reply to a message, if there's an
|
// Before initiating a reply to a message, if there's an
|
||||||
// in-progress composition, snapshot it.
|
// in-progress composition, snapshot it.
|
||||||
@@ -325,7 +324,7 @@ exports.respond_to_message = function (opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const new_opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
const new_opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
||||||
exports.start(new_opts.message_type, new_opts);
|
start(new_opts.message_type, new_opts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,22 +359,22 @@ exports.respond_to_message = function (opts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.start(msg_type, {
|
start(msg_type, {
|
||||||
stream,
|
stream,
|
||||||
topic,
|
topic,
|
||||||
private_message_recipient: pm_recipient,
|
private_message_recipient: pm_recipient,
|
||||||
trigger: opts.trigger,
|
trigger: opts.trigger,
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.reply_with_mention = function (opts) {
|
export function reply_with_mention(opts) {
|
||||||
exports.respond_to_message(opts);
|
respond_to_message(opts);
|
||||||
const message = current_msg_list.selected_message();
|
const message = current_msg_list.selected_message();
|
||||||
const mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
|
const mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
|
||||||
compose_ui.insert_syntax_and_focus(mention);
|
compose_ui.insert_syntax_and_focus(mention);
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.on_topic_narrow = function () {
|
export function on_topic_narrow() {
|
||||||
if (!compose_state.composing()) {
|
if (!compose_state.composing()) {
|
||||||
// If our compose box is closed, then just
|
// If our compose box is closed, then just
|
||||||
// leave it closed, assuming that the user is
|
// leave it closed, assuming that the user is
|
||||||
@@ -393,7 +392,7 @@ exports.on_topic_narrow = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, avoid a mix.
|
// Otherwise, avoid a mix.
|
||||||
exports.cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,9 +417,9 @@ exports.on_topic_narrow = function () {
|
|||||||
compose_fade.set_focused_recipient("stream");
|
compose_fade.set_focused_recipient("stream");
|
||||||
compose_fade.update_message_list();
|
compose_fade.update_message_list();
|
||||||
$("#compose-textarea").trigger("focus").trigger("select");
|
$("#compose-textarea").trigger("focus").trigger("select");
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.quote_and_reply = function (opts) {
|
export function quote_and_reply(opts) {
|
||||||
const textarea = $("#compose-textarea");
|
const textarea = $("#compose-textarea");
|
||||||
const message_id = current_msg_list.selected_id();
|
const message_id = current_msg_list.selected_id();
|
||||||
const message = current_msg_list.selected_message();
|
const message = current_msg_list.selected_message();
|
||||||
@@ -444,7 +443,7 @@ exports.quote_and_reply = function (opts) {
|
|||||||
// smarter about newlines.
|
// smarter about newlines.
|
||||||
textarea.caret(0);
|
textarea.caret(0);
|
||||||
} else {
|
} else {
|
||||||
exports.respond_to_message(opts);
|
respond_to_message(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea);
|
compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea);
|
||||||
@@ -476,16 +475,16 @@ exports.quote_and_reply = function (opts) {
|
|||||||
replace_content(message);
|
replace_content(message);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
exports.on_narrow = function (opts) {
|
export function on_narrow(opts) {
|
||||||
// We use force_close when jumping between PM narrows with the "p" key,
|
// We use force_close when jumping between PM narrows with the "p" key,
|
||||||
// so that we don't have an open compose box that makes it difficult
|
// so that we don't have an open compose box that makes it difficult
|
||||||
// to cycle quickly through unread messages.
|
// to cycle quickly through unread messages.
|
||||||
if (opts.force_close) {
|
if (opts.force_close) {
|
||||||
// This closes the compose box if it was already open, and it is
|
// This closes the compose box if it was already open, and it is
|
||||||
// basically a noop otherwise.
|
// basically a noop otherwise.
|
||||||
exports.cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,7 +494,7 @@ exports.on_narrow = function (opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (narrow_state.narrowed_by_topic_reply()) {
|
if (narrow_state.narrowed_by_topic_reply()) {
|
||||||
exports.on_topic_narrow();
|
on_topic_narrow();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,14 +510,12 @@ exports.on_narrow = function (opts) {
|
|||||||
if (opts.trigger === "search" && !opts.private_message_recipient) {
|
if (opts.trigger === "search" && !opts.private_message_recipient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exports.start("private");
|
start("private");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got this far, then we assume the user is now in "reading"
|
// If we got this far, then we assume the user is now in "reading"
|
||||||
// mode, so we close the compose box to make it easier to use navigation
|
// mode, so we close the compose box to make it easier to use navigation
|
||||||
// hotkeys and to provide more screen real estate for messages.
|
// hotkeys and to provide more screen real estate for messages.
|
||||||
exports.cancel();
|
cancel();
|
||||||
};
|
}
|
||||||
|
|
||||||
window.compose_actions = exports;
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as input_pill from "./input_pill";
|
import * as input_pill from "./input_pill";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as user_pill from "./user_pill";
|
import * as user_pill from "./user_pill";
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Handlebars from "handlebars/runtime";
|
|||||||
import render_draft_table_body from "../templates/draft_table_body.hbs";
|
import render_draft_table_body from "../templates/draft_table_body.hbs";
|
||||||
|
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_fade from "./compose_fade";
|
import * as compose_fade from "./compose_fade";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as compose_ui from "./compose_ui";
|
import * as compose_ui from "./compose_ui";
|
||||||
|
|||||||
1
static/js/global.d.ts
vendored
1
static/js/global.d.ts
vendored
@@ -4,7 +4,6 @@
|
|||||||
// to TS.
|
// to TS.
|
||||||
|
|
||||||
declare let blueslip: any;
|
declare let blueslip: any;
|
||||||
declare let compose_actions: any;
|
|
||||||
declare let composebox_typeahead: any;
|
declare let composebox_typeahead: any;
|
||||||
declare let csrf_token: any;
|
declare let csrf_token: any;
|
||||||
declare let current_msg_list: any;
|
declare let current_msg_list: any;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as emoji from "../shared/js/emoji";
|
|||||||
import * as activity from "./activity";
|
import * as activity from "./activity";
|
||||||
import * as common from "./common";
|
import * as common from "./common";
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as condense from "./condense";
|
import * as condense from "./condense";
|
||||||
import * as copy_and_paste from "./copy_and_paste";
|
import * as copy_and_paste from "./copy_and_paste";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import render_topic_edit_form from "../templates/topic_edit_form.hbs";
|
|||||||
|
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as condense from "./condense";
|
import * as condense from "./condense";
|
||||||
import * as echo from "./echo";
|
import * as echo from "./echo";
|
||||||
import * as loading from "./loading";
|
import * as loading from "./loading";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_fade from "./compose_fade";
|
import * as compose_fade from "./compose_fade";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as condense from "./condense";
|
import * as condense from "./condense";
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import render_user_info_popover_title from "../templates/user_info_popover_title
|
|||||||
import render_user_profile_modal from "../templates/user_profile_modal.hbs";
|
import render_user_profile_modal from "../templates/user_profile_modal.hbs";
|
||||||
|
|
||||||
import * as buddy_data from "./buddy_data";
|
import * as buddy_data from "./buddy_data";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as compose_ui from "./compose_ui";
|
import * as compose_ui from "./compose_ui";
|
||||||
import * as condense from "./condense";
|
import * as condense from "./condense";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import render_recent_topic_row from "../templates/recent_topic_row.hbs";
|
|||||||
import render_recent_topics_filters from "../templates/recent_topics_filters.hbs";
|
import render_recent_topics_filters from "../templates/recent_topics_filters.hbs";
|
||||||
import render_recent_topics_body from "../templates/recent_topics_table.hbs";
|
import render_recent_topics_body from "../templates/recent_topics_table.hbs";
|
||||||
|
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as drafts from "./drafts";
|
import * as drafts from "./drafts";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import * as ListWidget from "./list_widget";
|
import * as ListWidget from "./list_widget";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as activity from "./activity";
|
import * as activity from "./activity";
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as hashchange from "./hashchange";
|
import * as hashchange from "./hashchange";
|
||||||
import {localstorage} from "./localstorage";
|
import {localstorage} from "./localstorage";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ProgressBar from "@uppy/progress-bar";
|
|||||||
import XHRUpload from "@uppy/xhr-upload";
|
import XHRUpload from "@uppy/xhr-upload";
|
||||||
|
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
|
import * as compose_actions from "./compose_actions";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as compose_ui from "./compose_ui";
|
import * as compose_ui from "./compose_ui";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user