@editora/plugins 1.0.2 → 1.0.5

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 (105) hide show
  1. package/README.md +30 -5
  2. package/dist/a11y-checker.cjs.js +109 -0
  3. package/dist/a11y-checker.esm.js +509 -0
  4. package/dist/anchor.cjs.js +176 -0
  5. package/dist/anchor.esm.js +400 -0
  6. package/dist/background-color.cjs.js +218 -0
  7. package/dist/background-color.esm.js +482 -0
  8. package/dist/blockquote.cjs.js +1 -0
  9. package/dist/blockquote.esm.js +47 -0
  10. package/dist/bold.cjs.js +1 -0
  11. package/dist/bold.esm.js +44 -0
  12. package/dist/capitalization.cjs.js +1 -0
  13. package/dist/capitalization.esm.js +78 -0
  14. package/dist/checklist.cjs.js +1 -0
  15. package/dist/checklist.esm.js +305 -0
  16. package/dist/clear-formatting.cjs.js +1 -0
  17. package/dist/clear-formatting.esm.js +138 -0
  18. package/dist/code-sample.cjs.js +161 -0
  19. package/dist/code-sample.esm.js +381 -0
  20. package/dist/code.cjs.js +606 -0
  21. package/dist/code.esm.js +2164 -0
  22. package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
  23. package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
  24. package/dist/comments.cjs.js +354 -0
  25. package/dist/comments.esm.js +692 -0
  26. package/dist/direction.cjs.js +1 -0
  27. package/dist/direction.esm.js +129 -0
  28. package/dist/document-manager.cjs.js +1 -0
  29. package/dist/document-manager.esm.js +6 -0
  30. package/dist/{documentManager-CYC9totK.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
  31. package/dist/{documentManager-BGlu3WRB.js → documentManager-_tQQfQi9.js} +3 -3
  32. package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
  33. package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
  34. package/dist/embed-iframe.cjs.js +361 -0
  35. package/dist/embed-iframe.esm.js +556 -0
  36. package/dist/emojis.cjs.js +284 -0
  37. package/dist/emojis.esm.js +1080 -0
  38. package/dist/font-family.cjs.js +1 -0
  39. package/dist/font-family.esm.js +152 -0
  40. package/dist/font-size.cjs.js +1 -0
  41. package/dist/font-size.esm.js +278 -0
  42. package/dist/footnote.cjs.js +85 -0
  43. package/dist/footnote.esm.js +397 -0
  44. package/dist/fullscreen.cjs.js +1 -0
  45. package/dist/fullscreen.esm.js +73 -0
  46. package/dist/heading.cjs.js +1 -0
  47. package/dist/heading.esm.js +63 -0
  48. package/dist/history.cjs.js +1 -0
  49. package/dist/history.esm.js +246 -0
  50. package/dist/indent.cjs.js +1 -0
  51. package/dist/indent.esm.js +146 -0
  52. package/dist/index-Bskk414V.mjs +145 -0
  53. package/dist/index-D3pJyAsj.js +1 -0
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/{index.es-B-to-4j4.js → index.es-Cz1qItab.js} +1 -1
  56. package/dist/{index.es-BbXJ7tyO.mjs → index.es-DEcRmSTY.mjs} +1 -1
  57. package/dist/index.esm.js +89 -49
  58. package/dist/italic.cjs.js +1 -0
  59. package/dist/italic.esm.js +40 -0
  60. package/dist/line-height.cjs.js +1 -0
  61. package/dist/line-height.esm.js +145 -0
  62. package/dist/link.cjs.js +138 -0
  63. package/dist/link.esm.js +276 -0
  64. package/dist/list.cjs.js +1 -0
  65. package/dist/list.esm.js +102 -0
  66. package/dist/lite.cjs.js +1 -0
  67. package/dist/lite.esm.js +61 -0
  68. package/dist/math.cjs.js +45 -0
  69. package/dist/math.esm.js +249 -0
  70. package/dist/media-manager.cjs.js +619 -0
  71. package/dist/media-manager.esm.js +994 -0
  72. package/dist/merge-tag.cjs.js +93 -0
  73. package/dist/merge-tag.esm.js +412 -0
  74. package/dist/page-break.cjs.js +72 -0
  75. package/dist/page-break.esm.js +295 -0
  76. package/dist/plugins.css +1 -1
  77. package/dist/preview.cjs.js +230 -0
  78. package/dist/preview.esm.js +321 -0
  79. package/dist/print.cjs.js +254 -0
  80. package/dist/print.esm.js +309 -0
  81. package/dist/purify.es-DHhaBdbu.mjs +470 -0
  82. package/dist/purify.es-T2a3nLiC.js +3 -0
  83. package/dist/shared-config.cjs.js +1 -0
  84. package/dist/shared-config.esm.js +30 -0
  85. package/dist/special-characters.cjs.js +257 -0
  86. package/dist/special-characters.esm.js +772 -0
  87. package/dist/spell-check.cjs.js +512 -0
  88. package/dist/spell-check.esm.js +1013 -0
  89. package/dist/strikethrough.cjs.js +1 -0
  90. package/dist/strikethrough.esm.js +71 -0
  91. package/dist/table.cjs.js +35 -0
  92. package/dist/table.esm.js +477 -0
  93. package/dist/template.cjs.js +356 -0
  94. package/dist/template.esm.js +560 -0
  95. package/dist/text-alignment.cjs.js +1 -0
  96. package/dist/text-alignment.esm.js +105 -0
  97. package/dist/text-color.cjs.js +300 -0
  98. package/dist/text-color.esm.js +507 -0
  99. package/dist/underline.cjs.js +1 -0
  100. package/dist/underline.esm.js +34 -0
  101. package/index.d.ts +62 -0
  102. package/package.json +220 -7
  103. package/LICENSE +0 -21
  104. package/dist/index-BbORIHoM.mjs +0 -11763
  105. package/dist/index-C-OCBS_6.js +0 -3753
@@ -0,0 +1,994 @@
1
+ import "./shared-config.esm.js";
2
+ let T = null, s = null, d = null, R = [], A = !1, M = null, U = 0, V = 0, z = 0, $ = 0, _ = 1, I = null;
3
+ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
4
+ if (typeof document > "u" || document.getElementById("rte-media-dialog-styles")) return;
5
+ const e = document.createElement("style");
6
+ e.id = "rte-media-dialog-styles", e.textContent = `
7
+ .rte-media-overlay {
8
+ --rte-media-overlay-bg: rgba(15, 23, 36, 0.56);
9
+ --rte-media-bg: #ffffff;
10
+ --rte-media-text: #101828;
11
+ --rte-media-muted: #5f6b7d;
12
+ --rte-media-border: #d6dbe4;
13
+ --rte-media-surface: #f7f9fc;
14
+ --rte-media-surface-hover: #eef2f7;
15
+ --rte-media-accent: #1f75fe;
16
+ --rte-media-accent-hover: #165fd6;
17
+ --rte-media-danger: #dc3545;
18
+ --rte-media-danger-hover: #b92735;
19
+ --rte-media-ring: rgba(31, 117, 254, 0.18);
20
+ position: fixed;
21
+ top: 0;
22
+ left: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ background: var(--rte-media-overlay-bg);
26
+ backdrop-filter: blur(2px);
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ z-index: 99999;
31
+ padding: 16px;
32
+ box-sizing: border-box;
33
+ }
34
+
35
+ .rte-media-overlay.rte-ui-theme-dark {
36
+ --rte-media-overlay-bg: rgba(2, 8, 20, 0.72);
37
+ --rte-media-bg: #202938;
38
+ --rte-media-text: #e8effc;
39
+ --rte-media-muted: #a5b1c5;
40
+ --rte-media-border: #49566c;
41
+ --rte-media-surface: #2a3444;
42
+ --rte-media-surface-hover: #344256;
43
+ --rte-media-accent: #58a6ff;
44
+ --rte-media-accent-hover: #4598f4;
45
+ --rte-media-danger: #ff7b72;
46
+ --rte-media-danger-hover: #ff645b;
47
+ --rte-media-ring: rgba(88, 166, 255, 0.22);
48
+ }
49
+
50
+ .rte-media-dialog {
51
+ width: min(92vw, 640px);
52
+ max-height: 90vh;
53
+ display: flex;
54
+ flex-direction: column;
55
+ overflow: hidden;
56
+ background: var(--rte-media-bg);
57
+ color: var(--rte-media-text);
58
+ border: 1px solid var(--rte-media-border);
59
+ border-radius: 12px;
60
+ box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
61
+ }
62
+
63
+ .rte-media-dialog.rte-media-dialog-compact {
64
+ width: min(92vw, 520px);
65
+ }
66
+
67
+ .rte-media-header {
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: space-between;
71
+ padding: 16px 20px;
72
+ border-bottom: 1px solid var(--rte-media-border);
73
+ background: linear-gradient(180deg, rgba(127, 154, 195, 0.08) 0%, rgba(127, 154, 195, 0) 100%);
74
+ }
75
+
76
+ .rte-media-title {
77
+ margin: 0;
78
+ font-size: 18px;
79
+ font-weight: 600;
80
+ color: var(--rte-media-text);
81
+ }
82
+
83
+ .rte-media-close-btn {
84
+ width: 32px;
85
+ height: 32px;
86
+ border: none;
87
+ border-radius: 8px;
88
+ background: transparent;
89
+ color: var(--rte-media-muted);
90
+ font-size: 24px;
91
+ line-height: 1;
92
+ cursor: pointer;
93
+ transition: background-color 0.16s ease, color 0.16s ease;
94
+ }
95
+
96
+ .rte-media-close-btn:hover {
97
+ background: var(--rte-media-surface-hover);
98
+ color: var(--rte-media-text);
99
+ }
100
+
101
+ .rte-media-tabs {
102
+ display: grid;
103
+ grid-template-columns: 1fr 1fr;
104
+ border-bottom: 1px solid var(--rte-media-border);
105
+ gap: 0;
106
+ }
107
+
108
+ .rte-media-tab {
109
+ border: none;
110
+ border-right: 1px solid var(--rte-media-border);
111
+ padding: 12px 14px;
112
+ background: var(--rte-media-surface);
113
+ color: var(--rte-media-muted);
114
+ font-size: 14px;
115
+ font-weight: 600;
116
+ cursor: pointer;
117
+ transition: background-color 0.16s ease, color 0.16s ease;
118
+ }
119
+
120
+ .rte-media-tab:last-child {
121
+ border-right: none;
122
+ }
123
+
124
+ .rte-media-tab:hover {
125
+ background: var(--rte-media-surface-hover);
126
+ color: var(--rte-media-text);
127
+ }
128
+
129
+ .rte-media-tab.active {
130
+ background: var(--rte-media-accent);
131
+ color: #fff;
132
+ }
133
+
134
+ .rte-media-body {
135
+ padding: 20px;
136
+ overflow-y: auto;
137
+ flex: 1;
138
+ }
139
+
140
+ .rte-media-field {
141
+ margin-bottom: 16px;
142
+ }
143
+
144
+ .rte-media-grid {
145
+ display: grid;
146
+ grid-template-columns: 1fr 1fr;
147
+ gap: 12px;
148
+ margin-bottom: 16px;
149
+ }
150
+
151
+ .rte-media-label {
152
+ display: block;
153
+ margin-bottom: 8px;
154
+ color: var(--rte-media-text);
155
+ font-size: 14px;
156
+ font-weight: 600;
157
+ }
158
+
159
+ .rte-media-input,
160
+ .rte-media-textarea {
161
+ width: 100%;
162
+ box-sizing: border-box;
163
+ padding: 10px 12px;
164
+ border: 1px solid var(--rte-media-border);
165
+ border-radius: 8px;
166
+ background: var(--rte-media-surface);
167
+ color: var(--rte-media-text);
168
+ font-size: 14px;
169
+ transition: border-color 0.16s ease, box-shadow 0.16s ease;
170
+ }
171
+
172
+ .rte-media-input::placeholder,
173
+ .rte-media-textarea::placeholder {
174
+ color: var(--rte-media-muted);
175
+ }
176
+
177
+ .rte-media-input:focus,
178
+ .rte-media-textarea:focus {
179
+ outline: none;
180
+ border-color: var(--rte-media-accent);
181
+ box-shadow: 0 0 0 3px var(--rte-media-ring);
182
+ }
183
+
184
+ .rte-media-textarea {
185
+ min-height: 92px;
186
+ resize: vertical;
187
+ font-family: inherit;
188
+ }
189
+
190
+ .rte-media-dropzone {
191
+ border: 2px dashed var(--rte-media-border);
192
+ border-radius: 12px;
193
+ padding: 36px 18px;
194
+ text-align: center;
195
+ cursor: pointer;
196
+ background: var(--rte-media-surface);
197
+ transition: border-color 0.16s ease, background-color 0.16s ease;
198
+ }
199
+
200
+ .rte-media-dropzone:hover,
201
+ .rte-media-dropzone.is-dragover {
202
+ border-color: var(--rte-media-accent);
203
+ background: var(--rte-media-surface-hover);
204
+ }
205
+
206
+ .rte-media-dropzone-icon {
207
+ font-size: 40px;
208
+ margin-bottom: 10px;
209
+ line-height: 1;
210
+ }
211
+
212
+ .rte-media-dropzone-title {
213
+ margin: 0 0 8px 0;
214
+ font-size: 16px;
215
+ font-weight: 600;
216
+ color: var(--rte-media-text);
217
+ }
218
+
219
+ .rte-media-muted {
220
+ margin: 0 0 8px 0;
221
+ color: var(--rte-media-muted);
222
+ font-size: 14px;
223
+ }
224
+
225
+ .rte-media-hint {
226
+ margin: 0;
227
+ color: var(--rte-media-muted);
228
+ font-size: 12px;
229
+ }
230
+
231
+ .rte-media-progress {
232
+ margin-top: 16px;
233
+ }
234
+
235
+ .rte-media-progress-track {
236
+ height: 8px;
237
+ border-radius: 999px;
238
+ background: var(--rte-media-surface);
239
+ overflow: hidden;
240
+ border: 1px solid var(--rte-media-border);
241
+ }
242
+
243
+ .rte-media-progress-bar {
244
+ height: 100%;
245
+ width: 0;
246
+ background: var(--rte-media-accent);
247
+ transition: width 0.3s ease;
248
+ }
249
+
250
+ .rte-media-progress-text {
251
+ margin-top: 8px;
252
+ text-align: center;
253
+ color: var(--rte-media-muted);
254
+ font-size: 13px;
255
+ }
256
+
257
+ .rte-media-preview {
258
+ border: 1px solid var(--rte-media-border);
259
+ border-radius: 10px;
260
+ padding: 10px;
261
+ text-align: center;
262
+ background: var(--rte-media-surface);
263
+ }
264
+
265
+ .rte-media-preview img,
266
+ .rte-media-preview video {
267
+ max-width: 100%;
268
+ max-height: 240px;
269
+ }
270
+
271
+ .rte-media-helper {
272
+ margin-top: 8px;
273
+ margin-bottom: 0;
274
+ font-size: 12px;
275
+ color: var(--rte-media-muted);
276
+ line-height: 1.5;
277
+ }
278
+
279
+ .rte-media-footer {
280
+ display: flex;
281
+ justify-content: flex-end;
282
+ gap: 10px;
283
+ padding: 16px 20px;
284
+ border-top: 1px solid var(--rte-media-border);
285
+ background: var(--rte-media-surface);
286
+ }
287
+
288
+ .rte-media-footer.rte-media-footer-spread {
289
+ justify-content: space-between;
290
+ align-items: center;
291
+ }
292
+
293
+ .rte-media-btn {
294
+ border-radius: 8px;
295
+ border: 1px solid transparent;
296
+ padding: 10px 16px;
297
+ font-size: 14px;
298
+ font-weight: 600;
299
+ cursor: pointer;
300
+ transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
301
+ }
302
+
303
+ .rte-media-btn-secondary {
304
+ background: var(--rte-media-bg);
305
+ border-color: var(--rte-media-border);
306
+ color: var(--rte-media-text);
307
+ }
308
+
309
+ .rte-media-btn-secondary:hover {
310
+ background: var(--rte-media-surface-hover);
311
+ }
312
+
313
+ .rte-media-btn-primary {
314
+ background: var(--rte-media-accent);
315
+ color: #fff;
316
+ }
317
+
318
+ .rte-media-btn-primary:hover {
319
+ background: var(--rte-media-accent-hover);
320
+ }
321
+
322
+ .rte-media-btn-primary:disabled {
323
+ opacity: 0.55;
324
+ cursor: not-allowed;
325
+ }
326
+
327
+ .rte-media-btn-danger {
328
+ background: var(--rte-media-danger);
329
+ color: #fff;
330
+ }
331
+
332
+ .rte-media-btn-danger:hover {
333
+ background: var(--rte-media-danger-hover);
334
+ }
335
+
336
+ .rte-media-checkbox-label {
337
+ display: inline-flex;
338
+ align-items: center;
339
+ gap: 8px;
340
+ color: var(--rte-media-text);
341
+ font-size: 14px;
342
+ cursor: pointer;
343
+ }
344
+
345
+ .rte-media-checkbox-label input {
346
+ accent-color: var(--rte-media-accent);
347
+ }
348
+
349
+ .rte-media-actions {
350
+ display: flex;
351
+ gap: 10px;
352
+ }
353
+
354
+ .rte-media-spacer {
355
+ flex: 1;
356
+ }
357
+
358
+ .media-floating-toolbar {
359
+ --rte-media-toolbar-bg: #ffffff;
360
+ --rte-media-toolbar-border: #d6dbe4;
361
+ --rte-media-toolbar-text: #344054;
362
+ --rte-media-toolbar-hover-bg: #f3f6fb;
363
+ --rte-media-toolbar-hover-text: #101828;
364
+ --rte-media-toolbar-active-bg: #e6edf7;
365
+ --rte-media-toolbar-separator: #d9e1eb;
366
+ --rte-media-toolbar-danger-hover-bg: #fee2e2;
367
+ --rte-media-toolbar-danger-hover-text: #b42318;
368
+ position: absolute;
369
+ display: none;
370
+ align-items: center;
371
+ gap: 2px;
372
+ padding: 4px;
373
+ border: 1px solid var(--rte-media-toolbar-border);
374
+ border-radius: 8px;
375
+ background: var(--rte-media-toolbar-bg);
376
+ color: var(--rte-media-toolbar-text);
377
+ box-shadow: 0 10px 24px rgba(15, 23, 36, 0.18);
378
+ z-index: 10000;
379
+ pointer-events: auto;
380
+ backdrop-filter: blur(6px);
381
+ }
382
+
383
+ .media-floating-toolbar.rte-ui-theme-dark,
384
+ ${j} .media-floating-toolbar {
385
+ --rte-media-toolbar-bg: #24303f;
386
+ --rte-media-toolbar-border: #4a5a71;
387
+ --rte-media-toolbar-text: #d9e6fb;
388
+ --rte-media-toolbar-hover-bg: #33445a;
389
+ --rte-media-toolbar-hover-text: #f4f8ff;
390
+ --rte-media-toolbar-active-bg: #415875;
391
+ --rte-media-toolbar-separator: #566884;
392
+ --rte-media-toolbar-danger-hover-bg: #5f2a32;
393
+ --rte-media-toolbar-danger-hover-text: #ffd7d5;
394
+ box-shadow: 0 16px 30px rgba(2, 8, 20, 0.42);
395
+ }
396
+
397
+ .media-floating-toolbar-btn {
398
+ width: 30px;
399
+ height: 30px;
400
+ border: none;
401
+ border-radius: 6px;
402
+ background: transparent;
403
+ color: inherit;
404
+ display: inline-flex;
405
+ align-items: center;
406
+ justify-content: center;
407
+ cursor: pointer;
408
+ transition: background-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
409
+ }
410
+
411
+ .media-floating-toolbar-btn:hover {
412
+ background: var(--rte-media-toolbar-hover-bg);
413
+ color: var(--rte-media-toolbar-hover-text);
414
+ }
415
+
416
+ .media-floating-toolbar-btn:active {
417
+ background: var(--rte-media-toolbar-active-bg);
418
+ transform: scale(0.96);
419
+ }
420
+
421
+ .media-floating-toolbar-btn.btn-remove:hover {
422
+ background: var(--rte-media-toolbar-danger-hover-bg);
423
+ color: var(--rte-media-toolbar-danger-hover-text);
424
+ }
425
+
426
+ .media-floating-toolbar-separator {
427
+ width: 1px;
428
+ height: 20px;
429
+ margin: 0 2px;
430
+ background: var(--rte-media-toolbar-separator);
431
+ }
432
+ `, document.head.appendChild(e);
433
+ }, O = () => {
434
+ const e = window.getSelection();
435
+ if (!e || e.rangeCount === 0) return null;
436
+ const t = e.anchorNode;
437
+ return (t instanceof HTMLElement ? t : t?.parentElement)?.closest(".rte-content, .editora-content") || null;
438
+ }, X = (e) => {
439
+ if (e) return e;
440
+ const t = O();
441
+ if (t) return t;
442
+ if (I) return I;
443
+ const r = document.activeElement;
444
+ return r ? r.closest(".rte-content, .editora-content") || r : null;
445
+ }, F = (e) => {
446
+ const t = X(e);
447
+ return t ? !!t.closest(j) : !1;
448
+ }, D = (e) => {
449
+ G();
450
+ const t = document.createElement("div");
451
+ return t.className = "rte-media-overlay", F(e) && t.classList.add("rte-ui-theme-dark"), t;
452
+ }, B = (e = !1) => {
453
+ const t = document.createElement("div");
454
+ return t.className = e ? "rte-media-dialog rte-media-dialog-compact" : "rte-media-dialog", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t;
455
+ }, P = (e, t) => {
456
+ const r = window.getSelection();
457
+ r && r.rangeCount > 0 && (T = r.getRangeAt(0).cloneRange());
458
+ const i = D(t), a = B();
459
+ let o = "upload", n = "", c = "", m = "", b = "";
460
+ const v = () => {
461
+ a.innerHTML = `
462
+ <div class="rte-media-header">
463
+ <h2 class="rte-media-title">Insert ${e === "image" ? "Image" : "Video"}</h2>
464
+ <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
465
+ </div>
466
+
467
+ <div class="rte-media-tabs">
468
+ <button class="tab-upload rte-media-tab ${o === "upload" ? "active" : ""}" type="button">Upload</button>
469
+ <button class="tab-url rte-media-tab ${o === "url" ? "active" : ""}" type="button">URL</button>
470
+ </div>
471
+
472
+ <div class="rte-media-body">
473
+ ${o === "upload" ? `
474
+ <div id="upload-section">
475
+ <div class="dropzone rte-media-dropzone">
476
+ <div class="rte-media-dropzone-icon">📁</div>
477
+ <p class="rte-media-dropzone-title">Drag and drop your ${e} here</p>
478
+ <p class="rte-media-muted">or click to browse</p>
479
+ <p class="rte-media-hint">Max file size: 50MB</p>
480
+ </div>
481
+ <input type="file" id="file-input" accept="${e === "image" ? "image/*" : "video/*"}" style="display: none;">
482
+ <div id="upload-progress" class="rte-media-progress" style="display: none;">
483
+ <div class="rte-media-progress-track">
484
+ <div id="progress-bar" class="rte-media-progress-bar"></div>
485
+ </div>
486
+ <p id="progress-text" class="rte-media-progress-text">Uploading...</p>
487
+ </div>
488
+ </div>
489
+ ` : `
490
+ <div id="url-section">
491
+ <div class="rte-media-field">
492
+ <label class="rte-media-label">URL</label>
493
+ <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e === "image" ? "jpg" : "mp4"}" value="${n}">
494
+ </div>
495
+ ${e === "image" ? `
496
+ <div class="rte-media-field">
497
+ <label class="rte-media-label">Alt Text (for accessibility)</label>
498
+ <input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${b}">
499
+ </div>
500
+ ` : ""}
501
+ <div class="rte-media-grid">
502
+ <div class="rte-media-field">
503
+ <label class="rte-media-label">Width (px)</label>
504
+ <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${c}">
505
+ </div>
506
+ <div class="rte-media-field">
507
+ <label class="rte-media-label">Height (px)</label>
508
+ <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${m}">
509
+ </div>
510
+ </div>
511
+ ${n ? `
512
+ <div class="rte-media-field">
513
+ <label class="rte-media-label">Preview</label>
514
+ <div class="rte-media-preview">
515
+ ${e === "image" ? `<img src="${n}" alt="Preview">` : `<video src="${n}" controls></video>`}
516
+ </div>
517
+ </div>
518
+ ` : ""}
519
+ </div>
520
+ `}
521
+ </div>
522
+
523
+ <div class="rte-media-footer">
524
+ <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
525
+ <button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!n && o === "url" ? "disabled" : ""}>Insert</button>
526
+ </div>
527
+ `;
528
+ };
529
+ v(), i.appendChild(a), document.body.appendChild(i);
530
+ const h = () => {
531
+ i.parentNode && i.parentNode.removeChild(i);
532
+ }, E = () => {
533
+ if (!n) return;
534
+ const l = e === "image" ? document.createElement("img") : document.createElement("video");
535
+ l.src = n, l.setAttribute("data-media-type", e), e === "image" && b && (l.alt = b), c && (l.style.width = `${c}px`, l.setAttribute("width", c)), m && (l.style.height = `${m}px`, l.setAttribute("height", m)), e === "video" && (l.controls = !0), !c && !m ? l.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : l.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${c ? `width: ${c}px;` : "max-width: 100%;"} ${m ? `height: ${m}px;` : "height: auto;"}`, T && (T.deleteContents(), T.insertNode(l)), h();
536
+ }, y = async (l) => {
537
+ const g = a.querySelector("#upload-progress"), p = a.querySelector("#progress-bar"), x = a.querySelector("#progress-text");
538
+ if (g && p && x) {
539
+ g.style.display = "block";
540
+ let q = 0;
541
+ const f = setInterval(() => {
542
+ q += Math.random() * 30, q > 90 && (q = 90), p.style.width = `${q}%`;
543
+ }, 200);
544
+ try {
545
+ const k = new FileReader();
546
+ k.onload = () => {
547
+ clearInterval(f), p.style.width = "100%", x.textContent = "Upload complete", setTimeout(() => {
548
+ n = k.result, o = "url", v(), u();
549
+ }, 500);
550
+ }, k.readAsDataURL(l);
551
+ } catch {
552
+ clearInterval(f), x.textContent = "Upload failed";
553
+ }
554
+ }
555
+ }, u = () => {
556
+ const l = a.querySelector(".close-btn"), g = a.querySelector(".cancel-btn"), p = a.querySelector("#insert-btn"), x = a.querySelector(".tab-upload"), q = a.querySelector(".tab-url");
557
+ if (l?.addEventListener("click", h), g?.addEventListener("click", h), p?.addEventListener("click", E), x?.addEventListener("click", () => {
558
+ o = "upload", v(), u();
559
+ }), q?.addEventListener("click", () => {
560
+ o = "url", v(), u();
561
+ }), o === "upload") {
562
+ const f = a.querySelector(".dropzone"), k = a.querySelector("#file-input");
563
+ f?.addEventListener("click", () => k?.click()), f?.addEventListener("dragover", (L) => {
564
+ L.preventDefault(), f.classList.add("is-dragover");
565
+ }), f?.addEventListener("dragleave", () => {
566
+ f.classList.remove("is-dragover");
567
+ }), f?.addEventListener("drop", (L) => {
568
+ L.preventDefault(), f.classList.remove("is-dragover");
569
+ const S = L.dataTransfer?.files[0];
570
+ S && y(S);
571
+ }), k?.addEventListener("change", (L) => {
572
+ const S = L.target.files?.[0];
573
+ S && y(S);
574
+ });
575
+ }
576
+ if (o === "url") {
577
+ const f = a.querySelector("#url-input"), k = a.querySelector("#alt-input"), L = a.querySelector("#width-input"), S = a.querySelector("#height-input");
578
+ f?.addEventListener("input", () => {
579
+ n = f.value, v(), u();
580
+ }), k?.addEventListener("input", () => {
581
+ b = k.value;
582
+ }), L?.addEventListener("input", () => {
583
+ c = L.value;
584
+ }), S?.addEventListener("input", () => {
585
+ m = S.value;
586
+ });
587
+ }
588
+ };
589
+ u(), i.addEventListener("click", (l) => {
590
+ l.target === i && h();
591
+ });
592
+ }, Y = () => {
593
+ ["nw", "ne", "sw", "se"].forEach((t) => {
594
+ const r = document.createElement("div");
595
+ r.className = `media-resize-handle-${t}`, r.style.cssText = `
596
+ position: fixed;
597
+ width: 10px;
598
+ height: 10px;
599
+ background: #007bff;
600
+ border: 2px solid white;
601
+ border-radius: 50%;
602
+ cursor: ${t}-resize;
603
+ z-index: 10001;
604
+ display: none;
605
+ box-shadow: 0 1px 3px rgba(0,0,0,0.3);
606
+ `, r.setAttribute("data-position", t), document.body.appendChild(r), R.push(r);
607
+ });
608
+ }, C = () => {
609
+ if (!s) {
610
+ R.forEach((r) => r.style.display = "none");
611
+ return;
612
+ }
613
+ const e = s.getBoundingClientRect(), t = {
614
+ nw: { x: e.left - 5, y: e.top - 5 },
615
+ ne: { x: e.right - 5, y: e.top - 5 },
616
+ sw: { x: e.left - 5, y: e.bottom - 5 },
617
+ se: { x: e.right - 5, y: e.bottom - 5 }
618
+ };
619
+ R.forEach((r) => {
620
+ const i = r.getAttribute("data-position"), a = t[i];
621
+ r.style.left = `${a.x}px`, r.style.top = `${a.y}px`, r.style.display = "block";
622
+ });
623
+ }, Z = (e) => {
624
+ const t = D(e), r = B(!0);
625
+ r.innerHTML = `
626
+ <div class="rte-media-header">
627
+ <h2 class="rte-media-title">Edit Alt Text</h2>
628
+ <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
629
+ </div>
630
+ <div class="rte-media-body">
631
+ <label class="rte-media-label">Alternative Text (for accessibility)</label>
632
+ <textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${e.alt || ""}</textarea>
633
+ <p class="rte-media-helper">Good alt text is descriptive and concise. It helps users with visual impairments understand your content.</p>
634
+ </div>
635
+ <div class="rte-media-footer">
636
+ <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
637
+ <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
638
+ </div>
639
+ `, t.appendChild(r), document.body.appendChild(t);
640
+ const i = r.querySelector("#alt-text-input"), a = r.querySelector(".close-btn"), o = r.querySelector(".cancel-btn"), n = r.querySelector(".save-btn"), c = () => {
641
+ t.parentNode && t.parentNode.removeChild(t);
642
+ };
643
+ a.addEventListener("click", c), o.addEventListener("click", c), t.addEventListener("click", (m) => {
644
+ m.target === t && c();
645
+ }), n.addEventListener("click", () => {
646
+ e.alt = i.value, c();
647
+ }), i.focus(), i.select();
648
+ }, K = (e) => {
649
+ const t = e.closest("a"), r = t?.getAttribute("href") || "", i = t?.getAttribute("target") || "_self", a = t?.getAttribute("title") || "", o = D(e), n = B(!0);
650
+ n.innerHTML = `
651
+ <div class="rte-media-header">
652
+ <h2 class="rte-media-title">${t ? "Edit Link" : "Add Link"}</h2>
653
+ <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
654
+ </div>
655
+ <div class="rte-media-body">
656
+ <div class="rte-media-field">
657
+ <label class="rte-media-label">URL</label>
658
+ <input id="link-url" type="url" class="rte-media-input" value="${r}" placeholder="https://example.com" />
659
+ </div>
660
+ <div class="rte-media-field">
661
+ <label class="rte-media-label">Title (tooltip)</label>
662
+ <input id="link-title" type="text" class="rte-media-input" value="${a}" placeholder="Optional tooltip text" />
663
+ </div>
664
+ <label class="rte-media-checkbox-label">
665
+ <input id="link-target" type="checkbox" ${i === "_blank" ? "checked" : ""} />
666
+ Open in new window/tab
667
+ </label>
668
+ </div>
669
+ <div class="rte-media-footer rte-media-footer-spread">
670
+ ${t ? '<button class="remove-link-btn rte-media-btn rte-media-btn-danger" type="button">Remove Link</button>' : '<span class="rte-media-spacer"></span>'}
671
+ <div class="rte-media-actions">
672
+ <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
673
+ <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
674
+ </div>
675
+ </div>
676
+ `, o.appendChild(n), document.body.appendChild(o);
677
+ const c = n.querySelector("#link-url"), m = n.querySelector("#link-title"), b = n.querySelector("#link-target"), v = n.querySelector(".close-btn"), h = n.querySelector(".cancel-btn"), E = n.querySelector(".save-btn"), y = n.querySelector(".remove-link-btn"), u = () => {
678
+ o.parentNode && o.parentNode.removeChild(o);
679
+ };
680
+ v.addEventListener("click", u), h.addEventListener("click", u), o.addEventListener("click", (l) => {
681
+ l.target === o && u();
682
+ }), E.addEventListener("click", () => {
683
+ const l = c.value.trim();
684
+ if (l) {
685
+ const g = l.startsWith("http") ? l : `https://${l}`;
686
+ if (t)
687
+ t.setAttribute("href", g), t.setAttribute("target", b.checked ? "_blank" : "_self"), b.checked ? t.setAttribute("rel", "noopener noreferrer") : t.removeAttribute("rel"), m.value.trim() ? t.setAttribute("title", m.value.trim()) : t.removeAttribute("title");
688
+ else {
689
+ const p = document.createElement("a");
690
+ p.href = g, p.target = b.checked ? "_blank" : "_self", b.checked && (p.rel = "noopener noreferrer"), m.value.trim() && (p.title = m.value.trim()), e.replaceWith(p), p.appendChild(e);
691
+ }
692
+ u(), d && s && H(s);
693
+ }
694
+ }), y?.addEventListener("click", () => {
695
+ t && confirm("Remove link from this media?") && (t.replaceWith(e), u(), d && s && H(s));
696
+ }), c.focus();
697
+ }, J = (e) => {
698
+ const t = D(e), r = B();
699
+ let i = "url", a = e.src;
700
+ const o = () => {
701
+ r.innerHTML = `
702
+ <div class="rte-media-header">
703
+ <h2 class="rte-media-title">Replace Image</h2>
704
+ <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
705
+ </div>
706
+
707
+ <div class="rte-media-tabs">
708
+ <button class="tab-upload rte-media-tab ${i === "upload" ? "active" : ""}" type="button">Upload</button>
709
+ <button class="tab-url rte-media-tab ${i === "url" ? "active" : ""}" type="button">URL</button>
710
+ </div>
711
+
712
+ <div class="rte-media-body">
713
+ ${i === "upload" ? `
714
+ <div id="upload-section">
715
+ <div class="dropzone rte-media-dropzone">
716
+ <div class="rte-media-dropzone-icon">📁</div>
717
+ <p class="rte-media-dropzone-title">Drag and drop your image here</p>
718
+ <p class="rte-media-muted">or click to browse</p>
719
+ </div>
720
+ <input type="file" id="file-input" accept="image/*" style="display: none;">
721
+ <div id="upload-progress" class="rte-media-progress" style="display: none;">
722
+ <div class="rte-media-progress-track">
723
+ <div id="progress-bar" class="rte-media-progress-bar"></div>
724
+ </div>
725
+ <p id="progress-text" class="rte-media-progress-text">Uploading...</p>
726
+ </div>
727
+ </div>
728
+ ` : `
729
+ <div id="url-section">
730
+ <div class="rte-media-field">
731
+ <label class="rte-media-label">Image URL</label>
732
+ <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${a}">
733
+ </div>
734
+ ${a ? `
735
+ <div class="rte-media-field">
736
+ <label class="rte-media-label">Preview</label>
737
+ <div class="rte-media-preview">
738
+ <img src="${a}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
739
+ </div>
740
+ </div>
741
+ ` : ""}
742
+ </div>
743
+ `}
744
+ </div>
745
+
746
+ <div class="rte-media-footer">
747
+ <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
748
+ <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!a && i === "url" ? "disabled" : ""}>Replace</button>
749
+ </div>
750
+ `;
751
+ };
752
+ o(), t.appendChild(r), document.body.appendChild(t);
753
+ const n = () => {
754
+ t.parentNode && t.parentNode.removeChild(t);
755
+ }, c = () => {
756
+ a && (e.src = a, n());
757
+ }, m = async (v) => {
758
+ const h = r.querySelector("#upload-progress"), E = r.querySelector("#progress-bar"), y = r.querySelector("#progress-text");
759
+ if (h && E && y) {
760
+ h.style.display = "block";
761
+ let u = 0;
762
+ const l = setInterval(() => {
763
+ u += Math.random() * 30, u > 90 && (u = 90), E.style.width = `${u}%`;
764
+ }, 200);
765
+ try {
766
+ const g = new FileReader();
767
+ g.onload = () => {
768
+ clearInterval(l), E.style.width = "100%", y.textContent = "Upload complete", setTimeout(() => {
769
+ a = g.result, i = "url", o(), b();
770
+ }, 500);
771
+ }, g.readAsDataURL(v);
772
+ } catch {
773
+ clearInterval(l), y.textContent = "Upload failed";
774
+ }
775
+ }
776
+ }, b = () => {
777
+ const v = r.querySelector(".close-btn"), h = r.querySelector(".cancel-btn"), E = r.querySelector("#replace-btn"), y = r.querySelector(".tab-upload"), u = r.querySelector(".tab-url");
778
+ if (v?.addEventListener("click", n), h?.addEventListener("click", n), E?.addEventListener("click", c), y?.addEventListener("click", () => {
779
+ i = "upload", o(), b();
780
+ }), u?.addEventListener("click", () => {
781
+ i = "url", o(), b();
782
+ }), i === "upload") {
783
+ const l = r.querySelector(".dropzone"), g = r.querySelector("#file-input");
784
+ l?.addEventListener("click", () => g?.click()), l?.addEventListener("dragover", (p) => {
785
+ p.preventDefault(), l.classList.add("is-dragover");
786
+ }), l?.addEventListener("dragleave", () => {
787
+ l.classList.remove("is-dragover");
788
+ }), l?.addEventListener("drop", (p) => {
789
+ p.preventDefault(), l.classList.remove("is-dragover");
790
+ const x = p.dataTransfer?.files[0];
791
+ x && m(x);
792
+ }), g?.addEventListener("change", (p) => {
793
+ const x = p.target.files?.[0];
794
+ x && m(x);
795
+ });
796
+ }
797
+ if (i === "url") {
798
+ const l = r.querySelector("#url-input");
799
+ l?.addEventListener("input", () => {
800
+ a = l.value, o(), b();
801
+ });
802
+ }
803
+ };
804
+ b(), t.addEventListener("click", (v) => {
805
+ v.target === t && n();
806
+ });
807
+ }, w = () => {
808
+ if (!d || !s) return;
809
+ const e = d.offsetHeight || 40, t = s.offsetTop, r = s.offsetLeft, i = s.offsetWidth, a = t - e - 8, o = r + i / 2 - (d.offsetWidth || 120) / 2;
810
+ d.style.top = `${a}px`, d.style.left = `${o}px`, setTimeout(() => {
811
+ d && (d.style.display = "flex");
812
+ }, 100);
813
+ }, H = (e) => {
814
+ d && (d._cleanup && d._cleanup(), d.remove());
815
+ const t = e.parentElement;
816
+ if (t) {
817
+ const n = t.style.position;
818
+ (!n || n === "static") && (t.style.position = "relative", t._originalPosition = n), d = document.createElement("div"), d.className = "media-floating-toolbar", F(e) && d.classList.add("rte-ui-theme-dark"), t.insertBefore(d, t.firstChild), w();
819
+ }
820
+ const r = e.tagName === "IMG", i = e.closest("a");
821
+ d.innerHTML = `
822
+ <button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
823
+ <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>
824
+ </button>
825
+ <button class="media-floating-toolbar-btn btn-align-center" title="Align Center" type="button">
826
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="10" x2="6" 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="18" y1="18" x2="6" y2="18"></line></svg>
827
+ </button>
828
+ <button class="media-floating-toolbar-btn btn-align-right" title="Align Right" type="button">
829
+ <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>
830
+ </button>
831
+ <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
832
+ ${r ? `
833
+ <button class="media-floating-toolbar-btn btn-alt" title="Edit Alt Text" type="button">
834
+ <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>
835
+ </button>` : ""}
836
+ <button class="media-floating-toolbar-btn btn-link" title="${i ? "Edit/Remove Link" : "Add Link"}" type="button">
837
+ <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>
838
+ </button>
839
+ ${r ? `
840
+ <button class="media-floating-toolbar-btn btn-replace" title="Replace Image" type="button">
841
+ <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>
842
+ </button>` : ""}
843
+ <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
844
+ <button class="media-floating-toolbar-btn btn-remove" title="Remove" type="button">
845
+ <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>
846
+ </button>
847
+ `, setTimeout(() => {
848
+ w();
849
+ }, 0);
850
+ const a = () => w();
851
+ let o = s.parentElement;
852
+ for (; o; )
853
+ o.addEventListener("scroll", a), o = o.parentElement;
854
+ window.addEventListener("scroll", a), window.addEventListener("resize", a), d._cleanup = () => {
855
+ let n = s?.parentElement;
856
+ for (; n; )
857
+ n.removeEventListener("scroll", a), n = n.parentElement;
858
+ window.removeEventListener("scroll", a), window.removeEventListener("resize", a);
859
+ }, d.querySelector(".btn-align-left")?.addEventListener("click", () => {
860
+ e.style.display = "block", e.style.marginLeft = "0", e.style.marginRight = "auto", w();
861
+ }), d.querySelector(".btn-align-center")?.addEventListener("click", () => {
862
+ e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "auto", w();
863
+ }), d.querySelector(".btn-align-right")?.addEventListener("click", () => {
864
+ e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "0", w();
865
+ }), d.querySelector(".btn-alt")?.addEventListener("click", () => {
866
+ e.tagName === "IMG" && Z(e);
867
+ }), d.querySelector(".btn-link")?.addEventListener("click", () => {
868
+ K(e);
869
+ }), d.querySelector(".btn-replace")?.addEventListener("click", () => {
870
+ e.tagName === "IMG" && J(e);
871
+ }), d.querySelector(".btn-resize")?.addEventListener("click", () => {
872
+ const n = prompt("Enter width in pixels:", String(e.width || e.offsetWidth));
873
+ if (n && !isNaN(parseInt(n))) {
874
+ const c = parseInt(n);
875
+ e.style.width = `${c}px`, e.setAttribute("width", String(c)), C(), w();
876
+ }
877
+ }), d.querySelector(".btn-remove")?.addEventListener("click", () => {
878
+ confirm("Remove this media?") && (e.remove(), d && (d._cleanup && d._cleanup(), d.remove(), d = null), s = null, C());
879
+ }), d._cleanup = () => {
880
+ window.removeEventListener("scroll", w), window.removeEventListener("resize", w);
881
+ };
882
+ }, W = (e) => {
883
+ I = e || null, Y(), document.addEventListener("click", (t) => {
884
+ const r = t.target;
885
+ if (r.tagName === "IMG" || r.tagName === "VIDEO") {
886
+ const i = r;
887
+ let a = !1;
888
+ if (I ? a = I.contains(i) : a = !!i.closest('[contenteditable="true"]'), a) {
889
+ t.preventDefault(), t.stopPropagation(), s = i, s.style.display = "block", H(i), C();
890
+ return;
891
+ }
892
+ }
893
+ if (!r.closest(".btn-link, .btn-resize, .btn-remove") && d && !r.closest("button")) {
894
+ if (d._cleanup && d._cleanup(), d.remove(), d = null, s && s.parentElement) {
895
+ const i = s.parentElement;
896
+ i._originalPosition !== void 0 && (i.style.position = i._originalPosition, delete i._originalPosition);
897
+ }
898
+ s = null, C();
899
+ }
900
+ }), R.forEach((t) => {
901
+ t.addEventListener("mousedown", (r) => {
902
+ if (!s) return;
903
+ r.preventDefault(), r.stopPropagation(), A = !0, M = t.getAttribute("data-position"), U = r.clientX, V = r.clientY;
904
+ const i = s.getBoundingClientRect();
905
+ z = i.width, $ = i.height, _ = z / $, document.body.style.userSelect = "none", document.body.style.cursor = `${M}-resize`;
906
+ });
907
+ }), document.addEventListener("mousemove", (t) => {
908
+ if (!A || !s || !M) return;
909
+ const r = t.clientX - U, i = t.clientY - V;
910
+ let a = z, o = $;
911
+ switch (M) {
912
+ case "se":
913
+ a = z + r, o = $ + i;
914
+ break;
915
+ case "sw":
916
+ a = z - r, o = $ + i;
917
+ break;
918
+ case "ne":
919
+ a = z + r, o = $ - i;
920
+ break;
921
+ case "nw":
922
+ a = z - r, o = $ - i;
923
+ break;
924
+ }
925
+ Math.abs(r) > Math.abs(i) ? o = a / _ : a = o * _, 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))), C(), w();
926
+ }), document.addEventListener("mouseup", () => {
927
+ A && (A = !1, M = null, document.body.style.userSelect = "", document.body.style.cursor = "");
928
+ }), window.addEventListener("scroll", C), window.addEventListener("resize", C);
929
+ };
930
+ typeof window < "u" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, W());
931
+ const te = () => ({
932
+ name: "image",
933
+ initialize: (e) => {
934
+ const t = e?.editorElement;
935
+ W(t);
936
+ },
937
+ toolbar: [
938
+ {
939
+ label: "Image",
940
+ command: "insertImage",
941
+ 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>'
942
+ },
943
+ {
944
+ label: "Video",
945
+ command: "insertVideo",
946
+ 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>'
947
+ }
948
+ ],
949
+ commands: {
950
+ insertImage: (e, t) => {
951
+ const r = t?.contentElement instanceof HTMLElement ? t.contentElement : void 0;
952
+ return P("image", r), !0;
953
+ },
954
+ insertVideo: (e, t) => {
955
+ const r = t?.contentElement instanceof HTMLElement ? t.contentElement : void 0;
956
+ return P("video", r), !0;
957
+ }
958
+ },
959
+ keymap: {
960
+ "Mod-Shift-i": "insertImage"
961
+ }
962
+ }), Q = {
963
+ apiEndpoints: {
964
+ upload: "/media/upload",
965
+ library: "/media/library",
966
+ delete: "/media/library"
967
+ },
968
+ maxFileSize: 10 * 1024 * 1024,
969
+ // 10MB
970
+ allowedTypes: [
971
+ "image/jpeg",
972
+ "image/png",
973
+ "image/gif",
974
+ "video/mp4",
975
+ "video/webm"
976
+ ],
977
+ headers: {
978
+ // Add default headers if needed (e.g., API key)
979
+ // 'Authorization': 'Bearer YOUR_API_KEY',
980
+ // 'X-API-Key': 'YOUR_API_KEY'
981
+ }
982
+ };
983
+ let N = { ...Q };
984
+ function re(e) {
985
+ N = { ...N, ...e };
986
+ }
987
+ function ae() {
988
+ return { ...N };
989
+ }
990
+ export {
991
+ te as MediaManagerPlugin,
992
+ ae as getMediaManagerConfig,
993
+ re as setMediaManagerConfig
994
+ };