@editora/plugins 1.0.9 → 1.0.11

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.
@@ -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,s=null,l=null,R=[],D=!1,I=null,V=0,j=0,C=0,$=0,N=1,T=null;const W='[data-theme="dark"], .dark, .editora-theme-dark',B=(e,t)=>{const r=i=>{i.key!=="Escape"||!e.isConnected||(i.preventDefault(),i.stopPropagation(),t())};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0)}},X=()=>{if(typeof document>"u"||document.getElementById("rte-media-dialog-styles"))return;const e=document.createElement("style");e.id="rte-media-dialog-styles",e.textContent=`
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,R=[],D=!1,I=null,V=0,j=0,C=0,$=0,N=1,T=null;const W='[data-theme="dark"], .dark, .editora-theme-dark',B=(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)}},X=()=>{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;
@@ -424,7 +424,7 @@
424
424
  margin: 0 2px;
425
425
  background: var(--rte-media-toolbar-separator);
426
426
  }
427
- `,document.head.appendChild(e)},Y=()=>{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},Z=e=>{if(e)return e;const t=Y();if(t)return t;if(T)return T;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},O=e=>{const t=Z(e);return t?!!t.closest(W):!1},_=e=>{X();const t=document.createElement("div");return t.className="rte-media-overlay",O(e)&&t.classList.add("rte-ui-theme-dark"),t},H=(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},F=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(A=r.getRangeAt(0).cloneRange());const i=_(t),a=H();let o="upload",d="",c="",p="",g="";const v=()=>{a.innerHTML=`
427
+ `,document.head.appendChild(e)},Y=()=>{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},Z=e=>{if(e)return e;const t=Y();if(t)return t;if(T)return T;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},O=e=>{const t=Z(e);return t?!!t.closest(W):!1},_=e=>{X();const t=document.createElement("div");return t.className="rte-media-overlay",O(e)&&t.classList.add("rte-ui-theme-dark"),t},H=(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},F=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(A=r.getRangeAt(0).cloneRange());const a=_(t),i=H();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>
@@ -467,11 +467,11 @@
467
467
  <div class="rte-media-grid">
468
468
  <div class="rte-media-field">
469
469
  <label class="rte-media-label">Width (px)</label>
470
- <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${c}">
470
+ <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${l}">
471
471
  </div>
472
472
  <div class="rte-media-field">
473
473
  <label class="rte-media-label">Height (px)</label>
474
- <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${p}">
474
+ <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${c}">
475
475
  </div>
476
476
  </div>
477
477
  ${d?`
@@ -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(),i.appendChild(a),document.body.appendChild(i);let k=()=>{};const h=()=>{k(),i.parentNode&&i.parentNode.removeChild(i)};k=B(i,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),c&&(n.style.width=`${c}px`,n.setAttribute("width",c)),p&&(n.style.height=`${p}px`,n.setAttribute("height",p)),e==="video"&&(n.controls=!0),!c&&!p?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; ${c?`width: ${c}px;`:"max-width: 100%;"} ${p?`height: ${p}px;`:"height: auto;"}`,A&&(A.deleteContents(),A.insertNode(n)),h()},x=async n=>{const b=a.querySelector("#upload-progress"),u=a.querySelector("#progress-bar"),y=a.querySelector("#progress-text");if(b&&u&&y){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%",y.textContent="Upload complete",setTimeout(()=>{d=w.result,o="url",v(),m()},500)},w.readAsDataURL(n)}catch{clearInterval(f),y.textContent="Upload failed"}}},m=()=>{const n=a.querySelector(".close-btn"),b=a.querySelector(".cancel-btn"),u=a.querySelector("#insert-btn"),y=a.querySelector(".tab-upload"),q=a.querySelector(".tab-url");if(n?.addEventListener("click",h),b?.addEventListener("click",h),u?.addEventListener("click",L),y?.addEventListener("click",()=>{o="upload",v(),m()}),q?.addEventListener("click",()=>{o="url",v(),m()}),o==="upload"){const f=a.querySelector(".dropzone"),w=a.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&&x(z)}),w?.addEventListener("change",S=>{const z=S.target.files?.[0];z&&x(z)})}if(o==="url"){const f=a.querySelector("#url-input"),w=a.querySelector("#alt-input"),S=a.querySelector("#width-input"),z=a.querySelector("#height-input");f?.addEventListener("input",()=>{d=f.value,v(),m()}),w?.addEventListener("input",()=>{g=w.value}),S?.addEventListener("input",()=>{c=S.value}),z?.addEventListener("input",()=>{p=z.value})}};m(),i.addEventListener("click",n=>{n.target===i&&h()})},K=()=>{["nw","ne","sw","se"].forEach(t=>{const r=document.createElement("div");r.className=`media-resize-handle-${t}`,r.style.cssText=`
493
+ `};v(),a.appendChild(i),document.body.appendChild(a);let k=()=>{};const h=()=>{k(),a.parentNode&&a.parentNode.removeChild(a)};k=B(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()},x=async n=>{const b=i.querySelector("#upload-progress"),u=i.querySelector("#progress-bar"),y=i.querySelector("#progress-text");if(b&&u&&y){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%",y.textContent="Upload complete",setTimeout(()=>{d=w.result,o="url",v(),m()},500)},w.readAsDataURL(n)}catch{clearInterval(f),y.textContent="Upload failed"}}},m=()=>{const n=i.querySelector(".close-btn"),b=i.querySelector(".cancel-btn"),u=i.querySelector("#insert-btn"),y=i.querySelector(".tab-upload"),q=i.querySelector(".tab-url");if(n?.addEventListener("click",h),b?.addEventListener("click",h),u?.addEventListener("click",L),y?.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&&x(z)}),w?.addEventListener("change",S=>{const z=S.target.files?.[0];z&&x(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()})},K=()=>{["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,7 +501,7 @@
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(!s){R.forEach(r=>r.style.display="none");return}const e=s.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 i=r.getAttribute("data-position"),a=t[i];r.style.left=`${a.x}px`,r.style.top=`${a.y}px`,r.style.display="block"})},J=e=>{const t=_(e),r=H(!0);r.innerHTML=`
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"})},J=e=>{const t=_(e),r=H(!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>
@@ -515,7 +515,7 @@
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 i=r.querySelector("#alt-text-input"),a=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),d=r.querySelector(".save-btn");let c=()=>{};const p=()=>{c(),t.parentNode&&t.parentNode.removeChild(t)};c=B(t,p),a.addEventListener("click",p),o.addEventListener("click",p),t.addEventListener("click",g=>{g.target===t&&p()}),d.addEventListener("click",()=>{e.alt=i.value,p()}),i.focus(),i.select()},Q=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",i=t?.getAttribute("target")||"_self",a=t?.getAttribute("title")||"",o=_(e),d=H(!0);d.innerHTML=`
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=B(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()},Q=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",a=t?.getAttribute("target")||"_self",i=t?.getAttribute("title")||"",o=_(e),d=H(!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>
@@ -527,10 +527,10 @@
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="${a}" placeholder="Optional tooltip text" />
530
+ <input id="link-title" type="text" class="rte-media-input" value="${i}" placeholder="Optional tooltip text" />
531
531
  </div>
532
532
  <label class="rte-media-checkbox-label">
533
- <input id="link-target" type="checkbox" ${i==="_blank"?"checked":""} />
533
+ <input id="link-target" type="checkbox" ${a==="_blank"?"checked":""} />
534
534
  Open in new window/tab
535
535
  </label>
536
536
  </div>
@@ -541,19 +541,19 @@
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 c=d.querySelector("#link-url"),p=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 x=()=>{};const m=()=>{x(),o.parentNode&&o.parentNode.removeChild(o)};x=B(o,m),v.addEventListener("click",m),k.addEventListener("click",m),o.addEventListener("click",n=>{n.target===o&&m()}),h.addEventListener("click",()=>{const n=c.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"),p.value.trim()?t.setAttribute("title",p.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"),p.value.trim()&&(u.title=p.value.trim()),e.replaceWith(u),u.appendChild(e)}m(),l&&s&&U(s)}}),L?.addEventListener("click",()=>{t&&confirm("Remove link from this media?")&&(t.replaceWith(e),m(),l&&s&&U(s))}),c.focus()},ee=e=>{const t=_(e),r=H();let i="url",a=e.src;const o=()=>{r.innerHTML=`
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 x=()=>{};const m=()=>{x(),o.parentNode&&o.parentNode.removeChild(o)};x=B(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&&U(p)}}),L?.addEventListener("click",()=>{t&&confirm("Remove link from this media?")&&(t.replaceWith(e),m(),s&&p&&U(p))}),l.focus()},ee=e=>{const t=_(e),r=H();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>
548
548
  </div>
549
549
 
550
550
  <div class="rte-media-tabs">
551
- <button class="tab-upload rte-media-tab ${i==="upload"?"active":""}" type="button">Upload</button>
552
- <button class="tab-url rte-media-tab ${i==="url"?"active":""}" type="button">URL</button>
551
+ <button class="tab-upload rte-media-tab ${a==="upload"?"active":""}" type="button">Upload</button>
552
+ <button class="tab-url rte-media-tab ${a==="url"?"active":""}" type="button">URL</button>
553
553
  </div>
554
554
 
555
555
  <div class="rte-media-body">
556
- ${i==="upload"?`
556
+ ${a==="upload"?`
557
557
  <div id="upload-section">
558
558
  <div class="dropzone rte-media-dropzone">
559
559
  <div class="rte-media-dropzone-icon">📁</div>
@@ -572,13 +572,13 @@
572
572
  <div id="url-section">
573
573
  <div class="rte-media-field">
574
574
  <label class="rte-media-label">Image URL</label>
575
- <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${a}">
575
+ <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${i}">
576
576
  </div>
577
- ${a?`
577
+ ${i?`
578
578
  <div class="rte-media-field">
579
579
  <label class="rte-media-label">Preview</label>
580
580
  <div class="rte-media-preview">
581
- <img src="${a}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
581
+ <img src="${i}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
582
582
  </div>
583
583
  </div>
584
584
  `:""}
@@ -588,9 +588,9 @@
588
588
 
589
589
  <div class="rte-media-footer">
590
590
  <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
591
- <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!a&&i==="url"?"disabled":""}>Replace</button>
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 c=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=B(t,c);const p=()=>{a&&(e.src=a,c())},g=async k=>{const h=r.querySelector("#upload-progress"),L=r.querySelector("#progress-bar"),x=r.querySelector("#progress-text");if(h&&L&&x){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%",x.textContent="Upload complete",setTimeout(()=>{a=b.result,i="url",o(),v()},500)},b.readAsDataURL(k)}catch{clearInterval(n),x.textContent="Upload failed"}}},v=()=>{const k=r.querySelector(".close-btn"),h=r.querySelector(".cancel-btn"),L=r.querySelector("#replace-btn"),x=r.querySelector(".tab-upload"),m=r.querySelector(".tab-url");if(k?.addEventListener("click",c),h?.addEventListener("click",c),L?.addEventListener("click",p),x?.addEventListener("click",()=>{i="upload",o(),v()}),m?.addEventListener("click",()=>{i="url",o(),v()}),i==="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 y=u.dataTransfer?.files[0];y&&g(y)}),b?.addEventListener("change",u=>{const y=u.target.files?.[0];y&&g(y)})}if(i==="url"){const n=r.querySelector("#url-input");n?.addEventListener("input",()=>{a=n.value,o(),v()})}};v(),t.addEventListener("click",k=>{k.target===t&&c()})},E=()=>{if(!l||!s)return;const e=l.offsetHeight||40,t=s.offsetTop,r=s.offsetLeft,i=s.offsetWidth,a=t-e-8,o=r+i/2-(l.offsetWidth||120)/2;l.style.top=`${a}px`,l.style.left=`${o}px`,setTimeout(()=>{l&&(l.style.display="flex")},100)},U=e=>{l&&(l._cleanup&&l._cleanup(),l.remove());const t=e.parentElement;if(t){const d=t.style.position;(!d||d==="static")&&(t.style.position="relative",t._originalPosition=d),l=document.createElement("div"),l.className="media-floating-toolbar",O(e)&&l.classList.add("rte-ui-theme-dark"),t.insertBefore(l,t.firstChild),E()}const r=e.tagName==="IMG",i=e.closest("a");l.innerHTML=`
593
+ `};o(),t.appendChild(r),document.body.appendChild(t);let d=()=>{};const l=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=B(t,l);const c=()=>{i&&(e.src=i,l())},g=async k=>{const h=r.querySelector("#upload-progress"),L=r.querySelector("#progress-bar"),x=r.querySelector("#progress-text");if(h&&L&&x){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%",x.textContent="Upload complete",setTimeout(()=>{i=b.result,a="url",o(),v()},500)},b.readAsDataURL(k)}catch{clearInterval(n),x.textContent="Upload failed"}}},v=()=>{const k=r.querySelector(".close-btn"),h=r.querySelector(".cancel-btn"),L=r.querySelector("#replace-btn"),x=r.querySelector(".tab-upload"),m=r.querySelector(".tab-url");if(k?.addEventListener("click",l),h?.addEventListener("click",l),L?.addEventListener("click",c),x?.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 y=u.dataTransfer?.files[0];y&&g(y)}),b?.addEventListener("change",u=>{const y=u.target.files?.[0];y&&g(y)})}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)},U=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",O(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>
@@ -601,14 +601,14 @@
601
601
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="21" y1="10" x2="7" 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="21" y1="18" x2="7" y2="18"></line></svg>
602
602
  </button>
603
603
  <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
604
- ${r?`
604
+ ${a?`
605
605
  <button class="media-floating-toolbar-btn btn-alt" title="Edit Alt Text" type="button">
606
606
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
607
607
  </button>`:""}
608
608
  <button class="media-floating-toolbar-btn btn-link" title="${i?"Edit/Remove Link":"Add Link"}" type="button">
609
609
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
610
610
  </button>
611
- ${r?`
611
+ ${a?`
612
612
  <button class="media-floating-toolbar-btn btn-replace" title="Replace Image" type="button">
613
613
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
614
614
  </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 a=()=>E();let o=s.parentElement;for(;o;)o.addEventListener("scroll",a),o=o.parentElement;window.addEventListener("scroll",a),window.addEventListener("resize",a),l._cleanup=()=>{let d=s?.parentElement;for(;d;)d.removeEventListener("scroll",a),d=d.parentElement;window.removeEventListener("scroll",a),window.removeEventListener("resize",a)},l.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",E()}),l.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",E()}),l.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",E()}),l.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&J(e)}),l.querySelector(".btn-link")?.addEventListener("click",()=>{Q(e)}),l.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&ee(e)}),l.querySelector(".btn-resize")?.addEventListener("click",()=>{const d=prompt("Enter width in pixels:",String(e.width||e.offsetWidth));if(d&&!isNaN(parseInt(d))){const c=parseInt(d);e.style.width=`${c}px`,e.setAttribute("width",String(c)),M(),E()}}),l.querySelector(".btn-remove")?.addEventListener("click",()=>{confirm("Remove this media?")&&(e.remove(),l&&(l._cleanup&&l._cleanup(),l.remove(),l=null),s=null,M())}),l._cleanup=()=>{window.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},G=e=>{T=e||null,K(),document.addEventListener("click",t=>{const r=t.target;if(r.tagName==="IMG"||r.tagName==="VIDEO"){const i=r;let a=!1;if(T?a=T.contains(i):a=!!i.closest('[contenteditable="true"]'),a){t.preventDefault(),t.stopPropagation(),s=i,s.style.display="block",U(i),M();return}}if(!r.closest(".btn-link, .btn-resize, .btn-remove")&&l&&!r.closest("button")){if(l._cleanup&&l._cleanup(),l.remove(),l=null,s&&s.parentElement){const i=s.parentElement;i._originalPosition!==void 0&&(i.style.position=i._originalPosition,delete i._originalPosition)}s=null,M()}}),R.forEach(t=>{t.addEventListener("mousedown",r=>{if(!s)return;r.preventDefault(),r.stopPropagation(),D=!0,I=t.getAttribute("data-position"),V=r.clientX,j=r.clientY;const i=s.getBoundingClientRect();C=i.width,$=i.height,N=C/$,document.body.style.userSelect="none",document.body.style.cursor=`${I}-resize`})}),document.addEventListener("mousemove",t=>{if(!D||!s||!I)return;const r=t.clientX-V,i=t.clientY-j;let a=C,o=$;switch(I){case"se":a=C+r,o=$+i;break;case"sw":a=C-r,o=$+i;break;case"ne":a=C+r,o=$-i;break;case"nw":a=C-r,o=$-i;break}Math.abs(r)>Math.abs(i)?o=a/N:a=o*N,a=Math.max(50,a),o=Math.max(50,o),s.style.width=`${a}px`,s.style.height=`${o}px`,s.setAttribute("width",String(Math.round(a))),s.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,G());const te=()=>({name:"image",initialize:e=>{const t=e?.editorElement;G(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 F("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return F("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),re={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 P={...re};function ae(e){P={...P,...e}}function ie(){return{...P}}exports.MediaManagerPlugin=te;exports.getMediaManagerConfig=ie;exports.setMediaManagerConfig=ae;
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"&&J(e)}),r.querySelector(".btn-link")?.addEventListener("click",()=>{Q(e)}),r.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&ee(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)}},G=e=>{T=e||null,K(),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",U(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"),V=r.clientX,j=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-V,a=t.clientY-j;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,G());const te=()=>({name:"image",initialize:e=>{const t=e?.editorElement;G(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 F("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return F("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),re={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 P={...re};function ae(e){P={...P,...e}}function ie(){return{...P}}exports.MediaManagerPlugin=te;exports.getMediaManagerConfig=ie;exports.setMediaManagerConfig=ae;