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 0.1.4 to 0.1.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 s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.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.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=0)}([function(t,e,i){t.exports=i(1)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(2),s=(i.n(n),i(3)),o=(i.n(s),i(4));Quill.register("modules/mention",class{constructor(t,e){this.isOpen=!1,this.itemIndex=0,this.atPos=null,this.cursorPos=null,this.values=[],this.quill=t,this.source=e.source,this.renderItem=e.renderItem,this.minChars=e.minChars||0,this.maxChars=(e.maxChars||30)+1,this.allowedChars=e.allowedChars||/^[a-zA-Z0-9_]*$/,this.mentionContainer=document.createElement("div"),this.mentionContainer.className="ql-mention-list-container",this.mentionContainer.style.cssText="display: none; position: absolute;",this.mentionList=document.createElement("ul"),this.mentionList.className="ql-mention-list",this.mentionContainer.appendChild(this.mentionList),document.body.appendChild(this.mentionContainer),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.keyboard.addBinding({key:o.a.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[9].unshift(t.keyboard.bindings[9].pop()),t.keyboard.addBinding({key:o.a.ENTER},this.selectHandler.bind(this)),t.keyboard.bindings[13].unshift(t.keyboard.bindings[13].pop()),t.keyboard.addBinding({key:o.a.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:o.a.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:o.a.DOWN},this.downHandler.bind(this))}selectHandler(){return!this.isOpen||(this.selectItem(),!1)}escapeHandler(){return!this.isOpen||(this.hideMentionList(),!1)}upHandler(){return!this.isOpen||(this.prevItem(),!1)}downHandler(){return!this.isOpen||(this.nextItem(),!1)}showMentionList(){this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.setMentionContainerPosition(),this.isOpen=!0}hideMentionList(){this.mentionContainer.style.display="none",this.isOpen=!1}highlightItem(){for(let t=0;t<this.mentionList.childNodes.length;t+=1)this.mentionList.childNodes[t].classList.remove("selected");this.mentionList.childNodes[this.itemIndex].classList.add("selected")}getItemData(){return{id:this.mentionList.childNodes[this.itemIndex].dataset.id,value:this.mentionList.childNodes[this.itemIndex].dataset.value}}selectItem(){const t=this.getItemData();this.quill.deleteText(this.atPos,this.cursorPos-this.atPos,Quill.sources.API),this.quill.insertEmbed(this.atPos,"mention",t,Quill.sources.API),this.quill.insertText(this.atPos+1," ",Quill.sources.API),this.quill.setSelection(this.atPos+2,Quill.sources.API),this.hideMentionList()}onItemClick(t){t.stopImmediatePropagation(),t.preventDefault(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}renderList(t,e){if(t&&t.length>0){this.values=t,this.mentionList.innerHTML="";for(let i=0;i<t.length;i+=1){const n=document.createElement("li");n.className="ql-mention-list-item",n.dataset.index=i,n.dataset.id=t[i].id,n.dataset.value=t[i].value,n.innerHTML=this.renderItem(t[i],e),n.onclick=this.onItemClick.bind(this),this.mentionList.appendChild(n)}this.itemIndex=0,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}nextItem(){this.itemIndex=(this.itemIndex+1)%this.values.length,this.highlightItem()}prevItem(){this.itemIndex=(this.itemIndex+this.values.length-1)%this.values.length,this.highlightItem()}hasValidChars(t){return this.allowedChars.test(t)}setMentionContainerPosition(){const t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.atPos);let i=window.scrollY+t.top+e.bottom,n=window.scrollX+t.left+e.left;i+this.mentionContainer.offsetHeight>window.scrollY+window.innerHeight&&(i=window.scrollY+t.top+e.top-this.mentionContainer.offsetHeight),n+this.mentionContainer.offsetWidth>window.scrollX+window.innerWidth&&(n=window.innerWidth-this.mentionContainer.offsetWidth),this.mentionContainer.style.top=`${i}px`,this.mentionContainer.style.left=`${n}px`,this.mentionContainer.style.visibility="visible"}onSomethingChange(){const t=this.quill.getSelection();if(null==t)return;this.cursorPos=t.index;const e=Math.max(0,this.cursorPos-this.maxChars),i=this.quill.getText(e,this.cursorPos-e),n=i.lastIndexOf("@");if(n>-1){const t=this.cursorPos-(i.length-n);this.atPos=t;const e=i.substring(n+1);e.length>=this.minChars&&this.hasValidChars(e)?this.source(e):this.hideMentionList()}else this.hideMentionList()}onTextChange(t,e,i){"user"===i&&this.onSomethingChange()}onSelectionChange(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}})},function(t,e){},function(t,e){const i=Quill.import("blots/embed");class n extends i{static create(t){const e=super.create(),i=document.createElement("span");return i.className="ql-mention-at-sign",i.innerHTML="@",e.appendChild(i),e.innerHTML+=t.value,e.dataset.id=t.id,e.dataset.value=t.value,e}static value(t){return{id:t.dataset.id,value:t.dataset.value}}}n.blotName="mention",n.tagName="span",n.className="mention",Quill.register(n)},function(t,e,i){"use strict";e.a={TAB:9,ENTER:13,ESCAPE:27,UP:38,DOWN:40}}]);
!function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.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.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=0)}([function(t,e,i){t.exports=i(1)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(2),s=(i.n(n),i(3)),o=(i.n(s),i(4));Quill.register("modules/mention",class{constructor(t,e){this.isOpen=!1,this.itemIndex=0,this.atPos=null,this.cursorPos=null,this.values=[],this.quill=t,this.source=e.source,this.renderItem=e.renderItem,this.minChars=e.minChars||0,this.maxChars=(e.maxChars||30)+1,this.allowedChars=e.allowedChars||/^[a-zA-Z0-9_]*$/,this.mentionContainer=document.createElement("div"),this.mentionContainer.className="ql-mention-list-container",this.mentionContainer.style.cssText="display: none; position: absolute;",this.mentionList=document.createElement("ul"),this.mentionList.className="ql-mention-list",this.mentionContainer.appendChild(this.mentionList),document.body.appendChild(this.mentionContainer),t.on("text-change",this.onTextChange.bind(this)),t.on("selection-change",this.onSelectionChange.bind(this)),t.keyboard.addBinding({key:o.a.TAB},this.selectHandler.bind(this)),t.keyboard.bindings[9].unshift(t.keyboard.bindings[9].pop()),t.keyboard.addBinding({key:o.a.ENTER},this.selectHandler.bind(this)),t.keyboard.bindings[13].unshift(t.keyboard.bindings[13].pop()),t.keyboard.addBinding({key:o.a.ESCAPE},this.escapeHandler.bind(this)),t.keyboard.addBinding({key:o.a.UP},this.upHandler.bind(this)),t.keyboard.addBinding({key:o.a.DOWN},this.downHandler.bind(this))}selectHandler(){return!this.isOpen||(this.selectItem(),!1)}escapeHandler(){return!this.isOpen||(this.hideMentionList(),!1)}upHandler(){return!this.isOpen||(this.prevItem(),!1)}downHandler(){return!this.isOpen||(this.nextItem(),!1)}showMentionList(){this.mentionContainer.style.visibility="hidden",this.mentionContainer.style.display="",this.setMentionContainerPosition(),this.isOpen=!0}hideMentionList(){this.mentionContainer.style.display="none",this.isOpen=!1}highlightItem(){for(let t=0;t<this.mentionList.childNodes.length;t+=1)this.mentionList.childNodes[t].classList.remove("selected");this.mentionList.childNodes[this.itemIndex].classList.add("selected")}getItemData(){return{id:this.mentionList.childNodes[this.itemIndex].dataset.id,value:this.mentionList.childNodes[this.itemIndex].dataset.value}}selectItem(){const t=this.getItemData();this.quill.deleteText(this.atPos,this.cursorPos-this.atPos,Quill.sources.API),this.quill.insertEmbed(this.atPos,"mention",t,Quill.sources.API),this.quill.insertText(this.atPos+1," ",Quill.sources.API),this.quill.setSelection(this.atPos+2,Quill.sources.API),this.hideMentionList()}onItemClick(t){t.stopImmediatePropagation(),t.preventDefault(),this.itemIndex=t.currentTarget.dataset.index,this.highlightItem(),this.selectItem()}renderList(t,e){if(t&&t.length>0){this.values=t,this.mentionList.innerHTML="";for(let i=0;i<t.length;i+=1){const n=document.createElement("li");n.className="ql-mention-list-item",n.dataset.index=i,n.dataset.id=t[i].id,n.dataset.value=t[i].value,n.innerHTML=this.renderItem(t[i],e),n.onclick=this.onItemClick.bind(this),this.mentionList.appendChild(n)}this.itemIndex=0,this.highlightItem(),this.showMentionList()}else this.hideMentionList()}nextItem(){this.itemIndex=(this.itemIndex+1)%this.values.length,this.highlightItem()}prevItem(){this.itemIndex=(this.itemIndex+this.values.length-1)%this.values.length,this.highlightItem()}hasValidChars(t){return this.allowedChars.test(t)}setMentionContainerPosition(){const t=this.quill.container.getBoundingClientRect(),e=this.quill.getBounds(this.atPos);let i=window.scrollY+t.top+e.bottom,n=window.scrollX+t.left+e.left;i+this.mentionContainer.offsetHeight>window.scrollY+window.innerHeight&&(i=window.scrollY+t.top+e.top-this.mentionContainer.offsetHeight),n+this.mentionContainer.offsetWidth>window.scrollX+document.documentElement.clientWidth&&(n=window.scrollX+document.documentElement.clientWidth-this.mentionContainer.offsetWidth),this.mentionContainer.style.top=`${i}px`,this.mentionContainer.style.left=`${n}px`,this.mentionContainer.style.visibility="visible"}onSomethingChange(){const t=this.quill.getSelection();if(null==t)return;this.cursorPos=t.index;const e=Math.max(0,this.cursorPos-this.maxChars),i=this.quill.getText(e,this.cursorPos-e),n=i.lastIndexOf("@");if(n>-1){const t=this.cursorPos-(i.length-n);this.atPos=t;const e=i.substring(n+1);e.length>=this.minChars&&this.hasValidChars(e)?this.source(e):this.hideMentionList()}else this.hideMentionList()}onTextChange(t,e,i){"user"===i&&this.onSomethingChange()}onSelectionChange(t){t&&0===t.length?this.onSomethingChange():this.hideMentionList()}})},function(t,e){},function(t,e){const i=Quill.import("blots/embed");class n extends i{static create(t){const e=super.create(),i=document.createElement("span");return i.className="ql-mention-at-sign",i.innerHTML="@",e.appendChild(i),e.innerHTML+=t.value,e.dataset.id=t.id,e.dataset.value=t.value,e}static value(t){return{id:t.dataset.id,value:t.dataset.value}}}n.blotName="mention",n.tagName="span",n.className="mention",Quill.register(n)},function(t,e,i){"use strict";e.a={TAB:9,ENTER:13,ESCAPE:27,UP:38,DOWN:40}}]);
{
"name": "quill-mention",
"version": "0.1.4",
"version": "0.1.5",
"description": "@mentions for the Quill rich text editor",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -176,4 +176,4 @@ import './quill.mention.css';

}
if (leftPos + this.mentionContainer.offsetWidth > window.scrollX + window.innerWidth) {
leftPos = window.innerWidth - this.mentionContainer.offsetWidth;
if (leftPos + this.mentionContainer.offsetWidth > window.scrollX + document.documentElement.clientWidth) {
leftPos = (window.scrollX + document.documentElement.clientWidth) - this.mentionContainer.offsetWidth;
}

@@ -180,0 +180,0 @@ this.mentionContainer.style.top = `${topPos}px`;

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