@editora/plugins 1.0.23 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,619 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./escapeHtml-D2Zh82pD.js"),ne=require("./dialogHelpers-BxSQ7A6M.js"),le=require("./historyHelpers-Cu8Pk7m1.js"),F=require("./confirmDialog-C4UWENes.js");require("./shared-config.cjs.js");let M=null,m=null,s=null;const B=[];let D=!1,H=null,K=0,J=0,T=0,A=0,W=1,I=null;const ee='[data-theme="dark"], .dark, .editora-theme-dark',U=(e,t)=>{const r=a=>{a.key!=="Escape"||!e.isConnected||(a.preventDefault(),a.stopPropagation(),t())};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0)}},de=()=>{if(typeof document>"u"||document.getElementById("rte-media-dialog-styles"))return;const e=document.createElement("style");e.id="rte-media-dialog-styles",e.textContent=`
2
- .rte-media-overlay {
3
- --rte-media-overlay-bg: rgba(15, 23, 36, 0.56);
4
- --rte-media-bg: #ffffff;
5
- --rte-media-text: #101828;
6
- --rte-media-muted: #5f6b7d;
7
- --rte-media-border: #d6dbe4;
8
- --rte-media-surface: #f7f9fc;
9
- --rte-media-surface-hover: #eef2f7;
10
- --rte-media-accent: #1560e8;
11
- --rte-media-accent-hover: #165fd6;
12
- --rte-media-danger: #dc3545;
13
- --rte-media-danger-hover: #b92735;
14
- --rte-media-ring: rgba(31, 117, 254, 0.18);
15
- position: fixed;
16
- top: 0;
17
- left: 0;
18
- right: 0;
19
- bottom: 0;
20
- background: var(--rte-media-overlay-bg);
21
- backdrop-filter: blur(2px);
22
- display: flex;
23
- align-items: center;
24
- justify-content: center;
25
- z-index: 99999;
26
- padding: 16px;
27
- box-sizing: border-box;
28
- }
29
-
30
- .rte-media-overlay.rte-ui-theme-dark {
31
- --rte-media-overlay-bg: rgba(2, 8, 20, 0.72);
32
- --rte-media-bg: #202938;
33
- --rte-media-text: #e8effc;
34
- --rte-media-muted: #a5b1c5;
35
- --rte-media-border: #49566c;
36
- --rte-media-surface: #2a3444;
37
- --rte-media-surface-hover: #344256;
38
- --rte-media-accent: #1f6feb;
39
- --rte-media-accent-hover: #4598f4;
40
- --rte-media-danger: #ff7b72;
41
- --rte-media-danger-hover: #ff645b;
42
- --rte-media-ring: rgba(88, 166, 255, 0.22);
43
- }
44
-
45
- .rte-media-dialog {
46
- width: min(92vw, 640px);
47
- max-height: 90vh;
48
- display: flex;
49
- flex-direction: column;
50
- overflow: hidden;
51
- background: var(--rte-media-bg);
52
- color: var(--rte-media-text);
53
- border: 1px solid var(--rte-media-border);
54
- border-radius: 12px;
55
- box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
56
- }
57
-
58
- .rte-media-dialog.rte-media-dialog-compact {
59
- width: min(92vw, 520px);
60
- }
61
-
62
- .rte-media-header {
63
- display: flex;
64
- align-items: center;
65
- justify-content: space-between;
66
- padding: 16px 20px;
67
- border-bottom: 1px solid var(--rte-media-border);
68
- background: linear-gradient(180deg, rgba(127, 154, 195, 0.08) 0%, rgba(127, 154, 195, 0) 100%);
69
- }
70
-
71
- .rte-media-title {
72
- margin: 0;
73
- font-size: 18px;
74
- font-weight: 600;
75
- color: var(--rte-media-text);
76
- }
77
-
78
- .rte-media-close-btn {
79
- width: 32px;
80
- height: 32px;
81
- border: none;
82
- border-radius: 8px;
83
- background: transparent;
84
- color: var(--rte-media-muted);
85
- font-size: 24px;
86
- line-height: 1;
87
- cursor: pointer;
88
- transition: background-color 0.16s ease, color 0.16s ease;
89
- }
90
-
91
- .rte-media-close-btn:hover {
92
- background: var(--rte-media-surface-hover);
93
- color: var(--rte-media-text);
94
- }
95
-
96
- .rte-media-tabs {
97
- display: grid;
98
- grid-template-columns: 1fr 1fr;
99
- border-bottom: 1px solid var(--rte-media-border);
100
- gap: 0;
101
- }
102
-
103
- .rte-media-tab {
104
- border: none;
105
- border-right: 1px solid var(--rte-media-border);
106
- padding: 12px 14px;
107
- background: var(--rte-media-surface);
108
- color: var(--rte-media-muted);
109
- font-size: 14px;
110
- font-weight: 600;
111
- cursor: pointer;
112
- transition: background-color 0.16s ease, color 0.16s ease;
113
- }
114
-
115
- .rte-media-tab:last-child {
116
- border-right: none;
117
- }
118
-
119
- .rte-media-tab:hover {
120
- background: var(--rte-media-surface-hover);
121
- color: var(--rte-media-text);
122
- }
123
-
124
- .rte-media-tab.active {
125
- background: var(--rte-media-accent);
126
- color: #fff;
127
- }
128
-
129
- .rte-media-body {
130
- padding: 20px;
131
- overflow-y: auto;
132
- flex: 1;
133
- }
134
-
135
- .rte-media-field {
136
- margin-bottom: 16px;
137
- }
138
-
139
- .rte-media-grid {
140
- display: grid;
141
- grid-template-columns: 1fr 1fr;
142
- gap: 12px;
143
- margin-bottom: 16px;
144
- }
145
-
146
- .rte-media-label {
147
- display: block;
148
- margin-bottom: 8px;
149
- color: var(--rte-media-text);
150
- font-size: 14px;
151
- font-weight: 600;
152
- }
153
-
154
- .rte-media-input,
155
- .rte-media-textarea {
156
- width: 100%;
157
- box-sizing: border-box;
158
- padding: 10px 12px;
159
- border: 1px solid var(--rte-media-border);
160
- border-radius: 8px;
161
- background: var(--rte-media-surface);
162
- color: var(--rte-media-text);
163
- font-size: 14px;
164
- transition: border-color 0.16s ease, box-shadow 0.16s ease;
165
- }
166
-
167
- .rte-media-input::placeholder,
168
- .rte-media-textarea::placeholder {
169
- color: var(--rte-media-muted);
170
- }
171
-
172
- .rte-media-input:focus,
173
- .rte-media-textarea:focus {
174
- outline: none;
175
- border-color: var(--rte-media-accent);
176
- box-shadow: 0 0 0 3px var(--rte-media-ring);
177
- }
178
-
179
- .rte-media-textarea {
180
- min-height: 92px;
181
- resize: vertical;
182
- font-family: inherit;
183
- }
184
-
185
- .rte-media-dropzone {
186
- border: 2px dashed var(--rte-media-border);
187
- border-radius: 12px;
188
- padding: 36px 18px;
189
- text-align: center;
190
- cursor: pointer;
191
- background: var(--rte-media-surface);
192
- transition: border-color 0.16s ease, background-color 0.16s ease;
193
- }
194
-
195
- .rte-media-dropzone:hover,
196
- .rte-media-dropzone.is-dragover {
197
- border-color: var(--rte-media-accent);
198
- background: var(--rte-media-surface-hover);
199
- }
200
-
201
- .rte-media-dropzone-icon {
202
- font-size: 40px;
203
- margin-bottom: 10px;
204
- line-height: 1;
205
- }
206
-
207
- .rte-media-dropzone-title {
208
- margin: 0 0 8px 0;
209
- font-size: 16px;
210
- font-weight: 600;
211
- color: var(--rte-media-text);
212
- }
213
-
214
- .rte-media-muted {
215
- margin: 0 0 8px 0;
216
- color: var(--rte-media-muted);
217
- font-size: 14px;
218
- }
219
-
220
- .rte-media-hint {
221
- margin: 0;
222
- color: var(--rte-media-muted);
223
- font-size: 12px;
224
- }
225
-
226
- .rte-media-progress {
227
- margin-top: 16px;
228
- }
229
-
230
- .rte-media-progress-track {
231
- height: 8px;
232
- border-radius: 999px;
233
- background: var(--rte-media-surface);
234
- overflow: hidden;
235
- border: 1px solid var(--rte-media-border);
236
- }
237
-
238
- .rte-media-progress-bar {
239
- height: 100%;
240
- width: 0;
241
- background: var(--rte-media-accent);
242
- transition: width 0.3s ease;
243
- }
244
-
245
- .rte-media-progress-text {
246
- margin-top: 8px;
247
- text-align: center;
248
- color: var(--rte-media-muted);
249
- font-size: 13px;
250
- }
251
-
252
- .rte-media-preview {
253
- border: 1px solid var(--rte-media-border);
254
- border-radius: 10px;
255
- padding: 10px;
256
- text-align: center;
257
- background: var(--rte-media-surface);
258
- }
259
-
260
- .rte-media-preview img,
261
- .rte-media-preview video {
262
- max-width: 100%;
263
- max-height: 240px;
264
- }
265
-
266
- .rte-media-helper {
267
- margin-top: 8px;
268
- margin-bottom: 0;
269
- font-size: 12px;
270
- color: var(--rte-media-muted);
271
- line-height: 1.5;
272
- }
273
-
274
- .rte-media-footer {
275
- display: flex;
276
- justify-content: flex-end;
277
- gap: 10px;
278
- padding: 16px 20px;
279
- border-top: 1px solid var(--rte-media-border);
280
- background: var(--rte-media-surface);
281
- }
282
-
283
- .rte-media-footer.rte-media-footer-spread {
284
- justify-content: space-between;
285
- align-items: center;
286
- }
287
-
288
- .rte-media-btn {
289
- border-radius: 8px;
290
- border: 1px solid transparent;
291
- padding: 10px 16px;
292
- font-size: 14px;
293
- font-weight: 600;
294
- cursor: pointer;
295
- transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
296
- }
297
-
298
- .rte-media-btn-secondary {
299
- background: var(--rte-media-bg);
300
- border-color: var(--rte-media-border);
301
- color: var(--rte-media-text);
302
- }
303
-
304
- .rte-media-btn-secondary:hover {
305
- background: var(--rte-media-surface-hover);
306
- }
307
-
308
- .rte-media-btn-primary {
309
- background: var(--rte-media-accent);
310
- color: #fff;
311
- }
312
-
313
- .rte-media-btn-primary:hover {
314
- background: var(--rte-media-accent-hover);
315
- }
316
-
317
- .rte-media-btn-primary:disabled {
318
- opacity: 0.55;
319
- cursor: not-allowed;
320
- }
321
-
322
- .rte-media-btn-danger {
323
- background: var(--rte-media-danger);
324
- color: #fff;
325
- }
326
-
327
- .rte-media-btn-danger:hover {
328
- background: var(--rte-media-danger-hover);
329
- }
330
-
331
- .rte-media-checkbox-label {
332
- display: inline-flex;
333
- align-items: center;
334
- gap: 8px;
335
- color: var(--rte-media-text);
336
- font-size: 14px;
337
- cursor: pointer;
338
- }
339
-
340
- .rte-media-checkbox-label input {
341
- accent-color: var(--rte-media-accent);
342
- }
343
-
344
- .rte-media-actions {
345
- display: flex;
346
- gap: 10px;
347
- }
348
-
349
- .rte-media-spacer {
350
- flex: 1;
351
- }
352
-
353
- .media-floating-toolbar {
354
- --rte-media-toolbar-bg: #ffffff;
355
- --rte-media-toolbar-border: #d6dbe4;
356
- --rte-media-toolbar-text: #344054;
357
- --rte-media-toolbar-hover-bg: #f3f6fb;
358
- --rte-media-toolbar-hover-text: #101828;
359
- --rte-media-toolbar-active-bg: #e6edf7;
360
- --rte-media-toolbar-separator: #d9e1eb;
361
- --rte-media-toolbar-danger-hover-bg: #fee2e2;
362
- --rte-media-toolbar-danger-hover-text: #b42318;
363
- position: absolute;
364
- display: none;
365
- align-items: center;
366
- gap: 2px;
367
- padding: 4px;
368
- border: 1px solid var(--rte-media-toolbar-border);
369
- border-radius: 8px;
370
- background: var(--rte-media-toolbar-bg);
371
- color: var(--rte-media-toolbar-text);
372
- box-shadow: 0 10px 24px rgba(15, 23, 36, 0.18);
373
- z-index: 10000;
374
- pointer-events: auto;
375
- backdrop-filter: blur(6px);
376
- }
377
-
378
- .media-floating-toolbar.rte-ui-theme-dark,
379
- ${ee} .media-floating-toolbar {
380
- --rte-media-toolbar-bg: #24303f;
381
- --rte-media-toolbar-border: #4a5a71;
382
- --rte-media-toolbar-text: #d9e6fb;
383
- --rte-media-toolbar-hover-bg: #33445a;
384
- --rte-media-toolbar-hover-text: #f4f8ff;
385
- --rte-media-toolbar-active-bg: #415875;
386
- --rte-media-toolbar-separator: #566884;
387
- --rte-media-toolbar-danger-hover-bg: #5f2a32;
388
- --rte-media-toolbar-danger-hover-text: #ffd7d5;
389
- box-shadow: 0 16px 30px rgba(2, 8, 20, 0.42);
390
- }
391
-
392
- .media-floating-toolbar-btn {
393
- width: 30px;
394
- height: 30px;
395
- border: none;
396
- border-radius: 6px;
397
- background: transparent;
398
- color: inherit;
399
- display: inline-flex;
400
- align-items: center;
401
- justify-content: center;
402
- cursor: pointer;
403
- transition: background-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
404
- }
405
-
406
- .media-floating-toolbar-btn:hover {
407
- background: var(--rte-media-toolbar-hover-bg);
408
- color: var(--rte-media-toolbar-hover-text);
409
- }
410
-
411
- .media-floating-toolbar-btn:active {
412
- background: var(--rte-media-toolbar-active-bg);
413
- transform: scale(0.96);
414
- }
415
-
416
- .media-floating-toolbar-btn.btn-remove:hover {
417
- background: var(--rte-media-toolbar-danger-hover-bg);
418
- color: var(--rte-media-toolbar-danger-hover-text);
419
- }
420
-
421
- .media-floating-toolbar-separator {
422
- width: 1px;
423
- height: 20px;
424
- margin: 0 2px;
425
- background: var(--rte-media-toolbar-separator);
426
- }
427
- `,document.head.appendChild(e)},se=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;return(t instanceof HTMLElement?t:t?.parentElement)?.closest(".rte-content, .editora-content")||null},te=e=>{if(e)return e;const t=se();if(t)return t;if(I)return I;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},re=e=>{const t=te(e);return t?!!t.closest(ee):!1},N=e=>{de();const t=document.createElement("div");return ne.initDialogOverlay(t),t.className="rte-media-overlay",re(e)&&t.classList.add("rte-ui-theme-dark"),t},_=(e,t)=>{e.querySelector(t==="upload"?".tab-upload":".tab-url")?.focus()},ae=(e,t)=>{e?.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t?.click())})},P=(e=!1)=>{const t=document.createElement("div");return t.className=e?"rte-media-dialog rte-media-dialog-compact":"rte-media-dialog",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t},Q=(e,t)=>{document.querySelectorAll(".rte-media-overlay").forEach(n=>n.remove());const r=window.getSelection();r&&r.rangeCount>0&&(M=r.getRangeAt(0).cloneRange());const a=N(t),i=P();let o="upload",d="",l="",u="",b="";const x=()=>`
428
- <div class="rte-media-field rte-media-preview-field">
429
- <span class="rte-media-label">Preview</span>
430
- <div class="rte-media-preview">
431
- ${e==="image"?`<img src="${w.escapeHtml(d)}" alt="Preview">`:`<video src="${w.escapeHtml(d)}" controls></video>`}
432
- </div>
433
- </div>
434
- `,y=()=>{i.innerHTML=`
435
- <div class="rte-media-header">
436
- <h2 class="rte-media-title">Insert ${e==="image"?"Image":"Video"}</h2>
437
- <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
438
- </div>
439
-
440
- <div class="rte-media-tabs" role="tablist" aria-label="Where to get the ${e==="image"?"image":"video"} from">
441
- <button class="tab-upload rte-media-tab ${o==="upload"?"active":""}" type="button" role="tab" aria-selected="${o==="upload"}">Upload</button>
442
- <button class="tab-url rte-media-tab ${o==="url"?"active":""}" type="button" role="tab" aria-selected="${o==="url"}">URL</button>
443
- </div>
444
-
445
- <div class="rte-media-body">
446
- ${o==="upload"?`
447
- <div id="upload-section">
448
- <div class="dropzone rte-media-dropzone" role="button" tabindex="0" aria-label="Drag and drop your ${e} here or click to browse. Max file size: 50MB">
449
- <div class="rte-media-dropzone-icon" aria-hidden="true">📁</div>
450
- <p class="rte-media-dropzone-title">Drag and drop your ${e} here</p>
451
- <p class="rte-media-muted">or click to browse</p>
452
- <p class="rte-media-hint">Max file size: 50MB</p>
453
- </div>
454
- <input type="file" id="file-input" aria-label="${e==="image"?"Choose an image file":"Choose a video file"}" accept="${e==="image"?"image/*":"video/*"}" style="display: none;">
455
- <div id="upload-progress" class="rte-media-progress" style="display: none;">
456
- <div class="rte-media-progress-track">
457
- <div id="progress-bar" class="rte-media-progress-bar"></div>
458
- </div>
459
- <p id="progress-text" class="rte-media-progress-text">Uploading...</p>
460
- </div>
461
- </div>
462
- `:`
463
- <div id="url-section">
464
- <div class="rte-media-field">
465
- <label class="rte-media-label" for="url-input">URL</label>
466
- <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e==="image"?"jpg":"mp4"}" value="${w.escapeHtml(d)}">
467
- </div>
468
- ${e==="image"?`
469
- <div class="rte-media-field">
470
- <label class="rte-media-label" for="alt-input">Alt Text (for accessibility)</label>
471
- <input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${w.escapeHtml(b)}">
472
- </div>
473
- `:""}
474
- <div class="rte-media-grid">
475
- <div class="rte-media-field">
476
- <label class="rte-media-label" for="width-input">Width (px)</label>
477
- <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${w.escapeHtml(l)}">
478
- </div>
479
- <div class="rte-media-field">
480
- <label class="rte-media-label" for="height-input">Height (px)</label>
481
- <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${w.escapeHtml(u)}">
482
- </div>
483
- </div>
484
- ${d?x():""}
485
- </div>
486
- `}
487
- </div>
488
-
489
- <div class="rte-media-footer">
490
- <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
491
- <button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d&&o==="url"?"disabled":""}>Insert</button>
492
- </div>
493
- `};y(),a.appendChild(i),document.body.appendChild(a);let C=()=>{};const f=()=>{C(),a.parentNode&&a.parentNode.removeChild(a)};C=U(a,f);const E=()=>{if(!d)return;const n=e==="image"?document.createElement("img"):document.createElement("video");n.src=d,n.setAttribute("data-media-type",e),e==="image"&&b&&(n.alt=b),l&&(n.style.width=`${l}px`,n.setAttribute("width",l)),u&&(n.style.height=`${u}px`,n.setAttribute("height",u)),e==="video"&&(n.controls=!0),!l&&!u?n.style.cssText="max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;":n.style.cssText=`display: block; margin: 1em 0; cursor: pointer; ${l?`width: ${l}px;`:"max-width: 100%;"} ${u?`height: ${u}px;`:"height: auto;"}`;const p=(M?(M.commonAncestorContainer instanceof HTMLElement?M.commonAncestorContainer:M.commonAncestorContainer.parentElement)?.closest('[contenteditable="true"]'):null)??te(t)?.closest('[contenteditable="true"]')??null,h=p?.innerHTML??"";if(M&&p?.contains(M.commonAncestorContainer)?(M.deleteContents(),M.insertNode(n)):p&&p.appendChild(n),f(),p&&n.isConnected){p.focus({preventScroll:!0});const $=window.getSelection();if($){const L=document.createRange();L.setStartAfter(n),L.collapse(!0),$.removeAllRanges(),$.addRange(L)}le.recordDomHistory(p,h),p.dispatchEvent(new Event("input",{bubbles:!0}))}},g=async n=>{const p=i.querySelector("#upload-progress"),h=i.querySelector("#progress-bar"),$=i.querySelector("#progress-text");if(p&&h&&$){p.style.display="block";let L=0;const v=setInterval(()=>{L+=Math.random()*30,L>90&&(L=90),h.style.width=`${L}%`},200);try{const k=new FileReader;k.onload=()=>{clearInterval(v),h.style.width="100%",$.textContent="Upload complete",setTimeout(()=>{d=k.result,o="url",y(),c()},500)},k.readAsDataURL(n)}catch{clearInterval(v),$.textContent="Upload failed"}}},c=()=>{const n=i.querySelector(".close-btn"),p=i.querySelector(".cancel-btn"),h=i.querySelector("#insert-btn"),$=i.querySelector(".tab-upload"),L=i.querySelector(".tab-url");if(n?.addEventListener("click",f),p?.addEventListener("click",f),h?.addEventListener("click",E),$?.addEventListener("click",()=>{o="upload",y(),c(),_(i,o)}),L?.addEventListener("click",()=>{o="url",y(),c(),_(i,o)}),o==="upload"){const v=i.querySelector(".dropzone"),k=i.querySelector("#file-input");v?.addEventListener("click",()=>k?.click()),ae(v,k),v?.addEventListener("dragover",z=>{z.preventDefault(),v.classList.add("is-dragover")}),v?.addEventListener("dragleave",()=>{v.classList.remove("is-dragover")}),v?.addEventListener("drop",z=>{z.preventDefault(),v.classList.remove("is-dragover");const q=z.dataTransfer?.files[0];q&&g(q)}),k?.addEventListener("change",z=>{const q=z.target.files?.[0];q&&g(q)})}if(o==="url"){const v=i.querySelector("#url-input"),k=i.querySelector("#alt-input"),z=i.querySelector("#width-input"),q=i.querySelector("#height-input");let X;v?.addEventListener("input",()=>{d=v.value;const Y=i.querySelector("#insert-btn");Y&&(Y.disabled=!d),clearTimeout(X),X=setTimeout(()=>{const V=i.querySelector("#url-section"),j=V?.querySelector(".rte-media-preview-field");if(!V)return;if(!d){j?.remove();return}if(j){const Z=j.querySelector("img, video");Z&&Z.setAttribute("src",d);return}V.querySelector(".rte-media-grid")?.insertAdjacentHTML("afterend",x())},400)}),k?.addEventListener("input",()=>{b=k.value}),z?.addEventListener("input",()=>{l=z.value}),q?.addEventListener("input",()=>{u=q.value})}};c(),a.addEventListener("click",n=>{n.target===a&&f()})},ce=()=>{["nw","ne","sw","se"].forEach(t=>{const r=document.createElement("div");r.className=`media-resize-handle-${t}`,r.style.cssText=`
494
- position: fixed;
495
- width: 10px;
496
- height: 10px;
497
- background: #007bff;
498
- border: 2px solid white;
499
- border-radius: 50%;
500
- cursor: ${t}-resize;
501
- z-index: 10001;
502
- display: none;
503
- box-shadow: 0 1px 3px rgba(0,0,0,0.3);
504
- `,r.setAttribute("data-position",t),document.body.appendChild(r),B.push(r)})},R=()=>{if(!m){B.forEach(r=>r.style.display="none");return}const e=m.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};B.forEach(r=>{const a=r.getAttribute("data-position"),i=t[a];r.style.left=`${i.x}px`,r.style.top=`${i.y}px`,r.style.display="block"})},pe=e=>{const t=N(e),r=P(!0);r.innerHTML=`
505
- <div class="rte-media-header">
506
- <h2 class="rte-media-title">Edit Alt Text</h2>
507
- <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
508
- </div>
509
- <div class="rte-media-body">
510
- <label class="rte-media-label">Alternative Text (for accessibility)</label>
511
- <textarea id="alt-text-input" class="rte-media-textarea" placeholder="Describe the image for screen readers...">${w.escapeHtml(e.alt||"")}</textarea>
512
- <p class="rte-media-helper">Good alt text is descriptive and concise. It helps users with visual impairments understand your content.</p>
513
- </div>
514
- <div class="rte-media-footer">
515
- <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
516
- <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
517
- </div>
518
- `,t.appendChild(r),document.body.appendChild(t);const a=r.querySelector("#alt-text-input"),i=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),d=r.querySelector(".save-btn");let l=()=>{};const u=()=>{l(),t.parentNode&&t.parentNode.removeChild(t)};l=U(t,u),i.addEventListener("click",u),o.addEventListener("click",u),t.addEventListener("click",b=>{b.target===t&&u()}),d.addEventListener("click",()=>{e.alt=a.value,u()}),a.focus(),a.select()},ue=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",a=t?.getAttribute("target")||"_self",i=t?.getAttribute("title")||"",o=N(e),d=P(!0);d.innerHTML=`
519
- <div class="rte-media-header">
520
- <h2 class="rte-media-title">${t?"Edit Link":"Add Link"}</h2>
521
- <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
522
- </div>
523
- <div class="rte-media-body">
524
- <div class="rte-media-field">
525
- <label class="rte-media-label">URL</label>
526
- <input id="link-url" type="url" class="rte-media-input" value="${w.escapeHtml(r)}" placeholder="https://example.com" />
527
- </div>
528
- <div class="rte-media-field">
529
- <label class="rte-media-label">Title (tooltip)</label>
530
- <input id="link-title" type="text" class="rte-media-input" value="${w.escapeHtml(i)}" placeholder="Optional tooltip text" />
531
- </div>
532
- <label class="rte-media-checkbox-label">
533
- <input id="link-target" type="checkbox" ${a==="_blank"?"checked":""} />
534
- Open in new window/tab
535
- </label>
536
- </div>
537
- <div class="rte-media-footer rte-media-footer-spread">
538
- ${t?'<button class="remove-link-btn rte-media-btn rte-media-btn-danger" type="button">Remove Link</button>':'<span class="rte-media-spacer"></span>'}
539
- <div class="rte-media-actions">
540
- <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
541
- <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
542
- </div>
543
- </div>
544
- `,o.appendChild(d),document.body.appendChild(o);const l=d.querySelector("#link-url"),u=d.querySelector("#link-title"),b=d.querySelector("#link-target"),x=d.querySelector(".close-btn"),y=d.querySelector(".cancel-btn"),C=d.querySelector(".save-btn"),f=d.querySelector(".remove-link-btn");let E=()=>{};const g=()=>{E(),o.parentNode&&o.parentNode.removeChild(o)};E=U(o,g),x.addEventListener("click",g),y.addEventListener("click",g),o.addEventListener("click",c=>{c.target===o&&g()}),C.addEventListener("click",()=>{const c=l.value.trim();if(c){const n=c.startsWith("http")?c:`https://${c}`;if(t)t.setAttribute("href",n),t.setAttribute("target",b.checked?"_blank":"_self"),b.checked?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel"),u.value.trim()?t.setAttribute("title",u.value.trim()):t.removeAttribute("title");else{const p=document.createElement("a");p.href=n,p.target=b.checked?"_blank":"_self",b.checked&&(p.rel="noopener noreferrer"),u.value.trim()&&(p.title=u.value.trim()),e.replaceWith(p),p.appendChild(e)}g(),s&&m&&O(m)}}),f?.addEventListener("click",async()=>{!t||!await F.confirmAction("Remove link from this media?",{title:"Remove link",confirmText:"Remove link",danger:!0,context:e})||!t.isConnected||(t.replaceWith(e),g(),s&&m&&O(m))}),l.focus()},me=e=>{const t=N(e),r=P();let a="url",i=e.src;const o=()=>{r.innerHTML=`
545
- <div class="rte-media-header">
546
- <h2 class="rte-media-title">Replace Image</h2>
547
- <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
548
- </div>
549
-
550
- <div class="rte-media-tabs" role="tablist" aria-label="Where to get the image from">
551
- <button class="tab-upload rte-media-tab ${a==="upload"?"active":""}" type="button" role="tab" aria-selected="${a==="upload"}">Upload</button>
552
- <button class="tab-url rte-media-tab ${a==="url"?"active":""}" type="button" role="tab" aria-selected="${a==="url"}">URL</button>
553
- </div>
554
-
555
- <div class="rte-media-body">
556
- ${a==="upload"?`
557
- <div id="upload-section">
558
- <div class="dropzone rte-media-dropzone" role="button" tabindex="0" aria-label="Drag and drop your image here or click to browse">
559
- <div class="rte-media-dropzone-icon" aria-hidden="true">📁</div>
560
- <p class="rte-media-dropzone-title">Drag and drop your image here</p>
561
- <p class="rte-media-muted">or click to browse</p>
562
- </div>
563
- <input type="file" id="file-input" aria-label="Choose an image file" accept="image/*" style="display: none;">
564
- <div id="upload-progress" class="rte-media-progress" style="display: none;">
565
- <div class="rte-media-progress-track">
566
- <div id="progress-bar" class="rte-media-progress-bar"></div>
567
- </div>
568
- <p id="progress-text" class="rte-media-progress-text">Uploading...</p>
569
- </div>
570
- </div>
571
- `:`
572
- <div id="url-section">
573
- <div class="rte-media-field">
574
- <label class="rte-media-label" for="url-input">Image URL</label>
575
- <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${w.escapeHtml(i)}">
576
- </div>
577
- ${i?`
578
- <div class="rte-media-field">
579
- <span class="rte-media-label">Preview</span>
580
- <div class="rte-media-preview">
581
- <img src="${w.escapeHtml(i)}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
582
- </div>
583
- </div>
584
- `:""}
585
- </div>
586
- `}
587
- </div>
588
-
589
- <div class="rte-media-footer">
590
- <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
591
- <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!i&&a==="url"?"disabled":""}>Replace</button>
592
- </div>
593
- `};o(),t.appendChild(r),document.body.appendChild(t);let d=()=>{};const l=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=U(t,l);const u=()=>{i&&(e.src=i,l())},b=async y=>{const C=r.querySelector("#upload-progress"),f=r.querySelector("#progress-bar"),E=r.querySelector("#progress-text");if(C&&f&&E){C.style.display="block";let g=0;const c=setInterval(()=>{g+=Math.random()*30,g>90&&(g=90),f.style.width=`${g}%`},200);try{const n=new FileReader;n.onload=()=>{clearInterval(c),f.style.width="100%",E.textContent="Upload complete",setTimeout(()=>{i=n.result,a="url",o(),x()},500)},n.readAsDataURL(y)}catch{clearInterval(c),E.textContent="Upload failed"}}},x=()=>{const y=r.querySelector(".close-btn"),C=r.querySelector(".cancel-btn"),f=r.querySelector("#replace-btn"),E=r.querySelector(".tab-upload"),g=r.querySelector(".tab-url");if(y?.addEventListener("click",l),C?.addEventListener("click",l),f?.addEventListener("click",u),E?.addEventListener("click",()=>{a="upload",o(),x(),_(r,a)}),g?.addEventListener("click",()=>{a="url",o(),x(),_(r,a)}),a==="upload"){const c=r.querySelector(".dropzone"),n=r.querySelector("#file-input");c?.addEventListener("click",()=>n?.click()),ae(c,n),c?.addEventListener("dragover",p=>{p.preventDefault(),c.classList.add("is-dragover")}),c?.addEventListener("dragleave",()=>{c.classList.remove("is-dragover")}),c?.addEventListener("drop",p=>{p.preventDefault(),c.classList.remove("is-dragover");const h=p.dataTransfer?.files[0];h&&b(h)}),n?.addEventListener("change",p=>{const h=p.target.files?.[0];h&&b(h)})}if(a==="url"){const c=r.querySelector("#url-input");c?.addEventListener("input",()=>{i=c.value;const n=r.querySelector("#replace-btn");n&&(n.disabled=!i)})}};x(),t.addEventListener("click",y=>{y.target===t&&l()})},S=()=>{if(!s||!m)return;const e=s.offsetHeight||40,t=s.offsetWidth||120,r=s.parentElement||m,a=r.getBoundingClientRect(),i=m.getBoundingClientRect(),o=i.top-a.top-r.clientTop+r.scrollTop,d=i.left-a.left-r.clientLeft+r.scrollLeft,l=m.closest('[contenteditable="true"]'),b=(l?i.top-l.getBoundingClientRect().top-e-8:1)<0?o+i.height+8:o-e-8,x=d+i.width/2-t/2;s.style.top=`${b}px`,s.style.left=`${x}px`,setTimeout(()=>{s&&(s.style.display="flex")},100)},ie=e=>{let t=e.parentElement;for(;t&&t.parentElement&&getComputedStyle(t).display==="inline";)t=t.parentElement;return t},O=e=>{s&&(s._cleanup&&s._cleanup(),s.remove());const t=ie(e);if(t){const l=t.style.position;(!l||l==="static")&&(t.style.position="relative",t._originalPosition=l),s=document.createElement("div"),s.className="media-floating-toolbar",re(e)&&s.classList.add("rte-ui-theme-dark"),t.insertBefore(s,t.firstChild),S()}const r=s;if(!r)return;const a=e.tagName==="IMG",i=e.closest("a");r.innerHTML=`
594
- <button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
595
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
596
- </button>
597
- <button class="media-floating-toolbar-btn btn-align-center" title="Align Center" type="button">
598
- <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>
599
- </button>
600
- <button class="media-floating-toolbar-btn btn-align-right" title="Align Right" type="button">
601
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="21" y1="10" x2="7" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="21" y1="18" x2="7" y2="18"></line></svg>
602
- </button>
603
- <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
604
- ${a?`
605
- <button class="media-floating-toolbar-btn btn-alt" title="Edit Alt Text" type="button">
606
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
607
- </button>`:""}
608
- <button class="media-floating-toolbar-btn btn-link" title="${i?"Edit/Remove Link":"Add Link"}" type="button">
609
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
610
- </button>
611
- ${a?`
612
- <button class="media-floating-toolbar-btn btn-replace" title="Replace Image" type="button">
613
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
614
- </button>`:""}
615
- <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
616
- <button class="media-floating-toolbar-btn btn-remove" title="Remove" type="button">
617
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
618
- </button>
619
- `,setTimeout(()=>{S()},0);const o=()=>S();let d=e.parentElement;for(;d;)d.addEventListener("scroll",o),d=d.parentElement;window.addEventListener("scroll",o),window.addEventListener("resize",o),r._cleanup=()=>{let l=e.parentElement;for(;l;)l.removeEventListener("scroll",o),l=l.parentElement;window.removeEventListener("scroll",o),window.removeEventListener("resize",o)},r.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",S()}),r.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",S()}),r.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",S()}),r.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&pe(e)}),r.querySelector(".btn-link")?.addEventListener("click",()=>{ue(e)}),r.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&me(e)}),r.querySelector(".btn-resize")?.addEventListener("click",async()=>{const l=await F.promptText("Enter width in pixels:",{title:"Resize",label:"Width (px)",initialValue:String(e.width||e.offsetWidth),inputMode:"numeric",confirmText:"Resize",context:e,validate:b=>/^\s*\d+\s*$/.test(b)&&parseInt(b,10)>0?null:"Enter a whole number of pixels, such as 480."});if(l===null)return;const u=parseInt(l,10);e.style.width=`${u}px`,e.setAttribute("width",String(u)),R(),S()}),r.querySelector(".btn-remove")?.addEventListener("click",async()=>{await F.confirmAction("Remove this media?",{title:"Remove media",confirmText:"Remove",danger:!0,context:e})&&(e.remove(),s&&(s._cleanup&&s._cleanup(),s.remove(),s=null),m=null,R())}),r._cleanup=()=>{window.removeEventListener("scroll",S),window.removeEventListener("resize",S)}},oe=e=>{I=e||null,ce(),document.addEventListener("click",t=>{const r=t.target;if(r.tagName==="IMG"||r.tagName==="VIDEO"){const a=r;let i=!1;if(I?i=I.contains(a):i=!!a.closest('[contenteditable="true"]'),i){t.preventDefault(),t.stopPropagation(),m=a,m.style.display="block",O(a),R();return}}if(!r.closest(".btn-link, .btn-resize, .btn-remove")&&s&&!r.closest("button")){s._cleanup&&s._cleanup(),s.remove(),s=null;const a=m&&ie(m);a&&a._originalPosition!==void 0&&(a.style.position=a._originalPosition,delete a._originalPosition),m=null,R()}}),B.forEach(t=>{t.addEventListener("mousedown",r=>{if(!m)return;r.preventDefault(),r.stopPropagation(),D=!0,H=t.getAttribute("data-position"),K=r.clientX,J=r.clientY;const a=m.getBoundingClientRect();T=a.width,A=a.height,W=T/A,document.body.style.userSelect="none",document.body.style.cursor=`${H}-resize`})}),document.addEventListener("mousemove",t=>{if(!D||!m||!H)return;const r=t.clientX-K,a=t.clientY-J;let i=T,o=A;switch(H){case"se":i=T+r,o=A+a;break;case"sw":i=T-r,o=A+a;break;case"ne":i=T+r,o=A-a;break;case"nw":i=T-r,o=A-a;break}Math.abs(r)>Math.abs(a)?o=i/W:i=o*W,i=Math.max(50,i),o=Math.max(50,o),m.style.width=`${i}px`,m.style.height=`${o}px`,m.setAttribute("width",String(Math.round(i))),m.setAttribute("height",String(Math.round(o))),R(),S()}),document.addEventListener("mouseup",()=>{D&&(D=!1,H=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",R),window.addEventListener("resize",R)};typeof window<"u"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,oe());const be=()=>({name:"image",initialize:e=>{const t=e?.editorElement;oe(t)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return Q("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return Q("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),ge={apiEndpoints:{upload:"/media/upload",library:"/media/library",delete:"/media/library"},maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif","video/mp4","video/webm"],headers:{}};let G={...ge};function ve(e){G={...G,...e}}function fe(){return{...G}}exports.MediaManagerPlugin=be;exports.getMediaManagerConfig=fe;exports.setMediaManagerConfig=ve;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./MediaManagerPlugin.native-CycfjOi4.js"),a=[{id:"image",label:"Image",description:"Upload or choose an image",command:"insertImage",keywords:["picture","photo","img","upload"]},{id:"audio",label:"Audio",description:"Upload or choose an audio file",command:"insertAudio",keywords:["sound","music","podcast","mp3"]},{id:"video",label:"Video",description:"Upload or choose a video",command:"insertVideo",keywords:["movie","clip","mp4"]}];exports.MediaManagerPlugin=e.MediaManagerPlugin;exports.MediaUploadError=e.MediaUploadError;exports.createBase64Provider=e.createBase64Provider;exports.createCallbackProvider=e.createCallbackProvider;exports.createRestProvider=e.createRestProvider;exports.getMediaManagerConfig=e.getMediaManagerConfig;exports.parseEmbedUrl=e.parseEmbedUrl;exports.setMediaManagerConfig=e.setMediaManagerConfig;exports.mediaSlashItems=a;