@editora/core 1.0.23 → 1.0.24

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.
Files changed (64) hide show
  1. package/dist/{A11yCheckerPlugin.native-qW_njhLY.mjs → A11yCheckerPlugin.native-BBCsR5Ur.mjs} +7 -5
  2. package/dist/{AnchorPlugin.native-Drmxhy98.mjs → AnchorPlugin.native-Dk9R26cF.mjs} +20 -19
  3. package/dist/{ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs → ApprovalWorkflowPlugin.native-AeJsehXM.mjs} +56 -55
  4. package/dist/{BackgroundColorPlugin.native-H3XyYD7_.mjs → BackgroundColorPlugin.native-DCAd94kp.mjs} +103 -98
  5. package/dist/{BlocksLibraryPlugin.native-CownM6Rk.mjs → BlocksLibraryPlugin.native-D9OPcnQV.mjs} +42 -43
  6. package/dist/{CitationsPlugin.native-C_7wWQ-k.mjs → CitationsPlugin.native-BFChgCSV.mjs} +51 -51
  7. package/dist/{CodePlugin.native-CAHk9ecG.mjs → CodePlugin.native-BRBEIqY7.mjs} +167 -113
  8. package/dist/{CodePlugin.native-DZgIez08.mjs → CodePlugin.native-CPfKDrkr.mjs} +1383 -1094
  9. package/dist/{CodeSamplePlugin.native-svbAFWh_.mjs → CodeSamplePlugin.native-Bai8bgl3.mjs} +5 -5
  10. package/dist/{CommentsPlugin.native-DncTHiEe.mjs → CommentsPlugin.native-DHCDUm9f.mjs} +161 -141
  11. package/dist/{ConditionalContentPlugin.native-Bf7XgRSW.mjs → ConditionalContentPlugin.native-B3R6xcqn.mjs} +3 -3
  12. package/dist/{ContentRulesPlugin.native-vPx5nC73.mjs → ContentRulesPlugin.native-BISqhQKJ.mjs} +52 -52
  13. package/dist/{DataBindingPlugin.native-B7lpI_0c.mjs → DataBindingPlugin.native-DbaDeXNp.mjs} +37 -37
  14. package/dist/{DocumentManagerPlugin.native-B8K-Oqom.mjs → DocumentManagerPlugin.native-tZqIa9o5.mjs} +21 -20
  15. package/dist/{EmbedIframePlugin.native-BfZ_HGlV.mjs → EmbedIframePlugin.native-qHMf1Jtg.mjs} +7 -7
  16. package/dist/{EmojisPlugin.native-D92aaOKi.mjs → EmojisPlugin.native-B64efKg5.mjs} +4 -4
  17. package/dist/{FormatPainterPlugin.native-BhjzsiVq.mjs → FormatPainterPlugin.native-CAc1N6xU.mjs} +183 -161
  18. package/dist/{HeadingPlugin.native-DZdvubrQ.mjs → HeadingPlugin.native-C3YiGERx.mjs} +85 -72
  19. package/dist/HistoryPlugin.native-C8GyxsgC.mjs +330 -0
  20. package/dist/{LinkPlugin.native-BsQXYsK6.mjs → LinkPlugin.native-Dt_p6Ukb.mjs} +4 -4
  21. package/dist/ListPlugin.native-UYaoRiub.mjs +239 -0
  22. package/dist/{MathPlugin.native-Byo3WL0f.mjs → MathPlugin.native-Cq9WQ7cq.mjs} +148 -130
  23. package/dist/MediaManagerPlugin.native-BjrEarV6.mjs +1161 -0
  24. package/dist/{MediaManagerPlugin.native-BT1NZIJS.mjs → MediaManagerPlugin.native-CRi24Mrb.mjs} +340 -281
  25. package/dist/{MentionPlugin.native-S_lwGZQO.mjs → MentionPlugin.native-Zb1dwdxU.mjs} +304 -300
  26. package/dist/{MergeTagPlugin.native-7-6F3S1Y.mjs → MergeTagPlugin.native-BXkVPvCo.mjs} +6 -4
  27. package/dist/{PIIRedactionPlugin.native-g7j4jOmm.mjs → PIIRedactionPlugin.native-Cm0bpzQb.mjs} +2 -2
  28. package/dist/{PreviewPlugin.native-Dv5OsffK.mjs → PreviewPlugin.native-CrfiwP2J.mjs} +2 -2
  29. package/dist/{SlashCommandsPlugin.native-BDIIwGNs.mjs → SlashCommandsPlugin.native-BzGTRmMB.mjs} +264 -240
  30. package/dist/{SmartPastePlugin.native-BATLCds5.mjs → SmartPastePlugin.native-DnOJhDsf.mjs} +2 -2
  31. package/dist/{SpecialCharactersPlugin.native-CdZoc1GB.mjs → SpecialCharactersPlugin.native-B0XaCfjZ.mjs} +4 -4
  32. package/dist/{SpellCheckPlugin.native-BGm2qPfn.mjs → SpellCheckPlugin.native-BE7os1Xj.mjs} +302 -265
  33. package/dist/{TablePlugin.native-C1YZ372P.mjs → TablePlugin.native-CWxEFpV8.mjs} +159 -136
  34. package/dist/{TemplatePlugin.native-Dwk8TgxI.mjs → TemplatePlugin.native-OD8Wc1R7.mjs} +6 -4
  35. package/dist/{TextColorPlugin.native-KMZ2uzlq.mjs → TextColorPlugin.native-C2IjioNM.mjs} +75 -71
  36. package/dist/{TranslationWorkflowPlugin.native-CZtG--06.mjs → TranslationWorkflowPlugin.native-BGXVJD9f.mjs} +101 -98
  37. package/dist/{VersionDiffPlugin.native-Ca1fMWUJ.mjs → VersionDiffPlugin.native-DJZIzFSK.mjs} +11 -11
  38. package/dist/anchoredPopover-QN4jNbW1.mjs +134 -0
  39. package/dist/confirmDialog-BP8hZPpX.mjs +112 -0
  40. package/dist/dialogHelpers-Dzn8DHoF.mjs +194 -0
  41. package/dist/{documentManager-BWK_-KJp.mjs → documentManager-8gnG-uG_.mjs} +1728 -1715
  42. package/dist/editora.min.js +21 -21
  43. package/dist/editora.umd.js +10 -10
  44. package/dist/{index-C1sO7DAC.js → index--wO0CZVN.js} +6 -6
  45. package/dist/{index-DGMYWPLx.mjs → index-BICrB5kg.mjs} +397 -326
  46. package/dist/index.cjs.js +1 -1
  47. package/dist/index.esm.js +2 -2
  48. package/dist/katex-DLIObQUm.mjs +11683 -0
  49. package/dist/katex.min--Ws3c9be.mjs +6 -0
  50. package/dist/notify-DCQGpmq-.mjs +60 -0
  51. package/dist/plugin-loader.js +54 -54
  52. package/dist/webcomponent-core.js +305 -234
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +153 -80
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +631 -560
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1677 -1328
  60. package/package.json +1 -1
  61. package/dist/HistoryPlugin.native-DPvhks6h.mjs +0 -246
  62. package/dist/ListPlugin.native-Bt0LANbO.mjs +0 -139
  63. package/dist/anchoredPopover-DJFD2oAP.mjs +0 -116
  64. package/dist/dialogHelpers-DBf7WqYH.mjs +0 -40
@@ -1,16 +1,18 @@
1
- import { e as V } from "./escapeHtml-CX8RelZ1.mjs";
2
- import { i as Y } from "./dialogHelpers-DBf7WqYH.mjs";
3
- let R = null, m = null, s = null;
4
- const _ = [];
5
- let H = !1, T = null, j = 0, W = 0, q = 0, M = 0, P = 1, D = null;
6
- const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
7
- const r = (i) => {
8
- i.key !== "Escape" || !t.isConnected || (i.preventDefault(), i.stopPropagation(), e());
1
+ import { e as T } from "./escapeHtml-CX8RelZ1.mjs";
2
+ import { i as ne } from "./dialogHelpers-Dzn8DHoF.mjs";
3
+ import { r as le } from "./historyHelpers-B0-4mq1E.mjs";
4
+ import { p as de, c as Q } from "./confirmDialog-BP8hZPpX.mjs";
5
+ let M = null, v = null, m = null;
6
+ const P = [];
7
+ let I = !1, B = null, Z = 0, K = 0, R = 0, z = 0, O = 1, N = null;
8
+ const ee = '[data-theme="dark"], .dark, .editora-theme-dark', j = (t, e) => {
9
+ const r = (a) => {
10
+ a.key !== "Escape" || !t.isConnected || (a.preventDefault(), a.stopPropagation(), e());
9
11
  };
10
12
  return document.addEventListener("keydown", r, !0), () => {
11
13
  document.removeEventListener("keydown", r, !0);
12
14
  };
13
- }, Z = () => {
15
+ }, se = () => {
14
16
  if (typeof document == "undefined" || document.getElementById("rte-media-dialog-styles")) return;
15
17
  const t = document.createElement("style");
16
18
  t.id = "rte-media-dialog-styles", t.textContent = `
@@ -22,7 +24,7 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
22
24
  --rte-media-border: #d6dbe4;
23
25
  --rte-media-surface: #f7f9fc;
24
26
  --rte-media-surface-hover: #eef2f7;
25
- --rte-media-accent: #1f75fe;
27
+ --rte-media-accent: #1560e8;
26
28
  --rte-media-accent-hover: #165fd6;
27
29
  --rte-media-danger: #dc3545;
28
30
  --rte-media-danger-hover: #b92735;
@@ -50,7 +52,7 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
50
52
  --rte-media-border: #49566c;
51
53
  --rte-media-surface: #2a3444;
52
54
  --rte-media-surface-hover: #344256;
53
- --rte-media-accent: #58a6ff;
55
+ --rte-media-accent: #1f6feb;
54
56
  --rte-media-accent-hover: #4598f4;
55
57
  --rte-media-danger: #ff7b72;
56
58
  --rte-media-danger-hover: #ff645b;
@@ -391,7 +393,7 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
391
393
  }
392
394
 
393
395
  .media-floating-toolbar.rte-ui-theme-dark,
394
- ${O} .media-floating-toolbar {
396
+ ${ee} .media-floating-toolbar {
395
397
  --rte-media-toolbar-bg: #24303f;
396
398
  --rte-media-toolbar-border: #4a5a71;
397
399
  --rte-media-toolbar-text: #d9e6fb;
@@ -440,56 +442,70 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
440
442
  background: var(--rte-media-toolbar-separator);
441
443
  }
442
444
  `, document.head.appendChild(t);
443
- }, K = () => {
445
+ }, ce = () => {
444
446
  const t = window.getSelection();
445
447
  if (!t || t.rangeCount === 0) return null;
446
448
  const e = t.anchorNode, r = e instanceof HTMLElement ? e : e == null ? void 0 : e.parentElement;
447
449
  return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
448
- }, J = (t) => {
450
+ }, te = (t) => {
449
451
  if (t) return t;
450
- const e = K();
452
+ const e = ce();
451
453
  if (e) return e;
452
- if (D) return D;
454
+ if (N) return N;
453
455
  const r = document.activeElement;
454
456
  return r ? r.closest(".rte-content, .editora-content") || r : null;
455
- }, G = (t) => {
456
- const e = J(t);
457
- return e ? !!e.closest(O) : !1;
458
- }, N = (t) => {
459
- Z();
457
+ }, re = (t) => {
458
+ const e = te(t);
459
+ return e ? !!e.closest(ee) : !1;
460
+ }, U = (t) => {
461
+ se();
460
462
  const e = document.createElement("div");
461
- return Y(e), e.className = "rte-media-overlay", G(t) && e.classList.add("rte-ui-theme-dark"), e;
462
- }, B = (t = !1) => {
463
+ return ne(e), e.className = "rte-media-overlay", re(t) && e.classList.add("rte-ui-theme-dark"), e;
464
+ }, V = (t, e) => {
465
+ var r;
466
+ (r = t.querySelector(e === "upload" ? ".tab-upload" : ".tab-url")) == null || r.focus();
467
+ }, ae = (t, e) => {
468
+ t == null || t.addEventListener("keydown", (r) => {
469
+ (r.key === "Enter" || r.key === " ") && (r.preventDefault(), e == null || e.click());
470
+ });
471
+ }, W = (t = !1) => {
463
472
  const e = document.createElement("div");
464
473
  return e.className = t ? "rte-media-dialog rte-media-dialog-compact" : "rte-media-dialog", e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true"), e;
465
- }, F = (t, e) => {
466
- document.querySelectorAll(".rte-media-overlay").forEach((a) => a.remove());
474
+ }, J = (t, e) => {
475
+ document.querySelectorAll(".rte-media-overlay").forEach((n) => n.remove());
467
476
  const r = window.getSelection();
468
- r && r.rangeCount > 0 && (R = r.getRangeAt(0).cloneRange());
469
- const i = N(e), o = B();
470
- let n = "upload", d = "", p = "", c = "", g = "";
471
- const h = () => {
472
- o.innerHTML = `
477
+ r && r.rangeCount > 0 && (M = r.getRangeAt(0).cloneRange());
478
+ const a = U(e), i = W();
479
+ let o = "upload", d = "", p = "", b = "", h = "";
480
+ const E = () => `
481
+ <div class="rte-media-field rte-media-preview-field">
482
+ <span class="rte-media-label">Preview</span>
483
+ <div class="rte-media-preview">
484
+ ${t === "image" ? `<img src="${T(d)}" alt="Preview">` : `<video src="${T(d)}" controls></video>`}
485
+ </div>
486
+ </div>
487
+ `, y = () => {
488
+ i.innerHTML = `
473
489
  <div class="rte-media-header">
474
490
  <h2 class="rte-media-title">Insert ${t === "image" ? "Image" : "Video"}</h2>
475
491
  <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
476
492
  </div>
477
493
 
478
- <div class="rte-media-tabs">
479
- <button class="tab-upload rte-media-tab ${n === "upload" ? "active" : ""}" type="button">Upload</button>
480
- <button class="tab-url rte-media-tab ${n === "url" ? "active" : ""}" type="button">URL</button>
494
+ <div class="rte-media-tabs" role="tablist" aria-label="Where to get the ${t === "image" ? "image" : "video"} from">
495
+ <button class="tab-upload rte-media-tab ${o === "upload" ? "active" : ""}" type="button" role="tab" aria-selected="${o === "upload"}">Upload</button>
496
+ <button class="tab-url rte-media-tab ${o === "url" ? "active" : ""}" type="button" role="tab" aria-selected="${o === "url"}">URL</button>
481
497
  </div>
482
498
 
483
499
  <div class="rte-media-body">
484
- ${n === "upload" ? `
500
+ ${o === "upload" ? `
485
501
  <div id="upload-section">
486
- <div class="dropzone rte-media-dropzone">
487
- <div class="rte-media-dropzone-icon">📁</div>
502
+ <div class="dropzone rte-media-dropzone" role="button" tabindex="0" aria-label="Drag and drop your ${t} here or click to browse. Max file size: 50MB">
503
+ <div class="rte-media-dropzone-icon" aria-hidden="true">📁</div>
488
504
  <p class="rte-media-dropzone-title">Drag and drop your ${t} here</p>
489
505
  <p class="rte-media-muted">or click to browse</p>
490
506
  <p class="rte-media-hint">Max file size: 50MB</p>
491
507
  </div>
492
- <input type="file" id="file-input" accept="${t === "image" ? "image/*" : "video/*"}" style="display: none;">
508
+ <input type="file" id="file-input" aria-label="${t === "image" ? "Choose an image file" : "Choose a video file"}" accept="${t === "image" ? "image/*" : "video/*"}" style="display: none;">
493
509
  <div id="upload-progress" class="rte-media-progress" style="display: none;">
494
510
  <div class="rte-media-progress-track">
495
511
  <div id="progress-bar" class="rte-media-progress-bar"></div>
@@ -500,113 +516,134 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
500
516
  ` : `
501
517
  <div id="url-section">
502
518
  <div class="rte-media-field">
503
- <label class="rte-media-label">URL</label>
504
- <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${t}.${t === "image" ? "jpg" : "mp4"}" value="${d}">
519
+ <label class="rte-media-label" for="url-input">URL</label>
520
+ <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${t}.${t === "image" ? "jpg" : "mp4"}" value="${T(d)}">
505
521
  </div>
506
522
  ${t === "image" ? `
507
523
  <div class="rte-media-field">
508
- <label class="rte-media-label">Alt Text (for accessibility)</label>
509
- <input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${g}">
524
+ <label class="rte-media-label" for="alt-input">Alt Text (for accessibility)</label>
525
+ <input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${T(h)}">
510
526
  </div>
511
527
  ` : ""}
512
528
  <div class="rte-media-grid">
513
529
  <div class="rte-media-field">
514
- <label class="rte-media-label">Width (px)</label>
515
- <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${p}">
530
+ <label class="rte-media-label" for="width-input">Width (px)</label>
531
+ <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${T(p)}">
516
532
  </div>
517
533
  <div class="rte-media-field">
518
- <label class="rte-media-label">Height (px)</label>
519
- <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${c}">
534
+ <label class="rte-media-label" for="height-input">Height (px)</label>
535
+ <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${T(b)}">
520
536
  </div>
521
537
  </div>
522
- ${d ? `
523
- <div class="rte-media-field">
524
- <label class="rte-media-label">Preview</label>
525
- <div class="rte-media-preview">
526
- ${t === "image" ? `<img src="${d}" alt="Preview">` : `<video src="${d}" controls></video>`}
527
- </div>
528
- </div>
529
- ` : ""}
538
+ ${d ? E() : ""}
530
539
  </div>
531
540
  `}
532
541
  </div>
533
542
 
534
543
  <div class="rte-media-footer">
535
544
  <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
536
- <button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d && n === "url" ? "disabled" : ""}>Insert</button>
545
+ <button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d && o === "url" ? "disabled" : ""}>Insert</button>
537
546
  </div>
538
547
  `;
539
548
  };
540
- h(), i.appendChild(o), document.body.appendChild(i);
541
- let w = () => {
549
+ y(), a.appendChild(i), document.body.appendChild(a);
550
+ let L = () => {
542
551
  };
543
- const f = () => {
544
- w(), i.parentNode && i.parentNode.removeChild(i);
552
+ const g = () => {
553
+ L(), a.parentNode && a.parentNode.removeChild(a);
545
554
  };
546
- w = I(i, f);
547
- const y = () => {
555
+ L = j(a, g);
556
+ const k = () => {
557
+ var x, q, u, f, S;
548
558
  if (!d) return;
549
- const a = t === "image" ? document.createElement("img") : document.createElement("video");
550
- a.src = d, a.setAttribute("data-media-type", t), t === "image" && g && (a.alt = g), p && (a.style.width = `${p}px`, a.setAttribute("width", p)), c && (a.style.height = `${c}px`, a.setAttribute("height", c)), t === "video" && (a.controls = !0), !p && !c ? a.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : a.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${p ? `width: ${p}px;` : "max-width: 100%;"} ${c ? `height: ${c}px;` : "height: auto;"}`, R && (R.deleteContents(), R.insertNode(a)), f();
551
- }, x = async (a) => {
552
- const b = o.querySelector("#upload-progress"), v = o.querySelector("#progress-bar"), L = o.querySelector("#progress-text");
553
- if (b && v && L) {
554
- b.style.display = "block";
555
- let E = 0;
559
+ const n = t === "image" ? document.createElement("img") : document.createElement("video");
560
+ n.src = d, n.setAttribute("data-media-type", t), t === "image" && h && (n.alt = h), p && (n.style.width = `${p}px`, n.setAttribute("width", p)), b && (n.style.height = `${b}px`, n.setAttribute("height", b)), t === "video" && (n.controls = !0), !p && !b ? 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; ${p ? `width: ${p}px;` : "max-width: 100%;"} ${b ? `height: ${b}px;` : "height: auto;"}`;
561
+ const s = (f = (u = M ? (x = M.commonAncestorContainer instanceof HTMLElement ? M.commonAncestorContainer : M.commonAncestorContainer.parentElement) == null ? void 0 : x.closest('[contenteditable="true"]') : null) != null ? u : (q = te(e)) == null ? void 0 : q.closest('[contenteditable="true"]')) != null ? f : null, w = (S = s == null ? void 0 : s.innerHTML) != null ? S : "";
562
+ if (M && (s != null && s.contains(M.commonAncestorContainer)) ? (M.deleteContents(), M.insertNode(n)) : s && s.appendChild(n), g(), s && n.isConnected) {
563
+ s.focus({ preventScroll: !0 });
564
+ const C = window.getSelection();
565
+ if (C) {
566
+ const $ = document.createRange();
567
+ $.setStartAfter(n), $.collapse(!0), C.removeAllRanges(), C.addRange($);
568
+ }
569
+ le(s, w), s.dispatchEvent(new Event("input", { bubbles: !0 }));
570
+ }
571
+ }, c = async (n) => {
572
+ const s = i.querySelector("#upload-progress"), w = i.querySelector("#progress-bar"), x = i.querySelector("#progress-text");
573
+ if (s && w && x) {
574
+ s.style.display = "block";
575
+ let q = 0;
556
576
  const u = setInterval(() => {
557
- E += Math.random() * 30, E > 90 && (E = 90), v.style.width = `${E}%`;
577
+ q += Math.random() * 30, q > 90 && (q = 90), w.style.width = `${q}%`;
558
578
  }, 200);
559
579
  try {
560
- const k = new FileReader();
561
- k.onload = () => {
562
- clearInterval(u), v.style.width = "100%", L.textContent = "Upload complete", setTimeout(() => {
563
- d = k.result, n = "url", h(), l();
580
+ const f = new FileReader();
581
+ f.onload = () => {
582
+ clearInterval(u), w.style.width = "100%", x.textContent = "Upload complete", setTimeout(() => {
583
+ d = f.result, o = "url", y(), l();
564
584
  }, 500);
565
- }, k.readAsDataURL(a);
566
- } catch (k) {
567
- clearInterval(u), L.textContent = "Upload failed";
585
+ }, f.readAsDataURL(n);
586
+ } catch (f) {
587
+ clearInterval(u), x.textContent = "Upload failed";
568
588
  }
569
589
  }
570
590
  }, l = () => {
571
- const a = o.querySelector(".close-btn"), b = o.querySelector(".cancel-btn"), v = o.querySelector("#insert-btn"), L = o.querySelector(".tab-upload"), E = o.querySelector(".tab-url");
572
- if (a == null || a.addEventListener("click", f), b == null || b.addEventListener("click", f), v == null || v.addEventListener("click", y), L == null || L.addEventListener("click", () => {
573
- n = "upload", h(), l();
574
- }), E == null || E.addEventListener("click", () => {
575
- n = "url", h(), l();
576
- }), n === "upload") {
577
- const u = o.querySelector(".dropzone"), k = o.querySelector("#file-input");
578
- u == null || u.addEventListener("click", () => k == null ? void 0 : k.click()), u == null || u.addEventListener("dragover", (S) => {
591
+ const n = i.querySelector(".close-btn"), s = i.querySelector(".cancel-btn"), w = i.querySelector("#insert-btn"), x = i.querySelector(".tab-upload"), q = i.querySelector(".tab-url");
592
+ if (n == null || n.addEventListener("click", g), s == null || s.addEventListener("click", g), w == null || w.addEventListener("click", k), x == null || x.addEventListener("click", () => {
593
+ o = "upload", y(), l(), V(i, o);
594
+ }), q == null || q.addEventListener("click", () => {
595
+ o = "url", y(), l(), V(i, o);
596
+ }), o === "upload") {
597
+ const u = i.querySelector(".dropzone"), f = i.querySelector("#file-input");
598
+ u == null || u.addEventListener("click", () => f == null ? void 0 : f.click()), ae(u, f), u == null || u.addEventListener("dragover", (S) => {
579
599
  S.preventDefault(), u.classList.add("is-dragover");
580
600
  }), u == null || u.addEventListener("dragleave", () => {
581
601
  u.classList.remove("is-dragover");
582
602
  }), u == null || u.addEventListener("drop", (S) => {
583
- var A;
603
+ var $;
584
604
  S.preventDefault(), u.classList.remove("is-dragover");
585
- const $ = (A = S.dataTransfer) == null ? void 0 : A.files[0];
586
- $ && x($);
587
- }), k == null || k.addEventListener("change", (S) => {
588
- var A;
589
- const $ = (A = S.target.files) == null ? void 0 : A[0];
590
- $ && x($);
605
+ const C = ($ = S.dataTransfer) == null ? void 0 : $.files[0];
606
+ C && c(C);
607
+ }), f == null || f.addEventListener("change", (S) => {
608
+ var $;
609
+ const C = ($ = S.target.files) == null ? void 0 : $[0];
610
+ C && c(C);
591
611
  });
592
612
  }
593
- if (n === "url") {
594
- const u = o.querySelector("#url-input"), k = o.querySelector("#alt-input"), S = o.querySelector("#width-input"), $ = o.querySelector("#height-input");
613
+ if (o === "url") {
614
+ const u = i.querySelector("#url-input"), f = i.querySelector("#alt-input"), S = i.querySelector("#width-input"), C = i.querySelector("#height-input");
615
+ let $;
595
616
  u == null || u.addEventListener("input", () => {
596
- d = u.value, h(), l();
597
- }), k == null || k.addEventListener("input", () => {
598
- g = k.value;
617
+ d = u.value;
618
+ const X = i.querySelector("#insert-btn");
619
+ X && (X.disabled = !d), clearTimeout($), $ = setTimeout(() => {
620
+ const H = i.querySelector("#url-section"), _ = H == null ? void 0 : H.querySelector(".rte-media-preview-field");
621
+ if (!H) return;
622
+ if (!d) {
623
+ _ == null || _.remove();
624
+ return;
625
+ }
626
+ if (_) {
627
+ const Y = _.querySelector("img, video");
628
+ Y && Y.setAttribute("src", d);
629
+ return;
630
+ }
631
+ const F = H.querySelector(".rte-media-grid");
632
+ F == null || F.insertAdjacentHTML("afterend", E());
633
+ }, 400);
634
+ }), f == null || f.addEventListener("input", () => {
635
+ h = f.value;
599
636
  }), S == null || S.addEventListener("input", () => {
600
637
  p = S.value;
601
- }), $ == null || $.addEventListener("input", () => {
602
- c = $.value;
638
+ }), C == null || C.addEventListener("input", () => {
639
+ b = C.value;
603
640
  });
604
641
  }
605
642
  };
606
- l(), i.addEventListener("click", (a) => {
607
- a.target === i && f();
643
+ l(), a.addEventListener("click", (n) => {
644
+ n.target === a && g();
608
645
  });
609
- }, Q = () => {
646
+ }, me = () => {
610
647
  ["nw", "ne", "sw", "se"].forEach((e) => {
611
648
  const r = document.createElement("div");
612
649
  r.className = `media-resize-handle-${e}`, r.style.cssText = `
@@ -620,25 +657,25 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
620
657
  z-index: 10001;
621
658
  display: none;
622
659
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
623
- `, r.setAttribute("data-position", e), document.body.appendChild(r), _.push(r);
660
+ `, r.setAttribute("data-position", e), document.body.appendChild(r), P.push(r);
624
661
  });
625
- }, z = () => {
626
- if (!m) {
627
- _.forEach((r) => r.style.display = "none");
662
+ }, D = () => {
663
+ if (!v) {
664
+ P.forEach((r) => r.style.display = "none");
628
665
  return;
629
666
  }
630
- const t = m.getBoundingClientRect(), e = {
667
+ const t = v.getBoundingClientRect(), e = {
631
668
  nw: { x: t.left - 5, y: t.top - 5 },
632
669
  ne: { x: t.right - 5, y: t.top - 5 },
633
670
  sw: { x: t.left - 5, y: t.bottom - 5 },
634
671
  se: { x: t.right - 5, y: t.bottom - 5 }
635
672
  };
636
- _.forEach((r) => {
637
- const i = r.getAttribute("data-position"), o = e[i];
638
- r.style.left = `${o.x}px`, r.style.top = `${o.y}px`, r.style.display = "block";
673
+ P.forEach((r) => {
674
+ const a = r.getAttribute("data-position"), i = e[a];
675
+ r.style.left = `${i.x}px`, r.style.top = `${i.y}px`, r.style.display = "block";
639
676
  });
640
- }, ee = (t) => {
641
- const e = N(t), r = B(!0);
677
+ }, ue = (t) => {
678
+ const e = U(t), r = W(!0);
642
679
  r.innerHTML = `
643
680
  <div class="rte-media-header">
644
681
  <h2 class="rte-media-title">Edit Alt Text</h2>
@@ -646,7 +683,7 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
646
683
  </div>
647
684
  <div class="rte-media-body">
648
685
  <label class="rte-media-label">Alternative Text (for accessibility)</label>
649
- <textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${V(t.alt || "")}</textarea>
686
+ <textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${T(t.alt || "")}</textarea>
650
687
  <p class="rte-media-helper">Good alt text is descriptive and concise. It helps users with visual impairments understand your content.</p>
651
688
  </div>
652
689
  <div class="rte-media-footer">
@@ -654,19 +691,19 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
654
691
  <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
655
692
  </div>
656
693
  `, e.appendChild(r), document.body.appendChild(e);
657
- const i = r.querySelector("#alt-text-input"), o = r.querySelector(".close-btn"), n = r.querySelector(".cancel-btn"), d = r.querySelector(".save-btn");
694
+ const a = r.querySelector("#alt-text-input"), i = r.querySelector(".close-btn"), o = r.querySelector(".cancel-btn"), d = r.querySelector(".save-btn");
658
695
  let p = () => {
659
696
  };
660
- const c = () => {
697
+ const b = () => {
661
698
  p(), e.parentNode && e.parentNode.removeChild(e);
662
699
  };
663
- p = I(e, c), o.addEventListener("click", c), n.addEventListener("click", c), e.addEventListener("click", (g) => {
664
- g.target === e && c();
700
+ p = j(e, b), i.addEventListener("click", b), o.addEventListener("click", b), e.addEventListener("click", (h) => {
701
+ h.target === e && b();
665
702
  }), d.addEventListener("click", () => {
666
- t.alt = i.value, c();
667
- }), i.focus(), i.select();
668
- }, te = (t) => {
669
- const e = t.closest("a"), r = (e == null ? void 0 : e.getAttribute("href")) || "", i = (e == null ? void 0 : e.getAttribute("target")) || "_self", o = (e == null ? void 0 : e.getAttribute("title")) || "", n = N(t), d = B(!0);
703
+ t.alt = a.value, b();
704
+ }), a.focus(), a.select();
705
+ }, pe = (t) => {
706
+ const e = t.closest("a"), r = (e == null ? void 0 : e.getAttribute("href")) || "", a = (e == null ? void 0 : e.getAttribute("target")) || "_self", i = (e == null ? void 0 : e.getAttribute("title")) || "", o = U(t), d = W(!0);
670
707
  d.innerHTML = `
671
708
  <div class="rte-media-header">
672
709
  <h2 class="rte-media-title">${e ? "Edit Link" : "Add Link"}</h2>
@@ -675,14 +712,14 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
675
712
  <div class="rte-media-body">
676
713
  <div class="rte-media-field">
677
714
  <label class="rte-media-label">URL</label>
678
- <input id="link-url" type="url" class="rte-media-input" value="${V(r)}" placeholder="https://example.com" />
715
+ <input id="link-url" type="url" class="rte-media-input" value="${T(r)}" placeholder="https://example.com" />
679
716
  </div>
680
717
  <div class="rte-media-field">
681
718
  <label class="rte-media-label">Title (tooltip)</label>
682
- <input id="link-title" type="text" class="rte-media-input" value="${V(o)}" placeholder="Optional tooltip text" />
719
+ <input id="link-title" type="text" class="rte-media-input" value="${T(i)}" placeholder="Optional tooltip text" />
683
720
  </div>
684
721
  <label class="rte-media-checkbox-label">
685
- <input id="link-target" type="checkbox" ${i === "_blank" ? "checked" : ""} />
722
+ <input id="link-target" type="checkbox" ${a === "_blank" ? "checked" : ""} />
686
723
  Open in new window/tab
687
724
  </label>
688
725
  </div>
@@ -693,54 +730,59 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
693
730
  <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
694
731
  </div>
695
732
  </div>
696
- `, n.appendChild(d), document.body.appendChild(n);
697
- const p = d.querySelector("#link-url"), c = d.querySelector("#link-title"), g = d.querySelector("#link-target"), h = d.querySelector(".close-btn"), w = d.querySelector(".cancel-btn"), f = d.querySelector(".save-btn"), y = d.querySelector(".remove-link-btn");
698
- let x = () => {
733
+ `, o.appendChild(d), document.body.appendChild(o);
734
+ const p = d.querySelector("#link-url"), b = d.querySelector("#link-title"), h = d.querySelector("#link-target"), E = d.querySelector(".close-btn"), y = d.querySelector(".cancel-btn"), L = d.querySelector(".save-btn"), g = d.querySelector(".remove-link-btn");
735
+ let k = () => {
699
736
  };
700
- const l = () => {
701
- x(), n.parentNode && n.parentNode.removeChild(n);
737
+ const c = () => {
738
+ k(), o.parentNode && o.parentNode.removeChild(o);
702
739
  };
703
- x = I(n, l), h.addEventListener("click", l), w.addEventListener("click", l), n.addEventListener("click", (a) => {
704
- a.target === n && l();
705
- }), f.addEventListener("click", () => {
706
- const a = p.value.trim();
707
- if (a) {
708
- const b = a.startsWith("http") ? a : `https://${a}`;
740
+ k = j(o, c), E.addEventListener("click", c), y.addEventListener("click", c), o.addEventListener("click", (l) => {
741
+ l.target === o && c();
742
+ }), L.addEventListener("click", () => {
743
+ const l = p.value.trim();
744
+ if (l) {
745
+ const n = l.startsWith("http") ? l : `https://${l}`;
709
746
  if (e)
710
- e.setAttribute("href", b), e.setAttribute("target", g.checked ? "_blank" : "_self"), g.checked ? e.setAttribute("rel", "noopener noreferrer") : e.removeAttribute("rel"), c.value.trim() ? e.setAttribute("title", c.value.trim()) : e.removeAttribute("title");
747
+ e.setAttribute("href", n), e.setAttribute("target", h.checked ? "_blank" : "_self"), h.checked ? e.setAttribute("rel", "noopener noreferrer") : e.removeAttribute("rel"), b.value.trim() ? e.setAttribute("title", b.value.trim()) : e.removeAttribute("title");
711
748
  else {
712
- const v = document.createElement("a");
713
- v.href = b, v.target = g.checked ? "_blank" : "_self", g.checked && (v.rel = "noopener noreferrer"), c.value.trim() && (v.title = c.value.trim()), t.replaceWith(v), v.appendChild(t);
749
+ const s = document.createElement("a");
750
+ s.href = n, s.target = h.checked ? "_blank" : "_self", h.checked && (s.rel = "noopener noreferrer"), b.value.trim() && (s.title = b.value.trim()), t.replaceWith(s), s.appendChild(t);
714
751
  }
715
- l(), s && m && U(m);
716
- }
717
- }), y == null || y.addEventListener("click", () => {
718
- e && confirm("Remove link from this media?") && (e.replaceWith(t), l(), s && m && U(m));
752
+ c(), m && v && G(v);
753
+ }
754
+ }), g == null || g.addEventListener("click", async () => {
755
+ !e || !await Q("Remove link from this media?", {
756
+ title: "Remove link",
757
+ confirmText: "Remove link",
758
+ danger: !0,
759
+ context: t
760
+ }) || !e.isConnected || (e.replaceWith(t), c(), m && v && G(v));
719
761
  }), p.focus();
720
- }, re = (t) => {
721
- const e = N(t), r = B();
722
- let i = "url", o = t.src;
723
- const n = () => {
762
+ }, be = (t) => {
763
+ const e = U(t), r = W();
764
+ let a = "url", i = t.src;
765
+ const o = () => {
724
766
  r.innerHTML = `
725
767
  <div class="rte-media-header">
726
768
  <h2 class="rte-media-title">Replace Image</h2>
727
769
  <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
728
770
  </div>
729
771
 
730
- <div class="rte-media-tabs">
731
- <button class="tab-upload rte-media-tab ${i === "upload" ? "active" : ""}" type="button">Upload</button>
732
- <button class="tab-url rte-media-tab ${i === "url" ? "active" : ""}" type="button">URL</button>
772
+ <div class="rte-media-tabs" role="tablist" aria-label="Where to get the image from">
773
+ <button class="tab-upload rte-media-tab ${a === "upload" ? "active" : ""}" type="button" role="tab" aria-selected="${a === "upload"}">Upload</button>
774
+ <button class="tab-url rte-media-tab ${a === "url" ? "active" : ""}" type="button" role="tab" aria-selected="${a === "url"}">URL</button>
733
775
  </div>
734
776
 
735
777
  <div class="rte-media-body">
736
- ${i === "upload" ? `
778
+ ${a === "upload" ? `
737
779
  <div id="upload-section">
738
- <div class="dropzone rte-media-dropzone">
739
- <div class="rte-media-dropzone-icon">📁</div>
780
+ <div class="dropzone rte-media-dropzone" role="button" tabindex="0" aria-label="Drag and drop your image here or click to browse">
781
+ <div class="rte-media-dropzone-icon" aria-hidden="true">📁</div>
740
782
  <p class="rte-media-dropzone-title">Drag and drop your image here</p>
741
783
  <p class="rte-media-muted">or click to browse</p>
742
784
  </div>
743
- <input type="file" id="file-input" accept="image/*" style="display: none;">
785
+ <input type="file" id="file-input" aria-label="Choose an image file" accept="image/*" style="display: none;">
744
786
  <div id="upload-progress" class="rte-media-progress" style="display: none;">
745
787
  <div class="rte-media-progress-track">
746
788
  <div id="progress-bar" class="rte-media-progress-bar"></div>
@@ -751,14 +793,14 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
751
793
  ` : `
752
794
  <div id="url-section">
753
795
  <div class="rte-media-field">
754
- <label class="rte-media-label">Image URL</label>
755
- <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${o}">
796
+ <label class="rte-media-label" for="url-input">Image URL</label>
797
+ <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${T(i)}">
756
798
  </div>
757
- ${o ? `
799
+ ${i ? `
758
800
  <div class="rte-media-field">
759
- <label class="rte-media-label">Preview</label>
801
+ <span class="rte-media-label">Preview</span>
760
802
  <div class="rte-media-preview">
761
- <img src="${o}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
803
+ <img src="${T(i)}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
762
804
  </div>
763
805
  </div>
764
806
  ` : ""}
@@ -768,88 +810,95 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
768
810
 
769
811
  <div class="rte-media-footer">
770
812
  <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
771
- <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!o && i === "url" ? "disabled" : ""}>Replace</button>
813
+ <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!i && a === "url" ? "disabled" : ""}>Replace</button>
772
814
  </div>
773
815
  `;
774
816
  };
775
- n(), e.appendChild(r), document.body.appendChild(e);
817
+ o(), e.appendChild(r), document.body.appendChild(e);
776
818
  let d = () => {
777
819
  };
778
820
  const p = () => {
779
821
  d(), e.parentNode && e.parentNode.removeChild(e);
780
822
  };
781
- d = I(e, p);
782
- const c = () => {
783
- o && (t.src = o, p());
784
- }, g = async (w) => {
785
- const f = r.querySelector("#upload-progress"), y = r.querySelector("#progress-bar"), x = r.querySelector("#progress-text");
786
- if (f && y && x) {
787
- f.style.display = "block";
788
- let l = 0;
789
- const a = setInterval(() => {
790
- l += Math.random() * 30, l > 90 && (l = 90), y.style.width = `${l}%`;
823
+ d = j(e, p);
824
+ const b = () => {
825
+ i && (t.src = i, p());
826
+ }, h = async (y) => {
827
+ const L = r.querySelector("#upload-progress"), g = r.querySelector("#progress-bar"), k = r.querySelector("#progress-text");
828
+ if (L && g && k) {
829
+ L.style.display = "block";
830
+ let c = 0;
831
+ const l = setInterval(() => {
832
+ c += Math.random() * 30, c > 90 && (c = 90), g.style.width = `${c}%`;
791
833
  }, 200);
792
834
  try {
793
- const b = new FileReader();
794
- b.onload = () => {
795
- clearInterval(a), y.style.width = "100%", x.textContent = "Upload complete", setTimeout(() => {
796
- o = b.result, i = "url", n(), h();
835
+ const n = new FileReader();
836
+ n.onload = () => {
837
+ clearInterval(l), g.style.width = "100%", k.textContent = "Upload complete", setTimeout(() => {
838
+ i = n.result, a = "url", o(), E();
797
839
  }, 500);
798
- }, b.readAsDataURL(w);
799
- } catch (b) {
800
- clearInterval(a), x.textContent = "Upload failed";
840
+ }, n.readAsDataURL(y);
841
+ } catch (n) {
842
+ clearInterval(l), k.textContent = "Upload failed";
801
843
  }
802
844
  }
803
- }, h = () => {
804
- const w = r.querySelector(".close-btn"), f = r.querySelector(".cancel-btn"), y = r.querySelector("#replace-btn"), x = r.querySelector(".tab-upload"), l = r.querySelector(".tab-url");
805
- if (w == null || w.addEventListener("click", p), f == null || f.addEventListener("click", p), y == null || y.addEventListener("click", c), x == null || x.addEventListener("click", () => {
806
- i = "upload", n(), h();
807
- }), l == null || l.addEventListener("click", () => {
808
- i = "url", n(), h();
809
- }), i === "upload") {
810
- const a = r.querySelector(".dropzone"), b = r.querySelector("#file-input");
811
- a == null || a.addEventListener("click", () => b == null ? void 0 : b.click()), a == null || a.addEventListener("dragover", (v) => {
812
- v.preventDefault(), a.classList.add("is-dragover");
813
- }), a == null || a.addEventListener("dragleave", () => {
814
- a.classList.remove("is-dragover");
815
- }), a == null || a.addEventListener("drop", (v) => {
816
- var E;
817
- v.preventDefault(), a.classList.remove("is-dragover");
818
- const L = (E = v.dataTransfer) == null ? void 0 : E.files[0];
819
- L && g(L);
820
- }), b == null || b.addEventListener("change", (v) => {
821
- var E;
822
- const L = (E = v.target.files) == null ? void 0 : E[0];
823
- L && g(L);
845
+ }, E = () => {
846
+ const y = r.querySelector(".close-btn"), L = r.querySelector(".cancel-btn"), g = r.querySelector("#replace-btn"), k = r.querySelector(".tab-upload"), c = r.querySelector(".tab-url");
847
+ if (y == null || y.addEventListener("click", p), L == null || L.addEventListener("click", p), g == null || g.addEventListener("click", b), k == null || k.addEventListener("click", () => {
848
+ a = "upload", o(), E(), V(r, a);
849
+ }), c == null || c.addEventListener("click", () => {
850
+ a = "url", o(), E(), V(r, a);
851
+ }), a === "upload") {
852
+ const l = r.querySelector(".dropzone"), n = r.querySelector("#file-input");
853
+ l == null || l.addEventListener("click", () => n == null ? void 0 : n.click()), ae(l, n), l == null || l.addEventListener("dragover", (s) => {
854
+ s.preventDefault(), l.classList.add("is-dragover");
855
+ }), l == null || l.addEventListener("dragleave", () => {
856
+ l.classList.remove("is-dragover");
857
+ }), l == null || l.addEventListener("drop", (s) => {
858
+ var x;
859
+ s.preventDefault(), l.classList.remove("is-dragover");
860
+ const w = (x = s.dataTransfer) == null ? void 0 : x.files[0];
861
+ w && h(w);
862
+ }), n == null || n.addEventListener("change", (s) => {
863
+ var x;
864
+ const w = (x = s.target.files) == null ? void 0 : x[0];
865
+ w && h(w);
824
866
  });
825
867
  }
826
- if (i === "url") {
827
- const a = r.querySelector("#url-input");
828
- a == null || a.addEventListener("input", () => {
829
- o = a.value, n(), h();
868
+ if (a === "url") {
869
+ const l = r.querySelector("#url-input");
870
+ l == null || l.addEventListener("input", () => {
871
+ i = l.value;
872
+ const n = r.querySelector("#replace-btn");
873
+ n && (n.disabled = !i);
830
874
  });
831
875
  }
832
876
  };
833
- h(), e.addEventListener("click", (w) => {
834
- w.target === e && p();
877
+ E(), e.addEventListener("click", (y) => {
878
+ y.target === e && p();
835
879
  });
836
- }, C = () => {
837
- if (!s || !m) return;
838
- const t = s.offsetHeight || 40, e = m.offsetTop, r = m.offsetLeft, i = m.offsetWidth, o = e - t - 8, n = r + i / 2 - (s.offsetWidth || 120) / 2;
839
- s.style.top = `${o}px`, s.style.left = `${n}px`, setTimeout(() => {
840
- s && (s.style.display = "flex");
880
+ }, A = () => {
881
+ if (!m || !v) return;
882
+ const t = m.offsetHeight || 40, e = m.offsetWidth || 120, r = m.parentElement || v, a = r.getBoundingClientRect(), i = v.getBoundingClientRect(), o = i.top - a.top - r.clientTop + r.scrollTop, d = i.left - a.left - r.clientLeft + r.scrollLeft, p = v.closest('[contenteditable="true"]'), h = (p ? i.top - p.getBoundingClientRect().top - t - 8 : 1) < 0 ? o + i.height + 8 : o - t - 8, E = d + i.width / 2 - e / 2;
883
+ m.style.top = `${h}px`, m.style.left = `${E}px`, setTimeout(() => {
884
+ m && (m.style.display = "flex");
841
885
  }, 100);
842
- }, U = (t) => {
843
- var p, c, g, h, w, f, y, x;
844
- s && (s._cleanup && s._cleanup(), s.remove());
845
- const e = t.parentElement;
886
+ }, ie = (t) => {
887
+ let e = t.parentElement;
888
+ for (; e && e.parentElement && getComputedStyle(e).display === "inline"; )
889
+ e = e.parentElement;
890
+ return e;
891
+ }, G = (t) => {
892
+ var p, b, h, E, y, L, g, k;
893
+ m && (m._cleanup && m._cleanup(), m.remove());
894
+ const e = ie(t);
846
895
  if (e) {
847
- const l = e.style.position;
848
- (!l || l === "static") && (e.style.position = "relative", e._originalPosition = l), s = document.createElement("div"), s.className = "media-floating-toolbar", G(t) && s.classList.add("rte-ui-theme-dark"), e.insertBefore(s, e.firstChild), C();
896
+ const c = e.style.position;
897
+ (!c || c === "static") && (e.style.position = "relative", e._originalPosition = c), m = document.createElement("div"), m.className = "media-floating-toolbar", re(t) && m.classList.add("rte-ui-theme-dark"), e.insertBefore(m, e.firstChild), A();
849
898
  }
850
- const r = s;
899
+ const r = m;
851
900
  if (!r) return;
852
- const i = t.tagName === "IMG", o = t.closest("a");
901
+ const a = t.tagName === "IMG", i = t.closest("a");
853
902
  r.innerHTML = `
854
903
  <button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
855
904
  <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>
@@ -861,14 +910,14 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
861
910
  <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>
862
911
  </button>
863
912
  <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
864
- ${i ? `
913
+ ${a ? `
865
914
  <button class="media-floating-toolbar-btn btn-alt" title="Edit Alt Text" type="button">
866
915
  <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>
867
916
  </button>` : ""}
868
- <button class="media-floating-toolbar-btn btn-link" title="${o ? "Edit/Remove Link" : "Add Link"}" type="button">
917
+ <button class="media-floating-toolbar-btn btn-link" title="${i ? "Edit/Remove Link" : "Add Link"}" type="button">
869
918
  <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>
870
919
  </button>
871
- ${i ? `
920
+ ${a ? `
872
921
  <button class="media-floating-toolbar-btn btn-replace" title="Replace Image" type="button">
873
922
  <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>
874
923
  </button>` : ""}
@@ -877,94 +926,104 @@ const O = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
877
926
  <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>
878
927
  </button>
879
928
  `, setTimeout(() => {
880
- C();
929
+ A();
881
930
  }, 0);
882
- const n = () => C();
931
+ const o = () => A();
883
932
  let d = t.parentElement;
884
933
  for (; d; )
885
- d.addEventListener("scroll", n), d = d.parentElement;
886
- window.addEventListener("scroll", n), window.addEventListener("resize", n), r._cleanup = () => {
887
- let l = t.parentElement;
888
- for (; l; )
889
- l.removeEventListener("scroll", n), l = l.parentElement;
890
- window.removeEventListener("scroll", n), window.removeEventListener("resize", n);
934
+ d.addEventListener("scroll", o), d = d.parentElement;
935
+ window.addEventListener("scroll", o), window.addEventListener("resize", o), r._cleanup = () => {
936
+ let c = t.parentElement;
937
+ for (; c; )
938
+ c.removeEventListener("scroll", o), c = c.parentElement;
939
+ window.removeEventListener("scroll", o), window.removeEventListener("resize", o);
891
940
  }, (p = r.querySelector(".btn-align-left")) == null || p.addEventListener("click", () => {
892
- t.style.display = "block", t.style.marginLeft = "0", t.style.marginRight = "auto", C();
893
- }), (c = r.querySelector(".btn-align-center")) == null || c.addEventListener("click", () => {
894
- t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "auto", C();
895
- }), (g = r.querySelector(".btn-align-right")) == null || g.addEventListener("click", () => {
896
- t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "0", C();
897
- }), (h = r.querySelector(".btn-alt")) == null || h.addEventListener("click", () => {
898
- t.tagName === "IMG" && ee(t);
899
- }), (w = r.querySelector(".btn-link")) == null || w.addEventListener("click", () => {
900
- te(t);
901
- }), (f = r.querySelector(".btn-replace")) == null || f.addEventListener("click", () => {
902
- t.tagName === "IMG" && re(t);
903
- }), (y = r.querySelector(".btn-resize")) == null || y.addEventListener("click", () => {
904
- const l = prompt("Enter width in pixels:", String(t.width || t.offsetWidth));
905
- if (l && !isNaN(parseInt(l))) {
906
- const a = parseInt(l);
907
- t.style.width = `${a}px`, t.setAttribute("width", String(a)), z(), C();
908
- }
909
- }), (x = r.querySelector(".btn-remove")) == null || x.addEventListener("click", () => {
910
- confirm("Remove this media?") && (t.remove(), s && (s._cleanup && s._cleanup(), s.remove(), s = null), m = null, z());
941
+ t.style.display = "block", t.style.marginLeft = "0", t.style.marginRight = "auto", A();
942
+ }), (b = r.querySelector(".btn-align-center")) == null || b.addEventListener("click", () => {
943
+ t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "auto", A();
944
+ }), (h = r.querySelector(".btn-align-right")) == null || h.addEventListener("click", () => {
945
+ t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "0", A();
946
+ }), (E = r.querySelector(".btn-alt")) == null || E.addEventListener("click", () => {
947
+ t.tagName === "IMG" && ue(t);
948
+ }), (y = r.querySelector(".btn-link")) == null || y.addEventListener("click", () => {
949
+ pe(t);
950
+ }), (L = r.querySelector(".btn-replace")) == null || L.addEventListener("click", () => {
951
+ t.tagName === "IMG" && be(t);
952
+ }), (g = r.querySelector(".btn-resize")) == null || g.addEventListener("click", async () => {
953
+ const c = await de("Enter width in pixels:", {
954
+ title: "Resize",
955
+ label: "Width (px)",
956
+ initialValue: String(t.width || t.offsetWidth),
957
+ inputMode: "numeric",
958
+ confirmText: "Resize",
959
+ context: t,
960
+ validate: (n) => /^\s*\d+\s*$/.test(n) && parseInt(n, 10) > 0 ? null : "Enter a whole number of pixels, such as 480."
961
+ });
962
+ if (c === null) return;
963
+ const l = parseInt(c, 10);
964
+ t.style.width = `${l}px`, t.setAttribute("width", String(l)), D(), A();
965
+ }), (k = r.querySelector(".btn-remove")) == null || k.addEventListener("click", async () => {
966
+ await Q("Remove this media?", {
967
+ title: "Remove media",
968
+ confirmText: "Remove",
969
+ danger: !0,
970
+ context: t
971
+ }) && (t.remove(), m && (m._cleanup && m._cleanup(), m.remove(), m = null), v = null, D());
911
972
  }), r._cleanup = () => {
912
- window.removeEventListener("scroll", C), window.removeEventListener("resize", C);
973
+ window.removeEventListener("scroll", A), window.removeEventListener("resize", A);
913
974
  };
914
- }, X = (t) => {
915
- D = t || null, Q(), document.addEventListener("click", (e) => {
975
+ }, oe = (t) => {
976
+ N = t || null, me(), document.addEventListener("click", (e) => {
916
977
  const r = e.target;
917
978
  if (r.tagName === "IMG" || r.tagName === "VIDEO") {
918
- const i = r;
919
- let o = !1;
920
- if (D ? o = D.contains(i) : o = !!i.closest('[contenteditable="true"]'), o) {
921
- e.preventDefault(), e.stopPropagation(), m = i, m.style.display = "block", U(i), z();
979
+ const a = r;
980
+ let i = !1;
981
+ if (N ? i = N.contains(a) : i = !!a.closest('[contenteditable="true"]'), i) {
982
+ e.preventDefault(), e.stopPropagation(), v = a, v.style.display = "block", G(a), D();
922
983
  return;
923
984
  }
924
985
  }
925
- if (!r.closest(".btn-link, .btn-resize, .btn-remove") && s && !r.closest("button")) {
926
- if (s._cleanup && s._cleanup(), s.remove(), s = null, m && m.parentElement) {
927
- const i = m.parentElement;
928
- i._originalPosition !== void 0 && (i.style.position = i._originalPosition, delete i._originalPosition);
929
- }
930
- m = null, z();
986
+ if (!r.closest(".btn-link, .btn-resize, .btn-remove") && m && !r.closest("button")) {
987
+ m._cleanup && m._cleanup(), m.remove(), m = null;
988
+ const a = v && ie(v);
989
+ a && a._originalPosition !== void 0 && (a.style.position = a._originalPosition, delete a._originalPosition), v = null, D();
931
990
  }
932
- }), _.forEach((e) => {
991
+ }), P.forEach((e) => {
933
992
  e.addEventListener("mousedown", (r) => {
934
- if (!m) return;
935
- r.preventDefault(), r.stopPropagation(), H = !0, T = e.getAttribute("data-position"), j = r.clientX, W = r.clientY;
936
- const i = m.getBoundingClientRect();
937
- q = i.width, M = i.height, P = q / M, document.body.style.userSelect = "none", document.body.style.cursor = `${T}-resize`;
993
+ if (!v) return;
994
+ r.preventDefault(), r.stopPropagation(), I = !0, B = e.getAttribute("data-position"), Z = r.clientX, K = r.clientY;
995
+ const a = v.getBoundingClientRect();
996
+ R = a.width, z = a.height, O = R / z, document.body.style.userSelect = "none", document.body.style.cursor = `${B}-resize`;
938
997
  });
939
998
  }), document.addEventListener("mousemove", (e) => {
940
- if (!H || !m || !T) return;
941
- const r = e.clientX - j, i = e.clientY - W;
942
- let o = q, n = M;
943
- switch (T) {
999
+ if (!I || !v || !B) return;
1000
+ const r = e.clientX - Z, a = e.clientY - K;
1001
+ let i = R, o = z;
1002
+ switch (B) {
944
1003
  case "se":
945
- o = q + r, n = M + i;
1004
+ i = R + r, o = z + a;
946
1005
  break;
947
1006
  case "sw":
948
- o = q - r, n = M + i;
1007
+ i = R - r, o = z + a;
949
1008
  break;
950
1009
  case "ne":
951
- o = q + r, n = M - i;
1010
+ i = R + r, o = z - a;
952
1011
  break;
953
1012
  case "nw":
954
- o = q - r, n = M - i;
1013
+ i = R - r, o = z - a;
955
1014
  break;
956
1015
  }
957
- Math.abs(r) > Math.abs(i) ? n = o / P : o = n * P, o = Math.max(50, o), n = Math.max(50, n), m.style.width = `${o}px`, m.style.height = `${n}px`, m.setAttribute("width", String(Math.round(o))), m.setAttribute("height", String(Math.round(n))), z(), C();
1016
+ Math.abs(r) > Math.abs(a) ? o = i / O : i = o * O, i = Math.max(50, i), o = Math.max(50, o), v.style.width = `${i}px`, v.style.height = `${o}px`, v.setAttribute("width", String(Math.round(i))), v.setAttribute("height", String(Math.round(o))), D(), A();
958
1017
  }), document.addEventListener("mouseup", () => {
959
- H && (H = !1, T = null, document.body.style.userSelect = "", document.body.style.cursor = "");
960
- }), window.addEventListener("scroll", z), window.addEventListener("resize", z);
1018
+ I && (I = !1, B = null, document.body.style.userSelect = "", document.body.style.cursor = "");
1019
+ }), window.addEventListener("scroll", D), window.addEventListener("resize", D);
961
1020
  };
962
- typeof window != "undefined" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, X());
963
- const oe = () => ({
1021
+ typeof window != "undefined" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, oe());
1022
+ const ye = () => ({
964
1023
  name: "image",
965
1024
  initialize: (t) => {
966
1025
  const e = t == null ? void 0 : t.editorElement;
967
- X(e);
1026
+ oe(e);
968
1027
  },
969
1028
  toolbar: [
970
1029
  {
@@ -981,11 +1040,11 @@ const oe = () => ({
981
1040
  commands: {
982
1041
  insertImage: (t, e) => {
983
1042
  const r = (e == null ? void 0 : e.contentElement) instanceof HTMLElement ? e.contentElement : void 0;
984
- return F("image", r), !0;
1043
+ return J("image", r), !0;
985
1044
  },
986
1045
  insertVideo: (t, e) => {
987
1046
  const r = (e == null ? void 0 : e.contentElement) instanceof HTMLElement ? e.contentElement : void 0;
988
- return F("video", r), !0;
1047
+ return J("video", r), !0;
989
1048
  }
990
1049
  },
991
1050
  keymap: {
@@ -993,6 +1052,6 @@ const oe = () => ({
993
1052
  }
994
1053
  });
995
1054
  export {
996
- oe as MediaManagerPlugin
1055
+ ye as MediaManagerPlugin
997
1056
  };
998
- //# sourceMappingURL=MediaManagerPlugin.native-BT1NZIJS.mjs.map
1057
+ //# sourceMappingURL=MediaManagerPlugin.native-CRi24Mrb.mjs.map