@editora/plugins 1.0.15 → 1.0.17
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.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/CodePlugin.native-CmnEFfJi.mjs +646 -0
- package/dist/CodePlugin.native-Cqi46sxh.js +460 -0
- package/dist/code.cjs.js +1 -669
- package/dist/code.esm.js +2 -4560
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-Jf0RbSks.js → documentManager-3nPkITwx.js} +2 -2
- package/dist/{documentManager-CTqRftU8.mjs → documentManager-CRumGpCT.mjs} +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +1 -1
- package/dist/{index-BFsKNTTj.mjs → index-CJ90EVWy.mjs} +3 -3
- package/dist/index-CxhJLMPS.js +221 -0
- package/dist/{index-tqLTHcO6.js → index-DTkvH8gX.js} +1 -1
- package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
- package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
- package/dist/index.esm.js +2 -2
- package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
- package/dist/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
- package/package.json +4 -4
- package/dist/index-CvJk4DKa.js +0 -221
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
"use strict";const l=require("@editora/light-code-editor"),T='[data-theme="dark"], .dark, .editora-theme-dark',I=`/* Source Editor Dialog Styles */
|
|
2
|
+
.rte-source-editor-overlay {
|
|
3
|
+
position: fixed !important;
|
|
4
|
+
top: 0 !important;
|
|
5
|
+
left: 0 !important;
|
|
6
|
+
right: 0 !important;
|
|
7
|
+
bottom: 0 !important;
|
|
8
|
+
width: 100vw !important;
|
|
9
|
+
height: 100vh !important;
|
|
10
|
+
background-color: rgba(0, 0, 0, 0.6) !important;
|
|
11
|
+
display: flex !important;
|
|
12
|
+
align-items: center !important;
|
|
13
|
+
justify-content: center !important;
|
|
14
|
+
z-index: 10000 !important;
|
|
15
|
+
padding: 20px !important;
|
|
16
|
+
box-sizing: border-box !important;
|
|
17
|
+
margin: 0 !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.rte-source-editor-overlay.fullscreen {
|
|
21
|
+
padding: 0 !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.rte-source-editor-modal {
|
|
25
|
+
background: white;
|
|
26
|
+
border-radius: 8px;
|
|
27
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
28
|
+
width: 100%;
|
|
29
|
+
max-width: 1200px;
|
|
30
|
+
max-height: 90vh;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.rte-source-editor-overlay.fullscreen .rte-source-editor-modal {
|
|
38
|
+
border-radius: 0;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
max-height: 100vh;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100vh;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.rte-source-editor-header {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
padding: 16px 20px;
|
|
50
|
+
border-bottom: 1px solid #e1e5e9;
|
|
51
|
+
background: #f8f9fa;
|
|
52
|
+
border-radius: 8px 8px 0 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.rte-source-editor-overlay.fullscreen .rte-source-editor-header {
|
|
56
|
+
border-radius: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.rte-source-editor-header h2 {
|
|
60
|
+
margin: 0;
|
|
61
|
+
font-size: 18px;
|
|
62
|
+
font-weight: 600;
|
|
63
|
+
color: #1a1a1a;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.rte-source-editor-header-toolbar {
|
|
67
|
+
display: flex;
|
|
68
|
+
gap: 8px;
|
|
69
|
+
margin-left: auto;
|
|
70
|
+
margin-right: 16px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.rte-source-editor-toolbar-btn {
|
|
74
|
+
background: none;
|
|
75
|
+
border: none;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
padding: 6px;
|
|
78
|
+
border-radius: 4px;
|
|
79
|
+
font-size: 16px;
|
|
80
|
+
line-height: 1;
|
|
81
|
+
transition: all 0.2s ease;
|
|
82
|
+
color: #666;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.rte-source-editor-toolbar-btn:hover:not(:disabled) {
|
|
86
|
+
background: #e1e5e9;
|
|
87
|
+
color: #1a1a1a;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.rte-source-editor-toolbar-btn:disabled {
|
|
91
|
+
opacity: 0.5;
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.rte-source-editor-toolbar-btn.active {
|
|
96
|
+
background: #007acc;
|
|
97
|
+
color: white;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.rte-source-editor-toolbar-btn.active:hover {
|
|
101
|
+
background: #0056b3;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.rte-source-editor-header-actions {
|
|
105
|
+
display: flex;
|
|
106
|
+
gap: 8px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.rte-source-editor-fullscreen-btn,
|
|
110
|
+
.rte-source-editor-close-btn {
|
|
111
|
+
background: none;
|
|
112
|
+
border: none;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
padding: 4px;
|
|
115
|
+
border-radius: 4px;
|
|
116
|
+
color: #666;
|
|
117
|
+
font-size: 16px;
|
|
118
|
+
line-height: 1;
|
|
119
|
+
transition: all 0.2s ease;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.rte-source-editor-fullscreen-btn:hover,
|
|
123
|
+
.rte-source-editor-close-btn:hover {
|
|
124
|
+
background: #e1e5e9;
|
|
125
|
+
color: #1a1a1a;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.rte-source-editor-body {
|
|
129
|
+
flex: 1;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
display: flex;
|
|
132
|
+
flex-direction: column;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.rte-source-editor-loading {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
padding: 40px;
|
|
141
|
+
color: #666;
|
|
142
|
+
position: absolute;
|
|
143
|
+
z-index: 9;
|
|
144
|
+
margin: 0 auto;
|
|
145
|
+
width: 100%;
|
|
146
|
+
top: 44%;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.rte-source-editor-spinner {
|
|
150
|
+
width: 32px;
|
|
151
|
+
height: 32px;
|
|
152
|
+
border: 3px solid #e1e5e9;
|
|
153
|
+
border-top: 3px solid #007acc;
|
|
154
|
+
border-radius: 50%;
|
|
155
|
+
animation: spin 1s linear infinite;
|
|
156
|
+
margin-bottom: 16px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@keyframes spin {
|
|
160
|
+
0% { transform: rotate(0deg); }
|
|
161
|
+
100% { transform: rotate(360deg); }
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.rte-source-editor-error {
|
|
165
|
+
background: #fee;
|
|
166
|
+
color: #c53030;
|
|
167
|
+
padding: 12px 16px;
|
|
168
|
+
border-left: 4px solid #c53030;
|
|
169
|
+
margin: 16px;
|
|
170
|
+
border-radius: 4px;
|
|
171
|
+
font-size: 14px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.rte-source-editor-content {
|
|
175
|
+
flex: 1;
|
|
176
|
+
display: flex;
|
|
177
|
+
flex-direction: column;
|
|
178
|
+
overflow: hidden;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.rte-source-editor-warning {
|
|
182
|
+
background: #fefcbf;
|
|
183
|
+
color: #744210;
|
|
184
|
+
padding: 8px 16px;
|
|
185
|
+
font-size: 12px;
|
|
186
|
+
font-weight: 500;
|
|
187
|
+
border-bottom: 1px solid #f6e05e;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.rte-source-editor-codemirror {
|
|
191
|
+
flex: 1;
|
|
192
|
+
overflow: auto;
|
|
193
|
+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
194
|
+
font-size: 14px;
|
|
195
|
+
line-height: 1.5;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.rte-source-editor-codemirror .cm-editor {
|
|
199
|
+
height: 100%;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.rte-source-editor-codemirror .cm-focused {
|
|
203
|
+
outline: none;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.rte-source-editor-footer {
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
justify-content: space-between;
|
|
210
|
+
padding: 16px 20px;
|
|
211
|
+
border-top: 1px solid #e1e5e9;
|
|
212
|
+
background: #f8f9fa;
|
|
213
|
+
border-radius: 0 0 8px 8px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.rte-source-editor-overlay.fullscreen .rte-source-editor-footer {
|
|
217
|
+
border-radius: 0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.rte-source-editor-footer-info {
|
|
221
|
+
font-size: 12px;
|
|
222
|
+
color: #666;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.unsaved-changes {
|
|
226
|
+
color: #d69e2e;
|
|
227
|
+
font-weight: 500;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.rte-source-editor-footer-actions {
|
|
231
|
+
display: flex;
|
|
232
|
+
gap: 12px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.rte-source-editor-btn {
|
|
236
|
+
padding: 8px 16px;
|
|
237
|
+
border-radius: 4px;
|
|
238
|
+
font-size: 14px;
|
|
239
|
+
font-weight: 500;
|
|
240
|
+
cursor: pointer;
|
|
241
|
+
border: 1px solid transparent;
|
|
242
|
+
transition: all 0.2s ease;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.rte-source-editor-btn:disabled {
|
|
246
|
+
opacity: 0.6;
|
|
247
|
+
cursor: not-allowed;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.rte-source-editor-btn-cancel {
|
|
251
|
+
background: white;
|
|
252
|
+
border-color: #d1d5db;
|
|
253
|
+
color: #374151;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.rte-source-editor-btn-cancel:hover:not(:disabled) {
|
|
257
|
+
background: #f9fafb;
|
|
258
|
+
border-color: #9ca3af;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.rte-source-editor-btn-save {
|
|
262
|
+
background: #007acc;
|
|
263
|
+
color: white;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.rte-source-editor-btn-save:hover:not(:disabled) {
|
|
267
|
+
background: #0056b3;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-modal {
|
|
271
|
+
background: #1e1e1e;
|
|
272
|
+
color: #f8f9fa;
|
|
273
|
+
border: 1px solid #434d5f;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header,
|
|
277
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer {
|
|
278
|
+
background: #2a3442;
|
|
279
|
+
border-color: #434d5f;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header h2 {
|
|
283
|
+
color: #f8f9fa;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn,
|
|
287
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn,
|
|
288
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn {
|
|
289
|
+
color: #c1cede;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn:hover:not(:disabled),
|
|
293
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn:hover,
|
|
294
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn:hover {
|
|
295
|
+
background: #404a5a;
|
|
296
|
+
color: #f8fafc;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active {
|
|
300
|
+
background: #3b82f6;
|
|
301
|
+
color: #ffffff;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active:hover {
|
|
305
|
+
background: #2563eb;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-loading,
|
|
309
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer-info {
|
|
310
|
+
color: #cbd5e1;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-spinner {
|
|
314
|
+
border-color: #3f4b60;
|
|
315
|
+
border-top-color: #58a6ff;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-error {
|
|
319
|
+
background: #3f2124;
|
|
320
|
+
color: #fecaca;
|
|
321
|
+
border-color: #ef4444;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-warning {
|
|
325
|
+
background: #3b3220;
|
|
326
|
+
color: #fde68a;
|
|
327
|
+
border-color: #f59e0b;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel {
|
|
331
|
+
background: #334155;
|
|
332
|
+
border-color: #475569;
|
|
333
|
+
color: #f1f5f9;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel:hover:not(:disabled) {
|
|
337
|
+
background: #475569;
|
|
338
|
+
border-color: #64748b;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save {
|
|
342
|
+
background: #3b82f6;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save:hover:not(:disabled) {
|
|
346
|
+
background: #2563eb;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* Responsive design */
|
|
350
|
+
@media (max-width: 768px) {
|
|
351
|
+
.rte-source-editor-overlay {
|
|
352
|
+
padding: 10px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.rte-source-editor-modal {
|
|
356
|
+
max-height: 95vh;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.rte-source-editor-header {
|
|
360
|
+
padding: 12px 16px;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.rte-source-editor-footer {
|
|
364
|
+
padding: 12px 16px;
|
|
365
|
+
flex-direction: column;
|
|
366
|
+
gap: 12px;
|
|
367
|
+
align-items: stretch;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.rte-source-editor-footer-actions {
|
|
371
|
+
justify-content: stretch;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.rte-source-editor-btn {
|
|
375
|
+
flex: 1;
|
|
376
|
+
text-align: center;
|
|
377
|
+
}
|
|
378
|
+
}`,P=()=>({name:"code",toolbar:[{label:"Source",command:"toggleSourceView",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="nonzero"><path d="M9.8 15.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0l-4.4-4.1a.8.8 0 0 1 0-1.2l4.4-4.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L6 12l3.8 3.7ZM14.2 15.7c-.3.3-.3.8 0 1 .4.4.9.4 1.2 0l4.4-4.1c.3-.3.3-.9 0-1.2l-4.4-4.2a.8.8 0 0 0-1.2 0c-.3.3-.3.8 0 1.1L18 12l-3.8 3.7Z"></path></g></svg>',shortcut:"Mod-Shift-S"}],commands:{toggleSourceView:()=>{const u=(()=>{const a=window.getSelection();if(a&&a.anchorNode){let e=a.anchorNode instanceof HTMLElement?a.anchorNode:a.anchorNode.parentElement;for(;e;){if(e.classList?.contains("rte-content"))return e;e=e.parentElement}}if(document.activeElement){let e=document.activeElement;if(e.classList?.contains("rte-content"))return e;for(;e&&e!==document.body;){if(e.classList?.contains("rte-content"))return e;const n=e.querySelector(".rte-content");if(n)return n;e=e.parentElement}}const o=document.querySelector("[data-editora-editor]");if(o){const e=o.querySelector(".rte-content");if(e)return e}return document.querySelector(".rte-content")})();if(!u)return console.error("[CodePlugin] Editor content area not found"),alert("Editor content area not found. Please click inside the editor first."),!1;const N=u.innerHTML,D=a=>{let o="",e=0;const n=2,h=a.split(/(<\/?[a-zA-Z][^>]*>)/);for(const r of h)r.trim()&&(r.match(/^<\/[a-zA-Z]/)?(e=Math.max(0,e-1),o+=`
|
|
379
|
+
`+" ".repeat(e*n)+r):r.match(/^<[a-zA-Z]/)&&!r.match(/\/>$/)?(o+=`
|
|
380
|
+
`+" ".repeat(e*n)+r,e++):r.match(/^<[a-zA-Z].*\/>$/)?o+=`
|
|
381
|
+
`+" ".repeat(e*n)+r:o+=r.trim());return o.trim()};return(()=>{const o=D(N);let e=null,n="dark",h=!1,r=!1,v=!1,E=!1;const R=!!u.closest(T)||document.body.matches(T)||document.documentElement.matches(T),i=document.createElement("div");i.className="rte-source-editor-overlay",R&&i.classList.add("rte-theme-dark");const d=document.createElement("div");d.className="rte-source-editor-modal",d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby","source-editor-title");const f=document.createElement("div");f.className="rte-source-editor-header",f.innerHTML=`
|
|
382
|
+
<h2 id="source-editor-title">Source Editor</h2>
|
|
383
|
+
<div class="rte-source-editor-header-toolbar">
|
|
384
|
+
<button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
|
|
385
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
386
|
+
<circle cx="12" cy="12" r="5"/>
|
|
387
|
+
<line x1="12" y1="1" x2="12" y2="3"/>
|
|
388
|
+
<line x1="12" y1="21" x2="12" y2="23"/>
|
|
389
|
+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
|
|
390
|
+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
|
391
|
+
<line x1="1" y1="12" x2="3" y2="12"/>
|
|
392
|
+
<line x1="21" y1="12" x2="23" y2="12"/>
|
|
393
|
+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
|
|
394
|
+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
395
|
+
</svg>
|
|
396
|
+
</button>
|
|
397
|
+
<button class="rte-source-editor-toolbar-btn readonly-toggle-btn" title="Toggle read-only">
|
|
398
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
399
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
|
|
400
|
+
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
401
|
+
</svg>
|
|
402
|
+
</button>
|
|
403
|
+
</div>
|
|
404
|
+
<div class="rte-source-editor-header-actions">
|
|
405
|
+
<button class="rte-source-editor-fullscreen-btn" title="Toggle fullscreen">
|
|
406
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
407
|
+
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
|
|
408
|
+
</svg>
|
|
409
|
+
</button>
|
|
410
|
+
<button class="rte-source-editor-close-btn" aria-label="Close source editor">
|
|
411
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
412
|
+
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
413
|
+
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
414
|
+
</svg>
|
|
415
|
+
</button>
|
|
416
|
+
</div>
|
|
417
|
+
`;const C=document.createElement("div");C.className="rte-source-editor-body";const x=document.createElement("div");x.className="rte-source-editor-content";const M=document.createElement("div");M.className="rte-source-editor-warning",M.textContent="⚠️ Advanced users only. Invalid HTML may break the editor.";const g=document.createElement("div");g.className="rte-source-editor-light-editor",g.style.height="400px",x.appendChild(M),x.appendChild(g),C.appendChild(x);const b=document.createElement("div");if(b.className="rte-source-editor-footer",b.innerHTML=`
|
|
418
|
+
<div class="rte-source-editor-footer-info">
|
|
419
|
+
<span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
|
|
420
|
+
</div>
|
|
421
|
+
<div class="rte-source-editor-footer-actions">
|
|
422
|
+
<button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
|
|
423
|
+
<button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
|
|
424
|
+
</div>
|
|
425
|
+
`,d.appendChild(f),d.appendChild(C),d.appendChild(b),i.appendChild(d),!document.getElementById("rte-source-editor-styles")){const t=document.createElement("style");t.id="rte-source-editor-styles",t.textContent=I,document.head.appendChild(t)}const y=f.querySelector(".theme-toggle-btn"),p=f.querySelector(".readonly-toggle-btn"),k=f.querySelector(".rte-source-editor-fullscreen-btn"),H=f.querySelector(".rte-source-editor-close-btn"),z=b.querySelector(".rte-source-editor-btn-cancel"),B=b.querySelector(".rte-source-editor-btn-save"),q=b.querySelector(".unsaved-changes"),S=[],s=(t,c,L,w)=>{t.addEventListener(c,L,w),S.push(()=>t.removeEventListener(c,L,w))},A=t=>{v!==t&&(v=t,q&&(q.style.display=v?"inline":"none"))},m=()=>{if(!E){for(E=!0;S.length;)S.pop()?.();e&&(e.destroy(),e=null),i.isConnected&&i.remove()}},O=()=>{n=n==="dark"?"light":"dark",e?.setTheme(n),y&&(y.innerHTML=n==="light"?`
|
|
426
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
427
|
+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
|
|
428
|
+
</svg>
|
|
429
|
+
`:`
|
|
430
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
431
|
+
<circle cx="12" cy="12" r="5"/>
|
|
432
|
+
<line x1="12" y1="1" x2="12" y2="3"/>
|
|
433
|
+
<line x1="12" y1="21" x2="12" y2="23"/>
|
|
434
|
+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
|
|
435
|
+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
|
436
|
+
<line x1="1" y1="12" x2="3" y2="12"/>
|
|
437
|
+
<line x1="21" y1="12" x2="23" y2="12"/>
|
|
438
|
+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
|
|
439
|
+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
|
440
|
+
</svg>
|
|
441
|
+
`)},j=()=>{h=!h,e?.setReadOnly(h),p&&(p.classList.toggle("active",h),p.innerHTML=h?`
|
|
442
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
443
|
+
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
|
|
444
|
+
<circle cx="12" cy="16" r="1"/>
|
|
445
|
+
<path d="M7 11V7a5 5 0 0 1 10 0v4"/>
|
|
446
|
+
</svg>
|
|
447
|
+
`:`
|
|
448
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
449
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
|
|
450
|
+
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
451
|
+
</svg>
|
|
452
|
+
`)},F=()=>{r=!r,i.classList.toggle("fullscreen",r),g.style.height=r?"calc(100vh - 200px)":"400px",k&&(k.innerHTML=r?`
|
|
453
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
454
|
+
<path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3"/>
|
|
455
|
+
</svg>
|
|
456
|
+
`:`
|
|
457
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
458
|
+
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
|
|
459
|
+
</svg>
|
|
460
|
+
`)},V=()=>{v&&!confirm("You have unsaved changes. Are you sure you want to cancel?")||m()},Z=()=>{try{const t=e?.getValue()||"",c=document.createElement("div");c.innerHTML=t,c.querySelectorAll('script, iframe[src^="javascript:"], object, embed').forEach(w=>w.remove()),u.innerHTML=c.innerHTML;try{u.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!1,inputType:"insertReplacementText"}))}catch{u.dispatchEvent(new Event("input",{bubbles:!0}))}u.dispatchEvent(new Event("change",{bubbles:!0})),A(!1),m()}catch(t){alert("Failed to update HTML. Please check your syntax."),console.error("HTML update error:",t)}};y&&s(y,"click",O),p&&s(p,"click",j),k&&s(k,"click",F),H&&s(H,"click",m),z&&s(z,"click",V),B&&s(B,"click",Z),s(i,"click",t=>{t.target===i&&m()}),s(document,"keydown",t=>{const c=t;c.key==="Escape"&&(c.preventDefault(),m())}),document.body.appendChild(i),requestAnimationFrame(()=>{if(!(E||!i.isConnected))try{e=l.createEditor(g,{value:o,theme:"dark",readOnly:!1,extensions:[new l.LineNumbersExtension,new l.ThemeExtension,new l.ReadOnlyExtension,new l.BracketMatchingExtension,new l.SearchExtension,new l.CodeFoldingExtension,new l.SyntaxHighlightingExtension]}),e.on("change",()=>{const t=e?.getValue()||"";A(t!==o)}),requestAnimationFrame(()=>e?.focus())}catch(t){console.error("Failed to initialize code editor:",t)}})})(),!0}},keymap:{"Mod-Shift-s":"toggleSourceView","Mod-Shift-S":"toggleSourceView"}});exports.CodePlugin=P;
|