mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
compose: Add spaces around markdown for attachments.
If your cursor is in the middle of a word when you upload an image, the code will now properly put spaces in the markdown around the attachment link. Fixes: #7212.
This commit is contained in:
@@ -93,12 +93,16 @@ var upload_opts = upload.options({ mode: "compose" });
|
|||||||
function test(i, response, textbox_val) {
|
function test(i, response, textbox_val) {
|
||||||
var compose_ui_autosize_textarea_checked = false;
|
var compose_ui_autosize_textarea_checked = false;
|
||||||
var compose_actions_start_checked = false;
|
var compose_actions_start_checked = false;
|
||||||
|
var syntax_to_insert;
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
$("#compose-textarea").val('');
|
$("#compose-textarea").val('');
|
||||||
compose_ui.autosize_textarea = function () {
|
compose_ui.autosize_textarea = function () {
|
||||||
compose_ui_autosize_textarea_checked = true;
|
compose_ui_autosize_textarea_checked = true;
|
||||||
};
|
};
|
||||||
|
compose_ui.insert_syntax_and_focus = function (syntax) {
|
||||||
|
syntax_to_insert = syntax;
|
||||||
|
};
|
||||||
compose_state.set_message_type();
|
compose_state.set_message_type();
|
||||||
global.compose_actions = {
|
global.compose_actions = {
|
||||||
start: function (msg_type) {
|
start: function (msg_type) {
|
||||||
@@ -116,8 +120,8 @@ var upload_opts = upload.options({ mode: "compose" });
|
|||||||
}
|
}
|
||||||
|
|
||||||
function assert_side_effects() {
|
function assert_side_effects() {
|
||||||
assert.equal($("#compose-textarea").val(), textbox_val);
|
|
||||||
if (response.uri) {
|
if (response.uri) {
|
||||||
|
assert.equal(syntax_to_insert, textbox_val);
|
||||||
assert(compose_actions_start_checked);
|
assert(compose_actions_start_checked);
|
||||||
assert(compose_ui_autosize_textarea_checked);
|
assert(compose_ui_autosize_textarea_checked);
|
||||||
assert.equal($("#compose-send-button").prop('disabled'), false);
|
assert.equal($("#compose-send-button").prop('disabled'), false);
|
||||||
|
|||||||
@@ -114,10 +114,12 @@ exports.options = function (config) {
|
|||||||
|
|
||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
// This is a paste, so there's no filename. Show the image directly
|
// This is a paste, so there's no filename. Show the image directly
|
||||||
textarea.val(textarea.val() + "[pasted image](" + uri + ") ");
|
var pasted_image_uri = "[pasted image](" + uri + ")";
|
||||||
|
compose_ui.insert_syntax_and_focus(pasted_image_uri);
|
||||||
} else {
|
} else {
|
||||||
// This is a dropped file, so make the filename a link to the image
|
// This is a dropped file, so make the filename a link to the image
|
||||||
textarea.val(textarea.val() + "[" + filename + "](" + uri + ")" + " ");
|
var filename_uri = "[" + filename + "](" + uri + ")";
|
||||||
|
compose_ui.insert_syntax_and_focus(filename_uri);
|
||||||
}
|
}
|
||||||
compose_ui.autosize_textarea();
|
compose_ui.autosize_textarea();
|
||||||
send_button.prop("disabled", false);
|
send_button.prop("disabled", false);
|
||||||
|
|||||||
Reference in New Issue
Block a user