Socket
Socket
Sign inDemoInstall

quill-mention

Package Overview
Dependencies
30
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.1 to 4.0.0

328

dist/quill.mention.csj.js

@@ -11,38 +11,30 @@ 'use strict';

var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
function _classCallCheck(instance, Constructor) {

@@ -53,3 +45,2 @@ if (!(instance instanceof Constructor)) {

}
function _defineProperties(target, props) {

@@ -61,13 +52,15 @@ for (var i = 0; i < props.length; i++) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {

@@ -83,11 +76,8 @@ Object.defineProperty(obj, key, {

}
return obj;
}
function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -99,9 +89,6 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);
}
function _inherits(subClass, superClass) {

@@ -111,3 +98,2 @@ if (typeof superClass !== "function" && superClass !== null) {

}
subClass.prototype = Object.create(superClass && superClass.prototype, {

@@ -120,7 +106,9 @@ constructor: {

});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);

@@ -130,12 +118,9 @@ };

}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {

@@ -145,3 +130,2 @@ if (typeof Reflect === "undefined" || !Reflect.construct) return false;

if (typeof Proxy === "function") return true;
try {

@@ -154,3 +138,2 @@ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));

}
function _assertThisInitialized(self) {

@@ -160,6 +143,4 @@ if (self === void 0) {

}
return self;
}
function _possibleConstructorReturn(self, call) {

@@ -171,16 +152,11 @@ if (call && (typeof call === "object" || typeof call === "function")) {

}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);

@@ -190,7 +166,5 @@ } else {

}
return _possibleConstructorReturn(this, result);
};
}
function _superPropBase(object, property) {

@@ -201,27 +175,20 @@ while (!Object.prototype.hasOwnProperty.call(object, property)) {

}
return object;
}
function _get() {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
_get = Reflect.get.bind();
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
}
return desc.value;
};
}
return _get.apply(this, arguments);
}
function _unsupportedIterableToArray(o, minLen) {

@@ -235,14 +202,9 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {

@@ -252,5 +214,3 @@ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {

var i = 0;
var F = function () {};
return {

@@ -273,9 +233,7 @@ s: F,

}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
didErr = false,
err;
return {

@@ -303,2 +261,16 @@ s: function () {

}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}

@@ -324,11 +296,12 @@ var Keys = {

}
function setInnerContent(element, value) {
if (value === null) return;
if (_typeof(value) === "object") element.appendChild(value);else element.innerText = value;
}
function getMentionCharIndex(text, mentionDenotationChars, isolateChar, allowInlineMentionChar) {
return mentionDenotationChars.reduce(function (prev, mentionChar) {
var mentionCharIndex;
if (isolateChar && allowInlineMentionChar) {
var regex = new RegExp("^".concat(mentionChar, "|\\s").concat(mentionChar), 'g');
var lastMatch = (text.match(regex) || []).pop();
if (!lastMatch) {

@@ -340,3 +313,2 @@ return {

}
mentionCharIndex = lastMatch !== mentionChar ? text.lastIndexOf(lastMatch) + lastMatch.length - mentionChar.length : 0;

@@ -346,3 +318,2 @@ } else {

}
if (mentionCharIndex > prev.mentionCharIndex) {

@@ -354,3 +325,2 @@ return {

}
return {

@@ -365,7 +335,5 @@ mentionChar: prev.mentionChar,

}
function hasValidChars(text, allowedChars) {
return allowedChars.test(text);
}
function hasValidMentionCharIndex(mentionCharIndex, text, isolateChar, textPrefix) {

@@ -375,7 +343,5 @@ if (mentionCharIndex === -1) {

}
if (!isolateChar) {
return true;
}
var mentionPrefix = mentionCharIndex ? text[mentionCharIndex - 1] : textPrefix;

@@ -386,19 +352,11 @@ return !mentionPrefix || !!mentionPrefix.match(/\s/);

var Embed = Quill__default["default"]["import"]("blots/embed");
var MentionBlot = /*#__PURE__*/function (_Embed) {
_inherits(MentionBlot, _Embed);
var _super = _createSuper(MentionBlot);
function MentionBlot(scroll, node) {
var _this;
_classCallCheck(this, MentionBlot);
_this = _super.call(this, scroll, node);
_defineProperty(_assertThisInitialized(_this), "hoverHandler", void 0);
_defineProperty(_assertThisInitialized(_this), "hoverHandler", void 0);
_this.clickHandler = null;

@@ -409,3 +367,2 @@ _this.hoverHandler = null;

}
_createClass(MentionBlot, [{

@@ -415,3 +372,2 @@ key: "attach",

_get(_getPrototypeOf(MentionBlot.prototype), "attach", this).call(this);
if (!this.mounted) {

@@ -429,5 +385,3 @@ this.mounted = true;

_get(_getPrototypeOf(MentionBlot.prototype), "detach", this).call(this);
this.mounted = false;
if (this.clickHandler) {

@@ -442,6 +396,4 @@ this.domNode.removeEventListener("click", this.clickHandler);

var _this2 = this;
return function (e) {
var event = _this2.buildEvent("mention-clicked", e);
window.dispatchEvent(event);

@@ -455,6 +407,4 @@ e.preventDefault();

var _this3 = this;
return function (e) {
var event = _this3.buildEvent('mention-hovered', e);
window.dispatchEvent(event);

@@ -479,8 +429,11 @@ e.preventDefault();

var node = _get(_getPrototypeOf(MentionBlot), "create", this).call(this);
var denotationChar = document.createElement("span");
denotationChar.className = "ql-mention-denotation-char";
denotationChar.innerHTML = data.denotationChar;
denotationChar.innerText = data.denotationChar;
node.appendChild(denotationChar);
node.innerHTML += data.value;
if (typeof this.render === 'function') {
node.appendChild(this.render(data));
} else {
node.innerText += data.value;
}
return MentionBlot.setDataValues(node, data);

@@ -503,10 +456,8 @@ }

}]);
return MentionBlot;
}(Embed);
MentionBlot.blotName = "mention";
MentionBlot.tagName = "span";
MentionBlot.className = "mention";
Quill__default["default"].register(MentionBlot);
Quill__default["default"].register("blots/mention", MentionBlot);

@@ -516,5 +467,3 @@ var Mention = /*#__PURE__*/function () {

var _this = this;
_classCallCheck(this, Mention);
this.isOpen = false;

@@ -525,7 +474,7 @@ this.itemIndex = 0;

this.values = [];
this.suspendMouseEnter = false; //this token is an object that may contains one key "abandoned", set to
this.suspendMouseEnter = false;
//this token is an object that may contains one key "abandoned", set to
//true when the previous source call should be ignored in favor or a
//more recent execution. This token will be null unless a source call
//is in progress.
this.existingSourceExecutionToken = null;

@@ -535,4 +484,5 @@ this.quill = quill;

source: null,
renderItem: function renderItem(item) {
return "".concat(item.value);
renderItem: function renderItem(_ref) {
var value = _ref.value;
return "".concat(value);
},

@@ -576,8 +526,7 @@ renderLoading: function renderLoading() {

};
_extends(this.options, options, {
dataAttributes: Array.isArray(options.dataAttributes) ? this.options.dataAttributes.concat(options.dataAttributes) : this.options.dataAttributes
}); //Bind all option-functions so they have a reasonable context
});
//Bind all option-functions so they have a reasonable context
for (var o in this.options) {

@@ -587,5 +536,5 @@ if (typeof this.options[o] === 'function') {

}
} //create mention container
}
//create mention container
this.mentionContainer = document.createElement("div");

@@ -595,7 +544,5 @@ this.mentionContainer.className = this.options.mentionContainerClass ? this.options.mentionContainerClass : "";

this.mentionContainer.onmousemove = this.onContainerMouseMove.bind(this);
if (this.options.fixMentionsToQuill) {
this.mentionContainer.style.width = "auto";
}
this.mentionList = document.createElement("ul");

@@ -607,9 +554,9 @@ this.mentionList.id = 'quill-mention-list';

quill.on("text-change", this.onTextChange.bind(this));
quill.on("selection-change", this.onSelectionChange.bind(this)); //Pasting doesn't fire selection-change after the pasted text is
quill.on("selection-change", this.onSelectionChange.bind(this));
//Pasting doesn't fire selection-change after the pasted text is
//inserted, so here we manually trigger one
quill.container.addEventListener("paste", function () {
setTimeout(function () {
var range = quill.getSelection();
_this.onSelectionChange(range);

@@ -622,6 +569,4 @@ });

quill.keyboard.bindings[Keys.TAB].unshift(quill.keyboard.bindings[Keys.TAB].pop());
var _iterator = _createForOfIteratorHelper(this.options.selectKeys),
_step;
_step;
try {

@@ -639,3 +584,2 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) {

}
quill.keyboard.bindings[Keys.ENTER].unshift(quill.keyboard.bindings[Keys.ENTER].pop());

@@ -652,3 +596,2 @@ quill.keyboard.addBinding({

}
_createClass(Mention, [{

@@ -661,3 +604,2 @@ key: "selectHandler",

}
return true;

@@ -672,7 +614,5 @@ }

}
this.hideMentionList();
return false;
}
return true;

@@ -687,3 +627,2 @@ }

}
return true;

@@ -698,3 +637,2 @@ }

}
return true;

@@ -710,3 +648,2 @@ }

}
this.mentionContainer.style.visibility = "hidden";

@@ -731,14 +668,10 @@ this.mentionContainer.style.display = "";

var scrollItemInView = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
for (var i = 0; i < this.mentionList.childNodes.length; i += 1) {
this.mentionList.childNodes[i].classList.remove("selected");
}
if (this.itemIndex === -1 || this.mentionList.childNodes[this.itemIndex].dataset.disabled === "true") {
return;
}
this.mentionList.childNodes[this.itemIndex].classList.add("selected");
this.quill.root.setAttribute('aria-activedescendant', this.mentionList.childNodes[this.itemIndex].id);
if (scrollItemInView) {

@@ -749,3 +682,2 @@ var itemHeight = this.mentionList.childNodes[this.itemIndex].offsetHeight;

var containerBottom = containerTop + this.mentionContainer.offsetHeight;
if (itemPos < containerTop) {

@@ -761,15 +693,2 @@ // Scroll up if the item is above the top of the container

}, {
key: "getItemData",
value: function getItemData() {
var link = this.mentionList.childNodes[this.itemIndex].dataset.link;
var hasLinkValue = typeof link !== "undefined";
var itemTarget = this.mentionList.childNodes[this.itemIndex].dataset.target;
if (hasLinkValue) {
this.mentionList.childNodes[this.itemIndex].dataset.value = "<a href=\"".concat(link, "\" target=").concat(itemTarget || this.options.linkTarget, ">").concat(this.mentionList.childNodes[this.itemIndex].dataset.value);
}
return this.mentionList.childNodes[this.itemIndex].dataset;
}
}, {
key: "onContainerMouseMove",

@@ -783,13 +702,9 @@ value: function onContainerMouseMove() {

var _this2 = this;
if (this.itemIndex === -1) {
return;
}
var data = this.getItemData();
var data = this.mentionList.childNodes[this.itemIndex].dataset;
if (data.disabled) {
return;
}
this.options.onSelect(data, function (asyncData) {

@@ -807,15 +722,10 @@ var programmaticInsert = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

var render = data;
if (render === null) {
return;
}
var options = _objectSpread2(_objectSpread2({}, this.options), overriddenOptions);
if (!options.showDenotationChar) {
render.denotationChar = "";
}
var insertAtPos;
if (!programmaticInsert) {

@@ -827,8 +737,6 @@ insertAtPos = this.mentionCharPos;

}
var delta = this.quill.insertEmbed(insertAtPos, options.blotName, render, Quill__default["default"].sources.USER);
if (options.spaceAfterInsert) {
this.quill.insertText(insertAtPos + 1, " ", Quill__default["default"].sources.USER); // setSelection here sets cursor position
this.quill.insertText(insertAtPos + 1, " ", Quill__default["default"].sources.USER);
// setSelection here sets cursor position
this.quill.setSelection(insertAtPos + 2, Quill__default["default"].sources.USER);

@@ -838,3 +746,2 @@ } else {

}
this.hideMentionList();

@@ -849,5 +756,3 @@ return delta;

}
var index = Number(e.target.dataset.index);
if (!Number.isNaN(index) && index !== this.itemIndex) {

@@ -864,3 +769,2 @@ this.itemIndex = index;

}
this.itemIndex = -1;

@@ -875,3 +779,2 @@ this.highlightItem(false);

}
e.preventDefault();

@@ -893,7 +796,5 @@ e.stopImmediatePropagation();

var renderedLoading = this.options.renderLoading();
if (!renderedLoading) {
return;
}
if (this.mentionContainer.getElementsByClassName("ql-mention-loading").length > 0) {

@@ -903,7 +804,6 @@ this.showMentionList();

}
this.mentionList.innerHTML = "";
var loadingDiv = document.createElement("div");
loadingDiv.className = "ql-mention-loading";
loadingDiv.innerHTML = this.options.renderLoading();
setInnerContent(loadingDiv, this.options.renderLoading());
this.mentionContainer.append(loadingDiv);

@@ -916,3 +816,2 @@ this.showMentionList();

var loadingDiv = this.mentionContainer.getElementsByClassName("ql-mention-loading");
if (loadingDiv.length > 0) {

@@ -928,5 +827,4 @@ loadingDiv[0].remove();

this.values = data;
this.mentionList.innerHTML = "";
this.mentionList.innerText = "";
var initialSelection = -1;
for (var i = 0; i < data.length; i += 1) {

@@ -936,3 +834,2 @@ var li = document.createElement("li");

li.className = this.options.listItemClass ? this.options.listItemClass : "";
if (data[i].disabled) {

@@ -944,6 +841,5 @@ li.className += " disabled";

}
li.dataset.index = i;
li.innerHTML = this.options.renderItem(data[i], searchTerm);
var renderedItem = this.options.renderItem(data[i], searchTerm);
setInnerContent(li, renderedItem);
if (!data[i].disabled) {

@@ -956,7 +852,5 @@ li.onmouseenter = this.onItemMouseEnter.bind(this);

}
li.dataset.denotationChar = mentionChar;
this.mentionList.appendChild(attachDataValues(li, data[i], this.options.dataAttributes));
}
this.itemIndex = initialSelection;

@@ -974,3 +868,2 @@ this.highlightItem();

var newIndex;
do {

@@ -980,3 +873,2 @@ increment++;

var disabled = this.mentionList.childNodes[newIndex].dataset.disabled === "true";
if (increment === this.values.length + 1) {

@@ -988,3 +880,2 @@ //we've wrapped around w/o finding an enabled item

} while (disabled);
this.itemIndex = newIndex;

@@ -999,3 +890,2 @@ this.suspendMouseEnter = true;

var newIndex;
do {

@@ -1005,3 +895,2 @@ decrement++;

var disabled = this.mentionList.childNodes[newIndex].dataset.disabled === "true";
if (decrement === this.values.length + 1) {

@@ -1013,3 +902,2 @@ //we've wrapped around w/o finding an enabled item

} while (disabled);
this.itemIndex = newIndex;

@@ -1031,3 +919,2 @@ this.suspendMouseEnter = true;

}
var rightPos = leftPos + this.mentionContainer.offsetWidth + containerPos.left;

@@ -1046,3 +933,2 @@ var browserWidth = window.pageXOffset + document.documentElement.clientWidth;

}
this.isOpen = isOpen;

@@ -1064,3 +950,2 @@ }

var _this3 = this;
var containerPos = this.quill.container.getBoundingClientRect();

@@ -1070,4 +955,5 @@ var mentionCharPos = this.quill.getBounds(this.mentionCharPos);

var topPos = this.options.offsetTop;
var leftPos = this.options.offsetLeft; // handle horizontal positioning
var leftPos = this.options.offsetLeft;
// handle horizontal positioning
if (this.options.fixMentionsToQuill) {

@@ -1079,3 +965,2 @@ var rightPos = 0;

}
if (this.containerRightIsNotVisible(leftPos, containerPos)) {

@@ -1085,5 +970,5 @@ var containerWidth = this.mentionContainer.offsetWidth + this.options.offsetLeft;

leftPos = quillWidth - containerWidth;
} // handle vertical positioning
}
// handle vertical positioning
if (this.options.defaultMenuOrientation === "top") {

@@ -1095,8 +980,7 @@ // Attempt to align the mention container with the top of the quill editor

topPos = mentionCharPos.top - (containerHeight + this.options.offsetTop);
} // default to bottom if the top is not visible
}
// default to bottom if the top is not visible
if (topPos + containerPos.top <= 0) {
var overMentionCharPos = this.options.offsetTop;
if (this.options.fixMentionsToQuill) {

@@ -1107,3 +991,2 @@ overMentionCharPos += containerPos.height;

}
topPos = overMentionCharPos;

@@ -1117,20 +1000,16 @@ }

topPos += mentionCharPos.bottom;
} // default to the top if the bottom is not visible
}
// default to the top if the bottom is not visible
if (this.containerBottomIsNotVisible(topPos, containerPos)) {
var _overMentionCharPos = this.options.offsetTop * -1;
if (!this.options.fixMentionsToQuill) {
_overMentionCharPos += mentionCharPos.top;
}
topPos = _overMentionCharPos - containerHeight;
}
}
if (topPos >= 0) {
this.options.mentionContainerClass.split(' ').forEach(function (className) {
_this3.mentionContainer.classList.add("".concat(className, "-bottom"));
_this3.mentionContainer.classList.remove("".concat(className, "-top"));

@@ -1141,7 +1020,5 @@ });

_this3.mentionContainer.classList.add("".concat(className, "-top"));
_this3.mentionContainer.classList.remove("".concat(className, "-bottom"));
});
}
this.mentionContainer.style.top = "".concat(topPos, "px");

@@ -1155,3 +1032,2 @@ this.mentionContainer.style.left = "".concat(leftPos, "px");

var _this4 = this;
this.mentionContainer.style.position = "fixed";

@@ -1166,8 +1042,10 @@ this.mentionContainer.style.height = null;

height: mentionCharPos.height
}; //Which rectangle should it be relative to
};
//Which rectangle should it be relative to
var relativeToPos = this.options.fixMentionsToQuill ? containerPos : mentionCharPosAbsolute;
var topPos = this.options.offsetTop;
var leftPos = this.options.offsetLeft; // handle horizontal positioning
var leftPos = this.options.offsetLeft;
// handle horizontal positioning
if (this.options.fixMentionsToQuill) {

@@ -1177,4 +1055,5 @@ var rightPos = relativeToPos.right;

} else {
leftPos += relativeToPos.left; //if its off the righ edge, push it back
leftPos += relativeToPos.left;
//if its off the righ edge, push it back
if (leftPos + this.mentionContainer.offsetWidth > document.documentElement.clientWidth) {

@@ -1184,3 +1063,2 @@ leftPos -= leftPos + this.mentionContainer.offsetWidth - document.documentElement.clientWidth;

}
var availableSpaceTop = relativeToPos.top;

@@ -1191,3 +1069,2 @@ var availableSpaceBottom = document.documentElement.clientHeight - (relativeToPos.top + relativeToPos.height);

var placement;
if (this.options.defaultMenuOrientation === "top" && fitsTop) {

@@ -1201,6 +1078,4 @@ placement = "top";

}
if (placement === "bottom") {
topPos = relativeToPos.top + relativeToPos.height;
if (!fitsBottom) {

@@ -1211,6 +1086,4 @@ //shrink it to fit

}
this.options.mentionContainerClass.split(" ").forEach(function (className) {
_this4.mentionContainer.classList.add("".concat(className, "-bottom"));
_this4.mentionContainer.classList.remove("".concat(className, "-top"));

@@ -1220,3 +1093,2 @@ });

topPos = relativeToPos.top - this.mentionContainer.offsetHeight;
if (!fitsTop) {

@@ -1228,10 +1100,7 @@ //shrink it to fit

}
this.options.mentionContainerClass.split(" ").forEach(function (className) {
_this4.mentionContainer.classList.add("".concat(className, "-top"));
_this4.mentionContainer.classList.remove("".concat(className, "-bottom"));
});
}
this.mentionContainer.style.top = "".concat(topPos, "px");

@@ -1252,3 +1121,2 @@ this.mentionContainer.style.left = "".concat(leftPos, "px");

var _this5 = this;
var range = this.quill.getSelection();

@@ -1260,7 +1128,5 @@ if (range == null) return;

var textPrefix = textOffset ? this.quill.getText(textOffset - 1, textOffset) : '';
var _getMentionCharIndex = getMentionCharIndex(textBeforeCursor, this.options.mentionDenotationChars, this.options.isolateCharacter, this.options.allowInlineMentionChar),
mentionChar = _getMentionCharIndex.mentionChar,
mentionCharIndex = _getMentionCharIndex.mentionCharIndex;
mentionChar = _getMentionCharIndex.mentionChar,
mentionCharIndex = _getMentionCharIndex.mentionCharIndex;
if (hasValidMentionCharIndex(mentionCharIndex, textBeforeCursor, this.options.isolateCharacter, textPrefix)) {

@@ -1270,3 +1136,2 @@ var mentionCharPos = this.cursorPos - (textBeforeCursor.length - mentionCharIndex);

var textAfter = textBeforeCursor.substring(mentionCharIndex + mentionChar.length);
if (textAfter.length >= this.options.minChars && hasValidChars(textAfter, this.getAllowedCharsRegex(mentionChar))) {

@@ -1276,3 +1141,2 @@ if (this.existingSourceExecutionToken) {

}
this.renderLoading();

@@ -1287,5 +1151,3 @@ var sourceRequestToken = {

}
_this5.existingSourceExecutionToken = null;
_this5.renderList(mentionChar, data, searchTerm);

@@ -1297,3 +1159,2 @@ }, mentionChar);

}
this.hideMentionList();

@@ -1305,3 +1166,2 @@ }

}
this.hideMentionList();

@@ -1344,8 +1204,6 @@ }

}]);
return Mention;
}();
Quill__default["default"].register("modules/mention", Mention);
module.exports = Mention;

@@ -5,38 +5,30 @@ import Quill from 'quill';

var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
function _classCallCheck(instance, Constructor) {

@@ -47,3 +39,2 @@ if (!(instance instanceof Constructor)) {

}
function _defineProperties(target, props) {

@@ -55,13 +46,15 @@ for (var i = 0; i < props.length; i++) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {

@@ -77,11 +70,8 @@ Object.defineProperty(obj, key, {

}
return obj;
}
function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -93,9 +83,6 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);
}
function _inherits(subClass, superClass) {

@@ -105,3 +92,2 @@ if (typeof superClass !== "function" && superClass !== null) {

}
subClass.prototype = Object.create(superClass && superClass.prototype, {

@@ -114,7 +100,9 @@ constructor: {

});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);

@@ -124,12 +112,9 @@ };

}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {

@@ -139,3 +124,2 @@ if (typeof Reflect === "undefined" || !Reflect.construct) return false;

if (typeof Proxy === "function") return true;
try {

@@ -148,3 +132,2 @@ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));

}
function _assertThisInitialized(self) {

@@ -154,6 +137,4 @@ if (self === void 0) {

}
return self;
}
function _possibleConstructorReturn(self, call) {

@@ -165,16 +146,11 @@ if (call && (typeof call === "object" || typeof call === "function")) {

}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);

@@ -184,7 +160,5 @@ } else {

}
return _possibleConstructorReturn(this, result);
};
}
function _superPropBase(object, property) {

@@ -195,27 +169,20 @@ while (!Object.prototype.hasOwnProperty.call(object, property)) {

}
return object;
}
function _get() {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
_get = Reflect.get.bind();
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
}
return desc.value;
};
}
return _get.apply(this, arguments);
}
function _unsupportedIterableToArray(o, minLen) {

@@ -229,14 +196,9 @@ if (!o) return;

}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {

@@ -246,5 +208,3 @@ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {

var i = 0;
var F = function () {};
return {

@@ -267,9 +227,7 @@ s: F,

}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
didErr = false,
err;
return {

@@ -297,2 +255,16 @@ s: function () {

}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}

@@ -318,11 +290,12 @@ var Keys = {

}
function setInnerContent(element, value) {
if (value === null) return;
if (_typeof(value) === "object") element.appendChild(value);else element.innerText = value;
}
function getMentionCharIndex(text, mentionDenotationChars, isolateChar, allowInlineMentionChar) {
return mentionDenotationChars.reduce(function (prev, mentionChar) {
var mentionCharIndex;
if (isolateChar && allowInlineMentionChar) {
var regex = new RegExp("^".concat(mentionChar, "|\\s").concat(mentionChar), 'g');
var lastMatch = (text.match(regex) || []).pop();
if (!lastMatch) {

@@ -334,3 +307,2 @@ return {

}
mentionCharIndex = lastMatch !== mentionChar ? text.lastIndexOf(lastMatch) + lastMatch.length - mentionChar.length : 0;

@@ -340,3 +312,2 @@ } else {

}
if (mentionCharIndex > prev.mentionCharIndex) {

@@ -348,3 +319,2 @@ return {

}
return {

@@ -359,7 +329,5 @@ mentionChar: prev.mentionChar,

}
function hasValidChars(text, allowedChars) {
return allowedChars.test(text);
}
function hasValidMentionCharIndex(mentionCharIndex, text, isolateChar, textPrefix) {

@@ -369,7 +337,5 @@ if (mentionCharIndex === -1) {

}
if (!isolateChar) {
return true;
}
var mentionPrefix = mentionCharIndex ? text[mentionCharIndex - 1] : textPrefix;

@@ -380,19 +346,11 @@ return !mentionPrefix || !!mentionPrefix.match(/\s/);

var Embed = Quill["import"]("blots/embed");
var MentionBlot = /*#__PURE__*/function (_Embed) {
_inherits(MentionBlot, _Embed);
var _super = _createSuper(MentionBlot);
function MentionBlot(scroll, node) {
var _this;
_classCallCheck(this, MentionBlot);
_this = _super.call(this, scroll, node);
_defineProperty(_assertThisInitialized(_this), "hoverHandler", void 0);
_defineProperty(_assertThisInitialized(_this), "hoverHandler", void 0);
_this.clickHandler = null;

@@ -403,3 +361,2 @@ _this.hoverHandler = null;

}
_createClass(MentionBlot, [{

@@ -409,3 +366,2 @@ key: "attach",

_get(_getPrototypeOf(MentionBlot.prototype), "attach", this).call(this);
if (!this.mounted) {

@@ -423,5 +379,3 @@ this.mounted = true;

_get(_getPrototypeOf(MentionBlot.prototype), "detach", this).call(this);
this.mounted = false;
if (this.clickHandler) {

@@ -436,6 +390,4 @@ this.domNode.removeEventListener("click", this.clickHandler);

var _this2 = this;
return function (e) {
var event = _this2.buildEvent("mention-clicked", e);
window.dispatchEvent(event);

@@ -449,6 +401,4 @@ e.preventDefault();

var _this3 = this;
return function (e) {
var event = _this3.buildEvent('mention-hovered', e);
window.dispatchEvent(event);

@@ -473,8 +423,11 @@ e.preventDefault();

var node = _get(_getPrototypeOf(MentionBlot), "create", this).call(this);
var denotationChar = document.createElement("span");
denotationChar.className = "ql-mention-denotation-char";
denotationChar.innerHTML = data.denotationChar;
denotationChar.innerText = data.denotationChar;
node.appendChild(denotationChar);
node.innerHTML += data.value;
if (typeof this.render === 'function') {
node.appendChild(this.render(data));
} else {
node.innerText += data.value;
}
return MentionBlot.setDataValues(node, data);

@@ -497,10 +450,8 @@ }

}]);
return MentionBlot;
}(Embed);
MentionBlot.blotName = "mention";
MentionBlot.tagName = "span";
MentionBlot.className = "mention";
Quill.register(MentionBlot);
Quill.register("blots/mention", MentionBlot);

@@ -510,5 +461,3 @@ var Mention = /*#__PURE__*/function () {

var _this = this;
_classCallCheck(this, Mention);
this.isOpen = false;

@@ -519,7 +468,7 @@ this.itemIndex = 0;

this.values = [];
this.suspendMouseEnter = false; //this token is an object that may contains one key "abandoned", set to
this.suspendMouseEnter = false;
//this token is an object that may contains one key "abandoned", set to
//true when the previous source call should be ignored in favor or a
//more recent execution. This token will be null unless a source call
//is in progress.
this.existingSourceExecutionToken = null;

@@ -529,4 +478,5 @@ this.quill = quill;

source: null,
renderItem: function renderItem(item) {
return "".concat(item.value);
renderItem: function renderItem(_ref) {
var value = _ref.value;
return "".concat(value);
},

@@ -570,8 +520,7 @@ renderLoading: function renderLoading() {

};
_extends(this.options, options, {
dataAttributes: Array.isArray(options.dataAttributes) ? this.options.dataAttributes.concat(options.dataAttributes) : this.options.dataAttributes
}); //Bind all option-functions so they have a reasonable context
});
//Bind all option-functions so they have a reasonable context
for (var o in this.options) {

@@ -581,5 +530,5 @@ if (typeof this.options[o] === 'function') {

}
} //create mention container
}
//create mention container
this.mentionContainer = document.createElement("div");

@@ -589,7 +538,5 @@ this.mentionContainer.className = this.options.mentionContainerClass ? this.options.mentionContainerClass : "";

this.mentionContainer.onmousemove = this.onContainerMouseMove.bind(this);
if (this.options.fixMentionsToQuill) {
this.mentionContainer.style.width = "auto";
}
this.mentionList = document.createElement("ul");

@@ -601,9 +548,9 @@ this.mentionList.id = 'quill-mention-list';

quill.on("text-change", this.onTextChange.bind(this));
quill.on("selection-change", this.onSelectionChange.bind(this)); //Pasting doesn't fire selection-change after the pasted text is
quill.on("selection-change", this.onSelectionChange.bind(this));
//Pasting doesn't fire selection-change after the pasted text is
//inserted, so here we manually trigger one
quill.container.addEventListener("paste", function () {
setTimeout(function () {
var range = quill.getSelection();
_this.onSelectionChange(range);

@@ -616,6 +563,4 @@ });

quill.keyboard.bindings[Keys.TAB].unshift(quill.keyboard.bindings[Keys.TAB].pop());
var _iterator = _createForOfIteratorHelper(this.options.selectKeys),
_step;
_step;
try {

@@ -633,3 +578,2 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) {

}
quill.keyboard.bindings[Keys.ENTER].unshift(quill.keyboard.bindings[Keys.ENTER].pop());

@@ -646,3 +590,2 @@ quill.keyboard.addBinding({

}
_createClass(Mention, [{

@@ -655,3 +598,2 @@ key: "selectHandler",

}
return true;

@@ -666,7 +608,5 @@ }

}
this.hideMentionList();
return false;
}
return true;

@@ -681,3 +621,2 @@ }

}
return true;

@@ -692,3 +631,2 @@ }

}
return true;

@@ -704,3 +642,2 @@ }

}
this.mentionContainer.style.visibility = "hidden";

@@ -725,14 +662,10 @@ this.mentionContainer.style.display = "";

var scrollItemInView = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
for (var i = 0; i < this.mentionList.childNodes.length; i += 1) {
this.mentionList.childNodes[i].classList.remove("selected");
}
if (this.itemIndex === -1 || this.mentionList.childNodes[this.itemIndex].dataset.disabled === "true") {
return;
}
this.mentionList.childNodes[this.itemIndex].classList.add("selected");
this.quill.root.setAttribute('aria-activedescendant', this.mentionList.childNodes[this.itemIndex].id);
if (scrollItemInView) {

@@ -743,3 +676,2 @@ var itemHeight = this.mentionList.childNodes[this.itemIndex].offsetHeight;

var containerBottom = containerTop + this.mentionContainer.offsetHeight;
if (itemPos < containerTop) {

@@ -755,15 +687,2 @@ // Scroll up if the item is above the top of the container

}, {
key: "getItemData",
value: function getItemData() {
var link = this.mentionList.childNodes[this.itemIndex].dataset.link;
var hasLinkValue = typeof link !== "undefined";
var itemTarget = this.mentionList.childNodes[this.itemIndex].dataset.target;
if (hasLinkValue) {
this.mentionList.childNodes[this.itemIndex].dataset.value = "<a href=\"".concat(link, "\" target=").concat(itemTarget || this.options.linkTarget, ">").concat(this.mentionList.childNodes[this.itemIndex].dataset.value);
}
return this.mentionList.childNodes[this.itemIndex].dataset;
}
}, {
key: "onContainerMouseMove",

@@ -777,13 +696,9 @@ value: function onContainerMouseMove() {

var _this2 = this;
if (this.itemIndex === -1) {
return;
}
var data = this.getItemData();
var data = this.mentionList.childNodes[this.itemIndex].dataset;
if (data.disabled) {
return;
}
this.options.onSelect(data, function (asyncData) {

@@ -801,15 +716,10 @@ var programmaticInsert = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

var render = data;
if (render === null) {
return;
}
var options = _objectSpread2(_objectSpread2({}, this.options), overriddenOptions);
if (!options.showDenotationChar) {
render.denotationChar = "";
}
var insertAtPos;
if (!programmaticInsert) {

@@ -821,8 +731,6 @@ insertAtPos = this.mentionCharPos;

}
var delta = this.quill.insertEmbed(insertAtPos, options.blotName, render, Quill.sources.USER);
if (options.spaceAfterInsert) {
this.quill.insertText(insertAtPos + 1, " ", Quill.sources.USER); // setSelection here sets cursor position
this.quill.insertText(insertAtPos + 1, " ", Quill.sources.USER);
// setSelection here sets cursor position
this.quill.setSelection(insertAtPos + 2, Quill.sources.USER);

@@ -832,3 +740,2 @@ } else {

}
this.hideMentionList();

@@ -843,5 +750,3 @@ return delta;

}
var index = Number(e.target.dataset.index);
if (!Number.isNaN(index) && index !== this.itemIndex) {

@@ -858,3 +763,2 @@ this.itemIndex = index;

}
this.itemIndex = -1;

@@ -869,3 +773,2 @@ this.highlightItem(false);

}
e.preventDefault();

@@ -887,7 +790,5 @@ e.stopImmediatePropagation();

var renderedLoading = this.options.renderLoading();
if (!renderedLoading) {
return;
}
if (this.mentionContainer.getElementsByClassName("ql-mention-loading").length > 0) {

@@ -897,7 +798,6 @@ this.showMentionList();

}
this.mentionList.innerHTML = "";
var loadingDiv = document.createElement("div");
loadingDiv.className = "ql-mention-loading";
loadingDiv.innerHTML = this.options.renderLoading();
setInnerContent(loadingDiv, this.options.renderLoading());
this.mentionContainer.append(loadingDiv);

@@ -910,3 +810,2 @@ this.showMentionList();

var loadingDiv = this.mentionContainer.getElementsByClassName("ql-mention-loading");
if (loadingDiv.length > 0) {

@@ -922,5 +821,4 @@ loadingDiv[0].remove();

this.values = data;
this.mentionList.innerHTML = "";
this.mentionList.innerText = "";
var initialSelection = -1;
for (var i = 0; i < data.length; i += 1) {

@@ -930,3 +828,2 @@ var li = document.createElement("li");

li.className = this.options.listItemClass ? this.options.listItemClass : "";
if (data[i].disabled) {

@@ -938,6 +835,5 @@ li.className += " disabled";

}
li.dataset.index = i;
li.innerHTML = this.options.renderItem(data[i], searchTerm);
var renderedItem = this.options.renderItem(data[i], searchTerm);
setInnerContent(li, renderedItem);
if (!data[i].disabled) {

@@ -950,7 +846,5 @@ li.onmouseenter = this.onItemMouseEnter.bind(this);

}
li.dataset.denotationChar = mentionChar;
this.mentionList.appendChild(attachDataValues(li, data[i], this.options.dataAttributes));
}
this.itemIndex = initialSelection;

@@ -968,3 +862,2 @@ this.highlightItem();

var newIndex;
do {

@@ -974,3 +867,2 @@ increment++;

var disabled = this.mentionList.childNodes[newIndex].dataset.disabled === "true";
if (increment === this.values.length + 1) {

@@ -982,3 +874,2 @@ //we've wrapped around w/o finding an enabled item

} while (disabled);
this.itemIndex = newIndex;

@@ -993,3 +884,2 @@ this.suspendMouseEnter = true;

var newIndex;
do {

@@ -999,3 +889,2 @@ decrement++;

var disabled = this.mentionList.childNodes[newIndex].dataset.disabled === "true";
if (decrement === this.values.length + 1) {

@@ -1007,3 +896,2 @@ //we've wrapped around w/o finding an enabled item

} while (disabled);
this.itemIndex = newIndex;

@@ -1025,3 +913,2 @@ this.suspendMouseEnter = true;

}
var rightPos = leftPos + this.mentionContainer.offsetWidth + containerPos.left;

@@ -1040,3 +927,2 @@ var browserWidth = window.pageXOffset + document.documentElement.clientWidth;

}
this.isOpen = isOpen;

@@ -1058,3 +944,2 @@ }

var _this3 = this;
var containerPos = this.quill.container.getBoundingClientRect();

@@ -1064,4 +949,5 @@ var mentionCharPos = this.quill.getBounds(this.mentionCharPos);

var topPos = this.options.offsetTop;
var leftPos = this.options.offsetLeft; // handle horizontal positioning
var leftPos = this.options.offsetLeft;
// handle horizontal positioning
if (this.options.fixMentionsToQuill) {

@@ -1073,3 +959,2 @@ var rightPos = 0;

}
if (this.containerRightIsNotVisible(leftPos, containerPos)) {

@@ -1079,5 +964,5 @@ var containerWidth = this.mentionContainer.offsetWidth + this.options.offsetLeft;

leftPos = quillWidth - containerWidth;
} // handle vertical positioning
}
// handle vertical positioning
if (this.options.defaultMenuOrientation === "top") {

@@ -1089,8 +974,7 @@ // Attempt to align the mention container with the top of the quill editor

topPos = mentionCharPos.top - (containerHeight + this.options.offsetTop);
} // default to bottom if the top is not visible
}
// default to bottom if the top is not visible
if (topPos + containerPos.top <= 0) {
var overMentionCharPos = this.options.offsetTop;
if (this.options.fixMentionsToQuill) {

@@ -1101,3 +985,2 @@ overMentionCharPos += containerPos.height;

}
topPos = overMentionCharPos;

@@ -1111,20 +994,16 @@ }

topPos += mentionCharPos.bottom;
} // default to the top if the bottom is not visible
}
// default to the top if the bottom is not visible
if (this.containerBottomIsNotVisible(topPos, containerPos)) {
var _overMentionCharPos = this.options.offsetTop * -1;
if (!this.options.fixMentionsToQuill) {
_overMentionCharPos += mentionCharPos.top;
}
topPos = _overMentionCharPos - containerHeight;
}
}
if (topPos >= 0) {
this.options.mentionContainerClass.split(' ').forEach(function (className) {
_this3.mentionContainer.classList.add("".concat(className, "-bottom"));
_this3.mentionContainer.classList.remove("".concat(className, "-top"));

@@ -1135,7 +1014,5 @@ });

_this3.mentionContainer.classList.add("".concat(className, "-top"));
_this3.mentionContainer.classList.remove("".concat(className, "-bottom"));
});
}
this.mentionContainer.style.top = "".concat(topPos, "px");

@@ -1149,3 +1026,2 @@ this.mentionContainer.style.left = "".concat(leftPos, "px");

var _this4 = this;
this.mentionContainer.style.position = "fixed";

@@ -1160,8 +1036,10 @@ this.mentionContainer.style.height = null;

height: mentionCharPos.height
}; //Which rectangle should it be relative to
};
//Which rectangle should it be relative to
var relativeToPos = this.options.fixMentionsToQuill ? containerPos : mentionCharPosAbsolute;
var topPos = this.options.offsetTop;
var leftPos = this.options.offsetLeft; // handle horizontal positioning
var leftPos = this.options.offsetLeft;
// handle horizontal positioning
if (this.options.fixMentionsToQuill) {

@@ -1171,4 +1049,5 @@ var rightPos = relativeToPos.right;

} else {
leftPos += relativeToPos.left; //if its off the righ edge, push it back
leftPos += relativeToPos.left;
//if its off the righ edge, push it back
if (leftPos + this.mentionContainer.offsetWidth > document.documentElement.clientWidth) {

@@ -1178,3 +1057,2 @@ leftPos -= leftPos + this.mentionContainer.offsetWidth - document.documentElement.clientWidth;

}
var availableSpaceTop = relativeToPos.top;

@@ -1185,3 +1063,2 @@ var availableSpaceBottom = document.documentElement.clientHeight - (relativeToPos.top + relativeToPos.height);

var placement;
if (this.options.defaultMenuOrientation === "top" && fitsTop) {

@@ -1195,6 +1072,4 @@ placement = "top";

}
if (placement === "bottom") {
topPos = relativeToPos.top + relativeToPos.height;
if (!fitsBottom) {

@@ -1205,6 +1080,4 @@ //shrink it to fit

}
this.options.mentionContainerClass.split(" ").forEach(function (className) {
_this4.mentionContainer.classList.add("".concat(className, "-bottom"));
_this4.mentionContainer.classList.remove("".concat(className, "-top"));

@@ -1214,3 +1087,2 @@ });

topPos = relativeToPos.top - this.mentionContainer.offsetHeight;
if (!fitsTop) {

@@ -1222,10 +1094,7 @@ //shrink it to fit

}
this.options.mentionContainerClass.split(" ").forEach(function (className) {
_this4.mentionContainer.classList.add("".concat(className, "-top"));
_this4.mentionContainer.classList.remove("".concat(className, "-bottom"));
});
}
this.mentionContainer.style.top = "".concat(topPos, "px");

@@ -1246,3 +1115,2 @@ this.mentionContainer.style.left = "".concat(leftPos, "px");

var _this5 = this;
var range = this.quill.getSelection();

@@ -1254,7 +1122,5 @@ if (range == null) return;

var textPrefix = textOffset ? this.quill.getText(textOffset - 1, textOffset) : '';
var _getMentionCharIndex = getMentionCharIndex(textBeforeCursor, this.options.mentionDenotationChars, this.options.isolateCharacter, this.options.allowInlineMentionChar),
mentionChar = _getMentionCharIndex.mentionChar,
mentionCharIndex = _getMentionCharIndex.mentionCharIndex;
mentionChar = _getMentionCharIndex.mentionChar,
mentionCharIndex = _getMentionCharIndex.mentionCharIndex;
if (hasValidMentionCharIndex(mentionCharIndex, textBeforeCursor, this.options.isolateCharacter, textPrefix)) {

@@ -1264,3 +1130,2 @@ var mentionCharPos = this.cursorPos - (textBeforeCursor.length - mentionCharIndex);

var textAfter = textBeforeCursor.substring(mentionCharIndex + mentionChar.length);
if (textAfter.length >= this.options.minChars && hasValidChars(textAfter, this.getAllowedCharsRegex(mentionChar))) {

@@ -1270,3 +1135,2 @@ if (this.existingSourceExecutionToken) {

}
this.renderLoading();

@@ -1281,5 +1145,3 @@ var sourceRequestToken = {

}
_this5.existingSourceExecutionToken = null;
_this5.renderList(mentionChar, data, searchTerm);

@@ -1291,3 +1153,2 @@ }, mentionChar);

}
this.hideMentionList();

@@ -1299,3 +1160,2 @@ }

}
this.hideMentionList();

@@ -1338,8 +1198,6 @@ }

}]);
return Mention;
}();
Quill.register("modules/mention", Mention);
export { Mention as default };

@@ -1,1 +0,1 @@

var quillMention=function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){l(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function a(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function l(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(){return h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},h.apply(this,arguments)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return d(t)}function m(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=u(t);if(e){var o=u(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return f(this,n)}}function p(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=p(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},v.apply(this,arguments)}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function y(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return g(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,r=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return r=t.done,t},e:function(t){a=!0,s=t},f:function(){try{r||null==n.return||n.return()}finally{if(a)throw s}}}}var C=9,b=13,x=27,k=38,I=40;function L(t,e,n){var i=t;return Object.keys(e).forEach((function(t){n.indexOf(t)>-1?i.dataset[t]=e[t]:delete i.dataset[t]})),i}var E=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}(n,t);var e=m(n);function n(t,i){var o;return s(this,n),l(d(o=e.call(this,t,i)),"hoverHandler",void 0),l(d(o),"hoverHandler",void 0),o.clickHandler=null,o.hoverHandler=null,o.mounted=!1,o}return a(n,[{key:"attach",value:function(){v(u(n.prototype),"attach",this).call(this),this.mounted||(this.mounted=!0,this.clickHandler=this.getClickHandler(),this.hoverHandler=this.getHoverHandler(),this.domNode.addEventListener("click",this.clickHandler,!1),this.domNode.addEventListener("mouseenter",this.hoverHandler,!1))}},{key:"detach",value:function(){v(u(n.prototype),"detach",this).call(this),this.mounted=!1,this.clickHandler&&(this.domNode.removeEventListener("click",this.clickHandler),this.clickHandler=null)}},{key:"getClickHandler",value:function(){var t=this;return function(e){var n=t.buildEvent("mention-clicked",e);window.dispatchEvent(n),e.preventDefault()}}},{key:"getHoverHandler",value:function(){var t=this;return function(e){var n=t.buildEvent("mention-hovered",e);window.dispatchEvent(n),e.preventDefault()}}},{key:"buildEvent",value:function(t,e){var n=new Event(t,{bubbles:!0,cancelable:!0});return n.value=h({},this.domNode.dataset),n.event=e,n}}],[{key:"create",value:function(t){var e=v(u(n),"create",this).call(this),i=document.createElement("span");return i.className="ql-mention-denotation-char",i.innerHTML=t.denotationChar,e.appendChild(i),e.innerHTML+=t.value,n.setDataValues(e,t)}},{key:"setDataValues",value:function(t,e){var n=t;return Object.keys(e).forEach((function(t){n.dataset[t]=e[t]})),n}},{key:"value",value:function(t){return t.dataset}}]),n}(n.default.import("blots/embed"));E.blotName="mention",E.tagName="span",E.className="mention",n.default.register(E);var w=function(){function t(e,n){var i=this;for(var o in s(this,t),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.existingSourceExecutionToken=null,this.quill=e,this.options={source:null,renderItem:function(t){return"".concat(t.value)},renderLoading:function(){return null},onSelect:function(t,e){e(t)},mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,allowInlineMentionChar:!1,fixMentionsToQuill:!1,positioningStrategy:"normal",defaultMenuOrientation:"bottom",blotName:"mention",dataAttributes:["id","value","denotationChar","link","target","disabled"],linkTarget:"_blank",onOpen:function(){return!0},onBeforeClose:function(){return!0},onClose:function(){return!0},listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0,selectKeys:[b]},h(this.options,n,{dataAttributes:Array.isArray(n.dataAttributes)?this.options.dataAttributes.concat(n.dataAttributes):this.options.dataAttributes}),this.options)"function"==typeof this.options[o]&&(this.options[o]=this.options[o].bind(this));this.mentionContainer=document.createElement("div"),this.mentionContainer.className=this.options.mentionContainerClass?this.options.mentionContainerClass:"",this.mentionContainer.style.cssText="display: none; position: absolute;",this.mentionContainer.onmousemove=this.onContainerMouseMove.bind(this),this.options.fixMentionsToQuill&&(this.mentionContainer.style.width="auto"),this.mentionList=document.createElement("ul"),this.mentionList.id="quill-mention-list",e.root.setAttribute("aria-owns","quill-mention-list"),this.mentionList.className=this.options.mentionListClass?this.options.mentionListClass:"",this.mentionContainer.appendChild(this.mentionList),e.on("text-change",this.onTextChange.bind(this)),e.on("selection-change",this.onSelectionChange.bind(this)),e.container.addEventListener("paste",(function(){setTimeout((function(){var t=e.getSelection();i.onSelectionChange(t)}))})),e.keyboard.addBinding({key:C},this.selectHandler.bind(this)),e.keyboard.bindings[C].unshift(e.keyboard.bindings[C].pop());var r,a=y(this.options.selectKeys);try{for(a.s();!(r=a.n()).done;){var l=r.value;e.keyboard.addBinding({key:l},this.selectHandler.bind(this))}}catch(t){a.e(t)}finally{a.f()}e.keyboard.bindings[b].unshift(e.keyboard.bindings[b].pop()),e.keyboard.addBinding({key:x},this.escapeHandler.bind(this)),e.keyboard.addBinding({key:k},this.upHandler.bind(this)),e.keyboard.addBinding({key:I},this.downHandler.bind(this))}return a(t,[{key:"selectHandler",value:function(){return!(this.isOpen&&!this.existingSourceExecutionToken)||(this.selectItem(),!1)}},{key:"escapeHandler",value:function(){return!this.isOpen||(this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList(),!1)}},{key:"upHandler",value:function(){return!(this.isOpen&&!this.existingSourceExecutionToken)||(this.prevItem(),!1)}},{key:"downHandler",value:function(){return!(this.isOpen&&!this.existingSourceExecutionToken)||(this.nextItem(),!1)}},{key:"showMentionList",value:function(){"fixed"===this.options.positioningStrategy?document.body.appendChild(this.mentionContainer):this.quill.container.appendChild(this.mentionContainer),this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.mentionContainer.scrollTop=0,this.setMentionContainerPosition(),this.setIsOpen(!0)}},{key:"hideMentionList",value:function(){this.options.onBeforeClose(),this.mentionContainer.style.display="none",this.mentionContainer.remove(),this.setIsOpen(!1),this.quill.root.removeAttribute("aria-activedescendant")}},{key:"highlightItem",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=0;e<this.mentionList.childNodes.length;e+=1)this.mentionList.childNodes[e].classList.remove("selected");if(-1!==this.itemIndex&&"true"!==this.mentionList.childNodes[this.itemIndex].dataset.disabled&&(this.mentionList.childNodes[this.itemIndex].classList.add("selected"),this.quill.root.setAttribute("aria-activedescendant",this.mentionList.childNodes[this.itemIndex].id),t)){var n=this.mentionList.childNodes[this.itemIndex].offsetHeight,i=this.mentionList.childNodes[this.itemIndex].offsetTop,o=this.mentionContainer.scrollTop,s=o+this.mentionContainer.offsetHeight;i<o?this.mentionContainer.scrollTop=i:i>s-n&&(this.mentionContainer.scrollTop+=i-s+n)}}},{key:"getItemData",value:function(){var t=this.mentionList.childNodes[this.itemIndex].dataset.link,e=void 0!==t,n=this.mentionList.childNodes[this.itemIndex].dataset.target;return e&&(this.mentionList.childNodes[this.itemIndex].dataset.value='<a href="'.concat(t,'" target=').concat(n||this.options.linkTarget,">").concat(this.mentionList.childNodes[this.itemIndex].dataset.value)),this.mentionList.childNodes[this.itemIndex].dataset}},{key:"onContainerMouseMove",value:function(){this.suspendMouseEnter=!1}},{key:"selectItem",value:function(){var t=this;if(-1!==this.itemIndex){var e=this.getItemData();e.disabled||(this.options.onSelect(e,(function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.insertItem(e,n,i)})),this.hideMentionList())}}},{key:"insertItem",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=t;if(null!==s){var r,a=o(o({},this.options),i);a.showDenotationChar||(s.denotationChar=""),e?r=this.cursorPos:(r=this.mentionCharPos,this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,n.default.sources.USER));var l=this.quill.insertEmbed(r,a.blotName,s,n.default.sources.USER);return a.spaceAfterInsert?(this.quill.insertText(r+1," ",n.default.sources.USER),this.quill.setSelection(r+2,n.default.sources.USER)):this.quill.setSelection(r+1,n.default.sources.USER),this.hideMentionList(),l}}},{key:"onItemMouseEnter",value:function(t){if(!this.suspendMouseEnter){var e=Number(t.target.dataset.index);Number.isNaN(e)||e===this.itemIndex||(this.itemIndex=e,this.highlightItem(!1))}}},{key:"onDisabledItemMouseEnter",value:function(t){this.suspendMouseEnter||(this.itemIndex=-1,this.highlightItem(!1))}},{key:"onItemClick",value:function(t){0===t.button&&(t.preventDefault(),t.stopImmediatePropagation(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem())}},{key:"onItemMouseDown",value:function(t){t.preventDefault(),t.stopImmediatePropagation()}},{key:"renderLoading",value:function(){if(this.options.renderLoading())if(this.mentionContainer.getElementsByClassName("ql-mention-loading").length>0)this.showMentionList();else{this.mentionList.innerHTML="";var t=document.createElement("div");t.className="ql-mention-loading",t.innerHTML=this.options.renderLoading(),this.mentionContainer.append(t),this.showMentionList()}}},{key:"removeLoading",value:function(){var t=this.mentionContainer.getElementsByClassName("ql-mention-loading");t.length>0&&t[0].remove()}},{key:"renderList",value:function(t,e,n){if(e&&e.length>0){this.removeLoading(),this.values=e,this.mentionList.innerHTML="";for(var i=-1,o=0;o<e.length;o+=1){var s=document.createElement("li");s.id="quill-mention-item-"+o,s.className=this.options.listItemClass?this.options.listItemClass:"",e[o].disabled?(s.className+=" disabled",s.setAttribute("aria-hidden","true")):-1===i&&(i=o),s.dataset.index=o,s.innerHTML=this.options.renderItem(e[o],n),e[o].disabled?s.onmouseenter=this.onDisabledItemMouseEnter.bind(this):(s.onmouseenter=this.onItemMouseEnter.bind(this),s.onmouseup=this.onItemClick.bind(this),s.onmousedown=this.onItemMouseDown.bind(this)),s.dataset.denotationChar=t,this.mentionList.appendChild(L(s,e[o],this.options.dataAttributes))}this.itemIndex=i,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}},{key:"nextItem",value:function(){var t,e=0;do{e++,t=(this.itemIndex+e)%this.values.length;var n="true"===this.mentionList.childNodes[t].dataset.disabled;if(e===this.values.length+1){t=-1;break}}while(n);this.itemIndex=t,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"prevItem",value:function(){var t,e=0;do{e++,t=(this.itemIndex+this.values.length-e)%this.values.length;var n="true"===this.mentionList.childNodes[t].dataset.disabled;if(e===this.values.length+1){t=-1;break}}while(n);this.itemIndex=t,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"containerBottomIsNotVisible",value:function(t,e){return t+this.mentionContainer.offsetHeight+e.top>window.pageYOffset+window.innerHeight}},{key:"containerRightIsNotVisible",value:function(t,e){return!this.options.fixMentionsToQuill&&t+this.mentionContainer.offsetWidth+e.left>window.pageXOffset+document.documentElement.clientWidth}},{key:"setIsOpen",value:function(t){this.isOpen!==t&&(t?this.options.onOpen():this.options.onClose(),this.isOpen=t)}},{key:"setMentionContainerPosition",value:function(){"fixed"===this.options.positioningStrategy?this.setMentionContainerPosition_Fixed():this.setMentionContainerPosition_Normal()}},{key:"setMentionContainerPosition_Normal",value:function(){var t=this,e=this.quill.container.getBoundingClientRect(),n=this.quill.getBounds(this.mentionCharPos),i=this.mentionContainer.offsetHeight,o=this.options.offsetTop,s=this.options.offsetLeft;if(this.options.fixMentionsToQuill){this.mentionContainer.style.right="".concat(0,"px")}else s+=n.left;if(this.containerRightIsNotVisible(s,e)){var r=this.mentionContainer.offsetWidth+this.options.offsetLeft;s=e.width-r}if("top"===this.options.defaultMenuOrientation){if((o=this.options.fixMentionsToQuill?-1*(i+this.options.offsetTop):n.top-(i+this.options.offsetTop))+e.top<=0){var a=this.options.offsetTop;this.options.fixMentionsToQuill?a+=e.height:a+=n.bottom,o=a}}else if(this.options.fixMentionsToQuill?o+=e.height:o+=n.bottom,this.containerBottomIsNotVisible(o,e)){var l=-1*this.options.offsetTop;this.options.fixMentionsToQuill||(l+=n.top),o=l-i}o>=0?this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-bottom")),t.mentionContainer.classList.remove("".concat(e,"-top"))})):this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-top")),t.mentionContainer.classList.remove("".concat(e,"-bottom"))})),this.mentionContainer.style.top="".concat(o,"px"),this.mentionContainer.style.left="".concat(s,"px"),this.mentionContainer.style.visibility="visible"}},{key:"setMentionContainerPosition_Fixed",value:function(){var t=this;this.mentionContainer.style.position="fixed",this.mentionContainer.style.height=null;var e=this.quill.container.getBoundingClientRect(),n=this.quill.getBounds(this.mentionCharPos),i={left:e.left+n.left,top:e.top+n.top,width:0,height:n.height},o=this.options.fixMentionsToQuill?e:i,s=this.options.offsetTop,r=this.options.offsetLeft;if(this.options.fixMentionsToQuill){var a=o.right;this.mentionContainer.style.right="".concat(a,"px")}else(r+=o.left)+this.mentionContainer.offsetWidth>document.documentElement.clientWidth&&(r-=r+this.mentionContainer.offsetWidth-document.documentElement.clientWidth);var l=o.top,h=document.documentElement.clientHeight-(o.top+o.height),u=this.mentionContainer.offsetHeight<=h,c=this.mentionContainer.offsetHeight<=l;"bottom"===("top"===this.options.defaultMenuOrientation&&c?"top":"bottom"===this.options.defaultMenuOrientation&&u||h>l?"bottom":"top")?(s=o.top+o.height,u||(this.mentionContainer.style.height=h-3+"px"),this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-bottom")),t.mentionContainer.classList.remove("".concat(e,"-top"))}))):(s=o.top-this.mentionContainer.offsetHeight,c||(this.mentionContainer.style.height=l-3+"px",s=3),this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-top")),t.mentionContainer.classList.remove("".concat(e,"-bottom"))}))),this.mentionContainer.style.top="".concat(s,"px"),this.mentionContainer.style.left="".concat(r,"px"),this.mentionContainer.style.visibility="visible"}},{key:"getTextBeforeCursor",value:function(){var t=Math.max(0,this.cursorPos-this.options.maxChars);return this.quill.getText(t,this.cursorPos-t)}},{key:"onSomethingChange",value:function(){var t=this,e=this.quill.getSelection();if(null!=e){this.cursorPos=e.index;var n,i,o,s,r=this.getTextBeforeCursor(),a=Math.max(0,this.cursorPos-this.options.maxChars),l=a?this.quill.getText(a-1,a):"",h=(n=r,i=this.options.mentionDenotationChars,o=this.options.isolateCharacter,s=this.options.allowInlineMentionChar,i.reduce((function(t,e){var i;if(o&&s){var r=new RegExp("^".concat(e,"|\\s").concat(e),"g"),a=(n.match(r)||[]).pop();if(!a)return{mentionChar:t.mentionChar,mentionCharIndex:t.mentionCharIndex};i=a!==e?n.lastIndexOf(a)+a.length-e.length:0}else i=n.lastIndexOf(e);return i>t.mentionCharIndex?{mentionChar:e,mentionCharIndex:i}:{mentionChar:t.mentionChar,mentionCharIndex:t.mentionCharIndex}}),{mentionChar:null,mentionCharIndex:-1})),u=h.mentionChar,c=h.mentionCharIndex;if(function(t,e,n,i){if(-1===t)return!1;if(!n)return!0;var o=t?e[t-1]:i;return!o||!!o.match(/\s/)}(c,r,this.options.isolateCharacter,l)){var d=this.cursorPos-(r.length-c);this.mentionCharPos=d;var f=r.substring(c+u.length);if(f.length>=this.options.minChars&&function(t,e){return e.test(t)}(f,this.getAllowedCharsRegex(u))){this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.renderLoading();var m={abandoned:!1};this.existingSourceExecutionToken=m,this.options.source(f,(function(e,n){m.abandoned||(t.existingSourceExecutionToken=null,t.renderList(u,e,n))}),u)}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}}},{key:"getAllowedCharsRegex",value:function(t){return this.options.allowedChars instanceof RegExp?this.options.allowedChars:this.options.allowedChars(t)}},{key:"onTextChange",value:function(t,e,n){"user"===n&&this.onSomethingChange()}},{key:"onSelectionChange",value:function(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}},{key:"openMenu",value:function(t){var e=this.quill.getSelection(!0);this.quill.insertText(e.index,t),this.quill.blur(),this.quill.focus()}}]),t}();return n.default.register("modules/mention",w),w}(Quill);
var quillMention=function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){h(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,y(i.key),i)}}function l(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(){return u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},u.apply(this,arguments)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=c(t);if(e){var o=c(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}(this,n)}}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},p.apply(this,arguments)}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function g(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return v(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,r=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return r=t.done,t},e:function(t){a=!0,s=t},f:function(){try{r||null==n.return||n.return()}finally{if(a)throw s}}}}function y(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var b=9,C=13,x=27,k=38,I=40;function E(t,e,n){var i=t;return Object.keys(e).forEach((function(t){n.indexOf(t)>-1?i.dataset[t]=e[t]:delete i.dataset[t]})),i}function w(t,e){null!==e&&("object"===s(e)?t.appendChild(e):t.innerText=e)}var O=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(n,t);var e=m(n);function n(t,i){var o;return r(this,n),h(f(o=e.call(this,t,i)),"hoverHandler",void 0),h(f(o),"hoverHandler",void 0),o.clickHandler=null,o.hoverHandler=null,o.mounted=!1,o}return l(n,[{key:"attach",value:function(){p(c(n.prototype),"attach",this).call(this),this.mounted||(this.mounted=!0,this.clickHandler=this.getClickHandler(),this.hoverHandler=this.getHoverHandler(),this.domNode.addEventListener("click",this.clickHandler,!1),this.domNode.addEventListener("mouseenter",this.hoverHandler,!1))}},{key:"detach",value:function(){p(c(n.prototype),"detach",this).call(this),this.mounted=!1,this.clickHandler&&(this.domNode.removeEventListener("click",this.clickHandler),this.clickHandler=null)}},{key:"getClickHandler",value:function(){var t=this;return function(e){var n=t.buildEvent("mention-clicked",e);window.dispatchEvent(n),e.preventDefault()}}},{key:"getHoverHandler",value:function(){var t=this;return function(e){var n=t.buildEvent("mention-hovered",e);window.dispatchEvent(n),e.preventDefault()}}},{key:"buildEvent",value:function(t,e){var n=new Event(t,{bubbles:!0,cancelable:!0});return n.value=u({},this.domNode.dataset),n.event=e,n}}],[{key:"create",value:function(t){var e=p(c(n),"create",this).call(this),i=document.createElement("span");return i.className="ql-mention-denotation-char",i.innerText=t.denotationChar,e.appendChild(i),"function"==typeof this.render?e.appendChild(this.render(t)):e.innerText+=t.value,n.setDataValues(e,t)}},{key:"setDataValues",value:function(t,e){var n=t;return Object.keys(e).forEach((function(t){n.dataset[t]=e[t]})),n}},{key:"value",value:function(t){return t.dataset}}]),n}(n.default.import("blots/embed"));O.blotName="mention",O.tagName="span",O.className="mention",n.default.register("blots/mention",O);var L=function(){function t(e,n){var i=this;for(var o in r(this,t),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.existingSourceExecutionToken=null,this.quill=e,this.options={source:null,renderItem:function(t){var e=t.value;return"".concat(e)},renderLoading:function(){return null},onSelect:function(t,e){e(t)},mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,allowInlineMentionChar:!1,fixMentionsToQuill:!1,positioningStrategy:"normal",defaultMenuOrientation:"bottom",blotName:"mention",dataAttributes:["id","value","denotationChar","link","target","disabled"],linkTarget:"_blank",onOpen:function(){return!0},onBeforeClose:function(){return!0},onClose:function(){return!0},listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0,selectKeys:[C]},u(this.options,n,{dataAttributes:Array.isArray(n.dataAttributes)?this.options.dataAttributes.concat(n.dataAttributes):this.options.dataAttributes}),this.options)"function"==typeof this.options[o]&&(this.options[o]=this.options[o].bind(this));this.mentionContainer=document.createElement("div"),this.mentionContainer.className=this.options.mentionContainerClass?this.options.mentionContainerClass:"",this.mentionContainer.style.cssText="display: none; position: absolute;",this.mentionContainer.onmousemove=this.onContainerMouseMove.bind(this),this.options.fixMentionsToQuill&&(this.mentionContainer.style.width="auto"),this.mentionList=document.createElement("ul"),this.mentionList.id="quill-mention-list",e.root.setAttribute("aria-owns","quill-mention-list"),this.mentionList.className=this.options.mentionListClass?this.options.mentionListClass:"",this.mentionContainer.appendChild(this.mentionList),e.on("text-change",this.onTextChange.bind(this)),e.on("selection-change",this.onSelectionChange.bind(this)),e.container.addEventListener("paste",(function(){setTimeout((function(){var t=e.getSelection();i.onSelectionChange(t)}))})),e.keyboard.addBinding({key:b},this.selectHandler.bind(this)),e.keyboard.bindings[b].unshift(e.keyboard.bindings[b].pop());var s,a=g(this.options.selectKeys);try{for(a.s();!(s=a.n()).done;){var l=s.value;e.keyboard.addBinding({key:l},this.selectHandler.bind(this))}}catch(t){a.e(t)}finally{a.f()}e.keyboard.bindings[C].unshift(e.keyboard.bindings[C].pop()),e.keyboard.addBinding({key:x},this.escapeHandler.bind(this)),e.keyboard.addBinding({key:k},this.upHandler.bind(this)),e.keyboard.addBinding({key:I},this.downHandler.bind(this))}return l(t,[{key:"selectHandler",value:function(){return!(this.isOpen&&!this.existingSourceExecutionToken)||(this.selectItem(),!1)}},{key:"escapeHandler",value:function(){return!this.isOpen||(this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList(),!1)}},{key:"upHandler",value:function(){return!(this.isOpen&&!this.existingSourceExecutionToken)||(this.prevItem(),!1)}},{key:"downHandler",value:function(){return!(this.isOpen&&!this.existingSourceExecutionToken)||(this.nextItem(),!1)}},{key:"showMentionList",value:function(){"fixed"===this.options.positioningStrategy?document.body.appendChild(this.mentionContainer):this.quill.container.appendChild(this.mentionContainer),this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.mentionContainer.scrollTop=0,this.setMentionContainerPosition(),this.setIsOpen(!0)}},{key:"hideMentionList",value:function(){this.options.onBeforeClose(),this.mentionContainer.style.display="none",this.mentionContainer.remove(),this.setIsOpen(!1),this.quill.root.removeAttribute("aria-activedescendant")}},{key:"highlightItem",value:function(){for(var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=0;e<this.mentionList.childNodes.length;e+=1)this.mentionList.childNodes[e].classList.remove("selected");if(-1!==this.itemIndex&&"true"!==this.mentionList.childNodes[this.itemIndex].dataset.disabled&&(this.mentionList.childNodes[this.itemIndex].classList.add("selected"),this.quill.root.setAttribute("aria-activedescendant",this.mentionList.childNodes[this.itemIndex].id),t)){var n=this.mentionList.childNodes[this.itemIndex].offsetHeight,i=this.mentionList.childNodes[this.itemIndex].offsetTop,o=this.mentionContainer.scrollTop,s=o+this.mentionContainer.offsetHeight;i<o?this.mentionContainer.scrollTop=i:i>s-n&&(this.mentionContainer.scrollTop+=i-s+n)}}},{key:"onContainerMouseMove",value:function(){this.suspendMouseEnter=!1}},{key:"selectItem",value:function(){var t=this;if(-1!==this.itemIndex){var e=this.mentionList.childNodes[this.itemIndex].dataset;e.disabled||(this.options.onSelect(e,(function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.insertItem(e,n,i)})),this.hideMentionList())}}},{key:"insertItem",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=t;if(null!==s){var r,a=o(o({},this.options),i);a.showDenotationChar||(s.denotationChar=""),e?r=this.cursorPos:(r=this.mentionCharPos,this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,n.default.sources.USER));var l=this.quill.insertEmbed(r,a.blotName,s,n.default.sources.USER);return a.spaceAfterInsert?(this.quill.insertText(r+1," ",n.default.sources.USER),this.quill.setSelection(r+2,n.default.sources.USER)):this.quill.setSelection(r+1,n.default.sources.USER),this.hideMentionList(),l}}},{key:"onItemMouseEnter",value:function(t){if(!this.suspendMouseEnter){var e=Number(t.target.dataset.index);Number.isNaN(e)||e===this.itemIndex||(this.itemIndex=e,this.highlightItem(!1))}}},{key:"onDisabledItemMouseEnter",value:function(t){this.suspendMouseEnter||(this.itemIndex=-1,this.highlightItem(!1))}},{key:"onItemClick",value:function(t){0===t.button&&(t.preventDefault(),t.stopImmediatePropagation(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem())}},{key:"onItemMouseDown",value:function(t){t.preventDefault(),t.stopImmediatePropagation()}},{key:"renderLoading",value:function(){if(this.options.renderLoading())if(this.mentionContainer.getElementsByClassName("ql-mention-loading").length>0)this.showMentionList();else{this.mentionList.innerHTML="";var t=document.createElement("div");t.className="ql-mention-loading",w(t,this.options.renderLoading()),this.mentionContainer.append(t),this.showMentionList()}}},{key:"removeLoading",value:function(){var t=this.mentionContainer.getElementsByClassName("ql-mention-loading");t.length>0&&t[0].remove()}},{key:"renderList",value:function(t,e,n){if(e&&e.length>0){this.removeLoading(),this.values=e,this.mentionList.innerText="";for(var i=-1,o=0;o<e.length;o+=1){var s=document.createElement("li");s.id="quill-mention-item-"+o,s.className=this.options.listItemClass?this.options.listItemClass:"",e[o].disabled?(s.className+=" disabled",s.setAttribute("aria-hidden","true")):-1===i&&(i=o),s.dataset.index=o,w(s,this.options.renderItem(e[o],n)),e[o].disabled?s.onmouseenter=this.onDisabledItemMouseEnter.bind(this):(s.onmouseenter=this.onItemMouseEnter.bind(this),s.onmouseup=this.onItemClick.bind(this),s.onmousedown=this.onItemMouseDown.bind(this)),s.dataset.denotationChar=t,this.mentionList.appendChild(E(s,e[o],this.options.dataAttributes))}this.itemIndex=i,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}},{key:"nextItem",value:function(){var t,e=0;do{e++,t=(this.itemIndex+e)%this.values.length;var n="true"===this.mentionList.childNodes[t].dataset.disabled;if(e===this.values.length+1){t=-1;break}}while(n);this.itemIndex=t,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"prevItem",value:function(){var t,e=0;do{e++,t=(this.itemIndex+this.values.length-e)%this.values.length;var n="true"===this.mentionList.childNodes[t].dataset.disabled;if(e===this.values.length+1){t=-1;break}}while(n);this.itemIndex=t,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"containerBottomIsNotVisible",value:function(t,e){return t+this.mentionContainer.offsetHeight+e.top>window.pageYOffset+window.innerHeight}},{key:"containerRightIsNotVisible",value:function(t,e){return!this.options.fixMentionsToQuill&&t+this.mentionContainer.offsetWidth+e.left>window.pageXOffset+document.documentElement.clientWidth}},{key:"setIsOpen",value:function(t){this.isOpen!==t&&(t?this.options.onOpen():this.options.onClose(),this.isOpen=t)}},{key:"setMentionContainerPosition",value:function(){"fixed"===this.options.positioningStrategy?this.setMentionContainerPosition_Fixed():this.setMentionContainerPosition_Normal()}},{key:"setMentionContainerPosition_Normal",value:function(){var t=this,e=this.quill.container.getBoundingClientRect(),n=this.quill.getBounds(this.mentionCharPos),i=this.mentionContainer.offsetHeight,o=this.options.offsetTop,s=this.options.offsetLeft;if(this.options.fixMentionsToQuill){this.mentionContainer.style.right="".concat(0,"px")}else s+=n.left;if(this.containerRightIsNotVisible(s,e)){var r=this.mentionContainer.offsetWidth+this.options.offsetLeft;s=e.width-r}if("top"===this.options.defaultMenuOrientation){if((o=this.options.fixMentionsToQuill?-1*(i+this.options.offsetTop):n.top-(i+this.options.offsetTop))+e.top<=0){var a=this.options.offsetTop;this.options.fixMentionsToQuill?a+=e.height:a+=n.bottom,o=a}}else if(this.options.fixMentionsToQuill?o+=e.height:o+=n.bottom,this.containerBottomIsNotVisible(o,e)){var l=-1*this.options.offsetTop;this.options.fixMentionsToQuill||(l+=n.top),o=l-i}o>=0?this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-bottom")),t.mentionContainer.classList.remove("".concat(e,"-top"))})):this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-top")),t.mentionContainer.classList.remove("".concat(e,"-bottom"))})),this.mentionContainer.style.top="".concat(o,"px"),this.mentionContainer.style.left="".concat(s,"px"),this.mentionContainer.style.visibility="visible"}},{key:"setMentionContainerPosition_Fixed",value:function(){var t=this;this.mentionContainer.style.position="fixed",this.mentionContainer.style.height=null;var e=this.quill.container.getBoundingClientRect(),n=this.quill.getBounds(this.mentionCharPos),i={left:e.left+n.left,top:e.top+n.top,width:0,height:n.height},o=this.options.fixMentionsToQuill?e:i,s=this.options.offsetTop,r=this.options.offsetLeft;if(this.options.fixMentionsToQuill){var a=o.right;this.mentionContainer.style.right="".concat(a,"px")}else(r+=o.left)+this.mentionContainer.offsetWidth>document.documentElement.clientWidth&&(r-=r+this.mentionContainer.offsetWidth-document.documentElement.clientWidth);var l=o.top,h=document.documentElement.clientHeight-(o.top+o.height),u=this.mentionContainer.offsetHeight<=h,c=this.mentionContainer.offsetHeight<=l;"bottom"===("top"===this.options.defaultMenuOrientation&&c?"top":"bottom"===this.options.defaultMenuOrientation&&u||h>l?"bottom":"top")?(s=o.top+o.height,u||(this.mentionContainer.style.height=h-3+"px"),this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-bottom")),t.mentionContainer.classList.remove("".concat(e,"-top"))}))):(s=o.top-this.mentionContainer.offsetHeight,c||(this.mentionContainer.style.height=l-3+"px",s=3),this.options.mentionContainerClass.split(" ").forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-top")),t.mentionContainer.classList.remove("".concat(e,"-bottom"))}))),this.mentionContainer.style.top="".concat(s,"px"),this.mentionContainer.style.left="".concat(r,"px"),this.mentionContainer.style.visibility="visible"}},{key:"getTextBeforeCursor",value:function(){var t=Math.max(0,this.cursorPos-this.options.maxChars);return this.quill.getText(t,this.cursorPos-t)}},{key:"onSomethingChange",value:function(){var t=this,e=this.quill.getSelection();if(null!=e){this.cursorPos=e.index;var n,i,o,s,r=this.getTextBeforeCursor(),a=Math.max(0,this.cursorPos-this.options.maxChars),l=a?this.quill.getText(a-1,a):"",h=(n=r,i=this.options.mentionDenotationChars,o=this.options.isolateCharacter,s=this.options.allowInlineMentionChar,i.reduce((function(t,e){var i;if(o&&s){var r=new RegExp("^".concat(e,"|\\s").concat(e),"g"),a=(n.match(r)||[]).pop();if(!a)return{mentionChar:t.mentionChar,mentionCharIndex:t.mentionCharIndex};i=a!==e?n.lastIndexOf(a)+a.length-e.length:0}else i=n.lastIndexOf(e);return i>t.mentionCharIndex?{mentionChar:e,mentionCharIndex:i}:{mentionChar:t.mentionChar,mentionCharIndex:t.mentionCharIndex}}),{mentionChar:null,mentionCharIndex:-1})),u=h.mentionChar,c=h.mentionCharIndex;if(function(t,e,n,i){if(-1===t)return!1;if(!n)return!0;var o=t?e[t-1]:i;return!o||!!o.match(/\s/)}(c,r,this.options.isolateCharacter,l)){var d=this.cursorPos-(r.length-c);this.mentionCharPos=d;var f=r.substring(c+u.length);if(f.length>=this.options.minChars&&function(t,e){return e.test(t)}(f,this.getAllowedCharsRegex(u))){this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.renderLoading();var m={abandoned:!1};this.existingSourceExecutionToken=m,this.options.source(f,(function(e,n){m.abandoned||(t.existingSourceExecutionToken=null,t.renderList(u,e,n))}),u)}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}else this.existingSourceExecutionToken&&(this.existingSourceExecutionToken.abandoned=!0),this.hideMentionList()}}},{key:"getAllowedCharsRegex",value:function(t){return this.options.allowedChars instanceof RegExp?this.options.allowedChars:this.options.allowedChars(t)}},{key:"onTextChange",value:function(t,e,n){"user"===n&&this.onSomethingChange()}},{key:"onSelectionChange",value:function(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}},{key:"openMenu",value:function(t){var e=this.quill.getSelection(!0);this.quill.insertText(e.index,t),this.quill.blur(),this.quill.focus()}}]),t}();return n.default.register("modules/mention",L),L}(Quill);
{
"name": "quill-mention",
"version": "3.4.1",
"version": "4.0.0",
"description": "@mentions for the Quill rich text editor",

@@ -5,0 +5,0 @@ "homepage": "https://quill-mention.com/",

@@ -150,3 +150,3 @@ ![Quill Mention](docs/static/quill-mention.png "Quill Mention")

| `source(searchTerm, renderList, mentionChar)` | `null` | Required callback function to handle the search term and connect it to a data source for matches. The data source can be a local source or an AJAX request. The callback should call `renderList(matches, searchTerm);` with matches of JSON Objects in an array to show the result for the user. The JSON Objects should have `id` and `value` but can also have other values to be used in `renderItem` for custom display. |
| `renderItem(item, searchTerm)` | `function` | A function that gives you control over how matches from source are displayed. You can use this function to highlight the search term or change the design with custom HTML. |
| `renderItem(item, searchTerm)` | `function` | A function that gives you control over how matches from source are displayed. You can use this function to highlight the search term or change the design with custom HTML. This function will need to return either a string possibly containing unsanitized user content, or a class implementing the [Node](https://developer.mozilla.org/en-US/docs/Web/API/Node) interface which will be treated as a sanitized DOM node. |
| `allowedChars` | `[a-zA-Z0-9_]` (or `function`) | Allowed characters in search term triggering a search request using regular expressions. Can be a function that takes the denotationChar and returns a regex. |

@@ -175,3 +175,3 @@ | `minChars` | `0` | Minimum number of characters after the @ symbol triggering a search request |

| `positioningStrategy` | `'absolute'` | Options are `'normal'` and `'fixed'`. When `'fixed'`, the menu will be appended to the body and use fixed positioning. Use this if the menu is clipped by a parent element that's using `overflow:hidden|scroll`. |
| `renderLoading` | `function` | A function that returns the HTML for a loading message during async calls from `source`. The default functions returns `null` to prevent a loading message. |
| `renderLoading` | `function` | A function that returns the HTML for a loading message during async calls from `source`. The function will need to return either a string possibly containing unsanitized user content, or a class implementing the [Node](https://developer.mozilla.org/en-US/docs/Web/API/Node) interface which will be treated as a sanitized DOM node. The default functions returns `null` to prevent a loading message. |
| `selectKeys` | `[13]` | An array of keyboard key codes that will trigger the select action for the mention dropdown. Default is ENTER key. See [this reference](http://gcctech.org/csc/javascript/javascript_keycodes.htm) for a list of numbers for each keyboard key. |

@@ -192,2 +192,37 @@

#### Mention Blot Styling
Mention blots can also be dynamically styled from data attributes, but requires
implement a custom Quill blot. For example:
```javascript
const MentionBlot = Quill.import("blots/mention");
class StyledMentionBlot extends MentionBlot {
static render(data) {
const element = document.createElement('span');
element.innerText = data.value;
element.style.color = data.color;
return element;
}
}
StyledMentionBlot.blotName = "styled-mention";
Quill.register(StyledMentionBlot);
```
Then, when creating your Quill instance, use the following settings:
```javascript
const quill = new Quill('#editor', {
modules: {
mention: {
// ...
dataAttributes: ['id', 'value', 'denotationChar', 'link', 'target', 'disabled', 'color'],
blotName: 'styled-mention',
}
}
});
```
### Headers and Informational Items

@@ -197,2 +232,6 @@

### Upgrade Notes
As of 4.0.0, HTML embedded in `value` will no longer be rendered, due to potential XSS issues. Instead, to adjust rendering of list items, you can return a class implementing the [Node](https://developer.mozilla.org/en-US/docs/Web/API/Node) interface which will be treated as a sanitized DOM node, and in order to customize blot rendering, you will need to create a [custom mention blot](https://github.com/quill-mention/quill-mention#mention-blot-styling)
## Authors

@@ -199,0 +238,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc