@editora/core 1.0.3 → 1.0.4
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/README.md +34 -0
- package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
- package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
- package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
- package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
- package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
- package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-0Zari_zp.mjs} +329 -310
- package/dist/CodeSamplePlugin.native-B-KS1pOl.mjs +384 -0
- package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
- package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
- package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
- package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
- package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
- package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
- package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
- package/dist/HistoryPlugin.native-DCrPdeSW.mjs +257 -0
- package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
- package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
- package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
- package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
- package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
- package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
- package/dist/MergeTagPlugin.native-CU9LtsfD.mjs +416 -0
- package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
- package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
- package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
- package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
- package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
- package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
- package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
- package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
- package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
- package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
- package/dist/core.css +1 -1
- package/dist/editora.min.js +31 -29
- package/dist/editora.umd.js +31 -29
- package/dist/index-CqWQFb3D.js +10 -0
- package/dist/index-OwnkG39N.mjs +2227 -0
- package/dist/index.cjs.js +14 -18
- package/dist/index.esm.js +204 -521
- package/dist/plugin-loader.js +26 -26
- package/dist/webcomponent-core.js +1286 -295
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +100 -75
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +1252 -261
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +3616 -2109
- package/index.d.ts +355 -0
- package/package.json +19 -17
- package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
- package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
- package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
- package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
- package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
- package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
- package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
- package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
- package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
- package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
- package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
- package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
- package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
- package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
- package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
- package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
- package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
- package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
- package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
- package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
- package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
- package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
- package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
- package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
- package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
- package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
- package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
- package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
- package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
- package/dist/documentManager-irzj9n3V.mjs.map +0 -1
- package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
- package/dist/editora.min.js.map +0 -1
- package/dist/editora.umd.js.map +0 -1
- package/dist/index-BF5RBhL9.js +0 -4
- package/dist/index-BF5RBhL9.js.map +0 -1
- package/dist/index-BPsf460l.mjs +0 -1243
- package/dist/index-BPsf460l.mjs.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es-CuicffkQ.mjs.map +0 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/plugin-loader.js.map +0 -1
- package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
- package/dist/webcomponent-core.js.map +0 -1
- package/dist/webcomponent-core.min.js.map +0 -1
- package/dist/webcomponent.cjs.js.map +0 -1
- package/dist/webcomponent.esm.js.map +0 -1
- package/dist/webcomponent.js.map +0 -1
- package/dist/webcomponent.min.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class R {
|
|
2
2
|
constructor(e = "") {
|
|
3
3
|
this._lines = [], this._version = 0, this.setText(e);
|
|
4
4
|
}
|
|
@@ -42,9 +42,9 @@ class P {
|
|
|
42
42
|
const i = this.getLine(e.start.line), r = i.substring(0, e.start.column) + t + i.substring(e.end.column);
|
|
43
43
|
this._lines[e.start.line] = r;
|
|
44
44
|
} else {
|
|
45
|
-
const i = this.getLine(e.start.line), r = this.getLine(e.end.line),
|
|
45
|
+
const i = this.getLine(e.start.line), r = this.getLine(e.end.line), o = i.substring(0, e.start.column) + t, n = r.substring(e.end.column), l = t.split(`
|
|
46
46
|
`);
|
|
47
|
-
|
|
47
|
+
l[0] = o + l[0], l[l.length - 1] = l[l.length - 1] + n, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...l);
|
|
48
48
|
}
|
|
49
49
|
return this._version++, { range: e, text: t, oldText: s };
|
|
50
50
|
}
|
|
@@ -92,11 +92,11 @@ class P {
|
|
|
92
92
|
}
|
|
93
93
|
// Clone the model
|
|
94
94
|
clone() {
|
|
95
|
-
const e = new
|
|
95
|
+
const e = new R();
|
|
96
96
|
return e._lines = [...this._lines], e._version = this._version, e;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
class
|
|
99
|
+
class A {
|
|
100
100
|
constructor(e) {
|
|
101
101
|
this.gutterWidth = 50, this.lineHeight = 21, this.container = e, this.createDOM();
|
|
102
102
|
}
|
|
@@ -195,32 +195,32 @@ class B {
|
|
|
195
195
|
}
|
|
196
196
|
// Set cursor position
|
|
197
197
|
setCursorPosition(e) {
|
|
198
|
-
var g,
|
|
198
|
+
var g, h;
|
|
199
199
|
const t = this.getText().split(`
|
|
200
200
|
`), s = Math.min(e.line, t.length - 1), i = Math.min(e.column, ((g = t[s]) == null ? void 0 : g.length) || 0);
|
|
201
201
|
let r = 0;
|
|
202
202
|
for (let f = 0; f < s; f++)
|
|
203
203
|
r += t[f].length + 1;
|
|
204
204
|
r += i;
|
|
205
|
-
const
|
|
206
|
-
let
|
|
207
|
-
const
|
|
205
|
+
const o = document.createRange(), n = window.getSelection();
|
|
206
|
+
let l = 0, c = null, a = 0;
|
|
207
|
+
const u = document.createTreeWalker(
|
|
208
208
|
this.contentElement,
|
|
209
209
|
NodeFilter.SHOW_TEXT,
|
|
210
210
|
null
|
|
211
211
|
);
|
|
212
|
-
let
|
|
213
|
-
for (;
|
|
214
|
-
const f = ((
|
|
215
|
-
if (
|
|
216
|
-
c =
|
|
212
|
+
let d;
|
|
213
|
+
for (; d = u.nextNode(); ) {
|
|
214
|
+
const f = ((h = d.textContent) == null ? void 0 : h.length) || 0;
|
|
215
|
+
if (l + f >= r) {
|
|
216
|
+
c = d, a = r - l;
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
l += f;
|
|
220
220
|
}
|
|
221
221
|
if (c)
|
|
222
222
|
try {
|
|
223
|
-
|
|
223
|
+
o.setStart(c, a), o.setEnd(c, a), n == null || n.removeAllRanges(), n == null || n.addRange(o);
|
|
224
224
|
} catch (f) {
|
|
225
225
|
console.warn("Could not set cursor position:", f);
|
|
226
226
|
}
|
|
@@ -235,7 +235,7 @@ class B {
|
|
|
235
235
|
const i = s.toString().split(`
|
|
236
236
|
`), r = t.cloneRange();
|
|
237
237
|
r.selectNodeContents(this.contentElement), r.setEnd(t.endContainer, t.endOffset);
|
|
238
|
-
const
|
|
238
|
+
const o = r.toString().split(`
|
|
239
239
|
`);
|
|
240
240
|
return {
|
|
241
241
|
start: {
|
|
@@ -243,8 +243,8 @@ class B {
|
|
|
243
243
|
column: i[i.length - 1].length
|
|
244
244
|
},
|
|
245
245
|
end: {
|
|
246
|
-
line:
|
|
247
|
-
column:
|
|
246
|
+
line: o.length - 1,
|
|
247
|
+
column: o[o.length - 1].length
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
}
|
|
@@ -288,7 +288,7 @@ class B {
|
|
|
288
288
|
this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
class
|
|
291
|
+
class V {
|
|
292
292
|
constructor(e, t = {}) {
|
|
293
293
|
this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.expectingProgrammaticCursor = !1, this.config = {
|
|
294
294
|
value: "",
|
|
@@ -298,7 +298,7 @@ class K {
|
|
|
298
298
|
lineWrapping: !1,
|
|
299
299
|
lineNumbers: !0,
|
|
300
300
|
...t
|
|
301
|
-
}, this.textModel = new
|
|
301
|
+
}, this.textModel = new R(this.config.value), this.view = new A(e), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((s) => this.addExtension(s)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
|
|
302
302
|
}
|
|
303
303
|
// Public accessors for extensions
|
|
304
304
|
getTextModel() {
|
|
@@ -327,9 +327,9 @@ class K {
|
|
|
327
327
|
const t = this.view.getText(), s = this.textModel.getText();
|
|
328
328
|
if (t !== s) {
|
|
329
329
|
if (!this.suppressHistory) {
|
|
330
|
-
const i = this.getCursor().position, r = this.textModel.positionToOffset(i),
|
|
331
|
-
let
|
|
332
|
-
|
|
330
|
+
const i = this.getCursor().position, r = this.textModel.positionToOffset(i), o = this.getSelection();
|
|
331
|
+
let n, l;
|
|
332
|
+
o && (n = this.textModel.positionToOffset(o.start), l = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: s, cursorOffset: r, anchorOffset: n, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
|
|
333
333
|
}
|
|
334
334
|
this.textModel.setText(t), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
|
|
335
335
|
this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
|
|
@@ -347,26 +347,26 @@ class K {
|
|
|
347
347
|
if (!this.config.readOnly) {
|
|
348
348
|
const s = window.getSelection();
|
|
349
349
|
if (s && s.rangeCount > 0) {
|
|
350
|
-
const i = this.getCursor().position, r = this.textModel.positionToOffset(i),
|
|
351
|
-
let
|
|
352
|
-
|
|
350
|
+
const i = this.getCursor().position, r = this.textModel.positionToOffset(i), o = this.getSelection();
|
|
351
|
+
let n, l;
|
|
352
|
+
o && (n = this.textModel.positionToOffset(o.start), l = this.textModel.positionToOffset(o.end)), this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: r, anchorOffset: n, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
|
|
353
353
|
const c = s.getRangeAt(0);
|
|
354
354
|
c.deleteContents();
|
|
355
|
-
const
|
|
355
|
+
const a = document.createTextNode(`
|
|
356
356
|
`);
|
|
357
|
-
c.insertNode(
|
|
358
|
-
const
|
|
359
|
-
let
|
|
360
|
-
g && (
|
|
357
|
+
c.insertNode(a), c.setStartAfter(a), c.collapse(!0), s.removeAllRanges(), s.addRange(c);
|
|
358
|
+
const u = this.getCursor().position, d = this.textModel.positionToOffset(u), g = this.getSelection();
|
|
359
|
+
let h, f;
|
|
360
|
+
g && (h = this.textModel.positionToOffset(g.start), f = this.textModel.positionToOffset(g.end));
|
|
361
361
|
const p = this.view.getText();
|
|
362
362
|
this.textModel.setText(p), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
|
|
363
363
|
this.renderTextWithHighlight(this.textModel.getText(), !1), requestAnimationFrame(() => {
|
|
364
364
|
try {
|
|
365
|
-
if (g && (
|
|
366
|
-
const x =
|
|
367
|
-
this.setSelection({ start: L, end:
|
|
365
|
+
if (g && (h !== void 0 || f !== void 0)) {
|
|
366
|
+
const x = h !== void 0 ? h : d, b = f !== void 0 ? f : d, y = Math.min(x, b), C = Math.max(x, b), L = this.textModel.offsetToPosition(y), w = this.textModel.offsetToPosition(C);
|
|
367
|
+
this.setSelection({ start: L, end: w });
|
|
368
368
|
} else {
|
|
369
|
-
const x = this.textModel.offsetToPosition(
|
|
369
|
+
const x = this.textModel.offsetToPosition(d);
|
|
370
370
|
this.setCursor(x);
|
|
371
371
|
}
|
|
372
372
|
} catch (x) {
|
|
@@ -500,25 +500,25 @@ class K {
|
|
|
500
500
|
}, i = [], r = this.getValue();
|
|
501
501
|
r.split(`
|
|
502
502
|
`);
|
|
503
|
-
let
|
|
503
|
+
let o = s.caseSensitive ? r : r.toLowerCase(), n = s.caseSensitive ? e : e.toLowerCase();
|
|
504
504
|
if (s.regex) {
|
|
505
|
-
const
|
|
505
|
+
const l = new RegExp(n, s.caseSensitive ? "g" : "gi");
|
|
506
506
|
let c;
|
|
507
|
-
for (; (c =
|
|
508
|
-
const
|
|
507
|
+
for (; (c = l.exec(o)) !== null; ) {
|
|
508
|
+
const a = this.textModel.offsetToPosition(c.index), u = this.textModel.offsetToPosition(c.index + c[0].length);
|
|
509
509
|
i.push({
|
|
510
|
-
range: { start:
|
|
510
|
+
range: { start: a, end: u },
|
|
511
511
|
match: c[0]
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
514
|
} else {
|
|
515
|
-
let
|
|
515
|
+
let l = 0, c = o.indexOf(n, l);
|
|
516
516
|
for (; c !== -1; ) {
|
|
517
|
-
const
|
|
517
|
+
const a = c + e.length, u = this.textModel.offsetToPosition(c), d = this.textModel.offsetToPosition(a);
|
|
518
518
|
i.push({
|
|
519
|
-
range: { start:
|
|
520
|
-
match: r.substring(c,
|
|
521
|
-
}),
|
|
519
|
+
range: { start: u, end: d },
|
|
520
|
+
match: r.substring(c, a)
|
|
521
|
+
}), l = a, c = o.indexOf(n, l);
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
return i;
|
|
@@ -526,9 +526,9 @@ class K {
|
|
|
526
526
|
replace(e, t) {
|
|
527
527
|
const s = this.getValue();
|
|
528
528
|
if (!this.suppressHistory) {
|
|
529
|
-
const r = this.getCursor().position,
|
|
530
|
-
let
|
|
531
|
-
|
|
529
|
+
const r = this.getCursor().position, o = this.textModel.positionToOffset(r), n = this.getSelection();
|
|
530
|
+
let l, c;
|
|
531
|
+
n && (l = this.textModel.positionToOffset(n.start), c = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: s, cursorOffset: o, anchorOffset: l, focusOffset: c }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
|
|
532
532
|
}
|
|
533
533
|
const i = this.textModel.replaceRange(e, t);
|
|
534
534
|
this.renderTextWithHighlight(this.getValue(), !1), this.emit("change", [i]);
|
|
@@ -536,8 +536,8 @@ class K {
|
|
|
536
536
|
replaceAll(e, t, s = {}) {
|
|
537
537
|
const i = this.search(e, s);
|
|
538
538
|
let r = 0;
|
|
539
|
-
for (let
|
|
540
|
-
this.replace(i[
|
|
539
|
+
for (let o = i.length - 1; o >= 0; o--)
|
|
540
|
+
this.replace(i[o].range, t), r++;
|
|
541
541
|
return r;
|
|
542
542
|
}
|
|
543
543
|
// Folding (basic implementation)
|
|
@@ -574,23 +574,23 @@ class K {
|
|
|
574
574
|
if (s && typeof s.highlightHTML == "function")
|
|
575
575
|
try {
|
|
576
576
|
const i = !t && !this.expectingProgrammaticCursor;
|
|
577
|
-
let r,
|
|
577
|
+
let r, o, n, l;
|
|
578
578
|
if (t || i) {
|
|
579
579
|
r = this.getSelection();
|
|
580
|
-
const
|
|
581
|
-
|
|
580
|
+
const a = this.getCursor().position;
|
|
581
|
+
o = this.textModel.positionToOffset(a), r && (n = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end));
|
|
582
582
|
}
|
|
583
583
|
const c = s.highlightHTML(e);
|
|
584
584
|
typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), (t || i) && requestAnimationFrame(() => {
|
|
585
585
|
try {
|
|
586
|
-
if (r && (
|
|
587
|
-
const
|
|
588
|
-
this.view.setSelectionRange({ start:
|
|
589
|
-
} else if (
|
|
590
|
-
const
|
|
591
|
-
this.view.setCursorPosition(
|
|
586
|
+
if (r && (n !== void 0 || l !== void 0)) {
|
|
587
|
+
const a = n !== void 0 ? n : o, u = l !== void 0 ? l : o, d = Math.min(a, u), g = Math.max(a, u), h = this.textModel.offsetToPosition(d), f = this.textModel.offsetToPosition(g);
|
|
588
|
+
this.view.setSelectionRange({ start: h, end: f });
|
|
589
|
+
} else if (o !== void 0) {
|
|
590
|
+
const a = this.textModel.offsetToPosition(o);
|
|
591
|
+
this.view.setCursorPosition(a);
|
|
592
592
|
}
|
|
593
|
-
} catch (
|
|
593
|
+
} catch (a) {
|
|
594
594
|
}
|
|
595
595
|
});
|
|
596
596
|
return;
|
|
@@ -619,8 +619,8 @@ class K {
|
|
|
619
619
|
try {
|
|
620
620
|
if (i != null)
|
|
621
621
|
if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
|
|
622
|
-
const r = e.anchorOffset !== void 0 ? e.anchorOffset : i,
|
|
623
|
-
this.setSelection({ start: c, end:
|
|
622
|
+
const r = e.anchorOffset !== void 0 ? e.anchorOffset : i, o = e.focusOffset !== void 0 ? e.focusOffset : i, n = Math.min(r, o), l = Math.max(r, o), c = this.textModel.offsetToPosition(n), a = this.textModel.offsetToPosition(l);
|
|
623
|
+
this.setSelection({ start: c, end: a });
|
|
624
624
|
} else {
|
|
625
625
|
const r = this.textModel.offsetToPosition(i);
|
|
626
626
|
this.setCursor(r);
|
|
@@ -645,8 +645,8 @@ class K {
|
|
|
645
645
|
try {
|
|
646
646
|
if (i != null)
|
|
647
647
|
if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
|
|
648
|
-
const r = e.anchorOffset !== void 0 ? e.anchorOffset : i,
|
|
649
|
-
this.setSelection({ start: c, end:
|
|
648
|
+
const r = e.anchorOffset !== void 0 ? e.anchorOffset : i, o = e.focusOffset !== void 0 ? e.focusOffset : i, n = Math.min(r, o), l = Math.max(r, o), c = this.textModel.offsetToPosition(n), a = this.textModel.offsetToPosition(l);
|
|
649
|
+
this.setSelection({ start: c, end: a });
|
|
650
650
|
} else {
|
|
651
651
|
const r = this.textModel.offsetToPosition(i);
|
|
652
652
|
this.setCursor(r);
|
|
@@ -665,9 +665,9 @@ class K {
|
|
|
665
665
|
if (this.config.readOnly) return;
|
|
666
666
|
const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = " ".repeat(this.config.tabSize || 2), i = this.textModel.insertText(e, s), r = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + s.length);
|
|
667
667
|
if (!this.suppressHistory) {
|
|
668
|
-
const
|
|
669
|
-
let
|
|
670
|
-
|
|
668
|
+
const o = this.getSelection();
|
|
669
|
+
let n, l;
|
|
670
|
+
o && (n = this.textModel.positionToOffset(o.start), l = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: n, focusOffset: l }), this.redoStack.length = 0;
|
|
671
671
|
}
|
|
672
672
|
this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(r), setTimeout(() => {
|
|
673
673
|
this.expectingProgrammaticCursor = !1;
|
|
@@ -680,8 +680,8 @@ class K {
|
|
|
680
680
|
`), i = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
|
|
681
681
|
if (!this.suppressHistory) {
|
|
682
682
|
const r = this.getSelection();
|
|
683
|
-
let
|
|
684
|
-
r && (
|
|
683
|
+
let o, n;
|
|
684
|
+
r && (o = this.textModel.positionToOffset(r.start), n = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: n }), this.redoStack.length = 0;
|
|
685
685
|
}
|
|
686
686
|
this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(i), setTimeout(() => {
|
|
687
687
|
this.expectingProgrammaticCursor = !1;
|
|
@@ -701,7 +701,7 @@ class K {
|
|
|
701
701
|
s.length = 0;
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
|
-
class
|
|
704
|
+
class U {
|
|
705
705
|
constructor(e) {
|
|
706
706
|
this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
|
|
707
707
|
}
|
|
@@ -715,11 +715,11 @@ class V {
|
|
|
715
715
|
return this.editor.executeCommand(t.command), e.preventDefault(), e.stopPropagation(), !1;
|
|
716
716
|
}
|
|
717
717
|
findMatchingBinding(e) {
|
|
718
|
-
const { key: t, ctrlKey: s, altKey: i, shiftKey: r, metaKey:
|
|
719
|
-
if (!
|
|
720
|
-
for (const c of
|
|
721
|
-
const
|
|
722
|
-
if (
|
|
718
|
+
const { key: t, ctrlKey: s, altKey: i, shiftKey: r, metaKey: o } = e, n = String(t).toLowerCase(), l = this.keymap[n];
|
|
719
|
+
if (!l) return null;
|
|
720
|
+
for (const c of l) {
|
|
721
|
+
const a = c.ctrlKey === void 0 || c.ctrlKey === s, u = c.altKey === void 0 || c.altKey === i, d = c.shiftKey === void 0 || c.shiftKey === r, g = c.metaKey === void 0 || c.metaKey === o;
|
|
722
|
+
if (a && u && d && g)
|
|
723
723
|
return c;
|
|
724
724
|
}
|
|
725
725
|
return null;
|
|
@@ -775,7 +775,7 @@ class V {
|
|
|
775
775
|
this.keymap = {}, this.editor = null;
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
class
|
|
778
|
+
class z {
|
|
779
779
|
constructor() {
|
|
780
780
|
this.name = "transaction", this.transactions = [];
|
|
781
781
|
}
|
|
@@ -797,7 +797,7 @@ class A {
|
|
|
797
797
|
this.transactions = [];
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
class
|
|
800
|
+
class q {
|
|
801
801
|
constructor() {
|
|
802
802
|
this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
|
|
803
803
|
}
|
|
@@ -828,7 +828,7 @@ class U {
|
|
|
828
828
|
this.lineNumbersElement = null, this.editor = null;
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
|
-
class
|
|
831
|
+
class _ {
|
|
832
832
|
constructor() {
|
|
833
833
|
this.name = "theme", this.editor = null, this.currentTheme = "dark";
|
|
834
834
|
}
|
|
@@ -853,7 +853,7 @@ class z {
|
|
|
853
853
|
this.editor = null;
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
|
-
class
|
|
856
|
+
class F {
|
|
857
857
|
constructor() {
|
|
858
858
|
this.name = "read-only", this.editor = null, this.isReadOnly = !1;
|
|
859
859
|
}
|
|
@@ -880,7 +880,7 @@ class q {
|
|
|
880
880
|
this.editor = null;
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
|
-
class
|
|
883
|
+
class D {
|
|
884
884
|
constructor() {
|
|
885
885
|
this.name = "search", this.editor = null, this.searchUI = null, this.isVisible = !1, this.currentResults = [], this.currentIndex = -1;
|
|
886
886
|
}
|
|
@@ -989,14 +989,14 @@ class F {
|
|
|
989
989
|
margin-top: 4px;
|
|
990
990
|
" />
|
|
991
991
|
`;
|
|
992
|
-
const t = this.searchUI.querySelector("input"), s = this.searchUI.querySelector(".search-replace-input"), i = this.searchUI.querySelector(".search-prev"), r = this.searchUI.querySelector(".search-next"),
|
|
992
|
+
const t = this.searchUI.querySelector("input"), s = this.searchUI.querySelector(".search-replace-input"), i = this.searchUI.querySelector(".search-prev"), r = this.searchUI.querySelector(".search-next"), o = this.searchUI.querySelector(".search-close");
|
|
993
993
|
t.addEventListener("input", () => {
|
|
994
994
|
this.performSearch(t.value);
|
|
995
|
-
}), t.addEventListener("keydown", (
|
|
996
|
-
|
|
997
|
-
}), s.addEventListener("keydown", (
|
|
998
|
-
|
|
999
|
-
}), i.addEventListener("click", () => this.findPrev()), r.addEventListener("click", () => this.findNext()),
|
|
995
|
+
}), t.addEventListener("keydown", (n) => {
|
|
996
|
+
n.key === "Enter" && (n.preventDefault(), n.shiftKey ? this.findPrev() : this.findNext());
|
|
997
|
+
}), s.addEventListener("keydown", (n) => {
|
|
998
|
+
n.key === "Enter" && (n.preventDefault(), n.shiftKey ? this.replaceAll(t.value, s.value) : this.replaceCurrent(t.value, s.value));
|
|
999
|
+
}), i.addEventListener("click", () => this.findPrev()), r.addEventListener("click", () => this.findNext()), o.addEventListener("click", () => this.hideSearch()), e.appendChild(this.searchUI);
|
|
1000
1000
|
}
|
|
1001
1001
|
performSearch(e) {
|
|
1002
1002
|
if (!this.editor || !e.trim()) {
|
|
@@ -1006,9 +1006,9 @@ class F {
|
|
|
1006
1006
|
const t = this.editor.getValue(), s = [];
|
|
1007
1007
|
let i = t.toLowerCase().indexOf(e.toLowerCase());
|
|
1008
1008
|
for (; i !== -1; ) {
|
|
1009
|
-
const r = this.getPositionFromOffset(t, i),
|
|
1009
|
+
const r = this.getPositionFromOffset(t, i), o = this.getPositionFromOffset(t, i + e.length);
|
|
1010
1010
|
s.push({
|
|
1011
|
-
range: { start: r, end:
|
|
1011
|
+
range: { start: r, end: o },
|
|
1012
1012
|
match: t.substring(i, i + e.length)
|
|
1013
1013
|
}), i = t.toLowerCase().indexOf(e.toLowerCase(), i + 1);
|
|
1014
1014
|
}
|
|
@@ -1029,8 +1029,8 @@ class F {
|
|
|
1029
1029
|
if (!this.editor || !e.trim() || this.currentIndex === -1) return;
|
|
1030
1030
|
const s = this.currentResults[this.currentIndex];
|
|
1031
1031
|
if (!s) return;
|
|
1032
|
-
const i = this.editor.getValue(), r = this.getOffsetFromPosition(i, s.range.start),
|
|
1033
|
-
this.editor.setValue(
|
|
1032
|
+
const i = this.editor.getValue(), r = this.getOffsetFromPosition(i, s.range.start), o = i.substring(0, r), n = i.substring(r + e.length), l = o + t + n;
|
|
1033
|
+
this.editor.setValue(l), this.performSearch(e), this.updateStatus("Replaced current occurrence");
|
|
1034
1034
|
}
|
|
1035
1035
|
replaceAll(e, t) {
|
|
1036
1036
|
if (!this.editor || !e.trim()) return;
|
|
@@ -1061,7 +1061,7 @@ class F {
|
|
|
1061
1061
|
this.searchUI && this.searchUI.parentNode && this.searchUI.parentNode.removeChild(this.searchUI), this.searchUI = null, this.editor = null;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
class
|
|
1064
|
+
class W {
|
|
1065
1065
|
constructor() {
|
|
1066
1066
|
this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
|
|
1067
1067
|
"(": ")",
|
|
@@ -1102,22 +1102,22 @@ class _ {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
findMatchingBracket(e, t) {
|
|
1104
1104
|
const s = e.split(`
|
|
1105
|
-
`), i = t.position.line, r = t.position.column,
|
|
1106
|
-
return this.bracketPairs[
|
|
1105
|
+
`), i = t.position.line, r = t.position.column, o = t.char;
|
|
1106
|
+
return this.bracketPairs[o] ? this.findClosingBracket(e, s, i, r, o) : this.reverseBracketPairs[o] ? this.findOpeningBracket(e, s, i, r, o) : null;
|
|
1107
1107
|
}
|
|
1108
1108
|
findClosingBracket(e, t, s, i, r) {
|
|
1109
|
-
const
|
|
1110
|
-
let
|
|
1111
|
-
for (let
|
|
1112
|
-
const c = t[
|
|
1113
|
-
for (let
|
|
1114
|
-
const
|
|
1115
|
-
if (
|
|
1116
|
-
|
|
1117
|
-
else if (
|
|
1109
|
+
const o = this.bracketPairs[r];
|
|
1110
|
+
let n = 0;
|
|
1111
|
+
for (let l = s; l < t.length; l++) {
|
|
1112
|
+
const c = t[l], a = l === s ? i : 0;
|
|
1113
|
+
for (let u = a; u < c.length; u++) {
|
|
1114
|
+
const d = c[u];
|
|
1115
|
+
if (d === r)
|
|
1116
|
+
n++;
|
|
1117
|
+
else if (d === o && (n--, n === 0))
|
|
1118
1118
|
return {
|
|
1119
1119
|
open: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
|
|
1120
|
-
close: { start: { line:
|
|
1120
|
+
close: { start: { line: l, column: u }, end: { line: l, column: u + 1 } },
|
|
1121
1121
|
type: r
|
|
1122
1122
|
};
|
|
1123
1123
|
}
|
|
@@ -1125,19 +1125,19 @@ class _ {
|
|
|
1125
1125
|
return null;
|
|
1126
1126
|
}
|
|
1127
1127
|
findOpeningBracket(e, t, s, i, r) {
|
|
1128
|
-
const
|
|
1129
|
-
let
|
|
1130
|
-
for (let
|
|
1131
|
-
const c = t[
|
|
1132
|
-
for (let
|
|
1133
|
-
const
|
|
1134
|
-
if (
|
|
1135
|
-
|
|
1136
|
-
else if (
|
|
1128
|
+
const o = this.reverseBracketPairs[r];
|
|
1129
|
+
let n = 0;
|
|
1130
|
+
for (let l = s; l >= 0; l--) {
|
|
1131
|
+
const c = t[l], a = l === s ? i : c.length - 1;
|
|
1132
|
+
for (let u = a; u >= 0; u--) {
|
|
1133
|
+
const d = c[u];
|
|
1134
|
+
if (d === r)
|
|
1135
|
+
n++;
|
|
1136
|
+
else if (d === o && (n--, n === 0))
|
|
1137
1137
|
return {
|
|
1138
|
-
open: { start: { line:
|
|
1138
|
+
open: { start: { line: l, column: u }, end: { line: l, column: u + 1 } },
|
|
1139
1139
|
close: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
|
|
1140
|
-
type:
|
|
1140
|
+
type: o
|
|
1141
1141
|
};
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
@@ -1155,7 +1155,7 @@ class _ {
|
|
|
1155
1155
|
this.clearBracketHighlighting(), this.editor = null;
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
|
-
class
|
|
1158
|
+
class j {
|
|
1159
1159
|
constructor() {
|
|
1160
1160
|
this.name = "code-folding", this.editor = null, this.foldIndicators = [], this.foldingUI = null;
|
|
1161
1161
|
}
|
|
@@ -1234,7 +1234,7 @@ class D {
|
|
|
1234
1234
|
this.foldingUI && this.foldingUI.parentNode && this.foldingUI.parentNode.removeChild(this.foldingUI), this.foldingUI = null, this.foldIndicators = [], this.editor = null;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
class
|
|
1237
|
+
class Z {
|
|
1238
1238
|
constructor() {
|
|
1239
1239
|
this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
|
|
1240
1240
|
}
|
|
@@ -1322,111 +1322,111 @@ class W {
|
|
|
1322
1322
|
_highlightHTML(e, t) {
|
|
1323
1323
|
const s = t, i = (c) => this.escapeHTML(c);
|
|
1324
1324
|
let r = i(e);
|
|
1325
|
-
const
|
|
1326
|
-
let
|
|
1327
|
-
return
|
|
1328
|
-
const p = String(
|
|
1329
|
-
return `<span style="color: ${s.styleProp};">${
|
|
1330
|
-
}),
|
|
1331
|
-
},
|
|
1325
|
+
const o = (c) => {
|
|
1326
|
+
let a = c.replace(/"/g, '"').replace(/'/g, "'");
|
|
1327
|
+
return a = a.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${s.comment};">$1</span>`), a = a.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (u, d, g, h, f) => {
|
|
1328
|
+
const p = String(h).trim(), x = i(p);
|
|
1329
|
+
return `<span style="color: ${s.styleProp};">${d}</span>${g}<span style="color: ${s.styleVal};">${x}</span>${f}`;
|
|
1330
|
+
}), a;
|
|
1331
|
+
}, n = [];
|
|
1332
1332
|
try {
|
|
1333
|
-
e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (c,
|
|
1333
|
+
e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (c, a, u) => (n.push({ attrs: String(a || ""), inner: String(u || "") }), c));
|
|
1334
1334
|
} catch (c) {
|
|
1335
1335
|
}
|
|
1336
|
-
let
|
|
1337
|
-
return r = r.replace(/(<script\b([^&>]*)>)([\s\S]*?)(<\/script>)/gi, (c,
|
|
1338
|
-
var p, x,
|
|
1339
|
-
const
|
|
1340
|
-
(((
|
|
1341
|
-
const f = this._highlightJS(
|
|
1342
|
-
return `${
|
|
1343
|
-
}), r = r.replace(/(<style\b[^&]*>)([\s\S]*?)(<\/style>)/gi, (c,
|
|
1344
|
-
const g =
|
|
1345
|
-
return `${
|
|
1346
|
-
}), r = r.replace(/(<!--[\s\S]*?-->)/g, `<span style="color: ${s.comment};">$1</span>`), r = r.replace(/(<!DOCTYPE[\s\S]*?>)/i, `<span style="color: ${s.doctype};">$1</span>`), r = r.replace(/(<\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?>)/g, (c,
|
|
1347
|
-
const
|
|
1348
|
-
let f =
|
|
1349
|
-
return f = f.replace(/([\w:-]+)(\s*=\s*)(("[\s\S]*?"|'[\s\S]*?'|[^\s&>]+))/g, (p, x,
|
|
1336
|
+
let l = 0;
|
|
1337
|
+
return r = r.replace(/(<script\b([^&>]*)>)([\s\S]*?)(<\/script>)/gi, (c, a, u, d, g) => {
|
|
1338
|
+
var p, x, b;
|
|
1339
|
+
const h = (x = (p = n[l++]) == null ? void 0 : p.inner) != null ? x : this.unescapeEntitiesRepeated(d || "");
|
|
1340
|
+
(((b = n[l - 1]) == null ? void 0 : b.attrs) || u || "").toLowerCase();
|
|
1341
|
+
const f = this._highlightJS(h, s);
|
|
1342
|
+
return `${a}${f}${g}`;
|
|
1343
|
+
}), r = r.replace(/(<style\b[^&]*>)([\s\S]*?)(<\/style>)/gi, (c, a, u, d) => {
|
|
1344
|
+
const g = o(u);
|
|
1345
|
+
return `${a}${g}${d}`;
|
|
1346
|
+
}), r = r.replace(/(<!--[\s\S]*?-->)/g, `<span style="color: ${s.comment};">$1</span>`), r = r.replace(/(<!DOCTYPE[\s\S]*?>)/i, `<span style="color: ${s.doctype};">$1</span>`), r = r.replace(/(<\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?>)/g, (c, a, u, d, g) => {
|
|
1347
|
+
const h = `<span style="color: ${s.tag};">${u}</span>`;
|
|
1348
|
+
let f = d;
|
|
1349
|
+
return f = f.replace(/([\w:-]+)(\s*=\s*)(("[\s\S]*?"|'[\s\S]*?'|[^\s&>]+))/g, (p, x, b, y) => {
|
|
1350
1350
|
const C = String(x).toLowerCase(), L = `<span style="color: ${s.attrName};">${x}</span>`;
|
|
1351
|
-
let
|
|
1352
|
-
|
|
1353
|
-
let
|
|
1351
|
+
let w = y, v = "";
|
|
1352
|
+
y.startsWith(""") && y.endsWith(""") ? (w = y.slice(6, -6), v = """) : y.startsWith("'") && y.endsWith("'") && (w = y.slice(5, -5), v = "'");
|
|
1353
|
+
let T = y;
|
|
1354
1354
|
if (C === "style") {
|
|
1355
|
-
const S =
|
|
1356
|
-
|
|
1355
|
+
const S = w.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, ($, E, O, H) => `<span style="color: ${s.styleProp};">${E}</span>:<span style="color: ${s.styleVal};">${O.trim()}</span>${H}`);
|
|
1356
|
+
v ? T = `${v}${S}${v}` : T = S, T = `<span style="color: ${s.attrValue};">${T}</span>`;
|
|
1357
1357
|
} else
|
|
1358
|
-
|
|
1359
|
-
return `${L}${
|
|
1360
|
-
}), `${
|
|
1358
|
+
v && (T = `${v}${w}${v}`), T = `<span style="color: ${s.attrValue};">${T}</span>`;
|
|
1359
|
+
return `${L}${b}${T}`;
|
|
1360
|
+
}), `${a}${h}${f}${g}`;
|
|
1361
1361
|
}), r;
|
|
1362
1362
|
}
|
|
1363
1363
|
_highlightJS(e, t) {
|
|
1364
1364
|
const s = this.unescapeEntitiesRepeated(e);
|
|
1365
1365
|
this.escapeHTML(s);
|
|
1366
|
-
const i = [], r = (
|
|
1367
|
-
let g = "",
|
|
1366
|
+
const i = [], r = (d) => {
|
|
1367
|
+
let g = "", h = d;
|
|
1368
1368
|
do
|
|
1369
|
-
g = String.fromCharCode(97 +
|
|
1370
|
-
while (
|
|
1369
|
+
g = String.fromCharCode(97 + h % 26) + g, h = Math.floor(h / 26) - 1;
|
|
1370
|
+
while (h >= 0);
|
|
1371
1371
|
return g || "a";
|
|
1372
|
-
},
|
|
1372
|
+
}, o = (d) => `\0${r(d)}\0`, n = (d) => {
|
|
1373
1373
|
const g = i.length;
|
|
1374
|
-
return i.push(
|
|
1374
|
+
return i.push(d), o(g);
|
|
1375
1375
|
};
|
|
1376
|
-
let
|
|
1376
|
+
let l;
|
|
1377
1377
|
const c = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
|
|
1378
|
-
let
|
|
1379
|
-
for (;
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
const g =
|
|
1383
|
-
/^\/\*/.test(g) || /^\/\//.test(g) ?
|
|
1378
|
+
let a = 0, u = "";
|
|
1379
|
+
for (; l = c.exec(s); ) {
|
|
1380
|
+
const d = l.index;
|
|
1381
|
+
a < d && (u += this.escapeHTML(s.slice(a, d)));
|
|
1382
|
+
const g = l[0];
|
|
1383
|
+
/^\/\*/.test(g) || /^\/\//.test(g) ? u += n(`<span style="color: ${t.comment};">${this.escapeHTML(g)}</span>`) : u += n(`<span style="color: ${t.string};">${this.escapeHTML(g)}</span>`), a = c.lastIndex;
|
|
1384
1384
|
}
|
|
1385
|
-
return
|
|
1386
|
-
const f = h
|
|
1387
|
-
return f === "&" || f === "#" || p === ";" || p === "#" ?
|
|
1388
|
-
}),
|
|
1389
|
-
let
|
|
1385
|
+
return a < s.length && (u += this.escapeHTML(s.slice(a))), u = u.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, g, h) => {
|
|
1386
|
+
const f = u[h - 1] || "", p = u[h + d.length] || "";
|
|
1387
|
+
return f === "&" || f === "#" || p === ";" || p === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
|
|
1388
|
+
}), u = u.replace(/\b(const|let|var|function|class|if|else|return|for|while|switch|case|break|import|from|export|extends|new|try|catch|finally|throw|await|async|interface|type)\b/g, `<span style="color: ${t.keyword};">$1</span>`), u.replace(/\u0000([a-z]+)\u0000/g, (d, g) => {
|
|
1389
|
+
let h = 0;
|
|
1390
1390
|
for (let f = 0; f < g.length; f++)
|
|
1391
|
-
|
|
1392
|
-
return
|
|
1391
|
+
h = h * 26 + (g.charCodeAt(f) - 97 + 1);
|
|
1392
|
+
return h = h - 1, i[h] || "";
|
|
1393
1393
|
});
|
|
1394
1394
|
}
|
|
1395
1395
|
_highlightPHP(e, t) {
|
|
1396
1396
|
const s = this.unescapeEntitiesRepeated(e);
|
|
1397
1397
|
let i = this.escapeHTML(s);
|
|
1398
|
-
const r = [],
|
|
1399
|
-
let f = "", p =
|
|
1398
|
+
const r = [], o = (h) => {
|
|
1399
|
+
let f = "", p = h;
|
|
1400
1400
|
do
|
|
1401
1401
|
f = String.fromCharCode(97 + p % 26) + f, p = Math.floor(p / 26) - 1;
|
|
1402
1402
|
while (p >= 0);
|
|
1403
1403
|
return f || "a";
|
|
1404
|
-
},
|
|
1404
|
+
}, n = (h) => {
|
|
1405
1405
|
const f = r.length;
|
|
1406
|
-
return r.push(
|
|
1407
|
-
},
|
|
1408
|
-
const p = i.indexOf(
|
|
1409
|
-
return p === -1 ? !1 : (i = i.slice(0, p) + f + i.slice(p +
|
|
1406
|
+
return r.push(h), `\0${o(f)}\0`;
|
|
1407
|
+
}, l = (h, f) => {
|
|
1408
|
+
const p = i.indexOf(h);
|
|
1409
|
+
return p === -1 ? !1 : (i = i.slice(0, p) + f + i.slice(p + h.length), !0);
|
|
1410
1410
|
};
|
|
1411
1411
|
let c;
|
|
1412
|
-
const
|
|
1413
|
-
for (; c =
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
for (; c = h.exec(s); ) {
|
|
1418
|
-
const d = c[0];
|
|
1419
|
-
a(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
|
|
1412
|
+
const a = /\/\*[\s\S]*?\*\//g, u = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, g = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
|
|
1413
|
+
for (; c = a.exec(s); ) {
|
|
1414
|
+
const h = c[0];
|
|
1415
|
+
l(this.escapeHTML(h), n(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
|
|
1420
1416
|
}
|
|
1421
1417
|
for (; c = u.exec(s); ) {
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1418
|
+
const h = c[0];
|
|
1419
|
+
l(this.escapeHTML(h), n(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
|
|
1420
|
+
}
|
|
1421
|
+
for (; c = d.exec(s); ) {
|
|
1422
|
+
const h = c[0];
|
|
1423
|
+
l(this.escapeHTML(h), n(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
|
|
1424
1424
|
}
|
|
1425
1425
|
for (; c = g.exec(s); ) {
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1426
|
+
const h = c[0];
|
|
1427
|
+
l(this.escapeHTML(h), n(`<span style="color: ${t.string};">${this.escapeHTML(h)}</span>`));
|
|
1428
1428
|
}
|
|
1429
|
-
return i = i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), i = i.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g, `<span style="color: ${t.keyword};">$1</span>`), i = i.replace(/\u0000([a-z]+)\u0000/g, (
|
|
1429
|
+
return i = i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), i = i.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g, `<span style="color: ${t.keyword};">$1</span>`), i = i.replace(/\u0000([a-z]+)\u0000/g, (h, f) => {
|
|
1430
1430
|
let p = 0;
|
|
1431
1431
|
for (let x = 0; x < f.length; x++)
|
|
1432
1432
|
p = p * 26 + (f.charCodeAt(x) - 97 + 1);
|
|
@@ -1441,11 +1441,11 @@ class W {
|
|
|
1441
1441
|
this.editor = null, this.modes.clear();
|
|
1442
1442
|
}
|
|
1443
1443
|
}
|
|
1444
|
-
function
|
|
1444
|
+
function J(k, e) {
|
|
1445
1445
|
const t = { ...e };
|
|
1446
|
-
return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new
|
|
1446
|
+
return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new U(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new z()), new V(k, t);
|
|
1447
1447
|
}
|
|
1448
|
-
const
|
|
1448
|
+
const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Editor Dialog Styles */
|
|
1449
1449
|
.rte-source-editor-overlay {
|
|
1450
1450
|
position: fixed !important;
|
|
1451
1451
|
top: 0 !important;
|
|
@@ -1714,64 +1714,83 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1714
1714
|
background: #0056b3;
|
|
1715
1715
|
}
|
|
1716
1716
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
}
|
|
1717
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-modal {
|
|
1718
|
+
background: #1e1e1e;
|
|
1719
|
+
color: #f8f9fa;
|
|
1720
|
+
border: 1px solid #434d5f;
|
|
1721
|
+
}
|
|
1723
1722
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1723
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header,
|
|
1724
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer {
|
|
1725
|
+
background: #2a3442;
|
|
1726
|
+
border-color: #434d5f;
|
|
1727
|
+
}
|
|
1728
1728
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1729
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header h2 {
|
|
1730
|
+
color: #f8f9fa;
|
|
1731
|
+
}
|
|
1732
1732
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1733
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn,
|
|
1734
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn,
|
|
1735
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn {
|
|
1736
|
+
color: #c1cede;
|
|
1737
|
+
}
|
|
1737
1738
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1739
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn:hover:not(:disabled),
|
|
1740
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn:hover,
|
|
1741
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn:hover {
|
|
1742
|
+
background: #404a5a;
|
|
1743
|
+
color: #f8fafc;
|
|
1744
|
+
}
|
|
1743
1745
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
}
|
|
1746
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active {
|
|
1747
|
+
background: #3b82f6;
|
|
1748
|
+
color: #ffffff;
|
|
1749
|
+
}
|
|
1749
1750
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
border-color: #d97706;
|
|
1754
|
-
}
|
|
1751
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active:hover {
|
|
1752
|
+
background: #2563eb;
|
|
1753
|
+
}
|
|
1755
1754
|
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1755
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-loading,
|
|
1756
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer-info {
|
|
1757
|
+
color: #cbd5e1;
|
|
1758
|
+
}
|
|
1760
1759
|
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1760
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-spinner {
|
|
1761
|
+
border-color: #3f4b60;
|
|
1762
|
+
border-top-color: #58a6ff;
|
|
1763
|
+
}
|
|
1764
1764
|
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1765
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-error {
|
|
1766
|
+
background: #3f2124;
|
|
1767
|
+
color: #fecaca;
|
|
1768
|
+
border-color: #ef4444;
|
|
1769
|
+
}
|
|
1770
1770
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1771
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-warning {
|
|
1772
|
+
background: #3b3220;
|
|
1773
|
+
color: #fde68a;
|
|
1774
|
+
border-color: #f59e0b;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel {
|
|
1778
|
+
background: #334155;
|
|
1779
|
+
border-color: #475569;
|
|
1780
|
+
color: #f1f5f9;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel:hover:not(:disabled) {
|
|
1784
|
+
background: #475569;
|
|
1785
|
+
border-color: #64748b;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save {
|
|
1789
|
+
background: #3b82f6;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
.rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save:hover:not(:disabled) {
|
|
1793
|
+
background: #2563eb;
|
|
1775
1794
|
}
|
|
1776
1795
|
|
|
1777
1796
|
/* Responsive design */
|
|
@@ -1803,7 +1822,7 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1803
1822
|
flex: 1;
|
|
1804
1823
|
text-align: center;
|
|
1805
1824
|
}
|
|
1806
|
-
}`,
|
|
1825
|
+
}`, G = () => ({
|
|
1807
1826
|
name: "code",
|
|
1808
1827
|
// Toolbar button configuration
|
|
1809
1828
|
toolbar: [
|
|
@@ -1823,56 +1842,56 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1823
1842
|
*/
|
|
1824
1843
|
toggleSourceView: () => {
|
|
1825
1844
|
const e = (() => {
|
|
1826
|
-
var
|
|
1845
|
+
var n, l, c;
|
|
1827
1846
|
const r = window.getSelection();
|
|
1828
1847
|
if (r && r.anchorNode) {
|
|
1829
|
-
let
|
|
1830
|
-
for (;
|
|
1831
|
-
if ((
|
|
1832
|
-
return
|
|
1833
|
-
|
|
1848
|
+
let a = r.anchorNode instanceof HTMLElement ? r.anchorNode : r.anchorNode.parentElement;
|
|
1849
|
+
for (; a; ) {
|
|
1850
|
+
if ((n = a.classList) != null && n.contains("rte-content"))
|
|
1851
|
+
return a;
|
|
1852
|
+
a = a.parentElement;
|
|
1834
1853
|
}
|
|
1835
1854
|
}
|
|
1836
1855
|
if (document.activeElement) {
|
|
1837
|
-
let
|
|
1838
|
-
if ((
|
|
1839
|
-
return
|
|
1840
|
-
for (;
|
|
1841
|
-
if ((c =
|
|
1842
|
-
return
|
|
1843
|
-
const
|
|
1844
|
-
if (
|
|
1845
|
-
|
|
1856
|
+
let a = document.activeElement;
|
|
1857
|
+
if ((l = a.classList) != null && l.contains("rte-content"))
|
|
1858
|
+
return a;
|
|
1859
|
+
for (; a && a !== document.body; ) {
|
|
1860
|
+
if ((c = a.classList) != null && c.contains("rte-content"))
|
|
1861
|
+
return a;
|
|
1862
|
+
const u = a.querySelector(".rte-content");
|
|
1863
|
+
if (u) return u;
|
|
1864
|
+
a = a.parentElement;
|
|
1846
1865
|
}
|
|
1847
1866
|
}
|
|
1848
|
-
const
|
|
1849
|
-
if (
|
|
1850
|
-
const
|
|
1851
|
-
if (
|
|
1867
|
+
const o = document.querySelector("[data-editora-editor]");
|
|
1868
|
+
if (o) {
|
|
1869
|
+
const a = o.querySelector(".rte-content");
|
|
1870
|
+
if (a) return a;
|
|
1852
1871
|
}
|
|
1853
1872
|
return document.querySelector(".rte-content");
|
|
1854
1873
|
})();
|
|
1855
1874
|
if (!e)
|
|
1856
1875
|
return console.error("[CodePlugin] Editor content area not found"), alert("Editor content area not found. Please click inside the editor first."), !1;
|
|
1857
1876
|
const t = e.innerHTML, s = (r) => {
|
|
1858
|
-
let
|
|
1859
|
-
const
|
|
1860
|
-
for (const
|
|
1861
|
-
|
|
1862
|
-
` + " ".repeat(
|
|
1863
|
-
` + " ".repeat(
|
|
1864
|
-
` + " ".repeat(
|
|
1865
|
-
return
|
|
1877
|
+
let o = "", n = 0;
|
|
1878
|
+
const l = 2, c = r.split(/(<\/?[a-zA-Z][^>]*>)/);
|
|
1879
|
+
for (const a of c)
|
|
1880
|
+
a.trim() && (a.match(/^<\/[a-zA-Z]/) ? (n = Math.max(0, n - 1), o += `
|
|
1881
|
+
` + " ".repeat(n * l) + a) : a.match(/^<[a-zA-Z]/) && !a.match(/\/>$/) ? (o += `
|
|
1882
|
+
` + " ".repeat(n * l) + a, n++) : a.match(/^<[a-zA-Z].*\/>$/) ? o += `
|
|
1883
|
+
` + " ".repeat(n * l) + a : o += a.trim());
|
|
1884
|
+
return o.trim();
|
|
1866
1885
|
};
|
|
1867
1886
|
return (() => {
|
|
1868
|
-
var
|
|
1869
|
-
let r = null,
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
const u = document.createElement("div");
|
|
1873
|
-
u.className = "rte-source-editor-modal", u.setAttribute("role", "dialog"), u.setAttribute("aria-modal", "true"), u.setAttribute("aria-labelledby", "source-editor-title");
|
|
1887
|
+
var E, O, H, N, I, B;
|
|
1888
|
+
let r = null, o = "dark", n = !1, l = !1, c = !1;
|
|
1889
|
+
const a = t, u = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), d = document.createElement("div");
|
|
1890
|
+
d.className = "rte-source-editor-overlay", u && d.classList.add("rte-theme-dark");
|
|
1874
1891
|
const g = document.createElement("div");
|
|
1875
|
-
g.className = "rte-source-editor-
|
|
1892
|
+
g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
|
|
1893
|
+
const h = document.createElement("div");
|
|
1894
|
+
h.className = "rte-source-editor-header", h.innerHTML = `
|
|
1876
1895
|
<h2 id="source-editor-title">Source Editor</h2>
|
|
1877
1896
|
<div class="rte-source-editor-header-toolbar">
|
|
1878
1897
|
<button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
|
|
@@ -1909,14 +1928,14 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1909
1928
|
</button>
|
|
1910
1929
|
</div>
|
|
1911
1930
|
`;
|
|
1912
|
-
const d = document.createElement("div");
|
|
1913
|
-
d.className = "rte-source-editor-body";
|
|
1914
1931
|
const f = document.createElement("div");
|
|
1915
|
-
f.className = "rte-source-editor-
|
|
1932
|
+
f.className = "rte-source-editor-body";
|
|
1916
1933
|
const p = document.createElement("div");
|
|
1917
|
-
p.className = "rte-source-editor-
|
|
1934
|
+
p.className = "rte-source-editor-content";
|
|
1918
1935
|
const x = document.createElement("div");
|
|
1919
|
-
x.className = "rte-source-editor-
|
|
1936
|
+
x.className = "rte-source-editor-warning", x.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
|
|
1937
|
+
const b = document.createElement("div");
|
|
1938
|
+
b.className = "rte-source-editor-light-editor", b.style.height = "400px", p.appendChild(x), p.appendChild(b), f.appendChild(p);
|
|
1920
1939
|
const y = document.createElement("div");
|
|
1921
1940
|
if (y.className = "rte-source-editor-footer", y.innerHTML = `
|
|
1922
1941
|
<div class="rte-source-editor-footer-info">
|
|
@@ -1926,45 +1945,45 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1926
1945
|
<button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
|
|
1927
1946
|
<button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
|
|
1928
1947
|
</div>
|
|
1929
|
-
`,
|
|
1948
|
+
`, g.appendChild(h), g.appendChild(f), g.appendChild(y), d.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
|
|
1930
1949
|
const m = document.createElement("style");
|
|
1931
|
-
m.id = "rte-source-editor-styles", m.textContent =
|
|
1950
|
+
m.id = "rte-source-editor-styles", m.textContent = Y, document.head.appendChild(m);
|
|
1932
1951
|
}
|
|
1933
|
-
document.body.appendChild(
|
|
1952
|
+
document.body.appendChild(d);
|
|
1934
1953
|
try {
|
|
1935
|
-
r =
|
|
1954
|
+
r = J(b, {
|
|
1936
1955
|
value: s(t),
|
|
1937
1956
|
theme: "dark",
|
|
1938
1957
|
readOnly: !1,
|
|
1939
1958
|
extensions: [
|
|
1940
|
-
new U(),
|
|
1941
|
-
new z(),
|
|
1942
1959
|
new q(),
|
|
1943
1960
|
new _(),
|
|
1944
1961
|
new F(),
|
|
1962
|
+
new W(),
|
|
1945
1963
|
new D(),
|
|
1946
|
-
new
|
|
1964
|
+
new j(),
|
|
1965
|
+
new Z()
|
|
1947
1966
|
]
|
|
1948
1967
|
}), r.on("change", () => {
|
|
1949
|
-
c = ((r == null ? void 0 : r.getValue()) || "") !== s(
|
|
1968
|
+
c = ((r == null ? void 0 : r.getValue()) || "") !== s(a);
|
|
1950
1969
|
const M = y.querySelector(".unsaved-changes");
|
|
1951
1970
|
M && (M.style.display = c ? "inline" : "none");
|
|
1952
1971
|
}), setTimeout(() => r == null ? void 0 : r.focus(), 100);
|
|
1953
1972
|
} catch (m) {
|
|
1954
1973
|
console.error("Failed to initialize code editor:", m);
|
|
1955
1974
|
}
|
|
1956
|
-
const
|
|
1957
|
-
|
|
1958
|
-
const m =
|
|
1959
|
-
m &&
|
|
1975
|
+
const C = () => {
|
|
1976
|
+
o = o === "dark" ? "light" : "dark", r == null || r.setTheme(o);
|
|
1977
|
+
const m = h.querySelector(".theme-toggle-btn");
|
|
1978
|
+
m && o === "light" && (m.innerHTML = `
|
|
1960
1979
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1961
1980
|
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
|
|
1962
1981
|
</svg>
|
|
1963
1982
|
`);
|
|
1964
|
-
},
|
|
1965
|
-
|
|
1966
|
-
const m =
|
|
1967
|
-
m && (
|
|
1983
|
+
}, L = () => {
|
|
1984
|
+
n = !n, r == null || r.setReadOnly(n);
|
|
1985
|
+
const m = h.querySelector(".readonly-toggle-btn");
|
|
1986
|
+
m && (n ? (m.classList.add("active"), m.innerHTML = `
|
|
1968
1987
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1969
1988
|
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
|
|
1970
1989
|
<circle cx="12" cy="16" r="1"/>
|
|
@@ -1976,10 +1995,10 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1976
1995
|
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
1977
1996
|
</svg>
|
|
1978
1997
|
`));
|
|
1979
|
-
},
|
|
1980
|
-
|
|
1981
|
-
const m =
|
|
1982
|
-
m && (m.innerHTML =
|
|
1998
|
+
}, w = () => {
|
|
1999
|
+
l = !l, l ? (d.classList.add("fullscreen"), b.style.height = "calc(100vh - 200px)") : (d.classList.remove("fullscreen"), b.style.height = "400px");
|
|
2000
|
+
const m = h.querySelector(".rte-source-editor-fullscreen-btn");
|
|
2001
|
+
m && (m.innerHTML = l ? `
|
|
1983
2002
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1984
2003
|
<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"/>
|
|
1985
2004
|
</svg>
|
|
@@ -1988,25 +2007,25 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
1988
2007
|
<path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
|
|
1989
2008
|
</svg>
|
|
1990
2009
|
`);
|
|
2010
|
+
}, v = () => {
|
|
2011
|
+
r && (r.destroy(), r = null), document.body.removeChild(d);
|
|
1991
2012
|
}, T = () => {
|
|
1992
|
-
|
|
1993
|
-
},
|
|
1994
|
-
c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || T();
|
|
1995
|
-
}, w = () => {
|
|
2013
|
+
c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || v();
|
|
2014
|
+
}, S = () => {
|
|
1996
2015
|
try {
|
|
1997
2016
|
const m = (r == null ? void 0 : r.getValue()) || "", M = document.createElement("div");
|
|
1998
|
-
M.innerHTML = m, M.querySelectorAll('script, iframe[src^="javascript:"], object, embed').forEach((
|
|
2017
|
+
M.innerHTML = m, M.querySelectorAll('script, iframe[src^="javascript:"], object, embed').forEach((K) => K.remove()), e.innerHTML = M.innerHTML, c = !1, v();
|
|
1999
2018
|
} catch (m) {
|
|
2000
2019
|
alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", m);
|
|
2001
2020
|
}
|
|
2002
2021
|
};
|
|
2003
|
-
(
|
|
2004
|
-
m.target ===
|
|
2022
|
+
(E = h.querySelector(".theme-toggle-btn")) == null || E.addEventListener("click", C), (O = h.querySelector(".readonly-toggle-btn")) == null || O.addEventListener("click", L), (H = h.querySelector(".rte-source-editor-fullscreen-btn")) == null || H.addEventListener("click", w), (N = h.querySelector(".rte-source-editor-close-btn")) == null || N.addEventListener("click", v), (I = y.querySelector(".rte-source-editor-btn-cancel")) == null || I.addEventListener("click", T), (B = y.querySelector(".rte-source-editor-btn-save")) == null || B.addEventListener("click", S), d.addEventListener("click", (m) => {
|
|
2023
|
+
m.target === d && v();
|
|
2005
2024
|
});
|
|
2006
|
-
const
|
|
2007
|
-
m.key === "Escape" && (
|
|
2025
|
+
const $ = (m) => {
|
|
2026
|
+
m.key === "Escape" && (v(), document.removeEventListener("keydown", $));
|
|
2008
2027
|
};
|
|
2009
|
-
document.addEventListener("keydown",
|
|
2028
|
+
document.addEventListener("keydown", $);
|
|
2010
2029
|
})(), !0;
|
|
2011
2030
|
}
|
|
2012
2031
|
},
|
|
@@ -2017,6 +2036,6 @@ const Z = `/* Source Editor Dialog Styles */
|
|
|
2017
2036
|
}
|
|
2018
2037
|
});
|
|
2019
2038
|
export {
|
|
2020
|
-
|
|
2039
|
+
G as CodePlugin
|
|
2021
2040
|
};
|
|
2022
|
-
//# sourceMappingURL=CodePlugin.native-
|
|
2041
|
+
//# sourceMappingURL=CodePlugin.native-0Zari_zp.mjs.map
|