Forum Discussion
Akenefick
2 years agoGenius
Hi pp_01
I don't believe this is possible with any out of the box admin settings. You could add this JavaScript as a custom component to the Forum Topic Page. When a reply button is clicked it will grab that messages' id and make an API call to get the author info. Then it adds the mention to the reply editor.
<@liaAddScript>
;(function($){
var replyButtons = document.querySelectorAll('.reply-action-link');
var ed;
for (var i = 0; i < replyButtons.length; i++) {
replyButtons[i].addEventListener("click", (event) => {
var reply = event.target;
var message = reply.closest(".lia-message-view-wrapper");
var messageId = message.getAttribute("data-lia-message-uid");
var url = "/api/2.0/search?q=SELECT%20author.id,%20author.login%20FROM%20messages%20WHERE%20id%20=%27" + messageId + "%27"
tinymce.on('addeditor', function(e) {
ed = e.editor;
async function fetchAuthor() {
const response = await fetch(url);
const resp = await response.json();
console.log(resp)
var atMention = '<p><li-user login="' + resp.data.items[0].author.login + '" uid="' + resp.data.items[0].author.id + '"></li-user> </p>'
ed.execCommand('mceInsertContent', false, atMention);
var bm = ed.selection.getBookmark();
ed.selection.moveToBookmark(bm);
}
fetchAuthor()
})
})
}
})(LITHIUM.jQuery);
</@liaAddScript>
Related Content
- 2 years ago