upload: Use a placeholder when uploading.

Use the placeholder `[uploading file]()` when uploading before the
upload has completed. This behavior prevents an image from being
improperly placed when typing after starting an upload. This is based
on GitHub's handling of image uploading.

Also, add tests to the `upload` Node tests and update existing tests to
account for the new behavior.

Fix #10305.
This commit is contained in:
Marco Burstein
2018-08-14 18:57:35 -07:00
committed by Tim Abbott
parent fa22cf18f6
commit 6f57cd4d23
2 changed files with 24 additions and 8 deletions

View File

@@ -73,6 +73,7 @@ exports.options = function (config) {
send_status.append('<div class="progress active">' +
'<div class="bar" id="' + upload_bar + '-' + file.lastModified + '" style="width: 0"></div>' +
'</div>');
compose_ui.insert_syntax_and_focus("[Uploading " + file.name + "…]()", textarea);
};
var progressUpdated = function (i, file, progress) {
@@ -132,11 +133,11 @@ exports.options = function (config) {
if (i === -1) {
// This is a paste, so there's no filename. Show the image directly
var pasted_image_uri = "[pasted image](" + uri + ")";
compose_ui.insert_syntax_and_focus(pasted_image_uri, textarea);
compose_ui.replace_syntax("[Uploading " + file.name + "…]()", pasted_image_uri, textarea);
} else {
// This is a dropped file, so make the filename a link to the image
var filename_uri = "[" + filename + "](" + uri + ")";
compose_ui.insert_syntax_and_focus(filename_uri, textarea);
compose_ui.replace_syntax("[Uploading " + file.name + "…]()", filename_uri, textarea);
}
compose_ui.autosize_textarea();