Add option to converse-rich-text for /me messages

This commit is contained in:
JC Brand 2021-03-24 11:48:58 +01:00
parent bd8a57e0c3
commit b31eaadfab
3 changed files with 12 additions and 7 deletions

View File

@ -34,6 +34,7 @@ export default class MessageBody extends CustomElement {
'onImgLoad': () => this.onImgLoad(),
'render_styling': !this.model.get('is_unstyled') && api.settings.get('allow_message_styling'),
'show_images': api.settings.get('show_images_inline'),
'show_me_message': true
}
return renderRichText(this.text, offset, mentions, options, callback);
}

View File

@ -48,6 +48,7 @@ export class MessageText extends String {
* @param { String } options.nick - The current user's nickname (only relevant if the message is in a XEP-0045 MUC)
* @param { Boolean } options.render_styling - Whether XEP-0393 message styling should be applied to the message
* @param { Boolean } options.show_images - Whether image URLs should be rendered as <img> tags.
* @param { Boolean } options.show_me_message - Whether /me messages should be rendered differently
* @param { Function } options.onImgClick - Callback for when an inline rendered image has been clicked
* @param { Function } options.onImgLoad - Callback for when an inline rendered image has been loaded
*/
@ -269,7 +270,7 @@ export class MessageText extends String {
await api.trigger('afterMessageBodyTransformed', this, {'Synchronous': true});
this.payload = this.marshall();
this.trimMeMessage();
this.options.show_me_message && this.trimMeMessage();
this.payload = this.payload.map(item => isString(item) ? item : item.template);
}

View File

@ -6,14 +6,15 @@ export default class RichText extends CustomElement {
static get properties () {
return {
text: { type: String },
offset: { type: Number },
mentions: { type: Array },
nick: { type: String },
offset: { type: Number },
onImgClick: { type: Function },
onImgLoad: { type: Function },
render_styling: { type: Boolean },
show_images: { type: Boolean },
onImgClick: { type: Function },
onImgLoad: { type: Function }
show_me_message: { type: Boolean },
text: { type: String },
}
}
@ -23,15 +24,17 @@ export default class RichText extends CustomElement {
this.mentions = [];
this.render_styling = false;
this.show_images = false;
this.show_me_message = false;
}
render () {
const options = {
nick: this.nick,
render_styling: this.render_styling,
show_images: this.show_images,
onImgClick: this.onImgClick,
onImgLoad: this.onImgLoad,
render_styling: this.render_styling,
show_images: this.show_images,
show_me_message: this.show_me_message,
}
return renderRichText(this.text, this.offset, this.mentions, options);
}