quill-mention
Advanced tools
Comparing version 2.2.3 to 2.2.4
@@ -545,2 +545,4 @@ 'use strict'; | ||
value: function setMentionContainerPosition() { | ||
var _this2 = this; | ||
var containerPos = this.quill.container.getBoundingClientRect(); | ||
@@ -607,7 +609,13 @@ var mentionCharPos = this.quill.getBounds(this.mentionCharPos); | ||
if (topPos >= 0) { | ||
this.mentionContainer.classList.add("".concat(this.options.mentionContainerClass, "-bottom")); | ||
this.mentionContainer.classList.remove("".concat(this.options.mentionContainerClass, "-top")); | ||
this.mentionContainer.classList.forEach(function (className) { | ||
_this2.mentionContainer.classList.add("".concat(className, "-bottom")); | ||
_this2.mentionContainer.classList.remove("".concat(className, "-top")); | ||
}); | ||
} else { | ||
this.mentionContainer.classList.add("".concat(this.options.mentionContainerClass, "-top")); | ||
this.mentionContainer.classList.remove("".concat(this.options.mentionContainerClass, "-bottom")); | ||
this.mentionContainer.classList.forEach(function (className) { | ||
_this2.mentionContainer.classList.add("".concat(className, "-top")); | ||
_this2.mentionContainer.classList.remove("".concat(className, "-bottom")); | ||
}); | ||
} | ||
@@ -614,0 +622,0 @@ |
@@ -541,2 +541,4 @@ import Quill from 'quill'; | ||
value: function setMentionContainerPosition() { | ||
var _this2 = this; | ||
var containerPos = this.quill.container.getBoundingClientRect(); | ||
@@ -603,7 +605,13 @@ var mentionCharPos = this.quill.getBounds(this.mentionCharPos); | ||
if (topPos >= 0) { | ||
this.mentionContainer.classList.add("".concat(this.options.mentionContainerClass, "-bottom")); | ||
this.mentionContainer.classList.remove("".concat(this.options.mentionContainerClass, "-top")); | ||
this.mentionContainer.classList.forEach(function (className) { | ||
_this2.mentionContainer.classList.add("".concat(className, "-bottom")); | ||
_this2.mentionContainer.classList.remove("".concat(className, "-top")); | ||
}); | ||
} else { | ||
this.mentionContainer.classList.add("".concat(this.options.mentionContainerClass, "-top")); | ||
this.mentionContainer.classList.remove("".concat(this.options.mentionContainerClass, "-bottom")); | ||
this.mentionContainer.classList.forEach(function (className) { | ||
_this2.mentionContainer.classList.add("".concat(className, "-top")); | ||
_this2.mentionContainer.classList.remove("".concat(className, "-bottom")); | ||
}); | ||
} | ||
@@ -610,0 +618,0 @@ |
@@ -1,1 +0,1 @@ | ||
var quillMention=function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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 i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function o(){return(o=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}).apply(this,arguments)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function r(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t,e,n){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}t=t&&t.hasOwnProperty("default")?t.default:t;var l={TAB:9,ENTER:13,ESCAPE:27,UP:38,DOWN:40};function u(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 c=function(t){function n(){return e(this,n),r(this,s(n).apply(this,arguments))}return 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&&a(t,e)}(n,t),i(n,null,[{key:"create",value:function(t){var e=h(s(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}(t.import("blots/embed"));c.blotName="mention",c.tagName="span",c.className="mention",t.register(c);var d=function(){function n(t,i){e(this,n),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.quill=t,this.options={source:null,renderItem:function(t){return"".concat(t.value)},onSelect:function(t,e){e(t)},mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,fixMentionsToQuill:!1,defaultMenuOrientation:"bottom",dataAttributes:["id","value","denotationChar","link","target"],linkTarget:"_blank",onOpen:function(){return!0},onClose:function(){return!0},listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0},o(this.options,i,{dataAttributes:Array.isArray(i.dataAttributes)?this.options.dataAttributes.concat(i.dataAttributes):this.options.dataAttributes}),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.className=this.options.mentionListClass?this.options.mentionListClass:"",this.mentionContainer.appendChild(this.mentionList),this.quill.container.appendChild(this.mentionContainer),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.keyboard.addBinding({key:l.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[l.TAB].unshift(t.keyboard.bindings[l.TAB].pop()),t.keyboard.addBinding({key:l.ENTER},this.selectHandler.bind(this)),t.keyboard.bindings[l.ENTER].unshift(t.keyboard.bindings[l.ENTER].pop()),t.keyboard.addBinding({key:l.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:l.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:l.DOWN},this.downHandler.bind(this))}return i(n,[{key:"selectHandler",value:function(){return!this.isOpen||(this.selectItem(),!1)}},{key:"escapeHandler",value:function(){return!this.isOpen||(this.hideMentionList(),!1)}},{key:"upHandler",value:function(){return!this.isOpen||(this.prevItem(),!1)}},{key:"downHandler",value:function(){return!this.isOpen||(this.nextItem(),!1)}},{key:"showMentionList",value:function(){this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.setMentionContainerPosition(),this.setIsOpen(!0)}},{key:"hideMentionList",value:function(){this.mentionContainer.style.display="none",this.setIsOpen(!1)}},{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(this.mentionList.childNodes[this.itemIndex].classList.add("selected"),t){var n=this.mentionList.childNodes[this.itemIndex].offsetHeight,i=this.itemIndex*n,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,e=this.getItemData();this.options.onSelect(e,(function(e){t.insertItem(e)})),this.hideMentionList()}},{key:"insertItem",value:function(e){var n=e;if(null!==n){this.options.showDenotationChar||(n.denotationChar="");var i=this.mentionCharPos;this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,t.sources.USER),this.quill.insertEmbed(i,"mention",n,t.sources.USER),this.options.spaceAfterInsert?(this.quill.insertText(i+1," ",t.sources.USER),this.quill.setSelection(i+2,t.sources.USER)):this.quill.setSelection(i+1,t.sources.USER),this.hideMentionList()}}},{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:"onItemClick",value:function(t){t.preventDefault(),t.stopImmediatePropagation(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}},{key:"renderList",value:function(t,e,n){if(e&&e.length>0){this.values=e,this.mentionList.innerHTML="";for(var i=0;i<e.length;i+=1){var o=document.createElement("li");o.className=this.options.listItemClass?this.options.listItemClass:"",o.dataset.index=i,o.innerHTML=this.options.renderItem(e[i],n),o.onmouseenter=this.onItemMouseEnter.bind(this),o.dataset.denotationChar=t,o.onclick=this.onItemClick.bind(this),this.mentionList.appendChild(u(o,e[i],this.options.dataAttributes))}this.itemIndex=0,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}},{key:"nextItem",value:function(){this.itemIndex=(this.itemIndex+1)%this.values.length,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"prevItem",value:function(){this.itemIndex=(this.itemIndex+this.values.length-1)%this.values.length,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(){var t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.mentionCharPos),n=this.mentionContainer.offsetHeight,i=this.options.offsetTop,o=this.options.offsetLeft;if(this.options.fixMentionsToQuill){this.mentionContainer.style.right="".concat(0,"px")}else o+=e.left;if(this.containerRightIsNotVisible(o,t)){var s=this.mentionContainer.offsetWidth+this.options.offsetLeft;o=t.width-s}if("top"===this.options.defaultMenuOrientation){if((i=this.options.fixMentionsToQuill?-1*(n+this.options.offsetTop):e.top-(n+this.options.offsetTop))+t.top<=0){var a=this.options.offsetTop;this.options.fixMentionsToQuill?a+=t.height:a+=e.bottom,i=a}}else if(this.options.fixMentionsToQuill?i+=t.height:i+=e.bottom,this.containerBottomIsNotVisible(i,t)){var r=-1*this.options.offsetTop;this.options.fixMentionsToQuill||(r+=e.top),i=r-n}i>=0?(this.mentionContainer.classList.add("".concat(this.options.mentionContainerClass,"-bottom")),this.mentionContainer.classList.remove("".concat(this.options.mentionContainerClass,"-top"))):(this.mentionContainer.classList.add("".concat(this.options.mentionContainerClass,"-top")),this.mentionContainer.classList.remove("".concat(this.options.mentionContainerClass,"-bottom"))),this.mentionContainer.style.top="".concat(i,"px"),this.mentionContainer.style.left="".concat(o,"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.quill.getSelection();if(null!=t){this.cursorPos=t.index;var e,n=this.getTextBeforeCursor(),i=(e=n,this.options.mentionDenotationChars.reduce((function(t,n){var i=e.lastIndexOf(n);return i>t.mentionCharIndex?{mentionChar:n,mentionCharIndex:i}:{mentionChar:t.mentionChar,mentionCharIndex:t.mentionCharIndex}}),{mentionChar:null,mentionCharIndex:-1})),o=i.mentionChar,s=i.mentionCharIndex;if(function(t,e,n){return t>-1&&!(n&&0!==t&&!e[t-1].match(/\s/g))}(s,n,this.options.isolateCharacter)){var a=this.cursorPos-(n.length-s);this.mentionCharPos=a;var r=n.substring(s+o.length);r.length>=this.options.minChars&&function(t,e){return e.test(t)}(r,this.options.allowedChars)?this.options.source(r,this.renderList.bind(this,o),o):this.hideMentionList()}else this.hideMentionList()}}},{key:"onTextChange",value:function(t,e,n){"user"===n&&this.onSomethingChange()}},{key:"onSelectionChange",value:function(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}}]),n}();return t.register("modules/mention",d),d}(Quill); | ||
var quillMention=function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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 i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function o(){return(o=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}).apply(this,arguments)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function r(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t,e,n){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}t=t&&t.hasOwnProperty("default")?t.default:t;var l={TAB:9,ENTER:13,ESCAPE:27,UP:38,DOWN:40};function u(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 c=function(t){function n(){return e(this,n),r(this,s(n).apply(this,arguments))}return 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&&a(t,e)}(n,t),i(n,null,[{key:"create",value:function(t){var e=h(s(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}(t.import("blots/embed"));c.blotName="mention",c.tagName="span",c.className="mention",t.register(c);var d=function(){function n(t,i){e(this,n),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.quill=t,this.options={source:null,renderItem:function(t){return"".concat(t.value)},onSelect:function(t,e){e(t)},mentionDenotationChars:["@"],showDenotationChar:!0,allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,fixMentionsToQuill:!1,defaultMenuOrientation:"bottom",dataAttributes:["id","value","denotationChar","link","target"],linkTarget:"_blank",onOpen:function(){return!0},onClose:function(){return!0},listItemClass:"ql-mention-list-item",mentionContainerClass:"ql-mention-list-container",mentionListClass:"ql-mention-list",spaceAfterInsert:!0},o(this.options,i,{dataAttributes:Array.isArray(i.dataAttributes)?this.options.dataAttributes.concat(i.dataAttributes):this.options.dataAttributes}),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.className=this.options.mentionListClass?this.options.mentionListClass:"",this.mentionContainer.appendChild(this.mentionList),this.quill.container.appendChild(this.mentionContainer),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.keyboard.addBinding({key:l.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[l.TAB].unshift(t.keyboard.bindings[l.TAB].pop()),t.keyboard.addBinding({key:l.ENTER},this.selectHandler.bind(this)),t.keyboard.bindings[l.ENTER].unshift(t.keyboard.bindings[l.ENTER].pop()),t.keyboard.addBinding({key:l.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:l.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:l.DOWN},this.downHandler.bind(this))}return i(n,[{key:"selectHandler",value:function(){return!this.isOpen||(this.selectItem(),!1)}},{key:"escapeHandler",value:function(){return!this.isOpen||(this.hideMentionList(),!1)}},{key:"upHandler",value:function(){return!this.isOpen||(this.prevItem(),!1)}},{key:"downHandler",value:function(){return!this.isOpen||(this.nextItem(),!1)}},{key:"showMentionList",value:function(){this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.setMentionContainerPosition(),this.setIsOpen(!0)}},{key:"hideMentionList",value:function(){this.mentionContainer.style.display="none",this.setIsOpen(!1)}},{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(this.mentionList.childNodes[this.itemIndex].classList.add("selected"),t){var n=this.mentionList.childNodes[this.itemIndex].offsetHeight,i=this.itemIndex*n,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,e=this.getItemData();this.options.onSelect(e,(function(e){t.insertItem(e)})),this.hideMentionList()}},{key:"insertItem",value:function(e){var n=e;if(null!==n){this.options.showDenotationChar||(n.denotationChar="");var i=this.mentionCharPos;this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,t.sources.USER),this.quill.insertEmbed(i,"mention",n,t.sources.USER),this.options.spaceAfterInsert?(this.quill.insertText(i+1," ",t.sources.USER),this.quill.setSelection(i+2,t.sources.USER)):this.quill.setSelection(i+1,t.sources.USER),this.hideMentionList()}}},{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:"onItemClick",value:function(t){t.preventDefault(),t.stopImmediatePropagation(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}},{key:"renderList",value:function(t,e,n){if(e&&e.length>0){this.values=e,this.mentionList.innerHTML="";for(var i=0;i<e.length;i+=1){var o=document.createElement("li");o.className=this.options.listItemClass?this.options.listItemClass:"",o.dataset.index=i,o.innerHTML=this.options.renderItem(e[i],n),o.onmouseenter=this.onItemMouseEnter.bind(this),o.dataset.denotationChar=t,o.onclick=this.onItemClick.bind(this),this.mentionList.appendChild(u(o,e[i],this.options.dataAttributes))}this.itemIndex=0,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}},{key:"nextItem",value:function(){this.itemIndex=(this.itemIndex+1)%this.values.length,this.suspendMouseEnter=!0,this.highlightItem()}},{key:"prevItem",value:function(){this.itemIndex=(this.itemIndex+this.values.length-1)%this.values.length,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(){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 a=this.mentionContainer.offsetWidth+this.options.offsetLeft;s=e.width-a}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 r=this.options.offsetTop;this.options.fixMentionsToQuill?r+=e.height:r+=n.bottom,o=r}}else if(this.options.fixMentionsToQuill?o+=e.height:o+=n.bottom,this.containerBottomIsNotVisible(o,e)){var h=-1*this.options.offsetTop;this.options.fixMentionsToQuill||(h+=n.top),o=h-i}o>=0?this.mentionContainer.classList.forEach((function(e){t.mentionContainer.classList.add("".concat(e,"-bottom")),t.mentionContainer.classList.remove("".concat(e,"-top"))})):this.mentionContainer.classList.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:"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.quill.getSelection();if(null!=t){this.cursorPos=t.index;var e,n=this.getTextBeforeCursor(),i=(e=n,this.options.mentionDenotationChars.reduce((function(t,n){var i=e.lastIndexOf(n);return i>t.mentionCharIndex?{mentionChar:n,mentionCharIndex:i}:{mentionChar:t.mentionChar,mentionCharIndex:t.mentionCharIndex}}),{mentionChar:null,mentionCharIndex:-1})),o=i.mentionChar,s=i.mentionCharIndex;if(function(t,e,n){return t>-1&&!(n&&0!==t&&!e[t-1].match(/\s/g))}(s,n,this.options.isolateCharacter)){var a=this.cursorPos-(n.length-s);this.mentionCharPos=a;var r=n.substring(s+o.length);r.length>=this.options.minChars&&function(t,e){return e.test(t)}(r,this.options.allowedChars)?this.options.source(r,this.renderList.bind(this,o),o):this.hideMentionList()}else this.hideMentionList()}}},{key:"onTextChange",value:function(t,e,n){"user"===n&&this.onSomethingChange()}},{key:"onSelectionChange",value:function(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}}]),n}();return t.register("modules/mention",d),d}(Quill); |
{ | ||
"name": "quill-mention", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "@mentions for the Quill rich text editor", | ||
@@ -5,0 +5,0 @@ "main": "dist/quill.mention.csj.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73269
1250