Add suggest menu for user mentions in text editor

This commit is contained in:
Frederic Guillot
2016-11-27 15:44:45 -05:00
parent 04ff67e26b
commit d8b0423d15
21 changed files with 454 additions and 30 deletions

View File

@@ -10,6 +10,14 @@ KB.dom = function (tag) {
return this;
};
this.data = function (attribute, value) {
if (arguments.length === 1) {
return element.dataset[attribute];
}
element.dataset[attribute] = value;
return this;
};
this.hide = function () {
element.style.display = 'none';
return this;
@@ -30,6 +38,11 @@ KB.dom = function (tag) {
return this;
};
this.style = function(attribute, value) {
element.style[attribute] = value;
return this;
};
this.on = function (eventName, callback) {
element.addEventListener(eventName, function (e) {
e.preventDefault();
@@ -43,6 +56,10 @@ KB.dom = function (tag) {
return this.on('click', callback);
};
this.mouseover = function (callback) {
return this.on('mouseover', callback);
};
this.change = function (callback) {
return this.on('change', callback);
};
@@ -96,6 +113,11 @@ KB.dom = function (tag) {
return this;
};
this.remove = function () {
element.parentNode.removeChild(element);
return this;
};
this.parent = function (selector) {
for (; element && element !== document; element = element.parentNode) {
if (element.matches(selector)) {