Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quill-mention

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quill-mention - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

2

dist/quill.mention.min.js

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

!function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e){t.exports=Quill},function(t,e,i){"use strict";var n,o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=(n=i(0))&&n.__esModule?n:{default:n},a=s.default.import("blots/embed"),r=function(t){function e(){return function(t,i){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).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, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,a),o(e,null,[{key:"create",value:function(t){var i=function t(e,i,n){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,i);if(void 0===o){var s=Object.getPrototypeOf(e);return null===s?void 0:t(s,i,n)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(n):void 0}(e.__proto__||Object.getPrototypeOf(e),"create",this).call(this),n=document.createElement("span");return n.className="ql-mention-denotation-char",n.innerHTML=t.denotationChar,i.appendChild(n),i.innerHTML+=t.value,i.dataset.id=t.id,i.dataset.value=t.value,i.dataset.denotationChar=t.denotationChar,t.link&&(i.dataset.link=t.link),i}},{key:"value",value:function(t){return{id:t.dataset.id,value:t.dataset.value,link:t.dataset.link||null,denotationChar:t.dataset.denotationChar}}}]),e}();r.blotName="mention",r.tagName="span",r.className="mention",s.default.register(r)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={TAB:9,ENTER:13,ESCAPE:27,UP:38,DOWN:40}},function(t,e,i){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=r(i(0)),a=r(i(2));function r(t){return t&&t.__esModule?t:{default:t}}i(6),i(1);var l=function(){function t(e,i){!function(e,i){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.quill=e,this.options={source:null,renderItem:function(t,e){return""+t.value},mentionDenotationChars:["@"],allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,fixMentionsToQuill:!1,defaultMenuOrientation:"bottom"},n(this.options,i),this.mentionContainer=document.createElement("div"),this.mentionContainer.className="ql-mention-list-container",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="ql-mention-list",this.mentionContainer.appendChild(this.mentionList),this.quill.container.appendChild(this.mentionContainer),e.on("text-change",this.onTextChange.bind(this)),e.on("selection-change",this.onSelectionChange.bind(this)),e.keyboard.addBinding({key:a.default.TAB},this.selectHandler.bind(this)),e.keyboard.bindings[9].unshift(e.keyboard.bindings[9].pop()),e.keyboard.addBinding({key:a.default.ENTER},this.selectHandler.bind(this)),e.keyboard.bindings[13].unshift(e.keyboard.bindings[13].pop()),e.keyboard.addBinding({key:a.default.ESCAPE},this.escapeHandler.bind(this)),e.keyboard.addBinding({key:a.default.UP},this.upHandler.bind(this)),e.keyboard.addBinding({key:a.default.DOWN},this.downHandler.bind(this))}return o(t,[{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.isOpen=!0}},{key:"hideMentionList",value:function(){this.mentionContainer.style.display="none",this.isOpen=!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 i=this.mentionList.childNodes[this.itemIndex].offsetHeight,n=this.itemIndex*i,o=this.mentionContainer.scrollTop,s=o+this.mentionContainer.offsetHeight;n<o?this.mentionContainer.scrollTop=n:n>s-i&&(this.mentionContainer.scrollTop+=n-s+i)}}},{key:"getItemData",value:function(){var t=this.mentionList.childNodes[this.itemIndex].dataset.link;return{id:this.mentionList.childNodes[this.itemIndex].dataset.id,value:t?'<a href="'+t+'" target="_blank">'+this.mentionList.childNodes[this.itemIndex].dataset.value:this.mentionList.childNodes[this.itemIndex].dataset.value,link:t||null,denotationChar:this.mentionList.childNodes[this.itemIndex].dataset.denotationChar}}},{key:"onContainerMouseMove",value:function(){this.suspendMouseEnter=!1}},{key:"selectItem",value:function(){var t=this.getItemData();this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,s.default.sources.API),this.quill.insertEmbed(this.mentionCharPos,"mention",t,s.default.sources.API),this.quill.insertText(this.mentionCharPos+1," ",s.default.sources.API),this.quill.setSelection(this.mentionCharPos+2,s.default.sources.API),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.stopImmediatePropagation(),t.preventDefault(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}},{key:"renderList",value:function(t,e,i){if(e&&e.length>0){this.values=e,this.mentionList.innerHTML="";for(var n=0;n<e.length;n+=1){var o=document.createElement("li");o.className="ql-mention-list-item",o.dataset.index=n,o.dataset.id=e[n].id,o.dataset.value=e[n].value,o.dataset.denotationChar=t,e[n].link&&(o.dataset.link=e[n].link),o.innerHTML=this.options.renderItem(e[n],i),o.onmouseenter=this.onItemMouseEnter.bind(this),o.onclick=this.onItemClick.bind(this),this.mentionList.appendChild(o)}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:"hasValidChars",value:function(t){return this.options.allowedChars.test(t)}},{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:"setMentionContainerPosition",value:function(){var t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.mentionCharPos),i=this.mentionContainer.offsetHeight,n=this.options.offsetTop,o=this.options.offsetLeft;if(this.options.fixMentionsToQuill?this.mentionContainer.style.right="0px":o+=e.left,this.containerRightIsNotVisible(o,t)){var s=this.mentionContainer.offsetWidth+this.options.offsetLeft;o=t.width-s}if("top"===this.options.defaultMenuOrientation){if((n=this.options.fixMentionsToQuill?-1*(i+this.options.offsetTop):e.top-(i+this.options.offsetTop))+t.top<=0){var a=this.options.offsetTop;this.options.fixMentionsToQuill?a+=t.height:a+=e.bottom,n=a}}else if(this.options.fixMentionsToQuill?n+=t.height:n+=e.bottom,this.containerBottomIsNotVisible(n,t)){var r=-1*this.options.offsetTop;this.options.fixMentionsToQuill||(r+=e.top),n=r-i}this.mentionContainer.style.top=n+"px",this.mentionContainer.style.left=o+"px",this.mentionContainer.style.visibility="visible"}},{key:"onSomethingChange",value:function(){var t=this.quill.getSelection();if(null!=t){this.cursorPos=t.index;var e=Math.max(0,this.cursorPos-this.options.maxChars),i=this.quill.getText(e,this.cursorPos-e),n=this.options.mentionDenotationChars.reduce(function(t,e){var n=t,o=i.lastIndexOf(e);return o>n?o:n},-1);if(n>-1){if(this.options.isolateCharacter&&0!=n&&!i[n-1].match(/\s/g))return void this.hideMentionList();var o=this.cursorPos-(i.length-n);this.mentionCharPos=o;var s=i.substring(n+1);if(s.length>=this.options.minChars&&this.hasValidChars(s)){var a=i[n];this.options.source(s,this.renderList.bind(this,a),a)}else this.hideMentionList()}else this.hideMentionList()}}},{key:"onTextChange",value:function(t,e,i){"user"===i&&this.onSomethingChange()}},{key:"onSelectionChange",value:function(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}}]),t}();s.default.register("modules/mention",l)},function(t,e,i){t.exports=i(3)},,function(t,e){}]);
!function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e){t.exports=Quill},function(t,e,i){"use strict";var n,o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=(n=i(0))&&n.__esModule?n:{default:n},a=s.default.import("blots/embed"),r=function(t){function e(){return function(t,i){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).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, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,a),o(e,null,[{key:"create",value:function(t){var i=function t(e,i,n){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,i);if(void 0===o){var s=Object.getPrototypeOf(e);return null===s?void 0:t(s,i,n)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(n):void 0}(e.__proto__||Object.getPrototypeOf(e),"create",this).call(this),n=document.createElement("span");return n.className="ql-mention-denotation-char",n.innerHTML=t.denotationChar,i.appendChild(n),i.innerHTML+=t.value,e.setDataValues(i,t)}},{key:"setDataValues",value:function(t,e){var i=t;return Object.keys(e).forEach(function(t){i.dataset[t]=e[t]}),i}},{key:"value",value:function(t){return t.dataset}}]),e}();r.blotName="mention",r.tagName="span",r.className="mention",s.default.register(r)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={TAB:9,ENTER:13,ESCAPE:27,UP:38,DOWN:40}},function(t,e,i){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),s=r(i(0)),a=r(i(2));function r(t){return t&&t.__esModule?t:{default:t}}i(6),i(1);var h=function(){function t(e,i){!function(e,i){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.isOpen=!1,this.itemIndex=0,this.mentionCharPos=null,this.cursorPos=null,this.values=[],this.suspendMouseEnter=!1,this.quill=e,this.options={source:null,renderItem:function(t,e){return""+t.value},mentionDenotationChars:["@"],allowedChars:/^[a-zA-Z0-9_]*$/,minChars:0,maxChars:31,offsetTop:2,offsetLeft:0,isolateCharacter:!1,fixMentionsToQuill:!1,defaultMenuOrientation:"bottom",dataAttributes:["id","value","denotationChar","link"]},n(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="ql-mention-list-container",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="ql-mention-list",this.mentionContainer.appendChild(this.mentionList),this.quill.container.appendChild(this.mentionContainer),e.on("text-change",this.onTextChange.bind(this)),e.on("selection-change",this.onSelectionChange.bind(this)),e.keyboard.addBinding({key:a.default.TAB},this.selectHandler.bind(this)),e.keyboard.bindings[9].unshift(e.keyboard.bindings[9].pop()),e.keyboard.addBinding({key:a.default.ENTER},this.selectHandler.bind(this)),e.keyboard.bindings[13].unshift(e.keyboard.bindings[13].pop()),e.keyboard.addBinding({key:a.default.ESCAPE},this.escapeHandler.bind(this)),e.keyboard.addBinding({key:a.default.UP},this.upHandler.bind(this)),e.keyboard.addBinding({key:a.default.DOWN},this.downHandler.bind(this))}return o(t,[{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.isOpen=!0}},{key:"hideMentionList",value:function(){this.mentionContainer.style.display="none",this.isOpen=!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 i=this.mentionList.childNodes[this.itemIndex].offsetHeight,n=this.itemIndex*i,o=this.mentionContainer.scrollTop,s=o+this.mentionContainer.offsetHeight;n<o?this.mentionContainer.scrollTop=n:n>s-i&&(this.mentionContainer.scrollTop+=n-s+i)}}},{key:"getItemData",value:function(){var t=this.mentionList.childNodes[this.itemIndex].dataset.link;return void 0!==t&&(this.mentionList.childNodes[this.itemIndex].dataset.value='<a href="'+t+'" target="_blank">'+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.getItemData();this.quill.deleteText(this.mentionCharPos,this.cursorPos-this.mentionCharPos,s.default.sources.API),this.quill.insertEmbed(this.mentionCharPos,"mention",t,s.default.sources.API),this.quill.insertText(this.mentionCharPos+1," ",s.default.sources.API),this.quill.setSelection(this.mentionCharPos+2,s.default.sources.API),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.stopImmediatePropagation(),t.preventDefault(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}},{key:"attachDataValues",value:function(t,e){var i=this,n=t;return Object.keys(e).forEach(function(t){i.options.dataAttributes.includes(t)?n.dataset[t]=e[t]:delete n.dataset[t]}),n}},{key:"renderList",value:function(t,e,i){if(e&&e.length>0){this.values=e,this.mentionList.innerHTML="";for(var n=0;n<e.length;n+=1){var o=document.createElement("li");o.className="ql-mention-list-item",o.dataset.index=n,o.innerHTML=this.options.renderItem(e[n],i),o.onmouseenter=this.onItemMouseEnter.bind(this),o.dataset.denotationChar=t,o.onclick=this.onItemClick.bind(this),this.mentionList.appendChild(this.attachDataValues(o,e[n]))}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:"hasValidChars",value:function(t){return this.options.allowedChars.test(t)}},{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:"setMentionContainerPosition",value:function(){var t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.mentionCharPos),i=this.mentionContainer.offsetHeight,n=this.options.offsetTop,o=this.options.offsetLeft;if(this.options.fixMentionsToQuill?this.mentionContainer.style.right="0px":o+=e.left,this.containerRightIsNotVisible(o,t)){var s=this.mentionContainer.offsetWidth+this.options.offsetLeft;o=t.width-s}if("top"===this.options.defaultMenuOrientation){if((n=this.options.fixMentionsToQuill?-1*(i+this.options.offsetTop):e.top-(i+this.options.offsetTop))+t.top<=0){var a=this.options.offsetTop;this.options.fixMentionsToQuill?a+=t.height:a+=e.bottom,n=a}}else if(this.options.fixMentionsToQuill?n+=t.height:n+=e.bottom,this.containerBottomIsNotVisible(n,t)){var r=-1*this.options.offsetTop;this.options.fixMentionsToQuill||(r+=e.top),n=r-i}this.mentionContainer.style.top=n+"px",this.mentionContainer.style.left=o+"px",this.mentionContainer.style.visibility="visible"}},{key:"onSomethingChange",value:function(){var t=this.quill.getSelection();if(null!=t){this.cursorPos=t.index;var e=Math.max(0,this.cursorPos-this.options.maxChars),i=this.quill.getText(e,this.cursorPos-e),n=this.options.mentionDenotationChars.reduce(function(t,e){var n=t,o=i.lastIndexOf(e);return o>n?o:n},-1);if(n>-1){if(this.options.isolateCharacter&&0!==n&&!i[n-1].match(/\s/g))return void this.hideMentionList();var o=this.cursorPos-(i.length-n);this.mentionCharPos=o;var s=i.substring(n+1);if(s.length>=this.options.minChars&&this.hasValidChars(s)){var a=i[n];this.options.source(s,this.renderList.bind(this,a),a)}else this.hideMentionList()}else this.hideMentionList()}}},{key:"onTextChange",value:function(t,e,i){"user"===i&&this.onSomethingChange()}},{key:"onSelectionChange",value:function(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}}]),t}();s.default.register("modules/mention",h)},function(t,e,i){t.exports=i(3)},,function(t,e){}]);
{
"name": "quill-mention",
"version": "2.0.4",
"version": "2.0.5",
"description": "@mentions for the Quill rich text editor",

@@ -5,0 +5,0 @@ "main": "src/quill.mention.js",

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

}
if (searchTerm.length === 0) {

@@ -77,2 +77,3 @@ renderList(values, searchTerm);

| `defaultMenuOrientation` | `'bottom'` | Options are `'bottom'` and `'top'`. Determines what the default orientation of the menu will be. Quill-mention will attempt to render the menu either above or below the editor. If `'top'` is provided as a value, and there is not enough space above the editor, the menu will be rendered below. Vice versa, if there is not enough space below the editor, and `'bottom'` is provided as a value (or no value is provided at all), the menu will be rendered above the editor.
| `dataAttributes` | `['id', 'value', 'denotationChar', 'link']` | A list of data values you wish to be passed from your list data to the html node. (`id, value, denotationChar, link` are included by default).

@@ -79,0 +80,0 @@

@@ -14,18 +14,15 @@ import Quill from 'quill';

node.innerHTML += data.value;
node.dataset.id = data.id;
node.dataset.value = data.value;
node.dataset.denotationChar = data.denotationChar;
if (data.link) {
node.dataset.link = data.link;
}
return node;
return MentionBlot.setDataValues(node, data);
}
static setDataValues(element, data) {
const domNode = element;
Object.keys(data).forEach((key) => {
domNode.dataset[key] = data[key];
});
return domNode;
}
static value(domNode) {
return {
id: domNode.dataset.id,
value: domNode.dataset.value,
link: domNode.dataset.link || null,
denotationChar: domNode.dataset.denotationChar,
};
return domNode.dataset;
}

@@ -32,0 +29,0 @@ }

@@ -0,0 +0,0 @@ const Keys = {

@@ -32,5 +32,10 @@ import Quill from 'quill';

defaultMenuOrientation: 'bottom',
dataAttributes: ['id', 'value', 'denotationChar', 'link'],
};
Object.assign(this.options, options);
Object.assign(this.options, options, {
dataAttributes: Array.isArray(options.dataAttributes)
? this.options.dataAttributes.concat(options.dataAttributes)
: this.options.dataAttributes,
});

@@ -145,11 +150,9 @@ this.mentionContainer = document.createElement('div');

getItemData() {
const itemLink = this.mentionList.childNodes[this.itemIndex].dataset.link;
return {
id: this.mentionList.childNodes[this.itemIndex].dataset.id,
value: itemLink ?
`<a href="${itemLink}" target="_blank">${this.mentionList.childNodes[this.itemIndex].dataset.value}` :
this.mentionList.childNodes[this.itemIndex].dataset.value,
link: itemLink || null,
denotationChar: this.mentionList.childNodes[this.itemIndex].dataset.denotationChar,
};
const { link } = this.mentionList.childNodes[this.itemIndex].dataset;
const hasLinkValue = typeof link !== 'undefined';
if (hasLinkValue) {
this.mentionList.childNodes[this.itemIndex].dataset.value = `<a href="${link}" target="_blank">${this.mentionList.childNodes[this.itemIndex].dataset.value}`;
}
return this.mentionList.childNodes[this.itemIndex].dataset;
}

@@ -192,2 +195,14 @@

attachDataValues(element, data) {
const mention = element;
Object.keys(data).forEach((key) => {
if (this.options.dataAttributes.includes(key)) {
mention.dataset[key] = data[key];
} else {
delete mention.dataset[key];
}
});
return mention;
}
renderList(mentionChar, data, searchTerm) {

@@ -201,12 +216,7 @@ if (data && data.length > 0) {

li.dataset.index = i;
li.dataset.id = data[i].id;
li.dataset.value = data[i].value;
li.dataset.denotationChar = mentionChar;
if (data[i].link) {
li.dataset.link = data[i].link;
}
li.innerHTML = this.options.renderItem(data[i], searchTerm);
li.onmouseenter = this.onItemMouseEnter.bind(this);
li.dataset.denotationChar = mentionChar;
li.onclick = this.onItemClick.bind(this);
this.mentionList.appendChild(li);
this.mentionList.appendChild(this.attachDataValues(li, data[i]));
}

@@ -334,3 +344,3 @@ this.itemIndex = 0;

if (mentionCharIndex > -1) {
if (this.options.isolateCharacter && !(mentionCharIndex == 0 || !!beforeCursorPos[mentionCharIndex - 1].match(/\s/g))) {
if (this.options.isolateCharacter && !(mentionCharIndex === 0 || !!beforeCursorPos[mentionCharIndex - 1].match(/\s/g))) {
this.hideMentionList();

@@ -337,0 +347,0 @@ return;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc