textchecker-element
Version:
Overlay text checker web compoentns.
74 lines (73 loc) • 20.8 kB
JavaScript
import{render as e,html as t}from"lit-html";import{eventmit as n}from"eventmit";import o from"to-px";import i from"p-debounce";import r from"delay";var s,a=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],l=[{n:"direction",v:"inherit"},{n:"boxSizing",v:"inherit"},{n:"width",v:"auto"},{n:"height",v:"auto"},{n:"height",v:"auto"},{n:"borderTopWidth",v:"0px"},{n:"borderRightWidth",v:"0px"},{n:"borderBottomWidth",v:"0px"},{n:"borderLeftWidth",v:"0px"},{n:"borderStyle",v:"none"},{n:"paddingTop",v:"0px"},{n:"paddingRight",v:"0px"},{n:"paddingBottom",v:"0px"},{n:"paddingLeft",v:"0px"},{n:"marginTop",v:"0px"},{n:"maringRight",v:"0px"},{n:"maringBottom",v:"0px"},{n:"maringLeft",v:"0px"},{n:"fontStyle",v:"inherit"},{n:"fontVariant",v:"inherit"},{n:"fontWeight",v:"inherit"},{n:"fontStretch",v:"inherit"},{n:"fontSize",v:"inherit"},{n:"fontSizeAdjust",v:"inherit"},{n:"lineHeight",v:"inherit"},{n:"fontFamily",v:"inherit"},{n:"textAlign",v:"inherit"},{n:"textTransform",v:"inherit"},{n:"textIndent",v:"inherit"},{n:"textDecoration",v:"inherit"},{n:"letterSpacing",v:"inherit"},{n:"wordSpacing",v:"inherit"},{n:"tabSize",v:"inherit"}],d="undefined"!=typeof window,p=d&&null!=global.mozInnerScreenX,h=global.getComputedStyle?global.getComputedStyle:function(e){return e.currentStyle};function c(e,t){return t&&t.text?"function"==typeof t.text?t.text(e,t):t.text:e.value}const u=(()=>{let e="",t=null;return n=>{const o=n.value;return e===o||(e=o,t=h(n)),t}})();function g(e,t,n){if(!d)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var o=n&&n.debug||!1,i=o||n&&n.reuse||!1,r=function(e){var t,n=e&&e.id||"input-textarea-caret-position-mirror-div";return!!(e&&e.debug||e&&e.reuse)&&(t=document.getElementById(n)),t||((t=document.createElement("div")).id=n,document.body.appendChild(t),s=void 0),t}(n);!function(e,t,n,o){var i=o&&o.debug||!1;if(i||o&&o.reuse){var r,l=o&&o.forceUpdateStyle||!1;if(l||!o||o.reuse||(l=!0),(r=!l&&(o&&o.guessIfUpdateStyle||!1))&&("function"==typeof r&&!r(n)||s===e.tagName))return;s=e.tagName}else s=void 0;var d=n.style,c=h(e),u="INPUT"===e.nodeName;d.whiteSpace="pre-wrap",u?o&&o.allowInputWrap||(d.wordWrap="normal"):d.wordWrap="break-word",d.position="absolute",i||(d.visibility="hidden"),o&&!0===o.fontZoom&&(o.fontZoom=1/function(){var e=document.createElement("span"),t=e.style;t.position="absolute",t.visibility="hidden",t.fontSize="100px",document.body.appendChild(e);var n=parseFloat(h(e).getPropertyValue("font-size"));return null!==e.parentNode&&e.parentNode.removeChild(e),isFinite(n)?n/100:1}()),(o&&o.additionalStyles?a.concat(o.additionalStyles):a).forEach(function(e){if(u&&"lineHeight"===e){var t=c;if("normal"===c.lineHeight&&(d.lineHeight="1em",d.height=c.height,t=h(n)),"border-box"===c.boxSizing){var i=parseInt(c.height),r=parseInt(c.paddingTop)+parseInt(c.paddingBottom)+parseInt(c.borderTopWidth)+parseInt(c.borderBottomWidth),s=r+parseInt(t.lineHeight);d.lineHeight=i>s?i-r+"px":i===s?t.lineHeight:0}else{var a,l,p=0;isFinite(parseFloat(t.lineHeight))&&isFinite(a=parseFloat(c.height))?(["borderTop","borderBottom","paddingTop","paddingBottom","marginTop","marginBottom"].forEach(function(e){l=parseFloat(c[e]),isFinite(l)&&(p+=l)}),0===p?d.lineHeight=c.height:(l=Math.max(a-p,0),d.lineHeight=(l>0?l:a)+"px")):d[e]=t[e]}}else if(!o||"number"!=typeof o.fontZoom||"fontSize"!==e&&"lineHeight"!==e)d[e]=c[e];else{var g;d[e]=isFinite(g=parseFloat(c[e]))?g*o.fontZoom+"px":c[e]}}),p?e.scrollHeight>parseInt(c.height)&&(d.overflowY="scroll"):d.overflow="hidden"}(e,0,r,n);var g=function(e,t,n,o){e.scrollLeft&&(n.scrollLeft=e.scrollLeft),e.scrollTop&&(n.scrollTop=e.scrollTop),e.dir&&(n.dir=e.dir),o&&o.additionalAttributes&&o.additionalAttributes.forEach(function(t){n[t]=e[t]});var i=u(e),r="INPUT"===e.nodeName;n.textContent=c(e,o).substring(0,t),!r||o&&o.allowInputWrap||(n.textContent=n.textContent.replace(/\s/g," "));var s=document.createElement("span");if(s.textContent=c(e,o).substring(t)||".",o.fauxId&&(s.id=o.fauxId),o.forceClearFauxStyle){var a=s.style;l.forEach(function(e){a[e.n]=e.v})}n.appendChild(s);var d={top:s.offsetTop+parseInt(i.borderTopWidth),left:s.offsetLeft+parseInt(i.borderLeftWidth),height:parseInt(i.lineHeight)};return o&&o.returnHeight&&(d.height=s.offsetHeight),d}(e,t,r,n);o&&(r.style.backgroundColor="#aaa",g._div=r);var m=n&&n.returnDiv;return i||m?m&&(g._div=r):(s=void 0,document.body.removeChild(r)),g}function m(){return(m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}let v,f,x=e=>e;class b extends HTMLElement{constructor(o){super(),this.hoverPadding=8,this.attributeChangedCallback=(e,t,n)=>{this[e]&&(this[e]=n,"target"===e&&(this.targetElement=document.querySelector(n)))},this.updateOnScroll=()=>{},this.renderAnnotationMarkers=n=>{const o=n.rectItems.map(e=>((e,n=!1)=>t(n?v||(v=x`<span
style="pointer-events: none; border: 2px dotted red; position: absolute; left: ${0}px; top: ${0}px; width: ${0}px; height: ${0}px;"
></span>`):f||(f=x`<span
style="pointer-events: none; border-bottom: 2px dotted red; position: absolute; left: ${0}px; top: ${0}px; width: ${0}px; height: ${0}px;"
></span>`),e.left,e.top,e.width,e.height))(e,n.highlightRectIdSet.has(e.id)));e(o,this.annotationBox)},this.onMouseUpdate=e=>{const t=this.store.get(),n=this.hoverPadding,o=t.rectItems.filter(t=>{const o=e.clientX-t.boxAbsoluteX,i=e.clientY-t.boxAbsoluteY;return t.left-n<=o&&o<=t.left+t.width+n&&t.top-n<=i&&i<=t.top+t.height+n}).map(e=>e.id);t.rectItems.forEach(e=>{const n=t.mouseHoverReactIdMap.get(e.id),i=o.includes(e.id);var r;if(!1===n&&i)null==(r=t.annotationItems.find(t=>t.id===e.id))||r.onMouseEnter({rectItem:e});else if(!0===n&&!i){var s;null==(s=t.annotationItems.find(t=>t.id===e.id))||s.onMouseLeave({rectItem:e})}t.mouseHoverReactIdMap.set(e.id,i)}),this.store.highlightRectIndexes(o)},this.store=(e=>{let t=m({visibleTop:0,visibleLeft:0,visibleWidth:0,visibleHeight:0,rectItems:[],annotationItems:[],highlightRectIdSet:new Set,mouseHoverReactIdMap:new Map},void 0);const o=n();return{get:()=>t,onChange(e){o.on(e)},dispose(){o.offAll()},highlightRectIndexes(e){t=m({},t,{highlightRectIdSet:new Set(e)}),o.emit()},update(e){t=m({},t,e),o.emit()}}})(),this.targetElement=o.targetElement,this.hoverPadding=o.hoverPadding}static get observedAttributes(){return["target","hoverPadding"]}connectedCallback(){if(!this.targetElement)throw new Error("target element is not found");const e=this.attachShadow({mode:"open"}),t=document.createElement("div");t.className="overlay",t.setAttribute("style","color: transparent; border: 1px dotted blue; position: absolute; top: 0px; left: 0px; pointer-events: none;");const n=document.createElement("div");n.className="annotationBox",t.append(n),e.append(t),this.annotationBox=n,this.targetElement.addEventListener("mousemove",this.onMouseUpdate),this.targetElement.addEventListener("scroll",this.updateOnScroll),this.store.onChange(()=>{this.renderAnnotationMarkers(this.store.get())})}disconnectedCallback(){this.targetElement.removeEventListener("mousemove",this.onMouseUpdate),this.targetElement.removeEventListener("scroll",this.updateOnScroll)}resetAnnotations(){0!==this.store.get().rectItems.length&&this.store.update({rectItems:[]})}updateAnnotations(e){var t,n,i,r,s,a;const l=this.targetElement,d=window.getComputedStyle(l),p=["box-sizing"].map(e=>`${e}: ${d.getPropertyValue(e)};`).join("");this.annotationBox.setAttribute("style",`color: transparent; overflow:hidden; position: absolute; pointer-events: none; ${p}`);const h=l.offsetTop,c=l.offsetLeft,u=l.offsetHeight,m=l.clientWidth+parseInt(d.borderLeftWidth||"0",10)+parseInt(d.borderRightWidth||"0",10);this.annotationBox.style.zIndex=""+(1+(null!==d.zIndex&&"auto"!==d.zIndex?+d.zIndex:0)),this.annotationBox.style.left=`${c}px`,this.annotationBox.style.top=`${h}px`,this.annotationBox.style.height=`${u}px`,this.annotationBox.style.width=`${m}px`;const v=null!=(t=o(d.getPropertyValue("font-size")))?t:16.123,f=null!=(n=o(d.getPropertyValue("margin-top")))?n:0,x=null!=(i=o(d.getPropertyValue("margin-bottom")))?i:0,b=null!=(r=o(d.getPropertyValue("border-width")))?r:0,w=null!=(s=o(d.getPropertyValue("padding-top")))?s:0,I=null!=(a=o(d.getPropertyValue("padding-bottom")))?a:0,y=l.getBoundingClientRect(),L=y.x,C=y.y,E=y.width,H=y.height,M=l.scrollTop,S=l.scrollLeft;this.annotationBox.scrollTop=l.scrollTop,this.annotationBox.scrollLeft=l.scrollLeft;const A=e.slice().reverse();let B=!1;const T=A.flatMap(e=>{var t,n,o,i,r,s;if(B)return[];const a=e.end,l=g(this.targetElement,e.start,{reuse:!0,returnHeight:!0,returnDiv:!0,debug:!1});if(l.top+v<M)return B=!0,[];const d=g(this.targetElement,a,{reuse:!0,returnHeight:!0,returnDiv:!0,debug:!1});return l.top===d.top?[{id:e.id,left:l.left-S,top:l.top-M,height:v,width:d.left-l.left,boxMarginTop:f,boxMarginBottom:x,boxBorderWidth:b,boxAbsoluteX:L,boxAbsoluteY:C,boxWidth:E,boxHeight:H,boxPaddingTop:w,boxPaddingBottom:I}]:[{id:e.id,left:l.left-S,top:l.top-M,height:v,width:(null!=(t=null==l||null==(n=l._div)||null==(o=n.getBoundingClientRect())?void 0:o.width)?t:0)-l.left,boxMarginTop:f,boxMarginBottom:x,boxBorderWidth:b,boxAbsoluteX:L,boxAbsoluteY:C,boxWidth:E,boxHeight:H,boxPaddingTop:w,boxPaddingBottom:I},{id:e.id,left:-S,top:d.top-M,height:v,width:(null!=(i=null==l||null==(r=l._div)||null==(s=r.getBoundingClientRect())?void 0:s.left)?i:0)+d.left,boxMarginTop:f,boxMarginBottom:x,boxBorderWidth:b,boxAbsoluteX:L,boxAbsoluteY:C,boxWidth:E,boxHeight:H,boxPaddingTop:w,boxPaddingBottom:I}]});this.store.update({annotationItems:e,rectItems:T})}}window.customElements.get("text-checker-element")||window.customElements.define("text-checker-element",b);let w,I,y,L,C,E,H,M,S,A,B,T,$=e=>e;class k extends HTMLElement{constructor(o){super(),this.isHovering=!1,this.onMouseEnter=()=>{var e;this.isHovering=!0,null==(e=this.onEnter)||e.call(this)},this.onMouseLeave=()=>{var e;this.isHovering=!1,null==(e=this.onLeave)||e.call(this)},this.renderAnnotationMarkers=n=>{var o,i,r,s;const a=n.targetRect;if(!a)return;if(!n.card)return void e("",this.overlay);const l=n.card.message.split(/\n/)[0],d=t(w||(w=$` <svg
class="popup-listItem--icon"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M7.5 5.6L5 7L6.4 4.5L5 2L7.5 3.4L10 2L8.6 4.5L10 7L7.5 5.6ZM19.5 15.4L22 14L20.6 16.5L22 19L19.5 17.6L17 19L18.4 16.5L17 14L19.5 15.4ZM22 2L20.6 4.5L22 7L19.5 5.6L17 7L18.4 4.5L17 2L19.5 3.4L22 2ZM13.34 12.78L15.78 10.34L13.66 8.22L11.22 10.66L13.34 12.78ZM14.37 7.29L16.71 9.63C17.1 10 17.1 10.65 16.71 11.04L5.04 22.71C4.65 23.1 4 23.1 3.63 22.71L1.29 20.37C0.899998 20 0.899998 19.35 1.29 18.96L12.96 7.29C13.35 6.9 14 6.9 14.37 7.29Z"
/>
</svg>`)),p=[n.card.fixable?{message:l,label:t(I||(I=$`Fix it!`)),onClick:null==(o=n.handlers)?void 0:o.onFixText,icon:d}:{message:n.card.message},...n.card.fixable?[{label:t(y||(y=$`Fix
<span class="popup-listItem--ruleName">${0}</span> problems`),n.card.messageRuleId),onClick:null==(i=n.handlers)?void 0:i.onFixRule,icon:d}]:[],...n.card.fixable?[{label:t(L||(L=$`Fix all problems`)),onClick:null==(r=n.handlers)?void 0:r.onFixAll,icon:d}]:[],{label:t(C||(C=$`Ignore`)),onClick:()=>{var e;null==(e=n.handlers)||null==e.onIgnore||e.onIgnore()},icon:t(E||(E=$`
<svg
class="popup-listItem--icon"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.00299 20C5.00299 21.103 5.89999 22 7.00299 22H17.003C18.106 22 19.003 21.103 19.003 20V8H21.003V6H17.003V4C17.003 2.897 16.106 2 15.003 2H9.00299C7.89999 2 7.00299 2.897 7.00299 4V6H3.00299V8H5.00299V20ZM9.00299 4H15.003V6H9.00299V4ZM8.00299 8H17.003L17.004 20H7.00299V8H8.00299Z"
fill="#9095AA"
/>
<path d="M9.00299 10H11.003V18H9.00299V10ZM13.003 10H15.003V18H13.003V10Z" />
</svg>
`))},{label:t(H||(H=$`Rule <span class="popup-listItem--ruleName">${0}</span>`),n.card.messageRuleId),onClick:null==(s=n.handlers)?void 0:s.onSeeDocument,icon:t(M||(M=$` <svg
class="popup-listItem--iconImage"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z"
fill="#F4F4F4"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M8.33502 8.33504H5.39325V18.6067H18.6067V8.33504L18.6067 15.665H8.33502V8.33504Z"
fill="#878787"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M5.39325 5.39326H18.6067V8.33504H13.4831V18.6067L18.6067 18.6067H5.39325L10.5168 18.6067V8.33504H5.39325V5.39326Z"
fill="black"
/>
</svg>`))}],h=t(S||(S=$` <ul class="popoup-list" style="--padding: ${0}px">
${0}
</ul>`),16,p.map(e=>{const n={handleEvent:e.onClick};return e.message?e.onClick?t(A||(A=$` <li
@click=${0}
class="popup-listItem"
style="--padding: ${0}px;"
>
<p class="popup-listItem-message">${0}</p>
<p class="popup-listItem-content">${0}${0}</p>
</li>`),n,16,e.message,e.icon,e.label):t(B||(B=$` <li class="popup-listItem" style="--padding: ${0}px; padding-bottom: 0;">
<p class="popup-listItem-message">${0}</p>
<p class="popup-listItem-content">${0}${0}</p>
</li>`),16,e.message,e.icon,e.label):t(T||(T=$` <li @click=${0} class="popup-listItem" style="--padding: ${0}px;">
<p class="popup-listItem-content">${0}${0}</p>
</li>`),n,16,e.icon,e.label)}));this.overlay.setAttribute("style",`position: fixed; z-index: 2147483644; min-width: 300px; max-width: 800px; top: ${a.top}px; left: ${a.left-16}px;`),e(h,this.overlay)},this.onEnter=o.onEnter,this.onLeave=o.onLeave,this.store=(e=>{let t=m({},void 0);const o=n();return{get:()=>t,onChange(e){o.on(e)},dispose(){o.offAll()},update(e){t=m({},t,e),o.emit()},removeCardById(e){var n,i;(null==(n=t)||null==(i=n.card)?void 0:i.id)===e&&(t=m({},t,{card:void 0}),o.emit())},removeAllCard(){t=m({},t,{card:void 0}),o.emit()}}})()}connectedCallback(){const e=this.attachShadow({mode:"open"}),t=document.createElement("div");t.className="popup";const n=document.createElement("style");n.textContent="\n:root {\n --highlight-color: #F35373;\n --highlight-textColor: #9095AA;\n}\n.popup {\n color: #000;\n background-color: #fff;\n box-shadow: 0 2px 10px rgba(0,0,0,.2);\n padding: 0; \n}\n.popoup-list {\n margin: 0;\n padding: 0 0 var(--padding) 0;\n list-style: none;\n}\n.popup-listItem {\n padding: var(--padding);\n cursor: pointer;\n}\n\n.popup-listItem--icon, .popup-listItem--iconImage {\n padding-right: 12px; \n fill: #9095AA;\n width: 24px;\n height: 24px;\n min-height: 24px;\n min-width: 24px;\n}\n\n.popup-listItem:first-child {\n padding-top: var(--padding);\n padding-bottom: var(--padding);\n}\n\n.popup-listItem-message {\n font-size: 12px;\n margin: 0;\n padding: 0 0 6px 0;\n}\n\n.popup-listItem--ruleName {\n font-size: 12px;\n margin: 0 0.5em;\n}\n\n.popup-listItem-content {\n font-size: 16px;\n /* align icon + text */\n display: flex;\n align-items: center;\n margin: 0;\n padding: 0;\n}\n.popup-listItem:hover {\n color: #fff;\n background-color: #F35373;\n}\n.popup-listItem:hover .popup-listItem--icon {\n fill: #ffffff !important;\n stroke: #ffffff !important;\n}\n",this.overlay=t,this.overlay.addEventListener("mouseenter",this.onMouseEnter),this.overlay.addEventListener("mouseleave",this.onMouseLeave),e.append(n),e.append(t),this.store.onChange(()=>{this.renderAnnotationMarkers(this.store.get())})}disconnectedCallback(){this.overlay.removeEventListener("mouseenter",this.onMouseEnter),this.overlay.removeEventListener("mouseleave",this.onMouseLeave)}updateCard({card:e,rect:t,handlers:n}){this.store.update({card:e,targetRect:t,handlers:n})}dismissCard(e){this.store.removeCardById(e.id)}dismissCards(){this.store.removeAllCard()}}window.customElements.get("textchecker-popoup-element")||window.customElements.define("textchecker-popoup-element",k);const V=localStorage.DEBUG||"",W="*"===V||V.startsWith("@textlint")||"development"===process.env.NODE_ENV,z=(...e)=>{W&&console.log("[textchecker-element]",...e)};let F;const R=e=>F||(F=new k(e),document.body.append(F),F),P=({textAreaElement:e,lintingDebounceMs:t,lintEngine:n})=>{if(!e)return z("Can not attach. No textarea",e),()=>{};if(e.readOnly)return z("Can not attach textarea that is readonly",e),()=>{};const o=new b({targetElement:e,hoverPadding:20});e.before(o);const s=new Map,a=()=>{l.isHovering||0!==s.size||l.dismissCards()},l=R({onLeave(){l.isHovering||0!==s.size||l.dismissCards()}}),d=(()=>{let e=!1;return{onComposition:e,handleEvent:t=>{"compositionend"===t.type?e=!1:"compositionstart"===t.type&&(e=!0)}}})(),p=i(async()=>{if(d.onComposition)return;l.dismissCards();const t=e.value,i=await n.lintText({text:t});z("lint results",i);const a=async(n,o)=>{const i=e.value;i===t&&i!==n&&(e.value=n,await p(),l.dismissCard(o))},h=i.flatMap(e=>e.messages.map(o=>{const i={id:o.ruleId+"::"+o.index,message:o.message,messageRuleId:o.ruleId,fixable:Boolean(o.fix)},d=new WeakMap;return{id:`${o.ruleId}::${o.line}:${o.column}`,start:o.index,end:o.index+1,onMouseEnter:({rectItem:r})=>{s.set(r,!0);const h=d.get(r);z("enter",h),h&&h.abort(),d.set(r,new AbortController),l.updateCard({card:i,rect:{top:r.boxBorderWidth+r.boxMarginTop+r.boxPaddingTop+r.boxAbsoluteY+r.top+r.height,left:r.boxAbsoluteX+r.left,width:r.width},handlers:{async onFixText(){const e=await n.fixText({text:t,messages:[o]});await a(e.output,i)},async onFixAll(){const o=await n.fixText({text:t,messages:e.messages});await a(o.output,i)},async onFixRule(){const r=e.messages.filter(e=>e.ruleId===o.ruleId),s=await n.fixText({text:t,messages:r});await a(s.output,i)},async onIgnore(){await n.ignoreText({text:t,message:o}),await p()},onSeeDocument(){const e=o.ruleId.includes("/")?o.ruleId.split("/")[1]:o.ruleId;window.open(`https://github.com/search?q=textlint ${encodeURIComponent(e)}`,"_blank","noopener")}}})},async onMouseLeave({rectItem:e}){try{s.delete(e);const t=d.get(e);if(z("leave",t),await r(500,{signal:null==t?void 0:t.signal}),l.isHovering||s.get(e))return;l.dismissCard(i)}catch(e){z("Abort Canceled",e)}}}}));z("annotations",h),o.updateAnnotations(h)},t);e.addEventListener("compositionstart",d),e.addEventListener("compositionend",d),e.addEventListener("input",p),e.addEventListener("focusout",a),p();const h=new ResizeObserver(()=>{z("textarea resize"),l.dismissCards(),o.resetAnnotations(),p()});h.observe(e);const c=()=>{o.resetAnnotations(),p()};return window.addEventListener("scroll",c),e.addEventListener("scroll",c),()=>{window.removeEventListener("scroll",c),e.removeEventListener("scroll",c),e.removeEventListener("compositionstart",d),e.removeEventListener("compositionend",d),e.removeEventListener("input",p),e.removeEventListener("blur",a),h.disconnect()}};export{b as TextCheckerElement,k as TextCheckerPopupElement,P as attachToTextArea};
//# sourceMappingURL=index.modern.js.map