@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.
Files changed (109) hide show
  1. package/dist/CodePlugin.native-Bwf25lLX.js +460 -0
  2. package/dist/CodePlugin.native-Cpp4u3Jl.mjs +648 -0
  3. package/dist/a11y-checker.cjs.js +16 -16
  4. package/dist/a11y-checker.esm.js +79 -75
  5. package/dist/anchor.cjs.js +9 -9
  6. package/dist/anchor.esm.js +61 -60
  7. package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
  8. package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
  9. package/dist/approval-workflow.cjs.js +5 -5
  10. package/dist/approval-workflow.esm.js +105 -104
  11. package/dist/background-color.cjs.js +1 -1
  12. package/dist/background-color.esm.js +1 -1
  13. package/dist/blocks-library.cjs.js +6 -6
  14. package/dist/blocks-library.esm.js +226 -202
  15. package/dist/capitalization.cjs.js +1 -1
  16. package/dist/capitalization.esm.js +9 -4
  17. package/dist/checklist.cjs.js +1 -1
  18. package/dist/checklist.esm.js +154 -116
  19. package/dist/citations.cjs.js +43 -18
  20. package/dist/citations.esm.js +465 -446
  21. package/dist/clear-formatting.cjs.js +1 -1
  22. package/dist/clear-formatting.esm.js +21 -20
  23. package/dist/code-sample.cjs.js +85 -66
  24. package/dist/code-sample.esm.js +301 -190
  25. package/dist/code.cjs.js +1 -669
  26. package/dist/code.esm.js +2 -4560
  27. package/dist/collaboration.cjs.js +68 -0
  28. package/dist/collaboration.esm.js +7428 -0
  29. package/dist/comments.cjs.js +11 -11
  30. package/dist/comments.esm.js +284 -237
  31. package/dist/conditional-content.cjs.js +67 -60
  32. package/dist/conditional-content.esm.js +270 -220
  33. package/dist/data-binding.cjs.js +3 -3
  34. package/dist/data-binding.esm.js +28 -27
  35. package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
  36. package/dist/dialogHelpers-zU6zpMIA.js +12 -0
  37. package/dist/document-manager.cjs.js +1 -1
  38. package/dist/document-manager.esm.js +1 -1
  39. package/dist/{documentManager-Jf0RbSks.js → documentManager-BDz6tovy.js} +2 -2
  40. package/dist/{documentManager-CTqRftU8.mjs → documentManager-yjRBab4v.mjs} +3 -3
  41. package/dist/embed-iframe.cjs.js +37 -17
  42. package/dist/embed-iframe.esm.js +188 -143
  43. package/dist/emojis.cjs.js +13 -10
  44. package/dist/emojis.esm.js +288 -76
  45. package/dist/enterprise.cjs.js +1 -1
  46. package/dist/enterprise.esm.js +9 -7
  47. package/dist/escapeHtml-D2Zh82pD.js +1 -0
  48. package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
  49. package/dist/font-family.cjs.js +1 -1
  50. package/dist/font-family.esm.js +48 -41
  51. package/dist/font-size.cjs.js +1 -1
  52. package/dist/font-size.esm.js +67 -60
  53. package/dist/format-painter.cjs.js +1 -1
  54. package/dist/format-painter.esm.js +2 -1
  55. package/dist/history.cjs.js +1 -1
  56. package/dist/history.esm.js +40 -36
  57. package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
  58. package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
  59. package/dist/index-Bm1eqYHh.mjs +194 -0
  60. package/dist/index-CoflqYuK.js +30 -0
  61. package/dist/index-CxhJLMPS.js +221 -0
  62. package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
  63. package/dist/index.cjs.js +1 -1
  64. package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
  65. package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
  66. package/dist/index.esm.js +17 -15
  67. package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
  68. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
  69. package/dist/link.cjs.js +17 -13
  70. package/dist/link.esm.js +138 -69
  71. package/dist/list.cjs.js +1 -1
  72. package/dist/list.esm.js +66 -33
  73. package/dist/math.cjs.js +22 -22
  74. package/dist/math.esm.js +221 -126
  75. package/dist/media-manager.cjs.js +12 -12
  76. package/dist/media-manager.esm.js +55 -50
  77. package/dist/mentions.cjs.js +2 -2
  78. package/dist/mentions.esm.js +17 -12
  79. package/dist/merge-tag.cjs.js +2 -2
  80. package/dist/merge-tag.esm.js +43 -42
  81. package/dist/plugins.css +1 -1
  82. package/dist/preview.cjs.js +3 -3
  83. package/dist/preview.esm.js +30 -27
  84. package/dist/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
  85. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
  86. package/dist/slash-commands.cjs.js +13 -7
  87. package/dist/slash-commands.esm.js +90 -79
  88. package/dist/smart-paste.cjs.js +5 -5
  89. package/dist/smart-paste.esm.js +85 -81
  90. package/dist/special-characters.cjs.js +6 -3
  91. package/dist/special-characters.esm.js +72 -25
  92. package/dist/spell-check.cjs.js +8 -8
  93. package/dist/spell-check.esm.js +10189 -295
  94. package/dist/table.cjs.js +166 -13
  95. package/dist/table.esm.js +543 -266
  96. package/dist/template.cjs.js +11 -11
  97. package/dist/template.esm.js +290 -264
  98. package/dist/text-color.cjs.js +1 -1
  99. package/dist/text-color.esm.js +1 -1
  100. package/dist/translation-workflow.cjs.js +4 -4
  101. package/dist/translation-workflow.esm.js +33 -31
  102. package/dist/version-diff.cjs.js +6 -6
  103. package/dist/version-diff.esm.js +40 -40
  104. package/package.json +10 -4
  105. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  106. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  107. package/dist/index-BFsKNTTj.mjs +0 -145
  108. package/dist/index-CvJk4DKa.js +0 -221
  109. package/dist/index-tqLTHcO6.js +0 -1
@@ -1,12 +1,13 @@
1
- const D = [
1
+ import { i as M } from "./dialogHelpers-5d5BuOCW.mjs";
2
+ const j = [
2
3
  { label: "Inline Value", value: "inline" },
3
4
  { label: "Responsive - 21x9", value: "21x9" },
4
5
  { label: "Responsive - 16x9", value: "16x9" },
5
6
  { label: "Responsive - 4x3", value: "4x3" },
6
7
  { label: "Responsive - 1x1", value: "1x1" }
7
- ], u = '[data-theme="dark"], .dark, .editora-theme-dark';
8
+ ], h = '[data-theme="dark"], .dark, .editora-theme-dark';
8
9
  let c = null;
9
- const v = /* @__PURE__ */ new WeakMap(), s = (e) => (v.has(e) || v.set(e, {
10
+ const E = /* @__PURE__ */ new WeakMap(), s = (e) => (E.has(e) || E.set(e, {
10
11
  dialogElement: null,
11
12
  escapeHandler: null,
12
13
  savedRange: null,
@@ -24,14 +25,14 @@ const v = /* @__PURE__ */ new WeakMap(), s = (e) => (v.has(e) || v.set(e, {
24
25
  showBorder: !0,
25
26
  enableScrollbar: !0
26
27
  }
27
- }), v.get(e));
28
- function C(e) {
29
- return e?.matches(u) || e?.closest(u) || document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
28
+ }), E.get(e));
29
+ function U(e) {
30
+ return e?.matches(h) || e?.closest(h) || document.activeElement?.closest(h) ? !0 : document.body.matches(h) || document.documentElement.matches(h);
30
31
  }
31
- function x(e) {
32
+ function L(e) {
32
33
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
33
34
  }
34
- function R(e) {
35
+ function P(e) {
35
36
  const t = e?.editorElement;
36
37
  if (t instanceof HTMLElement) return t;
37
38
  const r = e?.contentElement;
@@ -41,31 +42,31 @@ function R(e) {
41
42
  }
42
43
  const o = window.__editoraCommandEditorRoot;
43
44
  if (o instanceof HTMLElement) return o;
44
- const a = window.getSelection();
45
- if (a && a.rangeCount > 0) {
46
- const l = x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
45
+ const n = window.getSelection();
46
+ if (n && n.rangeCount > 0) {
47
+ const l = L(n.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
47
48
  if (l instanceof HTMLElement) return l;
48
49
  }
49
- const n = document.activeElement;
50
- if (n instanceof HTMLElement) {
51
- const i = n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
50
+ const a = document.activeElement;
51
+ if (a instanceof HTMLElement) {
52
+ const i = a.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
52
53
  if (i instanceof HTMLElement) return i;
53
54
  }
54
55
  return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
55
56
  }
56
- function w(e) {
57
+ function I(e) {
57
58
  return e.getAttribute("contenteditable") === "true" ? e : e.querySelector('.rte-content, .editora-content, [contenteditable="true"]');
58
59
  }
59
- function h(e) {
60
- return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
60
+ function v(e) {
61
+ return L(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
61
62
  }
62
- function L(e) {
63
+ function O(e) {
63
64
  const t = window.getSelection();
64
65
  if (!t || t.rangeCount === 0) return null;
65
66
  const r = t.getRangeAt(0);
66
67
  return !e.contains(r.startContainer) || !e.contains(r.endContainer) ? null : r.cloneRange();
67
68
  }
68
- function k(e, t, r) {
69
+ function T(e, t, r) {
69
70
  if (t !== r) {
70
71
  if (typeof window.execEditorCommand == "function") {
71
72
  window.execEditorCommand("recordDomTransaction", e, t, r);
@@ -78,67 +79,67 @@ function k(e, t, r) {
78
79
  }
79
80
  }
80
81
  }
81
- function I(e, t) {
82
+ function $(e, t) {
82
83
  let r = t;
83
84
  for (; r && r.parentNode && r.parentNode !== e; )
84
85
  r = r.parentNode;
85
86
  return r && r.parentNode === e ? r : null;
86
87
  }
87
- function y(e, t) {
88
+ function C(e, t) {
88
89
  return e.tagName !== "P" ? !1 : Array.from(e.childNodes).every((r) => r === t ? !0 : r.nodeType === Node.ELEMENT_NODE ? r.tagName === "BR" : r.nodeType === Node.TEXT_NODE && !r.textContent?.trim());
89
90
  }
90
- function T(e) {
91
+ function B(e) {
91
92
  if (!(e instanceof Element)) return null;
92
93
  const t = e.closest("iframe");
93
94
  if (t instanceof HTMLIFrameElement) {
94
- const n = h(t);
95
- if (!n) return null;
95
+ const a = v(t);
96
+ if (!a) return null;
96
97
  const i = t.parentElement;
97
- return i && i.parentElement === n && y(i, t) ? i : t;
98
+ return i && i.parentElement === a && C(i, t) ? i : t;
98
99
  }
99
100
  const r = e.closest("p");
100
101
  if (!(r instanceof HTMLElement)) return null;
101
- const o = h(r);
102
+ const o = v(r);
102
103
  if (!o || r.parentElement !== o) return null;
103
- const a = Array.from(r.children).find(
104
- (n) => n instanceof HTMLIFrameElement
104
+ const n = Array.from(r.children).find(
105
+ (a) => a instanceof HTMLIFrameElement
105
106
  );
106
- return a && y(r, a) ? r : null;
107
+ return n && C(r, n) ? r : null;
107
108
  }
108
- function f() {
109
+ function m() {
109
110
  c && (c.classList.remove("rte-selected-embed-object"), c.querySelector("iframe")?.removeAttribute("data-rte-selected-object"), c instanceof HTMLIFrameElement && c.removeAttribute("data-rte-selected-object"), c = null);
110
111
  }
111
- function H(e) {
112
+ function F(e) {
112
113
  if (c === e) return;
113
- f(), c = e, e.classList.add("rte-selected-embed-object"), (e instanceof HTMLIFrameElement ? e : e.querySelector("iframe"))?.setAttribute("data-rte-selected-object", "true");
114
+ m(), c = e, e.classList.add("rte-selected-embed-object"), (e instanceof HTMLIFrameElement ? e : e.querySelector("iframe"))?.setAttribute("data-rte-selected-object", "true");
114
115
  const r = window.getSelection();
115
116
  if (!r) return;
116
117
  const o = document.createRange();
117
118
  o.selectNode(e), r.removeAllRanges(), r.addRange(o);
118
119
  }
119
- function N(e, t) {
120
+ function _(e, t) {
120
121
  const r = window.getSelection();
121
122
  if (!r) return;
122
123
  const o = document.createRange();
123
124
  t && t.parentNode === e ? o.setStartBefore(t) : (o.selectNodeContents(e), o.collapse(!1)), o.collapse(!0), r.removeAllRanges(), r.addRange(o);
124
125
  }
125
- function q(e) {
126
+ function V(e) {
126
127
  if (e.childNodes.length > 0) return;
127
128
  const t = document.createElement("p");
128
129
  t.appendChild(document.createElement("br")), e.appendChild(t);
129
130
  }
130
- function A() {
131
+ function Z() {
131
132
  if (!c || !c.isConnected)
132
- return f(), !1;
133
- const e = c, t = h(e);
133
+ return m(), !1;
134
+ const e = c, t = v(e);
134
135
  if (!t)
135
- return f(), !1;
136
+ return m(), !1;
136
137
  const r = t.innerHTML, o = e.nextSibling;
137
- e.remove(), q(t), f(), N(t, o);
138
- const a = t.innerHTML;
139
- return k(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
138
+ e.remove(), V(t), m(), _(t, o);
139
+ const n = t.innerHTML;
140
+ return T(t, r, n), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== n;
140
141
  }
141
- function E() {
142
+ function A() {
142
143
  if (document.getElementById("embed-iframe-object-selection-styles")) return;
143
144
  const e = document.createElement("style");
144
145
  e.id = "embed-iframe-object-selection-styles", e.textContent = `
@@ -160,25 +161,25 @@ function E() {
160
161
  }
161
162
  `, document.head.appendChild(e);
162
163
  }
163
- function M() {
164
- typeof window > "u" || window.__embedIframeObjectSelectionInitialized || (window.__embedIframeObjectSelectionInitialized = !0, E(), document.addEventListener("pointerdown", (e) => {
165
- const t = T(e.target);
164
+ function W() {
165
+ typeof window > "u" || window.__embedIframeObjectSelectionInitialized || (window.__embedIframeObjectSelectionInitialized = !0, A(), document.addEventListener("pointerdown", (e) => {
166
+ const t = B(e.target);
166
167
  if (!t) {
167
- e.target?.closest?.(".rte-embed-iframe-overlay") || f();
168
+ e.target?.closest?.(".rte-embed-iframe-overlay") || m();
168
169
  return;
169
170
  }
170
- e.preventDefault(), h(t)?.focus(), H(t);
171
+ e.preventDefault(), v(t)?.focus(), F(t);
171
172
  }, !0), document.addEventListener("keydown", (e) => {
172
173
  if (c) {
173
174
  if (e.key === "Escape") {
174
- f();
175
+ m();
175
176
  return;
176
177
  }
177
- e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), A());
178
+ e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), Z());
178
179
  }
179
180
  }, !0));
180
181
  }
181
- function z(e) {
182
+ function G(e) {
182
183
  try {
183
184
  const t = new URL(e), r = t.hostname.replace(/^www\./, "");
184
185
  if (r === "youtu.be") {
@@ -188,8 +189,8 @@ function z(e) {
188
189
  if (r === "youtube.com" || r === "m.youtube.com") {
189
190
  const o = t.searchParams.get("v");
190
191
  if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
191
- const a = t.pathname.match(/^\/embed\/([^/]+)/);
192
- if (a?.[1]) return `https://www.youtube.com/embed/${encodeURIComponent(a[1])}`;
192
+ const n = t.pathname.match(/^\/embed\/([^/]+)/);
193
+ if (n?.[1]) return `https://www.youtube.com/embed/${encodeURIComponent(n[1])}`;
193
194
  }
194
195
  if (r === "vimeo.com") {
195
196
  const o = t.pathname.split("/").filter(Boolean)[0];
@@ -200,9 +201,18 @@ function z(e) {
200
201
  return e;
201
202
  }
202
203
  }
203
- const W = () => ({
204
+ function R(e) {
205
+ if (/\s/.test(e)) return !1;
206
+ try {
207
+ const t = new URL(e);
208
+ return (t.protocol === "https:" || t.protocol === "http:") && t.hostname.length > 0;
209
+ } catch {
210
+ return !1;
211
+ }
212
+ }
213
+ const ne = () => ({
204
214
  name: "embedIframe",
205
- init: M,
215
+ init: W,
206
216
  toolbar: [
207
217
  {
208
218
  label: "Embed Content",
@@ -213,23 +223,23 @@ const W = () => ({
213
223
  }
214
224
  ],
215
225
  commands: {
216
- openEmbedIframeDialog: (e, t) => (j(R(t) || void 0), !0)
226
+ openEmbedIframeDialog: (e, t) => (K(P(t) || void 0), !0)
217
227
  },
218
228
  keymap: {
219
229
  "Mod-Shift-e": "openEmbedIframeDialog"
220
230
  }
221
231
  });
222
- function j(e) {
223
- if (!e) {
224
- const n = document.activeElement;
225
- n && n.closest("[data-editora-editor]") && (e = n.closest("[data-editora-editor]"));
232
+ function K(e) {
233
+ if (document.querySelectorAll(".rte-embed-iframe-overlay").forEach((a) => a.remove()), !e) {
234
+ const a = document.activeElement;
235
+ a && a.closest("[data-editora-editor]") && (e = a.closest("[data-editora-editor]"));
226
236
  }
227
237
  if (e || (e = document.querySelector("[data-editora-editor]")), !e) {
228
238
  console.warn("Editor element not found");
229
239
  return;
230
240
  }
231
- const t = s(e), r = w(e);
232
- t.savedRange = r ? L(r) : null, t.formData = {
241
+ const t = s(e), r = I(e);
242
+ t.savedRange = r ? O(r) : null, t.formData = {
233
243
  src: "",
234
244
  selectedSize: "inline",
235
245
  width: "100%",
@@ -243,12 +253,12 @@ function j(e) {
243
253
  enableScrollbar: !0
244
254
  }, t.activeTab = "general";
245
255
  const o = document.createElement("div");
246
- o.className = "rte-dialog-overlay rte-embed-iframe-overlay", C(e) && o.classList.add("rte-theme-dark"), o.onclick = () => b(e);
247
- const a = document.createElement("div");
248
- a.className = "rte-dialog-content embed-iframe-dialog", a.onclick = (n) => n.stopPropagation(), a.innerHTML = `
256
+ M(o), o.className = "rte-dialog-overlay rte-embed-iframe-overlay", U(e) && o.classList.add("rte-theme-dark"), o.onclick = () => g(e);
257
+ const n = document.createElement("div");
258
+ n.className = "rte-dialog-content embed-iframe-dialog", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-labelledby", "embed-iframe-dialog-title"), n.onclick = (a) => a.stopPropagation(), n.innerHTML = `
249
259
  <div class="rte-dialog-header">
250
- <h3>Embed Iframe</h3>
251
- <button class="rte-dialog-close">×</button>
260
+ <h3 id="embed-iframe-dialog-title">Embed Iframe</h3>
261
+ <button type="button" class="rte-dialog-close" aria-label="Close">×</button>
252
262
  </div>
253
263
  <div class="rte-dialog-body">
254
264
  <div class="rte-vertical-tabs">
@@ -259,22 +269,23 @@ function j(e) {
259
269
  <div class="rte-tab-content">
260
270
  <div class="rte-tab-panel" data-panel="general" style="display: block;">
261
271
  <div class="rte-form-group">
262
- <label class="rte-form-label">Source</label>
263
- <input type="url" class="rte-form-input" id="iframe-src" placeholder="https://example.com" required />
272
+ <label class="rte-form-label" for="iframe-src">Source</label>
273
+ <input type="url" class="rte-form-input" id="iframe-src" placeholder="https://example.com" required aria-describedby="iframe-src-error" />
274
+ <div class="rte-form-error" id="iframe-src-error" role="alert" hidden></div>
264
275
  </div>
265
276
  <div class="rte-form-group">
266
- <label class="rte-form-label">Size</label>
277
+ <label class="rte-form-label" for="iframe-size">Size</label>
267
278
  <select class="rte-form-select" id="iframe-size">
268
- ${D.map((n) => `<option value="${n.value}">${n.label}</option>`).join("")}
279
+ ${j.map((a) => `<option value="${a.value}">${a.label}</option>`).join("")}
269
280
  </select>
270
281
  </div>
271
282
  <div class="rte-form-row" id="dimensions-row">
272
283
  <div class="rte-form-group">
273
- <label class="rte-form-label">Width</label>
284
+ <label class="rte-form-label" for="iframe-width">Width</label>
274
285
  <input type="text" class="rte-form-input" id="iframe-width" placeholder="100%" value="100%" />
275
286
  </div>
276
287
  <div class="rte-form-group">
277
- <label class="rte-form-label">Height</label>
288
+ <label class="rte-form-label" for="iframe-height">Height</label>
278
289
  <input type="text" class="rte-form-input" id="iframe-height" placeholder="400px" value="400px" />
279
290
  </div>
280
291
  <div class="rte-form-group constrain-group">
@@ -284,20 +295,21 @@ function j(e) {
284
295
  </div>
285
296
  <div class="rte-tab-panel" data-panel="advanced" style="display: none;">
286
297
  <div class="rte-form-group">
287
- <label class="rte-form-label">Name</label>
298
+ <label class="rte-form-label" for="iframe-name">Name</label>
288
299
  <input type="text" class="rte-form-input" id="iframe-name" placeholder="Iframe name" />
289
300
  </div>
290
301
  <div class="rte-form-group">
291
- <label class="rte-form-label">Title</label>
302
+ <label class="rte-form-label" for="iframe-title">Title</label>
292
303
  <input type="text" class="rte-form-input" id="iframe-title" placeholder="Iframe title" />
293
304
  </div>
294
305
  <div class="rte-form-group">
295
- <label class="rte-form-label">Long Description</label>
306
+ <label class="rte-form-label" for="iframe-longdesc">Long Description</label>
296
307
  <textarea class="rte-form-textarea" id="iframe-longdesc" placeholder="Detailed description of the iframe content" rows="3"></textarea>
297
308
  </div>
298
309
  <div class="rte-form-group">
299
- <label class="rte-form-label">Description URL</label>
300
- <input type="url" class="rte-form-input" id="iframe-desc-url" placeholder="https://example.com/description" />
310
+ <label class="rte-form-label" for="iframe-desc-url">Description URL</label>
311
+ <input type="url" class="rte-form-input" id="iframe-desc-url" placeholder="https://example.com/description" aria-describedby="iframe-desc-url-error" />
312
+ <div class="rte-form-error" id="iframe-desc-url-error" role="alert" hidden></div>
301
313
  </div>
302
314
  <div class="rte-form-group">
303
315
  <label class="rte-checkbox-label">
@@ -319,115 +331,130 @@ function j(e) {
319
331
  <button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
320
332
  <button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
321
333
  </div>
322
- `, o.appendChild(a), document.body.appendChild(o), t.dialogElement = o, t.escapeHandler = (n) => {
323
- n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), b(e));
324
- }, document.addEventListener("keydown", t.escapeHandler, !0), P(a, e), V(), setTimeout(() => {
325
- a.querySelector("#iframe-src")?.focus();
334
+ `, o.appendChild(n), document.body.appendChild(o), t.dialogElement = o, t.escapeHandler = (a) => {
335
+ a.key === "Escape" && (a.preventDefault(), a.stopPropagation(), g(e));
336
+ }, document.addEventListener("keydown", t.escapeHandler, !0), X(n, e), oe(), setTimeout(() => {
337
+ n.querySelector("#iframe-src")?.focus();
326
338
  }, 100);
327
339
  }
328
- function P(e, t) {
329
- s(t), e.querySelector(".rte-dialog-close")?.addEventListener("click", () => b(t)), e.querySelectorAll(".rte-tab-button").forEach((n) => {
330
- n.addEventListener("click", (i) => {
340
+ function X(e, t) {
341
+ e.querySelector(".rte-dialog-close")?.addEventListener("click", () => g(t)), e.querySelectorAll(".rte-tab-button").forEach((a) => {
342
+ a.addEventListener("click", (i) => {
331
343
  const l = i.target.getAttribute("data-tab");
332
- l && O(e, l, t);
344
+ l && q(e, l, t);
333
345
  });
334
- }), e.querySelector("#iframe-size")?.addEventListener("change", (n) => B(e, n.target.value, t));
335
- const o = e.querySelector("#iframe-width"), a = e.querySelector("#iframe-height");
336
- o?.addEventListener("input", (n) => U(e, n.target.value, t)), a?.addEventListener("input", (n) => _(e, n.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => $(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => b(t)), e.querySelector("#save-btn")?.addEventListener("click", () => F(e, t));
346
+ }), e.querySelector("#iframe-size")?.addEventListener("change", (a) => J(e, a.target.value, t));
347
+ const o = e.querySelector("#iframe-width"), n = e.querySelector("#iframe-height");
348
+ o?.addEventListener("input", (a) => Q(e, a.target.value, t)), n?.addEventListener("input", (a) => Y(e, a.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => ee(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => g(t)), e.querySelector("#save-btn")?.addEventListener("click", () => te(e, t));
337
349
  }
338
- function O(e, t, r) {
350
+ function q(e, t, r) {
339
351
  const o = s(r);
340
- o.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((a) => {
341
- a.classList.toggle("active", a.getAttribute("data-tab") === t);
342
- }), e.querySelectorAll(".rte-tab-panel").forEach((a) => {
343
- a.style.display = a.getAttribute("data-panel") === t ? "block" : "none";
352
+ o.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((n) => {
353
+ n.classList.toggle("active", n.getAttribute("data-tab") === t);
354
+ }), e.querySelectorAll(".rte-tab-panel").forEach((n) => {
355
+ n.style.display = n.getAttribute("data-panel") === t ? "block" : "none";
344
356
  });
345
357
  }
346
- function B(e, t, r) {
358
+ function J(e, t, r) {
347
359
  const o = s(r);
348
360
  o.formData.selectedSize = t;
349
- const a = e.querySelector("#dimensions-row"), n = e.querySelector("#iframe-width"), i = e.querySelector("#iframe-height");
350
- t === "inline" ? (a.style.display = "flex", n.value = "100%", i.value = "400px", o.formData.width = "100%", o.formData.height = "400px") : (a.style.display = "none", o.formData.width = "100%", o.formData.height = "auto");
361
+ const n = e.querySelector("#dimensions-row"), a = e.querySelector("#iframe-width"), i = e.querySelector("#iframe-height");
362
+ t === "inline" ? (n.style.display = "flex", a.value = "100%", i.value = "400px", o.formData.width = "100%", o.formData.height = "400px") : (n.style.display = "none", o.formData.width = "100%", o.formData.height = "auto");
351
363
  }
352
- function U(e, t, r) {
364
+ function Q(e, t, r) {
353
365
  const o = s(r);
354
366
  if (o.formData.width = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
355
- const a = parseFloat(t);
356
- if (!isNaN(a)) {
357
- const n = a * 9 / 16;
358
- o.formData.height = `${n}px`;
367
+ const n = parseFloat(t);
368
+ if (!isNaN(n)) {
369
+ const a = n * 9 / 16;
370
+ o.formData.height = `${a}px`;
359
371
  const i = e.querySelector("#iframe-height");
360
372
  i && (i.value = o.formData.height);
361
373
  }
362
374
  }
363
375
  }
364
- function _(e, t, r) {
376
+ function Y(e, t, r) {
365
377
  const o = s(r);
366
378
  if (o.formData.height = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
367
- const a = parseFloat(t);
368
- if (!isNaN(a)) {
369
- const n = a * 16 / 9;
370
- o.formData.width = `${n}px`;
379
+ const n = parseFloat(t);
380
+ if (!isNaN(n)) {
381
+ const a = n * 16 / 9;
382
+ o.formData.width = `${a}px`;
371
383
  const i = e.querySelector("#iframe-width");
372
384
  i && (i.value = o.formData.width);
373
385
  }
374
386
  }
375
387
  }
376
- function $(e, t) {
388
+ function ee(e, t) {
377
389
  const r = s(t);
378
390
  r.formData.constrainProportions = !r.formData.constrainProportions;
379
391
  const o = e.querySelector("#constrain-btn");
380
392
  o && (o.textContent = r.formData.constrainProportions ? "🔒" : "🔓", o.className = `rte-constrain-btn ${r.formData.constrainProportions ? "locked" : "unlocked"}`, o.title = r.formData.constrainProportions ? "Unlock proportions" : "Lock proportions");
381
393
  }
382
- function F(e, t) {
383
- const r = s(t), o = e.querySelector("#iframe-src")?.value.trim();
384
- if (!o) {
385
- alert("Please enter a source URL");
394
+ function te(e, t) {
395
+ const r = s(t), o = e.querySelector("#iframe-src"), n = e.querySelector("#iframe-desc-url");
396
+ let a = o?.value.trim() || "";
397
+ a && !/^[a-z][a-z0-9+.-]*:/i.test(a) && /^[^\s/]+\.[^\s/]+/.test(a) && (a = `https://${a}`, o && (o.value = a));
398
+ const i = (b, w, p, z) => {
399
+ q(e, z, t);
400
+ const k = e.querySelector(`#${w}`);
401
+ k && (k.textContent = p, k.hidden = !1), b && (b.setAttribute("aria-invalid", "true"), b.focus());
402
+ }, l = (b, w) => {
403
+ const p = e.querySelector(`#${w}`);
404
+ p && (p.textContent = "", p.hidden = !0), b?.removeAttribute("aria-invalid");
405
+ };
406
+ if (l(o, "iframe-src-error"), l(n, "iframe-desc-url-error"), !a) {
407
+ i(o, "iframe-src-error", "Please enter a source URL.", "general");
408
+ return;
409
+ }
410
+ if (!R(a)) {
411
+ i(o, "iframe-src-error", "Enter a valid URL starting with https:// or http://.", "general");
386
412
  return;
387
413
  }
388
- if (!o.startsWith("https://") && !o.startsWith("http://")) {
389
- alert("Please enter a valid URL starting with https:// or http://");
414
+ const d = n?.value.trim() || "";
415
+ if (d && !R(d)) {
416
+ i(n, "iframe-desc-url-error", "Enter a valid URL starting with https:// or http://.", "advanced");
390
417
  return;
391
418
  }
392
- const a = e.querySelector("#iframe-name")?.value.trim(), n = e.querySelector("#iframe-title")?.value.trim(), i = e.querySelector("#iframe-longdesc")?.value.trim(), l = e.querySelector("#iframe-desc-url")?.value.trim(), p = e.querySelector("#iframe-border")?.checked ?? !0, g = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
393
- let d = r.formData.width, m = r.formData.height;
394
- r.formData.selectedSize !== "inline" && (d = "100%", m = "auto"), Z(t, {
395
- src: o,
396
- width: d,
397
- height: m,
419
+ const y = e.querySelector("#iframe-name")?.value.trim(), f = e.querySelector("#iframe-title")?.value.trim(), u = e.querySelector("#iframe-longdesc")?.value.trim(), x = d, H = e.querySelector("#iframe-border")?.checked ?? !0, N = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
420
+ let S = r.formData.width, D = r.formData.height;
421
+ r.formData.selectedSize !== "inline" && (S = "100%", D = "auto"), re(t, {
422
+ src: a,
423
+ width: S,
424
+ height: D,
398
425
  aspectRatio: r.formData.selectedSize,
399
- name: a || void 0,
400
- title: n || void 0,
401
- longDescription: i || void 0,
402
- descriptionUrl: l || void 0,
403
- showBorder: p,
404
- enableScrollbar: g
405
- }), b(t);
426
+ name: y || void 0,
427
+ title: f || void 0,
428
+ longDescription: u || void 0,
429
+ descriptionUrl: x || void 0,
430
+ showBorder: H,
431
+ enableScrollbar: N
432
+ }), g(t);
406
433
  }
407
- function Z(e, t) {
408
- const r = s(e), o = w(e);
434
+ function re(e, t) {
435
+ const r = s(e), o = I(e);
409
436
  if (!o) return;
410
- const a = o.innerHTML, n = document.createElement("iframe");
411
- n.src = z(t.src), n.width = t.width, n.height = t.height, n.allowFullscreen = !0, n.setAttribute("frameborder", t.showBorder ? "1" : "0"), n.setAttribute("scrolling", t.enableScrollbar ? "auto" : "no"), n.setAttribute("data-aspect-ratio", t.aspectRatio), t.aspectRatio !== "inline" && n.classList.add(`rte-iframe-${t.aspectRatio}`), t.name && (n.name = t.name), t.title && (n.title = t.title), t.longDescription && n.setAttribute("data-long-description", t.longDescription), t.descriptionUrl && n.setAttribute("longdesc", t.descriptionUrl);
437
+ const n = o.innerHTML, a = document.createElement("iframe");
438
+ a.src = G(t.src), a.width = t.width, a.height = t.height, a.allowFullscreen = !0, a.setAttribute("frameborder", t.showBorder ? "1" : "0"), a.setAttribute("scrolling", t.enableScrollbar ? "auto" : "no"), a.setAttribute("data-aspect-ratio", t.aspectRatio), a.setAttribute("data-editora-embed", "true"), t.aspectRatio !== "inline" && a.classList.add(`rte-iframe-${t.aspectRatio}`), t.name && (a.name = t.name), t.title && (a.title = t.title), t.longDescription && a.setAttribute("data-long-description", t.longDescription), t.descriptionUrl && a.setAttribute("longdesc", t.descriptionUrl);
412
439
  const i = document.createElement("p");
413
- i.appendChild(n), i.appendChild(document.createElement("br"));
440
+ i.appendChild(a), i.appendChild(document.createElement("br"));
414
441
  const l = r.savedRange && o.contains(r.savedRange.commonAncestorContainer) ? r.savedRange : document.createRange();
415
442
  (!r.savedRange || !o.contains(r.savedRange.commonAncestorContainer)) && (l.selectNodeContents(o), l.collapse(!1));
416
- const p = I(o, l.startContainer), g = p ? p.nextSibling : null;
417
- o.insertBefore(i, g);
418
- const d = document.createRange();
419
- d.setStartAfter(i), d.collapse(!0);
420
- const m = window.getSelection();
421
- m && (m.removeAllRanges(), m.addRange(d)), r.savedRange = null;
422
- const S = o.innerHTML;
423
- k(o, a, S), o.dispatchEvent(new window.Event("input", { bubbles: !0 }));
443
+ const d = $(o, l.startContainer), y = d ? d.nextSibling : null;
444
+ o.insertBefore(i, y);
445
+ const f = document.createRange();
446
+ f.setStartAfter(i), f.collapse(!0);
447
+ const u = window.getSelection();
448
+ u && (u.removeAllRanges(), u.addRange(f)), r.savedRange = null;
449
+ const x = o.innerHTML;
450
+ T(o, n, x), o.dispatchEvent(new CustomEvent("input", { bubbles: !0, detail: { allowedTags: ["iframe"] } }));
424
451
  }
425
- function b(e) {
452
+ function g(e) {
426
453
  const t = s(e);
427
454
  t.savedRange = null, t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
428
455
  }
429
- function V() {
430
- if (E(), document.getElementById("embed-iframe-dialog-styles")) return;
456
+ function oe() {
457
+ if (A(), document.getElementById("embed-iframe-dialog-styles")) return;
431
458
  const e = document.createElement("style");
432
459
  e.id = "embed-iframe-dialog-styles", e.textContent = `
433
460
  /* Embed Iframe Dialog Styles */
@@ -496,6 +523,24 @@ function V() {
496
523
  }
497
524
 
498
525
  .rte-form-textarea,
526
+ .rte-form-error {
527
+ margin-top: 4px;
528
+ font-size: 12px;
529
+ color: #c62828;
530
+ }
531
+
532
+ .rte-form-error[hidden] {
533
+ display: none;
534
+ }
535
+
536
+ .rte-form-input[aria-invalid="true"] {
537
+ border-color: #c62828;
538
+ }
539
+
540
+ .rte-embed-iframe-overlay.rte-theme-dark .rte-form-error {
541
+ color: #ff8a80;
542
+ }
543
+
499
544
  .rte-form-input,
500
545
  .rte-form-select {
501
546
  width: 100%;
@@ -718,5 +763,5 @@ function V() {
718
763
  `, document.head.appendChild(e);
719
764
  }
720
765
  export {
721
- W as EmbedIframePlugin
766
+ ne as EmbedIframePlugin
722
767
  };