Add a call by name via @
This commit is contained in:
parent
546f8091c3
commit
9c07f6b7ac
1 changed files with 15 additions and 0 deletions
|
@ -13,11 +13,13 @@ ForkBB.editor = (function (doc, win) {
|
|||
'use strict';
|
||||
|
||||
var instance,
|
||||
nameSelector = ".f-username",
|
||||
dataName = "data-SCEditorConfig",
|
||||
emotName = "data-smiliesEnabled",
|
||||
linkName = "data-linkEnabled",
|
||||
selector = "textarea[" + dataName + "]",
|
||||
textarea,
|
||||
elForScroll,
|
||||
options = {
|
||||
format: 'bbcode',
|
||||
icons: 'monocons',
|
||||
|
@ -83,6 +85,19 @@ ForkBB.editor = (function (doc, win) {
|
|||
instance.emoticons(true);
|
||||
}
|
||||
}
|
||||
|
||||
elForScroll = textarea.parentNode;
|
||||
var users = doc.querySelectorAll(nameSelector);
|
||||
|
||||
for (var node of users) {
|
||||
var a = doc.createElement("a");
|
||||
a.textContent = "@";
|
||||
a.addEventListener('click', function (e) {
|
||||
instance.insert("[b]" + e.target.parentNode.textContent + "[/b], ");
|
||||
elForScroll.scrollIntoView({behavior: "smooth", block: "end"});
|
||||
});
|
||||
node.insertBefore(a, node.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Reference in a new issue