Commit ceb2e5a3 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

Merge branch 'beta' into 'master'

Reactions, Retract upload...

Closes #270, #245, and #195

See merge request !136
parents 57c9b11c 256497ed
Pipeline #11001 passed with stage
in 1 minute and 46 seconds
......@@ -4,9 +4,16 @@ This file contains the changes applied to the sources of converse<br>
The current build version of converse is: `v7.0.3dev`<br>
If the converse sources have to be updated, apply these changes again, or fix them using plugins
### 2021-04-16
* Escaped an error on undefined `this.suggestions` when hovering the autocomplete results
* Escaped an error on undefined `this.suggestions` when selecting a mention (click)
### 2021-04-15
* Fix an endless loop when parsing bad formatted code block messages
### 2021-03-25
* Update retraction warning message in confirm modal
### 2021-03-12
* Added the `fa-reply` icon into the icons svg (icons.js)
......
......@@ -88814,9 +88814,12 @@ class autocomplete_AutoComplete {
this.status.textContent = list[i].textContent; // scroll to highlighted element in case parent's height is fixed
this.ul.scrollTop = list[i].offsetTop - this.ul.clientHeight + list[i].clientHeight;
this.trigger("suggestion-box-highlight", {
'text': this.suggestions[this.index]
});
if (this.suggestions) {
this.trigger("suggestion-box-highlight", {
'text': this.suggestions[this.index]
});
}
}
}
......@@ -88827,7 +88830,7 @@ class autocomplete_AutoComplete {
selected = this.ul.children[this.index];
}
if (selected) {
if (selected && this.suggestions) {
const suggestion = this.suggestions[this.index];
this.insertValue(suggestion);
this.close({
......@@ -98233,7 +98236,7 @@ const ChatBoxView = View.extend({
return headless_log.error("onMessageRetractButtonClicked called for someone else's message!");
}
const retraction_warning = i18n_('Be aware that other XMPP/Jabber clients (and servers) may ' + 'not yet support retractions and that this message may not ' + 'be removed everywhere.');
const retraction_warning = i18n_('Be aware that this message may have already been seen.');
const messages = [i18n_('Are you sure you want to retract this message?')];
......@@ -103323,7 +103326,7 @@ const ChatRoomViewMixin = {
},
async onMessageRetractButtonClicked(message) {
const retraction_warning = i18n_('Be aware that other XMPP/Jabber clients (and servers) may ' + 'not yet support retractions and that this message may not ' + 'be removed everywhere.');
const retraction_warning = i18n_('Be aware that this message may have already been seen.');
if (message.mayBeRetracted()) {
const messages = [i18n_('Are you sure you want to retract this message?')];
/**
* Custom mention autocomplete list.
*/
converse.plugins.add('sib-mention-autocomplete', {
overrides: {
ChatRoom: {
/**
* Move the `all` mention at the bottom.
* @returns {*}
*/
getAllKnownNicknames() {
const nicknames = this.__super__.getAllKnownNicknames.apply(this, arguments);
if (nicknames.indexOf('all') >= 0) {
return nicknames.filter(n => n !== 'all').concat(['all']);
}
return nicknames;
},
},
ChatRoomView: {
/**
* Disable sort so the `all` mention stays at the bottom.
*/
initMentionAutoComplete() {
this.__super__.initMentionAutoComplete.apply(this, arguments);
this.mention_auto_complete.sort = false;
},
/**
* Show a custom icon for `all`
* Render the full name on top of the nickname
*
* @param text
* @param input
* @returns {HTMLLIElement}
*/
getAutoCompleteListItem(text, input) {
const _converse = this.__super__._converse;
const { api } = _converse;
input = input.trim();
const element = document.createElement('li');
element.setAttribute('aria-selected', 'false');
const is_mention_all = text.toString() === 'all';
let vcard = null;
// Get the vcard for the current user
if (_converse.vcards && !is_mention_all) {
vcard = _converse.vcards.findWhere({
'nickname': text,
});
}
// Update the `@all` mention with a custom label
// Update the label with the user full name if available
// TODO: Add translation support
if (is_mention_all) {
text.title = 'Notifier tous les utilisateurs du cercle';
} else if (vcard && vcard.get('fullname')) {
text.title = vcard.get('fullname') || text.toString();
} else {
text.title = text.toString();
}
// Update mention item with the avatar
if (api.settings.get('muc_mention_autocomplete_show_avatar')) {
const ALL_IMAGE_TYPE = 'image/png';
const ALL_IMAGE = 'iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV/Tih9UFOwg4pChdrJQVMRRq1CECqFWaNXB5NIvaNKQpLg4Cq4FBz8Wqw4uzro6uAqC4AeIm5uToouU+L+k0CLWg+N+vLv3uHsHCPUy06xADNB020wl4mImuyp2vyKAQfQihojMLGNOkpLoOL7u4ePrX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JC4GAcgGVGI3ujk+MkH968+IORNscC8nyAT9lK9tHP7TIW4ZBB9NYlWUE73Zw1ar7++mTukEXs1QNRth4c4AntBvlHCS9LlWtFONhwuqnItSN/6VhbsDe64NjM5iSyJr17sLN6mzgSqUSJKuWy/2PllJJHz7wn/NMMH5KDogB+SAHJAD2l/8AVdEzx8qjlPAAAAAAElFTkSuQmCC';
const img = document.createElement('img');
let dataUri = 'data:' + _converse.DEFAULT_IMAGE_TYPE + ';base64,' + _converse.DEFAULT_IMAGE;
if (vcard) {
dataUri = 'data:' + vcard.get('image_type') + ';base64,' + vcard.get('image');
}
if (is_mention_all) {
dataUri = 'data:' + ALL_IMAGE_TYPE + ';base64,' + ALL_IMAGE;
}
img.setAttribute('src', dataUri);
img.setAttribute('width', '32');
img.setAttribute('height', '32');
img.setAttribute('class', 'avatar avatar-autocomplete');
element.appendChild(img);
}
const label = document.createElement('span');
label.appendChild(document.createTextNode(text.title));
const val = document.createElement('small');
val.appendChild(document.createTextNode('@'));
const regex = new RegExp('(' + input + ')', 'ig');
const parts = input ? text.split(regex) : [text];
parts.forEach(txt => {
if (input && txt.match(regex)) {
const match = document.createElement('mark');
match.textContent = txt;
val.appendChild(match);
} else {
val.appendChild(document.createTextNode(txt));
}
});
label.appendChild(val);
element.appendChild(label);
return element;
},
},
},
});
This diff is collapsed.
......@@ -13,6 +13,12 @@ converse.plugins.add('sib-reply-to-message', {
}
api.listen.on('getMessageActionButtons', (el, buttons) => {
// Do not add the reply button if the message is retracted or correcting
if (el.is_retracted || el.correcting) {
return buttons;
}
buttons.push({
'i18n_text': __('Reply'),
'handler': ev => {
......
/**
* Allow the user to retract a file upload.
*/
converse.plugins.add('sib-retract-file-upload', {
initialize() {
const _converse = this._converse;
const { api, Message } = _converse;
api.settings.extend({
'allow_upload_retraction': 'own',
});
const MessageMixin = {
/**
* The message can be retracted if the above option is correctly set.
* Overrides the 'allow_message_retraction' setting if disabled.
*
* @private
* @method _converse.Messages#mayBeRetracted
* @returns { Boolean }
*/
mayBeRetracted() {
return _mayBeRetracted.call(this) || (
this.get('sender') === 'me'
&& this.get('oob_url')
&& ['all', 'own'].includes(api.settings.get('allow_upload_retraction'))
);
},
};
const _mayBeRetracted = Message.prototype.mayBeRetracted;
Object.assign(Message.prototype, MessageMixin);
},
});
......@@ -12,9 +12,12 @@ import './plugins/sib-custom-hats.js';
import './plugins/sib-disconnected.js';
import './plugins/sib-emoji-picker.js';
import './plugins/sib-history-improved.js';
import './plugins/sib-mention-autocomplete.js';
import './plugins/sib-mention-mobile.js';
import './plugins/sib-reactions.js';
import './plugins/sib-remove-notifications.js';
import './plugins/sib-reply-to-message.js';
import './plugins/sib-retract-file-upload.js';
import './plugins/sib-scroll-down-on-focus.js';
import './plugins/sib-subscribe-to-rai.js';
......@@ -237,9 +240,11 @@ export const SolidXMPPChat = {
'sib-disconnected',
'sib-emoji-picker',
'sib-history-improved',
'sib-mention-autocomplete',
'sib-mention-mobile',
'sib-remove-notifications',
'sib-reply-to-message',
'sib-retract-file-upload',
'sib-scroll-down-on-focus',
'sib-subscribe-to-rai',
],
......
......@@ -139,6 +139,10 @@
outline: none;
}
.modal-dialog {
margin-top: 10rem !important;
}
/* Modal when the connection is lost*/
#alert-modal > .modal-dialog > .modal-content {
top: 47px;
......@@ -272,6 +276,19 @@
border-color: unset;
}
#converse-modals .form-group input.btn {
display: inline-block;
font-weight: 400;
text-align: center;
vertical-align: middle;
cursor: pointer;
user-select: none;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
}
@keyframes colorchange-chatmessage {
0% {
background-color: transparent;
......@@ -572,21 +589,46 @@
.suggestion-box .suggestion-box__results,
.suggestion-box > ul {
box-shadow: 0 0 5px 0 rgba(133, 140, 148, 0.09);
box-shadow: 0 0 5px 0 rgba(133, 140, 148, 0.25);
}
&.converse-fullscreen .chatroom .sendXMPPMessage .suggestion-box__results--above,
.chatroom .sendXMPPMessage .suggestion-box__results--above {
border: none;
position: absolute;
top: -3px;
transform: translateY(-100%);
bottom: unset;
z-index: 11;
li {
display: flex;
align-items: center;
color: var(--color-chat-suggestion);
font-size: 13px;
font-weight: 600;
border-bottom: 1px solid #E4E8ED;
small:before {
content: "\a";
white-space: pre;
}
}
@media (min-width: 768px) {
max-width: 30rem;
min-width: unset;
}
}
.suggestion-box {
position: unset;
}
.sendXMPPMessage {
position: relative;
}
&.converse-fullscreen .chatroom .sendXMPPMessage .chat-toolbar,
.chatroom .sendXMPPMessage .chat-toolbar {
border-top: 1px solid var(--chat-head-color);
......@@ -736,6 +778,11 @@
}
.message.date-separator {
position: sticky;
top: 0;
background: white;
z-index: 10;
.separator-text {
font-size: 12px;
text-transform: capitalize;
......@@ -824,23 +871,15 @@
}
.suggestion-box mark {
background: var(--hd-hightlight-color);
background: transparent !important;
font-weight: bold;
}
.suggestion-box > ul > li[aria-selected=true] {
background: transparent;
background: #f6f6f6 !important;
color: var(--chat-suggestion-selected-true) !important;
}
.suggestion-box li:hover mark {
background: var(--hd-hightlight-color);
}
.suggestion-box li[aria-selected=true] mark {
background: inherit;
font-weight: bold;
}
.modal-backdrop {
z-index: 1030;
}
......@@ -904,5 +943,54 @@
background: #f6f6f6;
border: 2px solid white;
border-radius: 3px;
z-index: 11;
}
//
// Reactions
// ---------------------------------
.chat-msg__actions--inline {
.chat-msg__action-react {
order: -1;
}
}
.chat-msg:not(:hover) .chat-msg--react {
display: none;
}
.chat-msg__reactions {
margin-top: 0.7em;
}
.chat-msg__reaction {
display: inline-block;
color: var(--text-color);
margin-right: 0.3em;
margin-top: 0.3em;
padding: 0.2em 0.3em;
border-radius: 3px;
text-decoration: none;
white-space: nowrap;
.count {
font-size: 0.8em;
}
&:hover {
.count {
color: var(--color-secondary);
}
}
&--me {
background-color: #e9e9e9;
.count {
color: #2e3f57 !important;
font-weight: bold;
}
}
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment