Add option to converse-rich-text
for /me messages
This commit is contained in:
parent
bd8a57e0c3
commit
b31eaadfab
@ -34,6 +34,7 @@ export default class MessageBody extends CustomElement {
|
|||||||
'onImgLoad': () => this.onImgLoad(),
|
'onImgLoad': () => this.onImgLoad(),
|
||||||
'render_styling': !this.model.get('is_unstyled') && api.settings.get('allow_message_styling'),
|
'render_styling': !this.model.get('is_unstyled') && api.settings.get('allow_message_styling'),
|
||||||
'show_images': api.settings.get('show_images_inline'),
|
'show_images': api.settings.get('show_images_inline'),
|
||||||
|
'show_me_message': true
|
||||||
}
|
}
|
||||||
return renderRichText(this.text, offset, mentions, options, callback);
|
return renderRichText(this.text, offset, mentions, options, callback);
|
||||||
}
|
}
|
||||||
|
@ -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 { 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.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_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.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
|
* @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});
|
await api.trigger('afterMessageBodyTransformed', this, {'Synchronous': true});
|
||||||
|
|
||||||
this.payload = this.marshall();
|
this.payload = this.marshall();
|
||||||
this.trimMeMessage();
|
this.options.show_me_message && this.trimMeMessage();
|
||||||
this.payload = this.payload.map(item => isString(item) ? item : item.template);
|
this.payload = this.payload.map(item => isString(item) ? item : item.template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,15 @@ export default class RichText extends CustomElement {
|
|||||||
|
|
||||||
static get properties () {
|
static get properties () {
|
||||||
return {
|
return {
|
||||||
text: { type: String },
|
|
||||||
offset: { type: Number },
|
|
||||||
mentions: { type: Array },
|
mentions: { type: Array },
|
||||||
nick: { type: String },
|
nick: { type: String },
|
||||||
|
offset: { type: Number },
|
||||||
|
onImgClick: { type: Function },
|
||||||
|
onImgLoad: { type: Function },
|
||||||
render_styling: { type: Boolean },
|
render_styling: { type: Boolean },
|
||||||
show_images: { type: Boolean },
|
show_images: { type: Boolean },
|
||||||
onImgClick: { type: Function },
|
show_me_message: { type: Boolean },
|
||||||
onImgLoad: { type: Function }
|
text: { type: String },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,15 +24,17 @@ export default class RichText extends CustomElement {
|
|||||||
this.mentions = [];
|
this.mentions = [];
|
||||||
this.render_styling = false;
|
this.render_styling = false;
|
||||||
this.show_images = false;
|
this.show_images = false;
|
||||||
|
this.show_me_message = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const options = {
|
const options = {
|
||||||
nick: this.nick,
|
nick: this.nick,
|
||||||
render_styling: this.render_styling,
|
|
||||||
show_images: this.show_images,
|
|
||||||
onImgClick: this.onImgClick,
|
onImgClick: this.onImgClick,
|
||||||
onImgLoad: this.onImgLoad,
|
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);
|
return renderRichText(this.text, this.offset, this.mentions, options);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user