mirror of https://github.com/zulip/zulip.git
message_edit: Added copy to clipboard button.
A copy-to-clipboard button is added over message-edit textarea. Closes #3239.
This commit is contained in:
parent
2991c19fea
commit
9707c74f33
|
@ -118,7 +118,8 @@
|
||||||
"Plotly": false,
|
"Plotly": false,
|
||||||
"emoji_codes": false,
|
"emoji_codes": false,
|
||||||
"drafts": false,
|
"drafts": false,
|
||||||
"katex": false
|
"katex": false,
|
||||||
|
"Clipboard": false
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-restricted-syntax": 0,
|
"no-restricted-syntax": 0,
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "",
|
"main": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"clipboard": "1.5.16",
|
||||||
"handlebars": "4.0.6",
|
"handlebars": "4.0.6",
|
||||||
"i18next": "3.4.4",
|
"i18next": "3.4.4",
|
||||||
"i18next-parser": "0.11.1",
|
"i18next-parser": "0.11.1",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 519 B |
|
@ -151,6 +151,14 @@ $(function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
});
|
});
|
||||||
|
$("body").on("click", ".copy_message", function (e) {
|
||||||
|
$(this).attr("data-original-title", "Copied!");
|
||||||
|
$(this).tooltip().tooltip('show');
|
||||||
|
var row = $(this).closest(".message_row");
|
||||||
|
message_edit.end(row);
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
$("body").on("click", "a", function () {
|
$("body").on("click", "a", function () {
|
||||||
if (document.activeElement === this) {
|
if (document.activeElement === this) {
|
||||||
ui_util.blur_active_element();
|
ui_util.blur_active_element();
|
||||||
|
|
|
@ -16,6 +16,10 @@ var editability_types = {
|
||||||
};
|
};
|
||||||
exports.editability_types = editability_types;
|
exports.editability_types = editability_types;
|
||||||
|
|
||||||
|
function initClipboard(elem) {
|
||||||
|
return new Clipboard(elem);
|
||||||
|
}
|
||||||
|
|
||||||
function get_editability(message, edit_limit_seconds_buffer) {
|
function get_editability(message, edit_limit_seconds_buffer) {
|
||||||
edit_limit_seconds_buffer = edit_limit_seconds_buffer || 0;
|
edit_limit_seconds_buffer = edit_limit_seconds_buffer || 0;
|
||||||
if (!(message && message.sent_by_me)) {
|
if (!(message && message.sent_by_me)) {
|
||||||
|
@ -189,6 +193,8 @@ function edit_message(row, raw_content) {
|
||||||
currently_editing_messages[message.id] = edit_obj;
|
currently_editing_messages[message.id] = edit_obj;
|
||||||
current_msg_list.show_edit_message(row, edit_obj);
|
current_msg_list.show_edit_message(row, edit_obj);
|
||||||
|
|
||||||
|
initClipboard(row.find('.copy_message')[0]);
|
||||||
|
|
||||||
form.keydown(_.partial(handle_edit_keydown, false));
|
form.keydown(_.partial(handle_edit_keydown, false));
|
||||||
|
|
||||||
var message_edit_content = row.find('textarea.message_edit_content');
|
var message_edit_content = row.find('textarea.message_edit_content');
|
||||||
|
|
|
@ -212,6 +212,25 @@ $(function () {
|
||||||
|
|
||||||
$('.message_failed i[data-toggle="tooltip"]').tooltip();
|
$('.message_failed i[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
|
$('.copy_message[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
|
$("body").on("mouseover", "#message_edit_content", function () {
|
||||||
|
$(this).closest(".message_row").find(".copy_message").show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on("mouseout", "#message_edit_content", function () {
|
||||||
|
$(this).closest(".message_row").find(".copy_message").hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on("mouseover", ".copy_message", function () {
|
||||||
|
$(this).show();
|
||||||
|
$(this).tooltip('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on("mouseout", ".copy_message", function () {
|
||||||
|
$(this).tooltip('hide');
|
||||||
|
});
|
||||||
|
|
||||||
if (!page_params.realm_allow_message_editing) {
|
if (!page_params.realm_allow_message_editing) {
|
||||||
$("#edit-message-hotkey-help").hide();
|
$("#edit-message-hotkey-help").hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,6 +281,27 @@ li,
|
||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.copy_message, .copy_message:focus {
|
||||||
|
background-image: url('/static/images/clippy.svg');
|
||||||
|
background-size: contain;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-color: white;
|
||||||
|
background-position: center;
|
||||||
|
height: 20px;
|
||||||
|
width: 15px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
border-radius: 2px;
|
||||||
|
position: relative;
|
||||||
|
top: 32px;
|
||||||
|
left: -5px;
|
||||||
|
margin-top: -8px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy_message:hover {
|
||||||
|
background-color: #dadada;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-large {
|
.btn-large {
|
||||||
font-size: 115%;
|
font-size: 115%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="control-group no-margin">
|
<div class="control-group no-margin">
|
||||||
<div class="controls edit-controls">
|
<div class="controls edit-controls">
|
||||||
|
<button class="btn pull-right copy_message" data-toggle="tooltip" title="{{t "Copy to clipboard" }}" data-clipboard-target="#message_edit_content">
|
||||||
|
</button>
|
||||||
<label class="edit-control-label" for="message_edit_topic">{{t "Content" }}</label>
|
<label class="edit-control-label" for="message_edit_topic">{{t "Content" }}</label>
|
||||||
<textarea class="message_edit_content" id="message_edit_content">{{content}}</textarea>
|
<textarea class="message_edit_content" id="message_edit_content">{{content}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
ZULIP_VERSION = "1.5.1+git"
|
ZULIP_VERSION = "1.5.1+git"
|
||||||
PROVISION_VERSION = '4.12'
|
PROVISION_VERSION = '4.13'
|
||||||
|
|
|
@ -793,6 +793,7 @@ JS_SPECS = {
|
||||||
'third/bootstrap-notify/js/bootstrap-notify.js',
|
'third/bootstrap-notify/js/bootstrap-notify.js',
|
||||||
'third/html5-formdata/formdata.js',
|
'third/html5-formdata/formdata.js',
|
||||||
'node_modules/jquery-validation/dist/jquery.validate.js',
|
'node_modules/jquery-validation/dist/jquery.validate.js',
|
||||||
|
'node_modules/clipboard/dist/clipboard.js',
|
||||||
'third/jquery-form/jquery.form.js',
|
'third/jquery-form/jquery.form.js',
|
||||||
'third/jquery-filedrop/jquery.filedrop.js',
|
'third/jquery-filedrop/jquery.filedrop.js',
|
||||||
'third/jquery-caret/jquery.caret.1.5.2.js',
|
'third/jquery-caret/jquery.caret.1.5.2.js',
|
||||||
|
|
Loading…
Reference in New Issue