@editora/plugins 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodePlugin.native-Bwf25lLX.js +460 -0
- package/dist/CodePlugin.native-Cpp4u3Jl.mjs +648 -0
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -669
- package/dist/code.esm.js +2 -4560
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-Jf0RbSks.js → documentManager-BDz6tovy.js} +2 -2
- package/dist/{documentManager-CTqRftU8.mjs → documentManager-yjRBab4v.mjs} +3 -3
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index-CxhJLMPS.js +221 -0
- package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
- package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
- package/dist/index.esm.js +17 -15
- package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +10 -4
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-BFsKNTTj.mjs +0 -145
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-tqLTHcO6.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./shared-config.cjs.js");let A=null,p=null,s=null
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const U=require("./escapeHtml-D2Zh82pD.js"),Y=require("./dialogHelpers-zU6zpMIA.js");require("./shared-config.cjs.js");let A=null,p=null,s=null;const R=[];let D=!1,I=null,j=0,F=0,C=0,$=0,N=1,T=null;const O='[data-theme="dark"], .dark, .editora-theme-dark',H=(e,t)=>{const r=a=>{a.key!=="Escape"||!e.isConnected||(a.preventDefault(),a.stopPropagation(),t())};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0)}},Z=()=>{if(typeof document>"u"||document.getElementById("rte-media-dialog-styles"))return;const e=document.createElement("style");e.id="rte-media-dialog-styles",e.textContent=`
|
|
2
2
|
.rte-media-overlay {
|
|
3
3
|
--rte-media-overlay-bg: rgba(15, 23, 36, 0.56);
|
|
4
4
|
--rte-media-bg: #ffffff;
|
|
@@ -376,7 +376,7 @@
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
.media-floating-toolbar.rte-ui-theme-dark,
|
|
379
|
-
${
|
|
379
|
+
${O} .media-floating-toolbar {
|
|
380
380
|
--rte-media-toolbar-bg: #24303f;
|
|
381
381
|
--rte-media-toolbar-border: #4a5a71;
|
|
382
382
|
--rte-media-toolbar-text: #d9e6fb;
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
margin: 0 2px;
|
|
425
425
|
background: var(--rte-media-toolbar-separator);
|
|
426
426
|
}
|
|
427
|
-
`,document.head.appendChild(e)},
|
|
427
|
+
`,document.head.appendChild(e)},K=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;return(t instanceof HTMLElement?t:t?.parentElement)?.closest(".rte-content, .editora-content")||null},J=e=>{if(e)return e;const t=K();if(t)return t;if(T)return T;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},G=e=>{const t=J(e);return t?!!t.closest(O):!1},B=e=>{Z();const t=document.createElement("div");return Y.initDialogOverlay(t),t.className="rte-media-overlay",G(e)&&t.classList.add("rte-ui-theme-dark"),t},_=(e=!1)=>{const t=document.createElement("div");return t.className=e?"rte-media-dialog rte-media-dialog-compact":"rte-media-dialog",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t},W=(e,t)=>{document.querySelectorAll(".rte-media-overlay").forEach(n=>n.remove());const r=window.getSelection();r&&r.rangeCount>0&&(A=r.getRangeAt(0).cloneRange());const a=B(t),i=_();let o="upload",d="",l="",c="",g="";const v=()=>{i.innerHTML=`
|
|
428
428
|
<div class="rte-media-header">
|
|
429
429
|
<h2 class="rte-media-title">Insert ${e==="image"?"Image":"Video"}</h2>
|
|
430
430
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -490,7 +490,7 @@
|
|
|
490
490
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
491
491
|
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d&&o==="url"?"disabled":""}>Insert</button>
|
|
492
492
|
</div>
|
|
493
|
-
`};v(),a.appendChild(i),document.body.appendChild(a);let k=()=>{};const h=()=>{k(),a.parentNode&&a.parentNode.removeChild(a)};k=
|
|
493
|
+
`};v(),a.appendChild(i),document.body.appendChild(a);let k=()=>{};const h=()=>{k(),a.parentNode&&a.parentNode.removeChild(a)};k=H(a,h);const L=()=>{if(!d)return;const n=e==="image"?document.createElement("img"):document.createElement("video");n.src=d,n.setAttribute("data-media-type",e),e==="image"&&g&&(n.alt=g),l&&(n.style.width=`${l}px`,n.setAttribute("width",l)),c&&(n.style.height=`${c}px`,n.setAttribute("height",c)),e==="video"&&(n.controls=!0),!l&&!c?n.style.cssText="max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;":n.style.cssText=`display: block; margin: 1em 0; cursor: pointer; ${l?`width: ${l}px;`:"max-width: 100%;"} ${c?`height: ${c}px;`:"height: auto;"}`,A&&(A.deleteContents(),A.insertNode(n)),h()},y=async n=>{const b=i.querySelector("#upload-progress"),u=i.querySelector("#progress-bar"),x=i.querySelector("#progress-text");if(b&&u&&x){b.style.display="block";let q=0;const f=setInterval(()=>{q+=Math.random()*30,q>90&&(q=90),u.style.width=`${q}%`},200);try{const w=new FileReader;w.onload=()=>{clearInterval(f),u.style.width="100%",x.textContent="Upload complete",setTimeout(()=>{d=w.result,o="url",v(),m()},500)},w.readAsDataURL(n)}catch{clearInterval(f),x.textContent="Upload failed"}}},m=()=>{const n=i.querySelector(".close-btn"),b=i.querySelector(".cancel-btn"),u=i.querySelector("#insert-btn"),x=i.querySelector(".tab-upload"),q=i.querySelector(".tab-url");if(n?.addEventListener("click",h),b?.addEventListener("click",h),u?.addEventListener("click",L),x?.addEventListener("click",()=>{o="upload",v(),m()}),q?.addEventListener("click",()=>{o="url",v(),m()}),o==="upload"){const f=i.querySelector(".dropzone"),w=i.querySelector("#file-input");f?.addEventListener("click",()=>w?.click()),f?.addEventListener("dragover",S=>{S.preventDefault(),f.classList.add("is-dragover")}),f?.addEventListener("dragleave",()=>{f.classList.remove("is-dragover")}),f?.addEventListener("drop",S=>{S.preventDefault(),f.classList.remove("is-dragover");const z=S.dataTransfer?.files[0];z&&y(z)}),w?.addEventListener("change",S=>{const z=S.target.files?.[0];z&&y(z)})}if(o==="url"){const f=i.querySelector("#url-input"),w=i.querySelector("#alt-input"),S=i.querySelector("#width-input"),z=i.querySelector("#height-input");f?.addEventListener("input",()=>{d=f.value,v(),m()}),w?.addEventListener("input",()=>{g=w.value}),S?.addEventListener("input",()=>{l=S.value}),z?.addEventListener("input",()=>{c=z.value})}};m(),a.addEventListener("click",n=>{n.target===a&&h()})},Q=()=>{["nw","ne","sw","se"].forEach(t=>{const r=document.createElement("div");r.className=`media-resize-handle-${t}`,r.style.cssText=`
|
|
494
494
|
position: fixed;
|
|
495
495
|
width: 10px;
|
|
496
496
|
height: 10px;
|
|
@@ -501,21 +501,21 @@
|
|
|
501
501
|
z-index: 10001;
|
|
502
502
|
display: none;
|
|
503
503
|
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
|
|
504
|
-
`,r.setAttribute("data-position",t),document.body.appendChild(r),R.push(r)})},M=()=>{if(!p){R.forEach(r=>r.style.display="none");return}const e=p.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};R.forEach(r=>{const a=r.getAttribute("data-position"),i=t[a];r.style.left=`${i.x}px`,r.style.top=`${i.y}px`,r.style.display="block"})},
|
|
504
|
+
`,r.setAttribute("data-position",t),document.body.appendChild(r),R.push(r)})},M=()=>{if(!p){R.forEach(r=>r.style.display="none");return}const e=p.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};R.forEach(r=>{const a=r.getAttribute("data-position"),i=t[a];r.style.left=`${i.x}px`,r.style.top=`${i.y}px`,r.style.display="block"})},ee=e=>{const t=B(e),r=_(!0);r.innerHTML=`
|
|
505
505
|
<div class="rte-media-header">
|
|
506
506
|
<h2 class="rte-media-title">Edit Alt Text</h2>
|
|
507
507
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
508
508
|
</div>
|
|
509
509
|
<div class="rte-media-body">
|
|
510
510
|
<label class="rte-media-label">Alternative Text (for accessibility)</label>
|
|
511
|
-
<textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${e.alt||""}</textarea>
|
|
511
|
+
<textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${U.escapeHtml(e.alt||"")}</textarea>
|
|
512
512
|
<p class="rte-media-helper">Good alt text is descriptive and concise. It helps users with visual impairments understand your content.</p>
|
|
513
513
|
</div>
|
|
514
514
|
<div class="rte-media-footer">
|
|
515
515
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
516
516
|
<button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
|
|
517
517
|
</div>
|
|
518
|
-
`,t.appendChild(r),document.body.appendChild(t);const a=r.querySelector("#alt-text-input"),i=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),d=r.querySelector(".save-btn");let l=()=>{};const c=()=>{l(),t.parentNode&&t.parentNode.removeChild(t)};l=
|
|
518
|
+
`,t.appendChild(r),document.body.appendChild(t);const a=r.querySelector("#alt-text-input"),i=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),d=r.querySelector(".save-btn");let l=()=>{};const c=()=>{l(),t.parentNode&&t.parentNode.removeChild(t)};l=H(t,c),i.addEventListener("click",c),o.addEventListener("click",c),t.addEventListener("click",g=>{g.target===t&&c()}),d.addEventListener("click",()=>{e.alt=a.value,c()}),a.focus(),a.select()},te=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",a=t?.getAttribute("target")||"_self",i=t?.getAttribute("title")||"",o=B(e),d=_(!0);d.innerHTML=`
|
|
519
519
|
<div class="rte-media-header">
|
|
520
520
|
<h2 class="rte-media-title">${t?"Edit Link":"Add Link"}</h2>
|
|
521
521
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -523,11 +523,11 @@
|
|
|
523
523
|
<div class="rte-media-body">
|
|
524
524
|
<div class="rte-media-field">
|
|
525
525
|
<label class="rte-media-label">URL</label>
|
|
526
|
-
<input id="link-url" type="url" class="rte-media-input" value="${r}" placeholder="https://example.com" />
|
|
526
|
+
<input id="link-url" type="url" class="rte-media-input" value="${U.escapeHtml(r)}" placeholder="https://example.com" />
|
|
527
527
|
</div>
|
|
528
528
|
<div class="rte-media-field">
|
|
529
529
|
<label class="rte-media-label">Title (tooltip)</label>
|
|
530
|
-
<input id="link-title" type="text" class="rte-media-input" value="${i}" placeholder="Optional tooltip text" />
|
|
530
|
+
<input id="link-title" type="text" class="rte-media-input" value="${U.escapeHtml(i)}" placeholder="Optional tooltip text" />
|
|
531
531
|
</div>
|
|
532
532
|
<label class="rte-media-checkbox-label">
|
|
533
533
|
<input id="link-target" type="checkbox" ${a==="_blank"?"checked":""} />
|
|
@@ -541,7 +541,7 @@
|
|
|
541
541
|
<button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
|
|
542
542
|
</div>
|
|
543
543
|
</div>
|
|
544
|
-
`,o.appendChild(d),document.body.appendChild(o);const l=d.querySelector("#link-url"),c=d.querySelector("#link-title"),g=d.querySelector("#link-target"),v=d.querySelector(".close-btn"),k=d.querySelector(".cancel-btn"),h=d.querySelector(".save-btn"),L=d.querySelector(".remove-link-btn");let
|
|
544
|
+
`,o.appendChild(d),document.body.appendChild(o);const l=d.querySelector("#link-url"),c=d.querySelector("#link-title"),g=d.querySelector("#link-target"),v=d.querySelector(".close-btn"),k=d.querySelector(".cancel-btn"),h=d.querySelector(".save-btn"),L=d.querySelector(".remove-link-btn");let y=()=>{};const m=()=>{y(),o.parentNode&&o.parentNode.removeChild(o)};y=H(o,m),v.addEventListener("click",m),k.addEventListener("click",m),o.addEventListener("click",n=>{n.target===o&&m()}),h.addEventListener("click",()=>{const n=l.value.trim();if(n){const b=n.startsWith("http")?n:`https://${n}`;if(t)t.setAttribute("href",b),t.setAttribute("target",g.checked?"_blank":"_self"),g.checked?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel"),c.value.trim()?t.setAttribute("title",c.value.trim()):t.removeAttribute("title");else{const u=document.createElement("a");u.href=b,u.target=g.checked?"_blank":"_self",g.checked&&(u.rel="noopener noreferrer"),c.value.trim()&&(u.title=c.value.trim()),e.replaceWith(u),u.appendChild(e)}m(),s&&p&&P(p)}}),L?.addEventListener("click",()=>{t&&confirm("Remove link from this media?")&&(t.replaceWith(e),m(),s&&p&&P(p))}),l.focus()},re=e=>{const t=B(e),r=_();let a="url",i=e.src;const o=()=>{r.innerHTML=`
|
|
545
545
|
<div class="rte-media-header">
|
|
546
546
|
<h2 class="rte-media-title">Replace Image</h2>
|
|
547
547
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
591
591
|
<button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!i&&a==="url"?"disabled":""}>Replace</button>
|
|
592
592
|
</div>
|
|
593
|
-
`};o(),t.appendChild(r),document.body.appendChild(t);let d=()=>{};const l=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=
|
|
593
|
+
`};o(),t.appendChild(r),document.body.appendChild(t);let d=()=>{};const l=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=H(t,l);const c=()=>{i&&(e.src=i,l())},g=async k=>{const h=r.querySelector("#upload-progress"),L=r.querySelector("#progress-bar"),y=r.querySelector("#progress-text");if(h&&L&&y){h.style.display="block";let m=0;const n=setInterval(()=>{m+=Math.random()*30,m>90&&(m=90),L.style.width=`${m}%`},200);try{const b=new FileReader;b.onload=()=>{clearInterval(n),L.style.width="100%",y.textContent="Upload complete",setTimeout(()=>{i=b.result,a="url",o(),v()},500)},b.readAsDataURL(k)}catch{clearInterval(n),y.textContent="Upload failed"}}},v=()=>{const k=r.querySelector(".close-btn"),h=r.querySelector(".cancel-btn"),L=r.querySelector("#replace-btn"),y=r.querySelector(".tab-upload"),m=r.querySelector(".tab-url");if(k?.addEventListener("click",l),h?.addEventListener("click",l),L?.addEventListener("click",c),y?.addEventListener("click",()=>{a="upload",o(),v()}),m?.addEventListener("click",()=>{a="url",o(),v()}),a==="upload"){const n=r.querySelector(".dropzone"),b=r.querySelector("#file-input");n?.addEventListener("click",()=>b?.click()),n?.addEventListener("dragover",u=>{u.preventDefault(),n.classList.add("is-dragover")}),n?.addEventListener("dragleave",()=>{n.classList.remove("is-dragover")}),n?.addEventListener("drop",u=>{u.preventDefault(),n.classList.remove("is-dragover");const x=u.dataTransfer?.files[0];x&&g(x)}),b?.addEventListener("change",u=>{const x=u.target.files?.[0];x&&g(x)})}if(a==="url"){const n=r.querySelector("#url-input");n?.addEventListener("input",()=>{i=n.value,o(),v()})}};v(),t.addEventListener("click",k=>{k.target===t&&l()})},E=()=>{if(!s||!p)return;const e=s.offsetHeight||40,t=p.offsetTop,r=p.offsetLeft,a=p.offsetWidth,i=t-e-8,o=r+a/2-(s.offsetWidth||120)/2;s.style.top=`${i}px`,s.style.left=`${o}px`,setTimeout(()=>{s&&(s.style.display="flex")},100)},P=e=>{s&&(s._cleanup&&s._cleanup(),s.remove());const t=e.parentElement;if(t){const l=t.style.position;(!l||l==="static")&&(t.style.position="relative",t._originalPosition=l),s=document.createElement("div"),s.className="media-floating-toolbar",G(e)&&s.classList.add("rte-ui-theme-dark"),t.insertBefore(s,t.firstChild),E()}const r=s;if(!r)return;const a=e.tagName==="IMG",i=e.closest("a");r.innerHTML=`
|
|
594
594
|
<button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
|
|
595
595
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
|
|
596
596
|
</button>
|
|
@@ -616,4 +616,4 @@
|
|
|
616
616
|
<button class="media-floating-toolbar-btn btn-remove" title="Remove" type="button">
|
|
617
617
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
618
618
|
</button>
|
|
619
|
-
`,setTimeout(()=>{E()},0);const o=()=>E();let d=e.parentElement;for(;d;)d.addEventListener("scroll",o),d=d.parentElement;window.addEventListener("scroll",o),window.addEventListener("resize",o),r._cleanup=()=>{let l=e.parentElement;for(;l;)l.removeEventListener("scroll",o),l=l.parentElement;window.removeEventListener("scroll",o),window.removeEventListener("resize",o)},r.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",E()}),r.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",E()}),r.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",E()}),r.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&
|
|
619
|
+
`,setTimeout(()=>{E()},0);const o=()=>E();let d=e.parentElement;for(;d;)d.addEventListener("scroll",o),d=d.parentElement;window.addEventListener("scroll",o),window.addEventListener("resize",o),r._cleanup=()=>{let l=e.parentElement;for(;l;)l.removeEventListener("scroll",o),l=l.parentElement;window.removeEventListener("scroll",o),window.removeEventListener("resize",o)},r.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",E()}),r.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",E()}),r.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",E()}),r.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&ee(e)}),r.querySelector(".btn-link")?.addEventListener("click",()=>{te(e)}),r.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&re(e)}),r.querySelector(".btn-resize")?.addEventListener("click",()=>{const l=prompt("Enter width in pixels:",String(e.width||e.offsetWidth));if(l&&!isNaN(parseInt(l))){const c=parseInt(l);e.style.width=`${c}px`,e.setAttribute("width",String(c)),M(),E()}}),r.querySelector(".btn-remove")?.addEventListener("click",()=>{confirm("Remove this media?")&&(e.remove(),s&&(s._cleanup&&s._cleanup(),s.remove(),s=null),p=null,M())}),r._cleanup=()=>{window.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},X=e=>{T=e||null,Q(),document.addEventListener("click",t=>{const r=t.target;if(r.tagName==="IMG"||r.tagName==="VIDEO"){const a=r;let i=!1;if(T?i=T.contains(a):i=!!a.closest('[contenteditable="true"]'),i){t.preventDefault(),t.stopPropagation(),p=a,p.style.display="block",P(a),M();return}}if(!r.closest(".btn-link, .btn-resize, .btn-remove")&&s&&!r.closest("button")){if(s._cleanup&&s._cleanup(),s.remove(),s=null,p&&p.parentElement){const a=p.parentElement;a._originalPosition!==void 0&&(a.style.position=a._originalPosition,delete a._originalPosition)}p=null,M()}}),R.forEach(t=>{t.addEventListener("mousedown",r=>{if(!p)return;r.preventDefault(),r.stopPropagation(),D=!0,I=t.getAttribute("data-position"),j=r.clientX,F=r.clientY;const a=p.getBoundingClientRect();C=a.width,$=a.height,N=C/$,document.body.style.userSelect="none",document.body.style.cursor=`${I}-resize`})}),document.addEventListener("mousemove",t=>{if(!D||!p||!I)return;const r=t.clientX-j,a=t.clientY-F;let i=C,o=$;switch(I){case"se":i=C+r,o=$+a;break;case"sw":i=C-r,o=$+a;break;case"ne":i=C+r,o=$-a;break;case"nw":i=C-r,o=$-a;break}Math.abs(r)>Math.abs(a)?o=i/N:i=o*N,i=Math.max(50,i),o=Math.max(50,o),p.style.width=`${i}px`,p.style.height=`${o}px`,p.setAttribute("width",String(Math.round(i))),p.setAttribute("height",String(Math.round(o))),M(),E()}),document.addEventListener("mouseup",()=>{D&&(D=!1,I=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",M),window.addEventListener("resize",M)};typeof window<"u"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,X());const ae=()=>({name:"image",initialize:e=>{const t=e?.editorElement;X(t)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return W("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return W("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),ie={apiEndpoints:{upload:"/media/upload",library:"/media/library",delete:"/media/library"},maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif","video/mp4","video/webm"],headers:{}};let V={...ie};function oe(e){V={...V,...e}}function ne(){return{...V}}exports.MediaManagerPlugin=ae;exports.getMediaManagerConfig=ne;exports.setMediaManagerConfig=oe;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { e as U } from "./escapeHtml-DyksyvcZ.mjs";
|
|
2
|
+
import { i as Y } from "./dialogHelpers-5d5BuOCW.mjs";
|
|
1
3
|
import "./shared-config.esm.js";
|
|
2
|
-
let A = null, p = null, s = null
|
|
3
|
-
const
|
|
4
|
+
let A = null, p = null, s = null;
|
|
5
|
+
const R = [];
|
|
6
|
+
let D = !1, I = null, j = 0, F = 0, $ = 0, C = 0, N = 1, T = null;
|
|
7
|
+
const O = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
4
8
|
const r = (a) => {
|
|
5
9
|
a.key !== "Escape" || !e.isConnected || (a.preventDefault(), a.stopPropagation(), t());
|
|
6
10
|
};
|
|
7
11
|
return document.addEventListener("keydown", r, !0), () => {
|
|
8
12
|
document.removeEventListener("keydown", r, !0);
|
|
9
13
|
};
|
|
10
|
-
},
|
|
14
|
+
}, Z = () => {
|
|
11
15
|
if (typeof document > "u" || document.getElementById("rte-media-dialog-styles")) return;
|
|
12
16
|
const e = document.createElement("style");
|
|
13
17
|
e.id = "rte-media-dialog-styles", e.textContent = `
|
|
@@ -388,7 +392,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
388
392
|
}
|
|
389
393
|
|
|
390
394
|
.media-floating-toolbar.rte-ui-theme-dark,
|
|
391
|
-
${
|
|
395
|
+
${O} .media-floating-toolbar {
|
|
392
396
|
--rte-media-toolbar-bg: #24303f;
|
|
393
397
|
--rte-media-toolbar-border: #4a5a71;
|
|
394
398
|
--rte-media-toolbar-text: #d9e6fb;
|
|
@@ -437,32 +441,33 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
437
441
|
background: var(--rte-media-toolbar-separator);
|
|
438
442
|
}
|
|
439
443
|
`, document.head.appendChild(e);
|
|
440
|
-
},
|
|
444
|
+
}, K = () => {
|
|
441
445
|
const e = window.getSelection();
|
|
442
446
|
if (!e || e.rangeCount === 0) return null;
|
|
443
447
|
const t = e.anchorNode;
|
|
444
448
|
return (t instanceof HTMLElement ? t : t?.parentElement)?.closest(".rte-content, .editora-content") || null;
|
|
445
|
-
},
|
|
449
|
+
}, J = (e) => {
|
|
446
450
|
if (e) return e;
|
|
447
|
-
const t =
|
|
451
|
+
const t = K();
|
|
448
452
|
if (t) return t;
|
|
449
453
|
if (T) return T;
|
|
450
454
|
const r = document.activeElement;
|
|
451
455
|
return r ? r.closest(".rte-content, .editora-content") || r : null;
|
|
452
456
|
}, G = (e) => {
|
|
453
|
-
const t =
|
|
454
|
-
return t ? !!t.closest(
|
|
455
|
-
},
|
|
456
|
-
|
|
457
|
+
const t = J(e);
|
|
458
|
+
return t ? !!t.closest(O) : !1;
|
|
459
|
+
}, H = (e) => {
|
|
460
|
+
Z();
|
|
457
461
|
const t = document.createElement("div");
|
|
458
|
-
return t.className = "rte-media-overlay", G(e) && t.classList.add("rte-ui-theme-dark"), t;
|
|
459
|
-
},
|
|
462
|
+
return Y(t), t.className = "rte-media-overlay", G(e) && t.classList.add("rte-ui-theme-dark"), t;
|
|
463
|
+
}, _ = (e = !1) => {
|
|
460
464
|
const t = document.createElement("div");
|
|
461
465
|
return t.className = e ? "rte-media-dialog rte-media-dialog-compact" : "rte-media-dialog", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t;
|
|
462
|
-
},
|
|
466
|
+
}, W = (e, t) => {
|
|
467
|
+
document.querySelectorAll(".rte-media-overlay").forEach((n) => n.remove());
|
|
463
468
|
const r = window.getSelection();
|
|
464
469
|
r && r.rangeCount > 0 && (A = r.getRangeAt(0).cloneRange());
|
|
465
|
-
const a =
|
|
470
|
+
const a = H(t), i = _();
|
|
466
471
|
let o = "upload", d = "", l = "", c = "", g = "";
|
|
467
472
|
const v = () => {
|
|
468
473
|
i.innerHTML = `
|
|
@@ -600,7 +605,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
600
605
|
m(), a.addEventListener("click", (n) => {
|
|
601
606
|
n.target === a && h();
|
|
602
607
|
});
|
|
603
|
-
},
|
|
608
|
+
}, Q = () => {
|
|
604
609
|
["nw", "ne", "sw", "se"].forEach((t) => {
|
|
605
610
|
const r = document.createElement("div");
|
|
606
611
|
r.className = `media-resize-handle-${t}`, r.style.cssText = `
|
|
@@ -631,8 +636,8 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
631
636
|
const a = r.getAttribute("data-position"), i = t[a];
|
|
632
637
|
r.style.left = `${i.x}px`, r.style.top = `${i.y}px`, r.style.display = "block";
|
|
633
638
|
});
|
|
634
|
-
},
|
|
635
|
-
const t =
|
|
639
|
+
}, ee = (e) => {
|
|
640
|
+
const t = H(e), r = _(!0);
|
|
636
641
|
r.innerHTML = `
|
|
637
642
|
<div class="rte-media-header">
|
|
638
643
|
<h2 class="rte-media-title">Edit Alt Text</h2>
|
|
@@ -640,7 +645,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
640
645
|
</div>
|
|
641
646
|
<div class="rte-media-body">
|
|
642
647
|
<label class="rte-media-label">Alternative Text (for accessibility)</label>
|
|
643
|
-
<textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${e.alt || ""}</textarea>
|
|
648
|
+
<textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${U(e.alt || "")}</textarea>
|
|
644
649
|
<p class="rte-media-helper">Good alt text is descriptive and concise. It helps users with visual impairments understand your content.</p>
|
|
645
650
|
</div>
|
|
646
651
|
<div class="rte-media-footer">
|
|
@@ -659,8 +664,8 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
659
664
|
}), d.addEventListener("click", () => {
|
|
660
665
|
e.alt = a.value, c();
|
|
661
666
|
}), a.focus(), a.select();
|
|
662
|
-
},
|
|
663
|
-
const t = e.closest("a"), r = t?.getAttribute("href") || "", a = t?.getAttribute("target") || "_self", i = t?.getAttribute("title") || "", o =
|
|
667
|
+
}, te = (e) => {
|
|
668
|
+
const t = e.closest("a"), r = t?.getAttribute("href") || "", a = t?.getAttribute("target") || "_self", i = t?.getAttribute("title") || "", o = H(e), d = _(!0);
|
|
664
669
|
d.innerHTML = `
|
|
665
670
|
<div class="rte-media-header">
|
|
666
671
|
<h2 class="rte-media-title">${t ? "Edit Link" : "Add Link"}</h2>
|
|
@@ -669,11 +674,11 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
669
674
|
<div class="rte-media-body">
|
|
670
675
|
<div class="rte-media-field">
|
|
671
676
|
<label class="rte-media-label">URL</label>
|
|
672
|
-
<input id="link-url" type="url" class="rte-media-input" value="${r}" placeholder="https://example.com" />
|
|
677
|
+
<input id="link-url" type="url" class="rte-media-input" value="${U(r)}" placeholder="https://example.com" />
|
|
673
678
|
</div>
|
|
674
679
|
<div class="rte-media-field">
|
|
675
680
|
<label class="rte-media-label">Title (tooltip)</label>
|
|
676
|
-
<input id="link-title" type="text" class="rte-media-input" value="${i}" placeholder="Optional tooltip text" />
|
|
681
|
+
<input id="link-title" type="text" class="rte-media-input" value="${U(i)}" placeholder="Optional tooltip text" />
|
|
677
682
|
</div>
|
|
678
683
|
<label class="rte-media-checkbox-label">
|
|
679
684
|
<input id="link-target" type="checkbox" ${a === "_blank" ? "checked" : ""} />
|
|
@@ -706,13 +711,13 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
706
711
|
const u = document.createElement("a");
|
|
707
712
|
u.href = b, u.target = g.checked ? "_blank" : "_self", g.checked && (u.rel = "noopener noreferrer"), c.value.trim() && (u.title = c.value.trim()), e.replaceWith(u), u.appendChild(e);
|
|
708
713
|
}
|
|
709
|
-
m(), s && p &&
|
|
714
|
+
m(), s && p && P(p);
|
|
710
715
|
}
|
|
711
716
|
}), L?.addEventListener("click", () => {
|
|
712
|
-
t && confirm("Remove link from this media?") && (t.replaceWith(e), m(), s && p &&
|
|
717
|
+
t && confirm("Remove link from this media?") && (t.replaceWith(e), m(), s && p && P(p));
|
|
713
718
|
}), l.focus();
|
|
714
|
-
},
|
|
715
|
-
const t =
|
|
719
|
+
}, re = (e) => {
|
|
720
|
+
const t = H(e), r = _();
|
|
716
721
|
let a = "url", i = e.src;
|
|
717
722
|
const o = () => {
|
|
718
723
|
r.innerHTML = `
|
|
@@ -831,7 +836,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
831
836
|
s.style.top = `${i}px`, s.style.left = `${o}px`, setTimeout(() => {
|
|
832
837
|
s && (s.style.display = "flex");
|
|
833
838
|
}, 100);
|
|
834
|
-
},
|
|
839
|
+
}, P = (e) => {
|
|
835
840
|
s && (s._cleanup && s._cleanup(), s.remove());
|
|
836
841
|
const t = e.parentElement;
|
|
837
842
|
if (t) {
|
|
@@ -886,11 +891,11 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
886
891
|
}), r.querySelector(".btn-align-right")?.addEventListener("click", () => {
|
|
887
892
|
e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "0", E();
|
|
888
893
|
}), r.querySelector(".btn-alt")?.addEventListener("click", () => {
|
|
889
|
-
e.tagName === "IMG" &&
|
|
894
|
+
e.tagName === "IMG" && ee(e);
|
|
890
895
|
}), r.querySelector(".btn-link")?.addEventListener("click", () => {
|
|
891
|
-
|
|
896
|
+
te(e);
|
|
892
897
|
}), r.querySelector(".btn-replace")?.addEventListener("click", () => {
|
|
893
|
-
e.tagName === "IMG" &&
|
|
898
|
+
e.tagName === "IMG" && re(e);
|
|
894
899
|
}), r.querySelector(".btn-resize")?.addEventListener("click", () => {
|
|
895
900
|
const l = prompt("Enter width in pixels:", String(e.width || e.offsetWidth));
|
|
896
901
|
if (l && !isNaN(parseInt(l))) {
|
|
@@ -902,14 +907,14 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
902
907
|
}), r._cleanup = () => {
|
|
903
908
|
window.removeEventListener("scroll", E), window.removeEventListener("resize", E);
|
|
904
909
|
};
|
|
905
|
-
},
|
|
906
|
-
T = e || null,
|
|
910
|
+
}, X = (e) => {
|
|
911
|
+
T = e || null, Q(), document.addEventListener("click", (t) => {
|
|
907
912
|
const r = t.target;
|
|
908
913
|
if (r.tagName === "IMG" || r.tagName === "VIDEO") {
|
|
909
914
|
const a = r;
|
|
910
915
|
let i = !1;
|
|
911
916
|
if (T ? i = T.contains(a) : i = !!a.closest('[contenteditable="true"]'), i) {
|
|
912
|
-
t.preventDefault(), t.stopPropagation(), p = a, p.style.display = "block",
|
|
917
|
+
t.preventDefault(), t.stopPropagation(), p = a, p.style.display = "block", P(a), q();
|
|
913
918
|
return;
|
|
914
919
|
}
|
|
915
920
|
}
|
|
@@ -923,13 +928,13 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
923
928
|
}), R.forEach((t) => {
|
|
924
929
|
t.addEventListener("mousedown", (r) => {
|
|
925
930
|
if (!p) return;
|
|
926
|
-
r.preventDefault(), r.stopPropagation(), D = !0, I = t.getAttribute("data-position"),
|
|
931
|
+
r.preventDefault(), r.stopPropagation(), D = !0, I = t.getAttribute("data-position"), j = r.clientX, F = r.clientY;
|
|
927
932
|
const a = p.getBoundingClientRect();
|
|
928
933
|
$ = a.width, C = a.height, N = $ / C, document.body.style.userSelect = "none", document.body.style.cursor = `${I}-resize`;
|
|
929
934
|
});
|
|
930
935
|
}), document.addEventListener("mousemove", (t) => {
|
|
931
936
|
if (!D || !p || !I) return;
|
|
932
|
-
const r = t.clientX -
|
|
937
|
+
const r = t.clientX - j, a = t.clientY - F;
|
|
933
938
|
let i = $, o = C;
|
|
934
939
|
switch (I) {
|
|
935
940
|
case "se":
|
|
@@ -950,12 +955,12 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
|
|
|
950
955
|
D && (D = !1, I = null, document.body.style.userSelect = "", document.body.style.cursor = "");
|
|
951
956
|
}), window.addEventListener("scroll", q), window.addEventListener("resize", q);
|
|
952
957
|
};
|
|
953
|
-
typeof window < "u" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0,
|
|
954
|
-
const
|
|
958
|
+
typeof window < "u" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, X());
|
|
959
|
+
const le = () => ({
|
|
955
960
|
name: "image",
|
|
956
961
|
initialize: (e) => {
|
|
957
962
|
const t = e?.editorElement;
|
|
958
|
-
|
|
963
|
+
X(t);
|
|
959
964
|
},
|
|
960
965
|
toolbar: [
|
|
961
966
|
{
|
|
@@ -972,17 +977,17 @@ const ae = () => ({
|
|
|
972
977
|
commands: {
|
|
973
978
|
insertImage: (e, t) => {
|
|
974
979
|
const r = t?.contentElement instanceof HTMLElement ? t.contentElement : void 0;
|
|
975
|
-
return
|
|
980
|
+
return W("image", r), !0;
|
|
976
981
|
},
|
|
977
982
|
insertVideo: (e, t) => {
|
|
978
983
|
const r = t?.contentElement instanceof HTMLElement ? t.contentElement : void 0;
|
|
979
|
-
return
|
|
984
|
+
return W("video", r), !0;
|
|
980
985
|
}
|
|
981
986
|
},
|
|
982
987
|
keymap: {
|
|
983
988
|
"Mod-Shift-i": "insertImage"
|
|
984
989
|
}
|
|
985
|
-
}),
|
|
990
|
+
}), ae = {
|
|
986
991
|
apiEndpoints: {
|
|
987
992
|
upload: "/media/upload",
|
|
988
993
|
library: "/media/library",
|
|
@@ -1003,15 +1008,15 @@ const ae = () => ({
|
|
|
1003
1008
|
// 'X-API-Key': 'YOUR_API_KEY'
|
|
1004
1009
|
}
|
|
1005
1010
|
};
|
|
1006
|
-
let
|
|
1007
|
-
function
|
|
1008
|
-
|
|
1011
|
+
let V = { ...ae };
|
|
1012
|
+
function de(e) {
|
|
1013
|
+
V = { ...V, ...e };
|
|
1009
1014
|
}
|
|
1010
|
-
function
|
|
1011
|
-
return { ...
|
|
1015
|
+
function se() {
|
|
1016
|
+
return { ...V };
|
|
1012
1017
|
}
|
|
1013
1018
|
export {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1019
|
+
le as MediaManagerPlugin,
|
|
1020
|
+
se as getMediaManagerConfig,
|
|
1021
|
+
de as setMediaManagerConfig
|
|
1017
1022
|
};
|
package/dist/mentions.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=".rte-content, .editora-content",Y="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",w='.rte-mention[data-mention="true"]',b=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=new WeakMap,R=new WeakMap;let q=!1,N=!1,T=null,v=0;function Q(e,n){if(n===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,n,e.innerHTML)}catch{}}function U(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function h(e,n){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(n),e.focus({preventScroll:!0}))}function S(e,n){return e.startContainer===n.startContainer&&e.startOffset===n.startOffset&&e.endContainer===n.endContainer&&e.endOffset===n.endOffset}function E(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const o=n.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function C(e){Array.from(e.querySelectorAll(w)).forEach(o=>{o.setAttribute("data-mention","true"),o.setAttribute("contenteditable","false"),o.setAttribute("spellcheck","false"),o.setAttribute("draggable","false"),o.classList.add("rte-mention")})}function _(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(e){return e.closest(Y)||e}function M(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function ne(e){const n=ee(e);if(M(n))return!0;const o=n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return M(o)?!0:M(document.documentElement)||M(document.body)}function W(e,n){e.classList.remove("rte-mention-theme-dark"),ne(n)&&e.classList.add("rte-mention-theme-dark")}function te(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const t=e.editorElement;if(t.matches(g))return t;const r=t.querySelector(g);if(r instanceof HTMLElement)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const t=n.getRangeAt(0).startContainer,i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(g);if(i)return i}const o=document.activeElement;if(o){if(o.matches(g))return o;const t=o.closest(g);if(t)return t}return document.querySelector(g)}function x(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function re(e,n){return n?n.split(".").filter(Boolean).reduce((o,t)=>{if(!(!D(o)&&!Array.isArray(o)))return o[t]},e):e}function oe(e){return e?/\s|[([{"'`]/.test(e):!0}function ie(e){if(!e.collapsed)return null;const n=e.startContainer,o=e.startOffset;if(n.nodeType===Node.TEXT_NODE){const t=n;return{node:t,textBefore:t.data.slice(0,o),caretOffset:o}}if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(o>0){const r=t.childNodes[o-1];if(r&&r.nodeType===Node.TEXT_NODE){const i=r;return{node:i,textBefore:i.data,caretOffset:i.length}}}}return null}function ae(e,n,o){let t=-1,r="";if(n.forEach(a=>{const l=e.lastIndexOf(a);l>t&&(t=l,r=a)}),t<0||!oe(e[t-1]))return null;const i=e.slice(t+1);return/\s/.test(i)||i.length>o?null:{trigger:r,query:i,startOffset:t}}function le(e,n){const o=n.cloneRange();o.collapse(!1);const t=o.getClientRects();if(t.length>0)return t[t.length-1];const r=document.createElement("span");r.textContent="",r.style.position="relative",o.insertNode(r);const i=r.getBoundingClientRect();return r.remove(),e.normalize(),i}function se(e,n){if(e.panel&&e.list)return;const o=document.createElement("div");o.className="rte-mention-panel",o.style.display="none";const t=document.createElement("div");t.className="rte-mention-list",o.appendChild(t),document.body.appendChild(o),W(o,e.editor),e.panel=o,e.list=t,o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",r=>{const i=r.target;if(!i)return;const a=i.closest(".rte-mention-item");if(!a)return;const l=Number(a.getAttribute("data-index"));Number.isFinite(l)&&K(e,n,l)})}function m(e){e.panel&&(e.debounceHandle!==null&&(window.clearTimeout(e.debounceHandle),e.debounceHandle=null),e.abortController&&(e.abortController.abort(),e.abortController=null),e.panel.style.display="none",e.panel.classList.remove("show"),e.isOpen=!1,e.loading=!1,e.items=[],e.activeIndex=0,e.query="",e.replaceRange=null)}function $(e,n){if(!e.panel)return;W(e.panel,e.editor);const o=le(e.editor,n),t=e.panel;t.style.display="block",t.classList.add("show"),t.style.left="0px",t.style.top="0px";const r=t.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;let l=Math.max(8,Math.min(o.left,i-r.width-8)),s=o.bottom+8;s+r.height>a-8&&(s=Math.max(8,o.top-r.height-8)),t.style.position="fixed",t.style.left=`${l}px`,t.style.top=`${s}px`}function ce(e,n){if(!n)return x(e);const o=e.toLowerCase(),t=n.toLowerCase(),r=o.indexOf(t);if(r<0)return x(e);const i=x(e.slice(0,r)),a=x(e.slice(r,r+n.length)),l=x(e.slice(r+n.length));return`${i}<mark>${a}</mark>${l}`}function B(e,n){if(!e.list)return;const o=e.list;if(o.innerHTML="",e.loading){const t=document.createElement("div");t.className="rte-mention-empty",t.textContent=n.loadingText,o.appendChild(t);return}if(e.items.length===0){const t=document.createElement("div");t.className="rte-mention-empty",t.textContent=e.query.length>0?n.noResultsText:n.emptyStateText,o.appendChild(t);return}e.items.forEach((t,r)=>{const i=document.createElement("button");i.type="button",i.className="rte-mention-item",r===e.activeIndex&&i.classList.add("active"),i.setAttribute("data-index",String(r));const a=n.itemRenderer?n.itemRenderer(t,e.query):`<span class="rte-mention-item-label">${ce(t.label,e.query)}</span>${t.meta?`<span class="rte-mention-item-meta">${x(t.meta)}</span>`:""}`;i.innerHTML=a,o.appendChild(i)})}function G(e,n){const o=new Set,t=[];return e.forEach(r=>{const i=(r.id||"").trim();!i||o.has(i)||(o.add(i),t.push({id:i,label:r.label||i,value:r.value,meta:r.meta}))}),t.slice(0,n)}function ue(e,n){if(e.buildRequest){const c=e.buildRequest(n);return{url:c.url,init:c.init||{}}}const o=(e.method||"GET").toUpperCase(),t=typeof e.headers=="function"?e.headers(n):e.headers||{},r=e.queryParam||"q",i=e.triggerParam||"trigger",a=e.limitParam||"limit",l=e.staticParams||{},s={method:o,headers:{...t},credentials:e.credentials,mode:e.mode,cache:e.cache,signal:n.signal},f=new URL(e.url,window.location.origin);if(o==="GET"||o==="HEAD"){const c=new URLSearchParams(f.search);Object.entries(l).forEach(([d,p])=>c.set(d,String(p))),c.set(r,n.query),c.set(i,n.trigger),c.set(a,String(n.limit)),f.search=c.toString()}else{const c=typeof e.body=="function"?e.body(n):e.body,d={[r]:n.query,[i]:n.trigger,[a]:n.limit,...l},p=c??d;if(D(p)){s.body=JSON.stringify(p);const y=s.headers;!y["Content-Type"]&&!y["content-type"]&&(y["Content-Type"]="application/json")}else s.body=p}return{url:f.toString(),init:s}}async function de(e,n,o,t){const r=n.api;if(!r)return[];e.abortController&&e.abortController.abort();const i=new AbortController;e.abortController=i;const a={query:o,trigger:t,limit:n.maxSuggestions,signal:i.signal},l=Math.max(0,r.timeoutMs??1e4);let s=null;l>0&&(s=window.setTimeout(()=>i.abort(),l));try{const{url:f,init:c}=ue(r,a),d=await fetch(f,{...c,signal:i.signal});if(!d.ok)throw new Error(`Mention API request failed: ${d.status}`);const y=(r.responseType||"json")==="text"?await d.text():await d.json();let O=[];if(r.transformResponse)O=r.transformResponse(y,a)||[];else{const P=re(y,r.responsePath);O=(Array.isArray(P)?P:Array.isArray(y)?y:[]).map((u,J)=>{if(r.mapItem)return r.mapItem(u,J);if(!D(u))return null;const I=String(u.id??u.value??u.key??"").trim();if(!I)return null;const Z=String(u.label??u.name??I).trim();return{id:I,label:Z,value:u.value?String(u.value):void 0,meta:u.meta?String(u.meta):void 0}}).filter(u=>!!u)}return G(O,n.maxSuggestions)}catch(f){return f?.name!=="AbortError"&&r.onError?.(f,a),[]}finally{s!==null&&window.clearTimeout(s),e.abortController===i&&(e.abortController=null)}}async function fe(e,n,o,t){const r=++e.requestId;let i=[];if(n.search){const a=await n.search(o,t);i=Array.isArray(a)?a:[]}else if(n.api)i=await de(e,n,o,t);else{const a=o.toLowerCase();i=n.items.filter(l=>a?l.label.toLowerCase().includes(a)||l.id.toLowerCase().includes(a):!0)}return r!==e.requestId?[]:G(i,n.maxSuggestions)}function me(e,n,o){const t=e.editor;if(C(t),!window.getSelection())return!1;const i=t.innerHTML;let a=e.replaceRange?e.replaceRange.cloneRange():E(t);if(!a||!t.contains(a.commonAncestorContainer)&&(a=E(t),!a))return!1;const l=A(t,a.cloneRange(),"after");S(l,a)||(h(t,l),a=l),a.deleteContents();const s=document.createElement("span");s.className="rte-mention",s.setAttribute("data-mention","true"),s.setAttribute("data-mention-id",o.id),s.setAttribute("contenteditable","false"),s.textContent=o.value||`${e.trigger}${o.label}`,a.insertNode(s);let f=s,c=1;if(n.insertSpaceAfterMention){const p=document.createTextNode(" ");s.after(p),f=p,c=1}const d=document.createRange();return d.setStart(f,c),d.collapse(!0),h(t,d),m(e),C(t),U(t),Q(t,i),!0}function K(e,n,o){if(o<0||o>=e.items.length)return;const t=e.items[o];me(e,n,t)}function pe(e){return e.startContainer!==e.endContainer||e.startContainer.nodeType!==Node.ELEMENT_NODE||e.endOffset-e.startOffset!==1?null:e.startContainer.childNodes[e.startOffset]||null}function ge(e,n){const o=pe(e);return!(o instanceof HTMLElement)||!o.matches(w)||!n.contains(o)?null:o}function V(e,n){const o=ge(e,n);if(o)return o;const r=_(e.startContainer)?.closest(w);if(r&&n.contains(r))return r;const a=_(e.endContainer)?.closest(w);return a&&n.contains(a)?a:null}function A(e,n,o="after"){const t=V(n,e);if(!t)return n;const r=document.createRange();return o==="before"?r.setStartBefore(t):r.setStartAfter(t),r.collapse(!0),r}function j(e,n,o="after"){const t=document.createRange();o==="before"?t.setStartBefore(n):t.setStartAfter(n),t.collapse(!0),h(e,t)}function he(e,n,o){if(!e.collapsed)return null;const t=e.startContainer,r=e.startOffset;let i=null;if(t.nodeType===Node.TEXT_NODE){const a=t;n==="backward"&&r===0?i=a.previousSibling:n==="forward"&&r===a.length&&(i=a.nextSibling)}else if(t.nodeType===Node.ELEMENT_NODE){const a=t;n==="backward"&&r>0?i=a.childNodes[r-1]||null:n==="forward"&&r<a.childNodes.length&&(i=a.childNodes[r]||null)}return!(i instanceof HTMLElement)||!i.matches(w)||!o.contains(i)?null:i}function z(e,n){const o=E(e);if(!o)return!1;const t=he(o,n,e);if(!t)return!1;const r=t.parentNode;if(!r)return!1;const i=e.innerHTML,a=Array.prototype.indexOf.call(r.childNodes,t);t.remove();const l=document.createRange();return l.setStart(r,Math.max(0,a)),l.collapse(!0),h(e,l),U(e),Q(e,i),!0}function X(e,n,o,t,r,i){if(se(e,n),e.query=t,e.trigger=r,e.replaceRange=i.cloneRange(),e.loading=!!(n.api&&!n.search),e.debounceHandle!==null&&(window.clearTimeout(e.debounceHandle),e.debounceHandle=null),!e.panel)return;e.isOpen||(e.panel.style.display="block",e.panel.classList.add("show"),e.isOpen=!0),B(e,n),$(e,o);const a=()=>{e.debounceHandle=null,fe(e,n,t,r).then(s=>{e.loading=!1,e.items=s,e.activeIndex=0,e.panel&&(B(e,n),$(e,o))})},l=n.api&&!n.search?Math.max(0,n.api.debounceMs??180):0;l>0?e.debounceHandle=window.setTimeout(a,l):a()}function ye(e,n){const o=e.editor;C(o);let t=E(o);if(!t||!t.collapsed){m(e);return}const r=A(o,t.cloneRange(),"after");if(!S(r,t)){h(o,r),t=r,m(e);return}const i=ie(t);if(!i){m(e);return}const a=ae(i.textBefore,n.triggerChars,n.maxQueryLength);if(!a){m(e);return}if(a.query.length<n.minChars){m(e);return}const l=t.cloneRange();l.setStart(i.node,a.startOffset),l.setEnd(i.node,i.caretOffset),X(e,n,t,a.query,a.trigger,l)}function F(e,n){if(e.items.length===0)return;const o=e.items.length;if(e.activeIndex=((e.activeIndex+n)%o+o)%o,!e.list)return;const t=Array.from(e.list.querySelectorAll(".rte-mention-item"));t.forEach((i,a)=>i.classList.toggle("active",a===e.activeIndex)),t[e.activeIndex]?.scrollIntoView({block:"nearest"})}function be(e){return{editor:e,panel:null,list:null,replaceRange:null,items:[],activeIndex:0,query:"",trigger:"@",loading:!1,isOpen:!1,requestId:0,debounceHandle:null,abortController:null}}function Ee(e){const n=L.get(e);n&&(n.panel?.parentNode&&n.panel.parentNode.removeChild(n.panel),L.delete(e))}function H(e,n,o){if(R.has(e))return;C(e);const t={beforeInput:r=>{C(e);const i=E(e);if(!i)return;const a=V(i,e);if(!a)return;const l=r.inputType||"";if(l.startsWith("insert")){if(r.preventDefault(),j(e,a,"after"),l==="insertParagraph"||l==="insertLineBreak"){const s=l==="insertLineBreak"?"insertLineBreak":"insertParagraph";document.execCommand(s,!1);return}if(l==="insertText"||l==="insertCompositionText"){const s=r.data||"";if(!s)return;document.execCommand("insertText",!1,s)}}},input:()=>{ye(n,o)},keydown:r=>{if(n.isOpen){if(r.key==="ArrowDown"){r.preventDefault(),F(n,1);return}if(r.key==="ArrowUp"){r.preventDefault(),F(n,-1);return}if(r.key==="Enter"||r.key==="Tab"){r.preventDefault(),K(n,o,n.activeIndex);return}if(r.key==="Escape"){r.preventDefault(),m(n);return}}const i=E(e);if(i){const a=A(e,i.cloneRange(),"after");if(!S(a,i)){if(r.key==="Enter"){r.preventDefault(),h(e,a),document.execCommand("insertParagraph",!1);return}r.key.length===1&&!r.metaKey&&!r.ctrlKey&&!r.altKey&&h(e,a)}}if(r.key==="Backspace"&&z(e,"backward")){r.preventDefault();return}if(r.key==="Delete"&&z(e,"forward")){r.preventDefault();return}},click:r=>{const i=r.target;if(!i)return;const l=(i.nodeType===Node.ELEMENT_NODE?i:i.parentElement)?.closest(w);!l||!e.contains(l)||(r.preventDefault(),r.stopPropagation(),j(e,l,"after"),m(n))},blur:()=>{window.setTimeout(()=>{const r=document.activeElement;n.panel&&r&&n.panel.contains(r)||m(n)},0)},mousedown:r=>{if(!n.isOpen||!n.panel)return;const i=r.target;i&&!n.panel.contains(i)&&!e.contains(i)&&m(n)}};e.addEventListener("beforeinput",t.beforeInput),e.addEventListener("input",t.input),e.addEventListener("keydown",t.keydown),e.addEventListener("click",t.click),e.addEventListener("blur",t.blur),document.addEventListener("mousedown",t.mousedown,!0),R.set(e,t)}function xe(e){const n=R.get(e);n&&(e.removeEventListener("beforeinput",n.beforeInput),e.removeEventListener("input",n.input),e.removeEventListener("keydown",n.keydown),e.removeEventListener("click",n.click),e.removeEventListener("blur",n.blur),document.removeEventListener("mousedown",n.mousedown,!0),R.delete(e))}function we(){if(q||typeof document>"u")return;q=!0;const e=document.createElement("style");e.id="rte-mention-plugin-styles",e.textContent=`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=".rte-content, .editora-content",Y="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",w='.rte-mention[data-mention="true"]',b=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=new WeakMap,N=new WeakMap;let q=!1,R=!1,T=null,v=0;function Q(e,n){if(n===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,n,e.innerHTML)}catch{}}function U(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function h(e,n){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(n),e.focus({preventScroll:!0}))}function S(e,n){return e.startContainer===n.startContainer&&e.startOffset===n.startOffset&&e.endContainer===n.endContainer&&e.endOffset===n.endOffset}function E(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const o=n.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function C(e){Array.from(e.querySelectorAll(w)).forEach(o=>{o.setAttribute("data-mention","true"),o.setAttribute("contenteditable","false"),o.setAttribute("spellcheck","false"),o.setAttribute("draggable","false"),o.classList.add("rte-mention")})}function _(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(e){return e.closest(Y)||e}function M(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function ne(e){const n=ee(e);if(M(n))return!0;const o=n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return M(o)?!0:M(document.documentElement)||M(document.body)}function W(e,n){e.classList.remove("rte-mention-theme-dark"),ne(n)&&e.classList.add("rte-mention-theme-dark")}function te(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const t=e.editorElement;if(t.matches(g))return t;const r=t.querySelector(g);if(r instanceof HTMLElement)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const t=n.getRangeAt(0).startContainer,i=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(g);if(i)return i}const o=document.activeElement;if(o){if(o.matches(g))return o;const t=o.closest(g);if(t)return t}return document.querySelector(g)}function x(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function re(e,n){return n?n.split(".").filter(Boolean).reduce((o,t)=>{if(!(!D(o)&&!Array.isArray(o)))return o[t]},e):e}function oe(e){return e?/\s|[([{"'`]/.test(e):!0}function ie(e){if(!e.collapsed)return null;const n=e.startContainer,o=e.startOffset;if(n.nodeType===Node.TEXT_NODE){const t=n;return{node:t,textBefore:t.data.slice(0,o),caretOffset:o}}if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(o>0){const r=t.childNodes[o-1];if(r&&r.nodeType===Node.TEXT_NODE){const i=r;return{node:i,textBefore:i.data,caretOffset:i.length}}}}return null}function ae(e,n,o){let t=-1,r="";if(n.forEach(a=>{const l=e.lastIndexOf(a);l>t&&(t=l,r=a)}),t<0||!oe(e[t-1]))return null;const i=e.slice(t+1);return/\s/.test(i)||i.length>o?null:{trigger:r,query:i,startOffset:t}}function le(e,n){const o=n.cloneRange();o.collapse(!1);const t=o.getClientRects();if(t.length>0)return t[t.length-1];const r=document.createElement("span");r.textContent="",r.style.position="relative",o.insertNode(r);const i=r.getBoundingClientRect();return r.remove(),e.normalize(),i}function se(e,n){if(e.panel&&e.list)return;const o=document.createElement("div");o.className="rte-mention-panel",o.style.display="none";const t=document.createElement("div");t.className="rte-mention-list",o.appendChild(t),document.body.appendChild(o),W(o,e.editor),e.panel=o,e.list=t,o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",r=>{const i=r.target;if(!i)return;const a=i.closest(".rte-mention-item");if(!a)return;const l=Number(a.getAttribute("data-index"));Number.isFinite(l)&&K(e,n,l)})}function m(e){e.panel&&(e.debounceHandle!==null&&(window.clearTimeout(e.debounceHandle),e.debounceHandle=null),e.abortController&&(e.abortController.abort(),e.abortController=null),e.panel.style.display="none",e.panel.classList.remove("show"),e.isOpen=!1,e.loading=!1,e.items=[],e.activeIndex=0,e.query="",e.replaceRange=null)}function $(e,n){if(!e.panel)return;W(e.panel,e.editor);const o=le(e.editor,n),t=e.panel;t.style.display="block",t.classList.add("show"),t.style.left="0px",t.style.top="0px";const r=t.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,l=Math.max(8,Math.min(o.left,i-r.width-8));let s=o.bottom+8;s+r.height>a-8&&(s=Math.max(8,o.top-r.height-8)),t.style.position="fixed",t.style.left=`${l}px`,t.style.top=`${s}px`}function ce(e,n){if(!n)return x(e);const o=e.toLowerCase(),t=n.toLowerCase(),r=o.indexOf(t);if(r<0)return x(e);const i=x(e.slice(0,r)),a=x(e.slice(r,r+n.length)),l=x(e.slice(r+n.length));return`${i}<mark>${a}</mark>${l}`}function B(e,n){if(!e.list)return;const o=e.list;if(o.innerHTML="",e.loading){const t=document.createElement("div");t.className="rte-mention-empty",t.textContent=n.loadingText,o.appendChild(t);return}if(e.items.length===0){const t=document.createElement("div");t.className="rte-mention-empty",t.textContent=e.query.length>0?n.noResultsText:n.emptyStateText,o.appendChild(t);return}e.items.forEach((t,r)=>{const i=document.createElement("button");i.type="button",i.className="rte-mention-item",r===e.activeIndex&&i.classList.add("active"),i.setAttribute("data-index",String(r));const a=n.itemRenderer?n.itemRenderer(t,e.query):`<span class="rte-mention-item-label">${ce(t.label,e.query)}</span>${t.meta?`<span class="rte-mention-item-meta">${x(t.meta)}</span>`:""}`;i.innerHTML=a,o.appendChild(i)})}function G(e,n){const o=new Set,t=[];return e.forEach(r=>{const i=(r.id||"").trim();!i||o.has(i)||(o.add(i),t.push({id:i,label:r.label||i,value:r.value,meta:r.meta}))}),t.slice(0,n)}function ue(e,n){if(e.buildRequest){const c=e.buildRequest(n);return{url:c.url,init:c.init||{}}}const o=(e.method||"GET").toUpperCase(),t=typeof e.headers=="function"?e.headers(n):e.headers||{},r=e.queryParam||"q",i=e.triggerParam||"trigger",a=e.limitParam||"limit",l=e.staticParams||{},s={method:o,headers:{...t},credentials:e.credentials,mode:e.mode,cache:e.cache,signal:n.signal},f=new URL(e.url,window.location.origin);if(o==="GET"||o==="HEAD"){const c=new URLSearchParams(f.search);Object.entries(l).forEach(([d,p])=>c.set(d,String(p))),c.set(r,n.query),c.set(i,n.trigger),c.set(a,String(n.limit)),f.search=c.toString()}else{const c=typeof e.body=="function"?e.body(n):e.body,d={[r]:n.query,[i]:n.trigger,[a]:n.limit,...l},p=c??d;if(D(p)){s.body=JSON.stringify(p);const y=s.headers;!y["Content-Type"]&&!y["content-type"]&&(y["Content-Type"]="application/json")}else s.body=p}return{url:f.toString(),init:s}}async function de(e,n,o,t){const r=n.api;if(!r)return[];e.abortController&&e.abortController.abort();const i=new AbortController;e.abortController=i;const a={query:o,trigger:t,limit:n.maxSuggestions,signal:i.signal},l=Math.max(0,r.timeoutMs??1e4);let s=null;l>0&&(s=window.setTimeout(()=>i.abort(),l));try{const{url:f,init:c}=ue(r,a),d=await fetch(f,{...c,signal:i.signal});if(!d.ok)throw new Error(`Mention API request failed: ${d.status}`);const y=(r.responseType||"json")==="text"?await d.text():await d.json();let O=[];if(r.transformResponse)O=r.transformResponse(y,a)||[];else{const P=re(y,r.responsePath);O=(Array.isArray(P)?P:Array.isArray(y)?y:[]).map((u,J)=>{if(r.mapItem)return r.mapItem(u,J);if(!D(u))return null;const I=String(u.id??u.value??u.key??"").trim();if(!I)return null;const Z=String(u.label??u.name??I).trim();return{id:I,label:Z,value:u.value?String(u.value):void 0,meta:u.meta?String(u.meta):void 0}}).filter(u=>!!u)}return G(O,n.maxSuggestions)}catch(f){return f?.name!=="AbortError"&&r.onError?.(f,a),[]}finally{s!==null&&window.clearTimeout(s),e.abortController===i&&(e.abortController=null)}}async function fe(e,n,o,t){const r=++e.requestId;let i=[];if(n.search){const a=await n.search(o,t);i=Array.isArray(a)?a:[]}else if(n.api)i=await de(e,n,o,t);else{const a=o.toLowerCase();i=n.items.filter(l=>a?l.label.toLowerCase().includes(a)||l.id.toLowerCase().includes(a):!0)}return r!==e.requestId?[]:G(i,n.maxSuggestions)}function me(e,n,o){const t=e.editor;if(C(t),!window.getSelection())return!1;const i=t.innerHTML;let a=e.replaceRange?e.replaceRange.cloneRange():E(t);if(!a||!t.contains(a.commonAncestorContainer)&&(a=E(t),!a))return!1;const l=A(t,a.cloneRange(),"after");S(l,a)||(h(t,l),a=l),a.deleteContents();const s=document.createElement("span");s.className="rte-mention",s.setAttribute("data-mention","true"),s.setAttribute("data-mention-id",o.id),s.setAttribute("contenteditable","false"),s.textContent=o.value||`${e.trigger}${o.label}`,a.insertNode(s);let f=s,c=1;if(n.insertSpaceAfterMention){const p=document.createTextNode(" ");s.after(p),f=p,c=1}const d=document.createRange();return d.setStart(f,c),d.collapse(!0),h(t,d),m(e),C(t),U(t),Q(t,i),!0}function K(e,n,o){if(o<0||o>=e.items.length)return;const t=e.items[o];me(e,n,t)}function pe(e){return e.startContainer!==e.endContainer||e.startContainer.nodeType!==Node.ELEMENT_NODE||e.endOffset-e.startOffset!==1?null:e.startContainer.childNodes[e.startOffset]||null}function ge(e,n){const o=pe(e);return!(o instanceof HTMLElement)||!o.matches(w)||!n.contains(o)?null:o}function V(e,n){const o=ge(e,n);if(o)return o;const r=_(e.startContainer)?.closest(w);if(r&&n.contains(r))return r;const a=_(e.endContainer)?.closest(w);return a&&n.contains(a)?a:null}function A(e,n,o="after"){const t=V(n,e);if(!t)return n;const r=document.createRange();return o==="before"?r.setStartBefore(t):r.setStartAfter(t),r.collapse(!0),r}function j(e,n,o="after"){const t=document.createRange();o==="before"?t.setStartBefore(n):t.setStartAfter(n),t.collapse(!0),h(e,t)}function he(e,n,o){if(!e.collapsed)return null;const t=e.startContainer,r=e.startOffset;let i=null;if(t.nodeType===Node.TEXT_NODE){const a=t;n==="backward"&&r===0?i=a.previousSibling:n==="forward"&&r===a.length&&(i=a.nextSibling)}else if(t.nodeType===Node.ELEMENT_NODE){const a=t;n==="backward"&&r>0?i=a.childNodes[r-1]||null:n==="forward"&&r<a.childNodes.length&&(i=a.childNodes[r]||null)}return!(i instanceof HTMLElement)||!i.matches(w)||!o.contains(i)?null:i}function z(e,n){const o=E(e);if(!o)return!1;const t=he(o,n,e);if(!t)return!1;const r=t.parentNode;if(!r)return!1;const i=e.innerHTML,a=Array.prototype.indexOf.call(r.childNodes,t);t.remove();const l=document.createRange();return l.setStart(r,Math.max(0,a)),l.collapse(!0),h(e,l),U(e),Q(e,i),!0}function X(e,n,o,t,r,i){if(se(e,n),e.query=t,e.trigger=r,e.replaceRange=i.cloneRange(),e.loading=!!(n.api&&!n.search),e.debounceHandle!==null&&(window.clearTimeout(e.debounceHandle),e.debounceHandle=null),!e.panel)return;e.isOpen||(e.panel.style.display="block",e.panel.classList.add("show"),e.isOpen=!0),B(e,n),$(e,o);const a=()=>{e.debounceHandle=null,fe(e,n,t,r).then(s=>{e.loading=!1,e.items=s,e.activeIndex=0,e.panel&&(B(e,n),$(e,o))})},l=n.api&&!n.search?Math.max(0,n.api.debounceMs??180):0;l>0?e.debounceHandle=window.setTimeout(a,l):a()}function ye(e,n){const o=e.editor;C(o);let t=E(o);if(!t||!t.collapsed){m(e);return}const r=A(o,t.cloneRange(),"after");if(!S(r,t)){h(o,r),t=r,m(e);return}const i=ie(t);if(!i){m(e);return}const a=ae(i.textBefore,n.triggerChars,n.maxQueryLength);if(!a){m(e);return}if(a.query.length<n.minChars){m(e);return}if(e.dismissedNode===i.node&&e.dismissedOffset===a.startOffset)return;e.dismissedNode=null,e.dismissedOffset=-1;const l=t.cloneRange();l.setStart(i.node,a.startOffset),l.setEnd(i.node,i.caretOffset),X(e,n,t,a.query,a.trigger,l)}function F(e,n){if(e.items.length===0)return;const o=e.items.length;if(e.activeIndex=((e.activeIndex+n)%o+o)%o,!e.list)return;const t=Array.from(e.list.querySelectorAll(".rte-mention-item"));t.forEach((i,a)=>i.classList.toggle("active",a===e.activeIndex)),t[e.activeIndex]?.scrollIntoView({block:"nearest"})}function be(e){return{editor:e,panel:null,list:null,replaceRange:null,items:[],activeIndex:0,query:"",trigger:"@",loading:!1,isOpen:!1,requestId:0,debounceHandle:null,abortController:null,dismissedNode:null,dismissedOffset:-1}}function Ee(e){const n=L.get(e);n&&(n.panel?.parentNode&&n.panel.parentNode.removeChild(n.panel),L.delete(e))}function H(e,n,o){if(N.has(e))return;C(e);const t={beforeInput:r=>{C(e);const i=E(e);if(!i)return;const a=V(i,e);if(!a)return;const l=r.inputType||"";if(l.startsWith("insert")){if(r.preventDefault(),j(e,a,"after"),l==="insertParagraph"||l==="insertLineBreak"){const s=l==="insertLineBreak"?"insertLineBreak":"insertParagraph";document.execCommand(s,!1);return}if(l==="insertText"||l==="insertCompositionText"){const s=r.data||"";if(!s)return;document.execCommand("insertText",!1,s)}}},input:()=>{ye(n,o)},keydown:r=>{if(n.isOpen){if(r.key==="ArrowDown"){r.preventDefault(),F(n,1);return}if(r.key==="ArrowUp"){r.preventDefault(),F(n,-1);return}if(r.key==="Enter"||r.key==="Tab"){r.preventDefault(),K(n,o,n.activeIndex);return}if(r.key==="Escape"){r.preventDefault(),n.replaceRange&&(n.dismissedNode=n.replaceRange.startContainer,n.dismissedOffset=n.replaceRange.startOffset),m(n);return}}const i=E(e);if(i){const a=A(e,i.cloneRange(),"after");if(!S(a,i)){if(r.key==="Enter"){r.preventDefault(),h(e,a),document.execCommand("insertParagraph",!1);return}r.key.length===1&&!r.metaKey&&!r.ctrlKey&&!r.altKey&&h(e,a)}}if(r.key==="Backspace"&&z(e,"backward")){r.preventDefault();return}if(r.key==="Delete"&&z(e,"forward")){r.preventDefault();return}},click:r=>{const i=r.target;if(!i)return;const l=(i.nodeType===Node.ELEMENT_NODE?i:i.parentElement)?.closest(w);!l||!e.contains(l)||(r.preventDefault(),r.stopPropagation(),j(e,l,"after"),m(n))},blur:()=>{window.setTimeout(()=>{const r=document.activeElement;n.panel&&r&&n.panel.contains(r)||m(n)},0)},mousedown:r=>{if(!n.isOpen||!n.panel)return;const i=r.target;i&&!n.panel.contains(i)&&!e.contains(i)&&m(n)}};e.addEventListener("beforeinput",t.beforeInput),e.addEventListener("input",t.input),e.addEventListener("keydown",t.keydown),e.addEventListener("click",t.click),e.addEventListener("blur",t.blur),document.addEventListener("mousedown",t.mousedown,!0),N.set(e,t)}function xe(e){const n=N.get(e);n&&(e.removeEventListener("beforeinput",n.beforeInput),e.removeEventListener("input",n.input),e.removeEventListener("keydown",n.keydown),e.removeEventListener("click",n.click),e.removeEventListener("blur",n.blur),document.removeEventListener("mousedown",n.mousedown,!0),N.delete(e))}function we(){if(q||typeof document>"u")return;q=!0;const e=document.createElement("style");e.id="rte-mention-plugin-styles",e.textContent=`
|
|
2
2
|
.rte-mention {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
padding: 0 6px;
|
|
@@ -102,4 +102,4 @@
|
|
|
102
102
|
.rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
|
|
103
103
|
color: #9ca3af;
|
|
104
104
|
}
|
|
105
|
-
`,document.head.appendChild(e)}function Te(e){const n=(e.triggerChars||["@"]).filter(o=>typeof o=="string"&&o.length>0).map(o=>o[0]);return{triggerChars:n.length>0?n:["@"],minChars:Math.max(0,e.minChars??1),maxQueryLength:Math.max(1,e.maxQueryLength??32),maxSuggestions:Math.max(1,e.maxSuggestions??8),items:e.items||[{id:"john.doe",label:"John Doe",meta:"john@acme.com"},{id:"sarah.lee",label:"Sarah Lee",meta:"sarah@acme.com"},{id:"alex.chen",label:"Alex Chen",meta:"alex@acme.com"}],api:e.api,search:e.search,itemRenderer:e.itemRenderer,emptyStateText:e.emptyStateText||"Type to search mentions",noResultsText:e.noResultsText||"No matching mentions",loadingText:e.loadingText||"Loading...",insertSpaceAfterMention:e.insertSpaceAfterMention!==!1}}function k(e){const n=L.get(e);if(n)return n;const o=be(e);return L.set(e,o),o}function Ce(e){
|
|
105
|
+
`,document.head.appendChild(e)}function Te(e){const n=(e.triggerChars||["@"]).filter(o=>typeof o=="string"&&o.length>0).map(o=>o[0]);return{triggerChars:n.length>0?n:["@"],minChars:Math.max(0,e.minChars??1),maxQueryLength:Math.max(1,e.maxQueryLength??32),maxSuggestions:Math.max(1,e.maxSuggestions??8),items:e.items||[{id:"john.doe",label:"John Doe",meta:"john@acme.com"},{id:"sarah.lee",label:"Sarah Lee",meta:"sarah@acme.com"},{id:"alex.chen",label:"Alex Chen",meta:"alex@acme.com"}],api:e.api,search:e.search,itemRenderer:e.itemRenderer,emptyStateText:e.emptyStateText||"Type to search mentions",noResultsText:e.noResultsText||"No matching mentions",loadingText:e.loadingText||"Loading...",insertSpaceAfterMention:e.insertSpaceAfterMention!==!1}}function k(e){const n=L.get(e);if(n)return n;const o=be(e);return L.set(e,o),o}function Ce(e){R||(R=!0,T=n=>{const o=n.target;if(!(o instanceof Node))return;const r=(o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest(g)||null;if(!r)return;const i=k(r);H(r,i,e)},document.addEventListener("focusin",T,!0))}function ve(){!R||!T||(document.removeEventListener("focusin",T,!0),R=!1,T=null)}const Me=(e={})=>{we();const n=Te(e);return{name:"mentions",toolbar:[{label:"Mention",command:"insertMention",icon:'<svg width="24" height="24" focusable="false"><path d="M12.1 4a7.9 7.9 0 0 0-8 8c0 4.4 3.6 8 8 8 1.6 0 3-.4 4.4-1.3.4-.3.5-.9.2-1.3a1 1 0 0 0-1.3-.3 6 6 0 0 1-3.3.9 6 6 0 1 1 6-6v1.6c0 .8-.5 1.4-1.2 1.4-.8 0-1.2-.6-1.2-1.4V12c0-2-1.6-3.5-3.7-3.5s-3.8 1.6-3.8 3.6c0 2 1.7 3.6 3.8 3.6 1 0 1.9-.4 2.6-1 .5 1 1.4 1.6 2.5 1.6 1.8 0 3.2-1.5 3.2-3.4V12A7.9 7.9 0 0 0 12 4Zm0 9.7c-1 0-1.8-.8-1.8-1.7s.8-1.7 1.8-1.7c1 0 1.7.8 1.7 1.7s-.8 1.7-1.7 1.7Z"></path></svg>'}],commands:{insertMention:(o,t)=>{const r=te(t);if(!r)return!1;const i=k(r);H(r,i,n);let a=E(r);a||(a=document.createRange(),a.selectNodeContents(r),a.collapse(!1),h(r,a));const l=A(r,a.cloneRange(),"after");S(l,a)||(h(r,l),a=l),i.query="";const s=a.cloneRange();return i.trigger=n.triggerChars[0],X(i,n,a,"",i.trigger,s),!0}},init:()=>{v+=1,Ce(n),Array.from(document.querySelectorAll(g)).forEach(t=>{const r=k(t);H(t,r,n)})},destroy:()=>{v=Math.max(0,v-1),Array.from(document.querySelectorAll(g)).forEach(t=>{m(k(t)),xe(t),Ee(t)}),v===0&&ve()}}};exports.MentionPlugin=Me;
|
package/dist/mentions.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const g = ".rte-content, .editora-content", Y = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", w = '.rte-mention[data-mention="true"]', b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', M = /* @__PURE__ */ new WeakMap(),
|
|
2
|
-
let P = !1,
|
|
1
|
+
const g = ".rte-content, .editora-content", Y = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", w = '.rte-mention[data-mention="true"]', b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', M = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
let P = !1, R = !1, T = null, v = 0;
|
|
3
3
|
function Q(e, n) {
|
|
4
4
|
if (n === e.innerHTML) return;
|
|
5
5
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
@@ -159,8 +159,8 @@ function $(e, n) {
|
|
|
159
159
|
W(e.panel, e.editor);
|
|
160
160
|
const o = le(e.editor, n), t = e.panel;
|
|
161
161
|
t.style.display = "block", t.classList.add("show"), t.style.left = "0px", t.style.top = "0px";
|
|
162
|
-
const r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
|
|
163
|
-
let
|
|
162
|
+
const r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(o.left, i - r.width - 8));
|
|
163
|
+
let s = o.bottom + 8;
|
|
164
164
|
s + r.height > a - 8 && (s = Math.max(8, o.top - r.height - 8)), t.style.position = "fixed", t.style.left = `${l}px`, t.style.top = `${s}px`;
|
|
165
165
|
}
|
|
166
166
|
function ce(e, n) {
|
|
@@ -411,6 +411,9 @@ function ye(e, n) {
|
|
|
411
411
|
m(e);
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
|
+
if (e.dismissedNode === i.node && e.dismissedOffset === a.startOffset)
|
|
415
|
+
return;
|
|
416
|
+
e.dismissedNode = null, e.dismissedOffset = -1;
|
|
414
417
|
const l = t.cloneRange();
|
|
415
418
|
l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset), X(e, n, t, a.query, a.trigger, l);
|
|
416
419
|
}
|
|
@@ -435,7 +438,9 @@ function be(e) {
|
|
|
435
438
|
isOpen: !1,
|
|
436
439
|
requestId: 0,
|
|
437
440
|
debounceHandle: null,
|
|
438
|
-
abortController: null
|
|
441
|
+
abortController: null,
|
|
442
|
+
dismissedNode: null,
|
|
443
|
+
dismissedOffset: -1
|
|
439
444
|
};
|
|
440
445
|
}
|
|
441
446
|
function Ee(e) {
|
|
@@ -443,7 +448,7 @@ function Ee(e) {
|
|
|
443
448
|
n && (n.panel?.parentNode && n.panel.parentNode.removeChild(n.panel), M.delete(e));
|
|
444
449
|
}
|
|
445
450
|
function H(e, n, o) {
|
|
446
|
-
if (
|
|
451
|
+
if (N.has(e)) return;
|
|
447
452
|
C(e);
|
|
448
453
|
const t = {
|
|
449
454
|
beforeInput: (r) => {
|
|
@@ -484,7 +489,7 @@ function H(e, n, o) {
|
|
|
484
489
|
return;
|
|
485
490
|
}
|
|
486
491
|
if (r.key === "Escape") {
|
|
487
|
-
r.preventDefault(), m(n);
|
|
492
|
+
r.preventDefault(), n.replaceRange && (n.dismissedNode = n.replaceRange.startContainer, n.dismissedOffset = n.replaceRange.startOffset), m(n);
|
|
488
493
|
return;
|
|
489
494
|
}
|
|
490
495
|
}
|
|
@@ -526,11 +531,11 @@ function H(e, n, o) {
|
|
|
526
531
|
i && !n.panel.contains(i) && !e.contains(i) && m(n);
|
|
527
532
|
}
|
|
528
533
|
};
|
|
529
|
-
e.addEventListener("beforeinput", t.beforeInput), e.addEventListener("input", t.input), e.addEventListener("keydown", t.keydown), e.addEventListener("click", t.click), e.addEventListener("blur", t.blur), document.addEventListener("mousedown", t.mousedown, !0),
|
|
534
|
+
e.addEventListener("beforeinput", t.beforeInput), e.addEventListener("input", t.input), e.addEventListener("keydown", t.keydown), e.addEventListener("click", t.click), e.addEventListener("blur", t.blur), document.addEventListener("mousedown", t.mousedown, !0), N.set(e, t);
|
|
530
535
|
}
|
|
531
536
|
function xe(e) {
|
|
532
|
-
const n =
|
|
533
|
-
n && (e.removeEventListener("beforeinput", n.beforeInput), e.removeEventListener("input", n.input), e.removeEventListener("keydown", n.keydown), e.removeEventListener("click", n.click), e.removeEventListener("blur", n.blur), document.removeEventListener("mousedown", n.mousedown, !0),
|
|
537
|
+
const n = N.get(e);
|
|
538
|
+
n && (e.removeEventListener("beforeinput", n.beforeInput), e.removeEventListener("input", n.input), e.removeEventListener("keydown", n.keydown), e.removeEventListener("click", n.click), e.removeEventListener("blur", n.blur), document.removeEventListener("mousedown", n.mousedown, !0), N.delete(e));
|
|
534
539
|
}
|
|
535
540
|
function we() {
|
|
536
541
|
if (P || typeof document > "u") return;
|
|
@@ -670,7 +675,7 @@ function L(e) {
|
|
|
670
675
|
return M.set(e, o), o;
|
|
671
676
|
}
|
|
672
677
|
function Ce(e) {
|
|
673
|
-
|
|
678
|
+
R || (R = !0, T = (n) => {
|
|
674
679
|
const o = n.target;
|
|
675
680
|
if (!(o instanceof Node)) return;
|
|
676
681
|
const r = (o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement)?.closest(g) || null;
|
|
@@ -680,7 +685,7 @@ function Ce(e) {
|
|
|
680
685
|
}, document.addEventListener("focusin", T, !0));
|
|
681
686
|
}
|
|
682
687
|
function ve() {
|
|
683
|
-
!
|
|
688
|
+
!R || !T || (document.removeEventListener("focusin", T, !0), R = !1, T = null);
|
|
684
689
|
}
|
|
685
690
|
const Le = (e = {}) => {
|
|
686
691
|
we();
|