@editora/core 1.0.15 → 1.0.16
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/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
- package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
- package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
- package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
- package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
- package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
- package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
- package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
- package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
- package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
- package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
- package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
- package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
- package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
- package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
- package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
- package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
- package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
- package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
- package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
- package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
- package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
- package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
- package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
- package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
- package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
- package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
- package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
- package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
- package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
- package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
- package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
- package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
- package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
- package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
- package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
- package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
- package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
- package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
- package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
- package/dist/core.css +1 -1
- package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
- package/dist/editora.min.js +26 -24
- package/dist/editora.umd.js +26 -24
- package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
- package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
- package/dist/index-B1_vtXRz.mjs +3910 -0
- package/dist/index-C6BoNR2t.js +12 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +17 -14
- package/dist/plugin-loader.js +53 -52
- package/dist/webcomponent-core.js +2039 -473
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +96 -66
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +2208 -641
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +1564 -1198
- package/index.d.ts +32 -0
- package/package.json +10 -3
- package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
- package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
- package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
- package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
- package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
- package/dist/index-BLm1MtzH.js +0 -10
- package/dist/index-Cd9jEuZP.mjs +0 -2341
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { i as Q } from "./dialogHelpers-DBf7WqYH.mjs";
|
|
2
|
+
class K {
|
|
2
3
|
constructor(e = "") {
|
|
3
4
|
this._lines = [], this._version = 0, this.setText(e);
|
|
4
5
|
}
|
|
@@ -84,7 +85,7 @@ class _ {
|
|
|
84
85
|
}
|
|
85
86
|
// Clone the model
|
|
86
87
|
clone() {
|
|
87
|
-
const e = new
|
|
88
|
+
const e = new K();
|
|
88
89
|
return e._lines = [...this._lines], e._version = this._version, e;
|
|
89
90
|
}
|
|
90
91
|
normalizeRange(e) {
|
|
@@ -97,7 +98,7 @@ class _ {
|
|
|
97
98
|
return e.line !== t.line ? e.line - t.line : e.column - t.column;
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
class
|
|
101
|
+
class Y {
|
|
101
102
|
constructor(e) {
|
|
102
103
|
this.gutterWidth = 50, this.gutterFoldColumnWidth = 20, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
|
|
103
104
|
}
|
|
@@ -508,8 +509,8 @@ class Q {
|
|
|
508
509
|
if (o instanceof Text) {
|
|
509
510
|
const l = o.textContent || "", a = this.buildVisibleToDomMap(l), h = Math.max(0, a.length - 1);
|
|
510
511
|
if (i + h >= t) {
|
|
511
|
-
const c = Math.max(0, t - i),
|
|
512
|
-
return { node: o, offset:
|
|
512
|
+
const c = Math.max(0, t - i), d = (s = a[c]) != null ? s : l.length;
|
|
513
|
+
return { node: o, offset: d };
|
|
513
514
|
}
|
|
514
515
|
i += h;
|
|
515
516
|
continue;
|
|
@@ -573,15 +574,15 @@ class Q {
|
|
|
573
574
|
const h = (l = (o = n.textContent) == null ? void 0 : o.length) != null ? l : 0, c = document.createRange();
|
|
574
575
|
if (s < h) {
|
|
575
576
|
c.setStart(n, s), c.setEnd(n, Math.min(h, s + 1));
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
578
|
-
return
|
|
577
|
+
const d = this.getUsableRangeRect(c);
|
|
578
|
+
if (d)
|
|
579
|
+
return d;
|
|
579
580
|
}
|
|
580
581
|
if (s > 0) {
|
|
581
582
|
c.setStart(n, s - 1), c.setEnd(n, s);
|
|
582
|
-
const
|
|
583
|
-
if (
|
|
584
|
-
return
|
|
583
|
+
const d = this.getUsableRangeRect(c);
|
|
584
|
+
if (d)
|
|
585
|
+
return d;
|
|
585
586
|
}
|
|
586
587
|
}
|
|
587
588
|
const r = n instanceof Element ? n : (a = n == null ? void 0 : n.parentElement) != null ? a : null;
|
|
@@ -822,10 +823,10 @@ class Q {
|
|
|
822
823
|
this.contentElement.__lceFoldPlaceholderSources = e;
|
|
823
824
|
}
|
|
824
825
|
}
|
|
825
|
-
let
|
|
826
|
-
const
|
|
826
|
+
let X = 0;
|
|
827
|
+
const w = class w {
|
|
827
828
|
constructor(e, t = {}) {
|
|
828
|
-
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.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.lastKnownCursor = { line: 0, column: 0 }, this.editorInstanceId = ++
|
|
829
|
+
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.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.lastKnownCursor = { line: 0, column: 0 }, this.editorInstanceId = ++X, this.decorationHighlightStyleId = `editora-decoration-style-${this.editorInstanceId}`, this.decorationHighlightLimit = 1e3, this.decorationLayers = /* @__PURE__ */ new Map(), this.inlineDecorationHighlightNames = /* @__PURE__ */ new Set(), this.decorationRenderRaf = null, this.decorationMutationObserver = null, this.hasCustomDecorationHighlightSupport = !1, this.lastProgrammaticClipboardInsertAt = 0, this.config = {
|
|
829
830
|
value: "",
|
|
830
831
|
theme: "default",
|
|
831
832
|
readOnly: !1,
|
|
@@ -833,7 +834,7 @@ const L = class L {
|
|
|
833
834
|
lineWrapping: !1,
|
|
834
835
|
lineNumbers: !0,
|
|
835
836
|
...t
|
|
836
|
-
}, this.textModel = new
|
|
837
|
+
}, this.textModel = new K(this.config.value), this.view = new Y(e), this.view.setTabSize(this.config.tabSize || 2), this.view.setLineWrapping(!!this.config.lineWrapping), this.view.setLineNumbersVisible(this.config.lineNumbers !== !1), this.hasCustomDecorationHighlightSupport = this.detectCustomHighlightSupport(), this.observeDecorationRelevantMutations(), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((i) => this.addExtension(i)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
|
|
837
838
|
}
|
|
838
839
|
// Public accessors for extensions
|
|
839
840
|
getTextModel() {
|
|
@@ -847,7 +848,9 @@ const L = class L {
|
|
|
847
848
|
}
|
|
848
849
|
// Register built-in editor commands like undo/redo/insertTab
|
|
849
850
|
registerBuiltInCommands() {
|
|
850
|
-
this.registerCommand("undo", () => this.undo()), this.registerCommand("redo", () => this.redo()), this.registerCommand("insertTab", () => this.insertTab()), this.registerCommand("
|
|
851
|
+
this.registerCommand("undo", () => this.undo()), this.registerCommand("redo", () => this.redo()), this.registerCommand("insertTab", () => this.insertTab()), this.registerCommand("outdent", () => {
|
|
852
|
+
this.shiftSelectedLines(!0);
|
|
853
|
+
}), this.registerCommand("save", () => {
|
|
851
854
|
this.emit("save");
|
|
852
855
|
});
|
|
853
856
|
}
|
|
@@ -874,13 +877,17 @@ const L = class L {
|
|
|
874
877
|
t.preventDefault(), this.pendingInputSnapshot = void 0, this.insertNewLine();
|
|
875
878
|
return;
|
|
876
879
|
}
|
|
877
|
-
if (t.
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
880
|
+
if (!t.isComposing) {
|
|
881
|
+
const i = w.deletionUnit(t.inputType, "Backward");
|
|
882
|
+
if (i) {
|
|
883
|
+
t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteBackward(i);
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
const n = w.deletionUnit(t.inputType, "Forward");
|
|
887
|
+
if (n) {
|
|
888
|
+
t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteForward(n);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
884
891
|
}
|
|
885
892
|
if (t.inputType === "deleteByCut") {
|
|
886
893
|
t.preventDefault(), this.pendingInputSnapshot = void 0, this.deleteSelection();
|
|
@@ -924,20 +931,21 @@ const L = class L {
|
|
|
924
931
|
}, document.addEventListener("selectionchange", this.documentSelectionChangeHandler), e.addEventListener("keydown", (t) => {
|
|
925
932
|
this.emit("keydown", t);
|
|
926
933
|
const i = Array.from(this.extensions.values()).reverse();
|
|
927
|
-
for (const
|
|
928
|
-
if (
|
|
934
|
+
for (const r of i)
|
|
935
|
+
if (r.onKeyDown && r.onKeyDown(t) === !1) {
|
|
929
936
|
t.preventDefault(), t.stopPropagation();
|
|
930
937
|
return;
|
|
931
938
|
}
|
|
932
939
|
if (t.key === "Tab" && !this.config.readOnly) {
|
|
933
|
-
this.insertTab(), t.preventDefault(), t.stopPropagation();
|
|
940
|
+
t.shiftKey ? this.shiftSelectedLines(!0) : this.insertTab(), t.preventDefault(), t.stopPropagation();
|
|
934
941
|
return;
|
|
935
942
|
}
|
|
936
|
-
|
|
943
|
+
const n = t.altKey || t.ctrlKey || t.metaKey, s = t.isComposing || t.keyCode === 229;
|
|
944
|
+
if (t.key === "Backspace" && !this.config.readOnly && !n && !s) {
|
|
937
945
|
this.deleteBackward(), t.preventDefault(), t.stopPropagation();
|
|
938
946
|
return;
|
|
939
947
|
}
|
|
940
|
-
if (t.key === "Delete" && !this.config.readOnly) {
|
|
948
|
+
if (t.key === "Delete" && !this.config.readOnly && !n && !s) {
|
|
941
949
|
this.deleteForward(), t.preventDefault(), t.stopPropagation();
|
|
942
950
|
return;
|
|
943
951
|
}
|
|
@@ -1115,33 +1123,33 @@ const L = class L {
|
|
|
1115
1123
|
} catch (f) {
|
|
1116
1124
|
return [];
|
|
1117
1125
|
}
|
|
1118
|
-
let
|
|
1119
|
-
for (; (
|
|
1120
|
-
const f = (h =
|
|
1126
|
+
let d;
|
|
1127
|
+
for (; (d = c.exec(r)) !== null; ) {
|
|
1128
|
+
const f = (h = d[0]) != null ? h : "";
|
|
1121
1129
|
if (f.length === 0) {
|
|
1122
|
-
c.lastIndex =
|
|
1130
|
+
c.lastIndex = d.index + 1;
|
|
1123
1131
|
continue;
|
|
1124
1132
|
}
|
|
1125
|
-
const
|
|
1126
|
-
i.wholeWord && !this.isWholeWordBoundary(r,
|
|
1133
|
+
const u = d.index, g = d.index + f.length;
|
|
1134
|
+
i.wholeWord && !this.isWholeWordBoundary(r, u, g) || this.pushSearchResultFromOffsets(
|
|
1127
1135
|
n,
|
|
1128
|
-
d,
|
|
1129
1136
|
u,
|
|
1137
|
+
g,
|
|
1130
1138
|
r,
|
|
1131
1139
|
o
|
|
1132
1140
|
);
|
|
1133
1141
|
}
|
|
1134
1142
|
} else {
|
|
1135
|
-
let c = 0,
|
|
1136
|
-
for (;
|
|
1137
|
-
const f =
|
|
1138
|
-
!i.wholeWord || this.isWholeWordBoundary(r,
|
|
1143
|
+
let c = 0, d = l.indexOf(a, c);
|
|
1144
|
+
for (; d !== -1; ) {
|
|
1145
|
+
const f = d + a.length;
|
|
1146
|
+
!i.wholeWord || this.isWholeWordBoundary(r, d, f) ? (this.pushSearchResultFromOffsets(
|
|
1139
1147
|
n,
|
|
1140
|
-
|
|
1148
|
+
d,
|
|
1141
1149
|
f,
|
|
1142
1150
|
r,
|
|
1143
1151
|
o
|
|
1144
|
-
), c = f) : c =
|
|
1152
|
+
), c = f) : c = d + 1, d = l.indexOf(a, c);
|
|
1145
1153
|
}
|
|
1146
1154
|
}
|
|
1147
1155
|
return n;
|
|
@@ -1166,7 +1174,7 @@ const L = class L {
|
|
|
1166
1174
|
let n = 0;
|
|
1167
1175
|
for (let s = 0; s < e.length; s++) {
|
|
1168
1176
|
const r = e[s];
|
|
1169
|
-
r === "" || r ===
|
|
1177
|
+
r === "" || r === w.CURSOR_SENTINEL || (t.push(r), n += 1, i[n] = s + 1);
|
|
1170
1178
|
}
|
|
1171
1179
|
return i[n] = e.length, {
|
|
1172
1180
|
normalizedText: t.join(""),
|
|
@@ -1181,10 +1189,12 @@ const L = class L {
|
|
|
1181
1189
|
}
|
|
1182
1190
|
replaceAll(e, t, i = {}) {
|
|
1183
1191
|
const n = this.search(e, i);
|
|
1184
|
-
|
|
1192
|
+
if (n.length === 0) return 0;
|
|
1193
|
+
this.suppressHistory || this.pushUndoSnapshot(this.captureHistorySnapshot(this.getValue()));
|
|
1194
|
+
const s = [];
|
|
1185
1195
|
for (let r = n.length - 1; r >= 0; r--)
|
|
1186
|
-
this.
|
|
1187
|
-
return s;
|
|
1196
|
+
s.push(this.textModel.replaceRange(n[r].range, t));
|
|
1197
|
+
return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", s), n.length;
|
|
1188
1198
|
}
|
|
1189
1199
|
// Folding (basic implementation)
|
|
1190
1200
|
fold(e) {
|
|
@@ -1228,10 +1238,10 @@ const L = class L {
|
|
|
1228
1238
|
if (i && typeof i.highlightHTML == "function")
|
|
1229
1239
|
try {
|
|
1230
1240
|
if (typeof this.view.setHighlightHTML == "function") {
|
|
1231
|
-
const
|
|
1232
|
-
(
|
|
1241
|
+
const g = this.view.getContentElement();
|
|
1242
|
+
(g.querySelector(
|
|
1233
1243
|
"[data-lce-fold-placeholder]"
|
|
1234
|
-
) ||
|
|
1244
|
+
) || g.textContent !== e) && this.view.setText(e);
|
|
1235
1245
|
const m = typeof i.highlight == "function" ? i.highlight(e) : i.highlightHTML(e);
|
|
1236
1246
|
this.view.setHighlightHTML(m), this.view.syncTrailingNewlineMarkerForText(e), this.scheduleDecorationRender();
|
|
1237
1247
|
return;
|
|
@@ -1240,21 +1250,21 @@ const L = class L {
|
|
|
1240
1250
|
let r, o, l, a;
|
|
1241
1251
|
const h = this.view.getSelectionState(), c = h.isInEditor && !!h.cursor;
|
|
1242
1252
|
(t || s) && c && (r = h.isCollapsed ? void 0 : h.range, o = this.textModel.positionToOffset(h.cursor), r && (l = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)));
|
|
1243
|
-
const
|
|
1244
|
-
typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(
|
|
1253
|
+
const d = c && (t || s) && !r && o !== void 0 && this.hasCollapsedSelectionInEditor(), f = d ? this.insertSentinelAtOffset(e, o) : e, u = typeof i.highlight == "function" ? i.highlight(f) : i.highlightHTML(f);
|
|
1254
|
+
typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(u) : this.view.setHTML(u), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && c && requestAnimationFrame(() => {
|
|
1245
1255
|
try {
|
|
1246
|
-
if (
|
|
1256
|
+
if (d && this.restoreCursorFromSentinel()) {
|
|
1247
1257
|
this.view.ensureCaretVisible();
|
|
1248
1258
|
return;
|
|
1249
1259
|
}
|
|
1250
1260
|
if (r && (l !== void 0 || a !== void 0)) {
|
|
1251
|
-
const
|
|
1252
|
-
this.view.setSelectionRange({ start:
|
|
1261
|
+
const g = l !== void 0 ? l : o, p = a !== void 0 ? a : o, m = Math.min(g, p), y = Math.max(g, p), T = this.textModel.offsetToPosition(m), S = this.textModel.offsetToPosition(y);
|
|
1262
|
+
this.view.setSelectionRange({ start: T, end: S });
|
|
1253
1263
|
} else if (o !== void 0) {
|
|
1254
|
-
const
|
|
1255
|
-
this.view.setCursorPosition(
|
|
1264
|
+
const g = this.textModel.offsetToPosition(o);
|
|
1265
|
+
this.view.setCursorPosition(g);
|
|
1256
1266
|
}
|
|
1257
|
-
} catch (
|
|
1267
|
+
} catch (g) {
|
|
1258
1268
|
}
|
|
1259
1269
|
}), this.scheduleDecorationRender();
|
|
1260
1270
|
return;
|
|
@@ -1281,19 +1291,19 @@ const L = class L {
|
|
|
1281
1291
|
return n.selectNodeContents(i), n.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(n.toString()).length;
|
|
1282
1292
|
}
|
|
1283
1293
|
stripVirtualMarkers(e) {
|
|
1284
|
-
return e.replace(/\u200B/g, "").split(
|
|
1294
|
+
return e.replace(/\u200B/g, "").split(w.CURSOR_SENTINEL).join("");
|
|
1285
1295
|
}
|
|
1286
1296
|
insertSentinelAtOffset(e, t) {
|
|
1287
1297
|
const i = Math.max(0, Math.min(t, e.length));
|
|
1288
|
-
return e.slice(0, i) +
|
|
1298
|
+
return e.slice(0, i) + w.CURSOR_SENTINEL + e.slice(i);
|
|
1289
1299
|
}
|
|
1290
1300
|
restoreCursorFromSentinel() {
|
|
1291
1301
|
var o;
|
|
1292
1302
|
const e = this.view.getContentElement(), t = window.getSelection(), i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
|
|
1293
1303
|
let n = i.nextNode(), s = null, r = 0;
|
|
1294
1304
|
for (; n; ) {
|
|
1295
|
-
const l = (o = n.textContent) != null ? o : "", a = l.indexOf(
|
|
1296
|
-
a !== -1 && (s || (s = n, r = a), n.textContent = l.split(
|
|
1305
|
+
const l = (o = n.textContent) != null ? o : "", a = l.indexOf(w.CURSOR_SENTINEL);
|
|
1306
|
+
a !== -1 && (s || (s = n, r = a), n.textContent = l.split(w.CURSOR_SENTINEL).join("")), n = i.nextNode();
|
|
1297
1307
|
}
|
|
1298
1308
|
if (!s || !t) return !1;
|
|
1299
1309
|
try {
|
|
@@ -1339,20 +1349,63 @@ const L = class L {
|
|
|
1339
1349
|
}
|
|
1340
1350
|
// Insert a tab character or spaces at current cursor
|
|
1341
1351
|
insertTab() {
|
|
1342
|
-
if (this.config.readOnly) return;
|
|
1352
|
+
if (this.config.readOnly || this.shiftSelectedLines(!1)) return;
|
|
1343
1353
|
const e = " ".repeat(this.config.tabSize || 2);
|
|
1344
1354
|
this.replaceSelectionWithText(e);
|
|
1345
1355
|
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Tab / Shift+Tab over whole lines. Tab only applies when the selection spans lines (a caret
|
|
1358
|
+
* or single-line selection keeps the plain "insert a tab" behaviour); Shift+Tab always
|
|
1359
|
+
* outdents the line(s) it touches. Returns false when the caller should fall back to inserting.
|
|
1360
|
+
* The edit is one replace, so it is one undo step, and the selection is kept on the same text.
|
|
1361
|
+
*/
|
|
1362
|
+
shiftSelectedLines(e) {
|
|
1363
|
+
if (this.config.readOnly) return !1;
|
|
1364
|
+
const t = this.textModel.getText(), { startOffset: i, endOffset: n } = this.getActiveSelectionOffsets(t), s = Math.min(i, n), r = Math.max(i, n);
|
|
1365
|
+
if (!e && !t.slice(s, r).includes(`
|
|
1366
|
+
`)) return !1;
|
|
1367
|
+
const o = " ".repeat(this.config.tabSize || 2), l = t.lastIndexOf(`
|
|
1368
|
+
`, s - 1) + 1, a = r > s && t[r - 1] === `
|
|
1369
|
+
` ? r - 1 : r, h = t.indexOf(`
|
|
1370
|
+
`, a), c = h === -1 ? t.length : h, d = t.slice(l, c).split(`
|
|
1371
|
+
`);
|
|
1372
|
+
let f = 0, u = 0;
|
|
1373
|
+
const g = d.map((y, T) => {
|
|
1374
|
+
let S = y;
|
|
1375
|
+
if (!e)
|
|
1376
|
+
S = y.length === 0 ? y : o + y;
|
|
1377
|
+
else if (y.startsWith(" "))
|
|
1378
|
+
S = y.slice(1);
|
|
1379
|
+
else {
|
|
1380
|
+
const C = /^ */.exec(y)[0].length;
|
|
1381
|
+
S = y.slice(Math.min(C, o.length));
|
|
1382
|
+
}
|
|
1383
|
+
const v = S.length - y.length;
|
|
1384
|
+
return T === 0 && (f = v), u += v, S;
|
|
1385
|
+
});
|
|
1386
|
+
if (u === 0) return !0;
|
|
1387
|
+
this.replaceOffsetsWithText(l, c, g.join(`
|
|
1388
|
+
`));
|
|
1389
|
+
const p = Math.max(l, s + f), m = Math.max(p, r + u);
|
|
1390
|
+
return s === r ? this.setCursor(this.textModel.offsetToPosition(p)) : this.setSelection({
|
|
1391
|
+
start: this.textModel.offsetToPosition(p),
|
|
1392
|
+
end: this.textModel.offsetToPosition(m)
|
|
1393
|
+
}), !0;
|
|
1394
|
+
}
|
|
1346
1395
|
// Insert a newline at current cursor position
|
|
1347
1396
|
insertNewLine() {
|
|
1348
1397
|
this.config.readOnly || this.replaceSelectionWithText(`
|
|
1349
1398
|
`);
|
|
1350
1399
|
}
|
|
1351
|
-
deleteBackward() {
|
|
1352
|
-
this.config.readOnly || this.deleteUsingDirection("backward");
|
|
1400
|
+
deleteBackward(e = "char") {
|
|
1401
|
+
this.config.readOnly || this.deleteUsingDirection("backward", e);
|
|
1402
|
+
}
|
|
1403
|
+
deleteForward(e = "char") {
|
|
1404
|
+
this.config.readOnly || this.deleteUsingDirection("forward", e);
|
|
1353
1405
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1406
|
+
/** Map an InputEvent.inputType to the unit it deletes, or null when it isn't a delete in that direction. */
|
|
1407
|
+
static deletionUnit(e, t) {
|
|
1408
|
+
return e === `deleteContent${t}` ? "char" : e === `deleteWord${t}` ? "word" : e === `deleteSoftLine${t}` || e === `deleteHardLine${t}` ? "line" : null;
|
|
1356
1409
|
}
|
|
1357
1410
|
deleteSelection() {
|
|
1358
1411
|
if (this.config.readOnly) return;
|
|
@@ -1544,19 +1597,97 @@ const L = class L {
|
|
|
1544
1597
|
endOffset: i
|
|
1545
1598
|
};
|
|
1546
1599
|
}
|
|
1547
|
-
deleteUsingDirection(e) {
|
|
1548
|
-
const
|
|
1549
|
-
if (
|
|
1550
|
-
this.replaceOffsetsWithText(
|
|
1600
|
+
deleteUsingDirection(e, t = "char") {
|
|
1601
|
+
const i = this.textModel.getText(), { startOffset: n, endOffset: s } = this.getActiveSelectionOffsets(i), r = Math.min(n, s), o = Math.max(n, s);
|
|
1602
|
+
if (r !== o) {
|
|
1603
|
+
this.replaceOffsetsWithText(r, o, "");
|
|
1551
1604
|
return;
|
|
1552
1605
|
}
|
|
1553
1606
|
if (e === "backward") {
|
|
1554
|
-
if (
|
|
1607
|
+
if (r === 0)
|
|
1555
1608
|
return;
|
|
1556
|
-
|
|
1609
|
+
const a = w.deletionBoundary(i, r, "backward", t);
|
|
1610
|
+
this.replaceOffsetsWithText(a, r, "");
|
|
1557
1611
|
return;
|
|
1558
1612
|
}
|
|
1559
|
-
|
|
1613
|
+
if (o >= i.length)
|
|
1614
|
+
return;
|
|
1615
|
+
const l = w.deletionBoundary(i, o, "forward", t);
|
|
1616
|
+
this.replaceOffsetsWithText(o, l, "");
|
|
1617
|
+
}
|
|
1618
|
+
static getGraphemeSegmenter() {
|
|
1619
|
+
if (w.graphemeSegmenter === void 0) {
|
|
1620
|
+
const e = Intl.Segmenter;
|
|
1621
|
+
w.graphemeSegmenter = e ? new e(void 0, { granularity: "grapheme" }) : null;
|
|
1622
|
+
}
|
|
1623
|
+
return w.graphemeSegmenter;
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Where a deletion of `unit` starting at `offset` ends. Characters are whole grapheme
|
|
1627
|
+
* clusters (an emoji is two UTF-16 units, a flag or ZWJ sequence several), so Backspace
|
|
1628
|
+
* never leaves half a surrogate pair behind - that used to turn "a😀b" into "a\uD83Db",
|
|
1629
|
+
* which is invalid text once saved.
|
|
1630
|
+
*/
|
|
1631
|
+
static deletionBoundary(e, t, i, n) {
|
|
1632
|
+
const s = (d) => /[A-Za-z0-9_]/.test(d), r = (d) => d === " " || d === " ";
|
|
1633
|
+
if (n === "line") {
|
|
1634
|
+
if (i === "backward") {
|
|
1635
|
+
const u = e.lastIndexOf(`
|
|
1636
|
+
`, t - 1) + 1;
|
|
1637
|
+
return u === t ? t - 1 : u;
|
|
1638
|
+
}
|
|
1639
|
+
const d = e.indexOf(`
|
|
1640
|
+
`, t), f = d === -1 ? e.length : d;
|
|
1641
|
+
return f === t ? Math.min(e.length, t + 1) : f;
|
|
1642
|
+
}
|
|
1643
|
+
if (n === "word") {
|
|
1644
|
+
let d = t;
|
|
1645
|
+
if (i === "backward") {
|
|
1646
|
+
if (e[d - 1] === `
|
|
1647
|
+
`) return d - 1;
|
|
1648
|
+
for (; d > 0 && r(e[d - 1]); ) d--;
|
|
1649
|
+
if (d > 0 && e[d - 1] !== `
|
|
1650
|
+
`) {
|
|
1651
|
+
const f = s(e[d - 1]);
|
|
1652
|
+
for (; d > 0 && e[d - 1] !== `
|
|
1653
|
+
` && !r(e[d - 1]) && s(e[d - 1]) === f; ) d--;
|
|
1654
|
+
}
|
|
1655
|
+
return d;
|
|
1656
|
+
}
|
|
1657
|
+
if (e[d] === `
|
|
1658
|
+
`) return d + 1;
|
|
1659
|
+
for (; d < e.length && r(e[d]); ) d++;
|
|
1660
|
+
if (d < e.length && e[d] !== `
|
|
1661
|
+
`) {
|
|
1662
|
+
const f = s(e[d]);
|
|
1663
|
+
for (; d < e.length && e[d] !== `
|
|
1664
|
+
` && !r(e[d]) && s(e[d]) === f; ) d++;
|
|
1665
|
+
}
|
|
1666
|
+
return d;
|
|
1667
|
+
}
|
|
1668
|
+
if (i === "backward") {
|
|
1669
|
+
const d = e.lastIndexOf(`
|
|
1670
|
+
`, t - 1) + 1;
|
|
1671
|
+
if (d === t) return t - 1;
|
|
1672
|
+
const f = w.getGraphemeSegmenter();
|
|
1673
|
+
if (f) {
|
|
1674
|
+
let p = 1;
|
|
1675
|
+
for (const { segment: m } of f.segment(e.slice(d, t))) p = m.length;
|
|
1676
|
+
return t - p;
|
|
1677
|
+
}
|
|
1678
|
+
const u = e.charCodeAt(t - 1), g = t >= 2 ? e.charCodeAt(t - 2) : 0;
|
|
1679
|
+
return u >= 56320 && u <= 57343 && g >= 55296 && g <= 56319 ? t - 2 : t - 1;
|
|
1680
|
+
}
|
|
1681
|
+
if (e[t] === `
|
|
1682
|
+
`) return t + 1;
|
|
1683
|
+
const o = e.indexOf(`
|
|
1684
|
+
`, t), l = o === -1 ? e.length : o, a = w.getGraphemeSegmenter();
|
|
1685
|
+
if (a) {
|
|
1686
|
+
for (const { segment: d } of a.segment(e.slice(t, l))) return t + d.length;
|
|
1687
|
+
return t + 1;
|
|
1688
|
+
}
|
|
1689
|
+
const h = e.charCodeAt(t), c = t + 1 < e.length ? e.charCodeAt(t + 1) : 0;
|
|
1690
|
+
return h >= 55296 && h <= 56319 && c >= 56320 && c <= 57343 ? t + 2 : t + 1;
|
|
1560
1691
|
}
|
|
1561
1692
|
replaceOffsetsWithText(e, t, i) {
|
|
1562
1693
|
var f;
|
|
@@ -1570,8 +1701,8 @@ const L = class L {
|
|
|
1570
1701
|
n
|
|
1571
1702
|
);
|
|
1572
1703
|
this.pendingInputSnapshot = void 0, this.suppressHistory || this.pushUndoSnapshot(r);
|
|
1573
|
-
const
|
|
1574
|
-
return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.textModel.getText(), !1), this.setCursor(this.textModel.offsetToPosition(
|
|
1704
|
+
const d = a + n.length;
|
|
1705
|
+
return this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.textModel.getText(), !1), this.setCursor(this.textModel.offsetToPosition(d)), setTimeout(() => {
|
|
1575
1706
|
this.expectingProgrammaticCursor = !1;
|
|
1576
1707
|
}, 20), this.emit("change", [c]), c;
|
|
1577
1708
|
}
|
|
@@ -1768,9 +1899,9 @@ const L = class L {
|
|
|
1768
1899
|
};
|
|
1769
1900
|
}
|
|
1770
1901
|
};
|
|
1771
|
-
|
|
1772
|
-
let V =
|
|
1773
|
-
class
|
|
1902
|
+
w.CURSOR_SENTINEL = "";
|
|
1903
|
+
let V = w;
|
|
1904
|
+
class J {
|
|
1774
1905
|
constructor(e) {
|
|
1775
1906
|
this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
|
|
1776
1907
|
}
|
|
@@ -1787,8 +1918,8 @@ class X {
|
|
|
1787
1918
|
const { key: t, ctrlKey: i, altKey: n, shiftKey: s, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
|
|
1788
1919
|
if (!l) return null;
|
|
1789
1920
|
for (const a of l) {
|
|
1790
|
-
const h = a.ctrlKey === void 0 || a.ctrlKey === i, c = a.altKey === void 0 || a.altKey === n,
|
|
1791
|
-
if (h && c &&
|
|
1921
|
+
const h = a.ctrlKey === void 0 || a.ctrlKey === i, c = a.altKey === void 0 || a.altKey === n, d = a.shiftKey === void 0 || a.shiftKey === s, f = a.metaKey === void 0 || a.metaKey === r;
|
|
1922
|
+
if (h && c && d && f)
|
|
1792
1923
|
return a;
|
|
1793
1924
|
}
|
|
1794
1925
|
return null;
|
|
@@ -1799,7 +1930,7 @@ class X {
|
|
|
1799
1930
|
}
|
|
1800
1931
|
getDefaultKeymap() {
|
|
1801
1932
|
const e = {};
|
|
1802
|
-
return this.addBinding(e, "f", { ctrlKey: !this.isMac, metaKey: this.isMac }, "find"), this.addBinding(e, "h", { ctrlKey: !this.isMac, metaKey: this.isMac }, "replace"), this.addBinding(e, "f3", {}, "findNext"), this.addBinding(e, "f3", { shiftKey: !0 }, "findPrev"), this.addBinding(e, "g", { ctrlKey: !this.isMac, metaKey: this.isMac }, "findNext"), this.addBinding(e, "[", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "fold"), this.addBinding(e, "]", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "unfold"), this.addBinding(e, "s", { ctrlKey: !0 }, "save"), this.addBinding(e, "s", { metaKey: !0 }, "save"), this.addBinding(e, "z", { ctrlKey: !0 }, "undo"), this.addBinding(e, "z", { metaKey: !0 }, "undo"), this.addBinding(e, "y", { ctrlKey: !0 }, "redo"), this.addBinding(e, "y", { metaKey: !0 }, "redo"), this.addBinding(e, "z", { ctrlKey: !0, shiftKey: !0 }, "redo"), this.addBinding(e, "z", { metaKey: !0, shiftKey: !0 }, "redo"), this.addBinding(e, "tab", {}, "insertTab"), this.addBinding(e, "t", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "toggleTheme"), this.addBinding(e, "f", { altKey: !0, shiftKey: !0 }, "formatDocument"), e;
|
|
1933
|
+
return this.addBinding(e, "f", { ctrlKey: !this.isMac, metaKey: this.isMac }, "find"), this.addBinding(e, "h", { ctrlKey: !this.isMac, metaKey: this.isMac }, "replace"), this.addBinding(e, "f3", {}, "findNext"), this.addBinding(e, "f3", { shiftKey: !0 }, "findPrev"), this.addBinding(e, "g", { ctrlKey: !this.isMac, metaKey: this.isMac }, "findNext"), this.addBinding(e, "[", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "fold"), this.addBinding(e, "]", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "unfold"), this.addBinding(e, "s", { ctrlKey: !0 }, "save"), this.addBinding(e, "s", { metaKey: !0 }, "save"), this.addBinding(e, "z", { ctrlKey: !0 }, "undo"), this.addBinding(e, "z", { metaKey: !0 }, "undo"), this.addBinding(e, "y", { ctrlKey: !0 }, "redo"), this.addBinding(e, "y", { metaKey: !0 }, "redo"), this.addBinding(e, "z", { ctrlKey: !0, shiftKey: !0 }, "redo"), this.addBinding(e, "z", { metaKey: !0, shiftKey: !0 }, "redo"), this.addBinding(e, "tab", { shiftKey: !0 }, "outdent"), this.addBinding(e, "tab", { shiftKey: !1, ctrlKey: !1, altKey: !1, metaKey: !1 }, "insertTab"), this.addBinding(e, "t", { ctrlKey: !this.isMac, metaKey: this.isMac, shiftKey: !0 }, "toggleTheme"), this.addBinding(e, "f", { altKey: !0, shiftKey: !0 }, "formatDocument"), e;
|
|
1803
1934
|
}
|
|
1804
1935
|
addBinding(e, t, i, n) {
|
|
1805
1936
|
const s = t.toLowerCase();
|
|
@@ -1844,7 +1975,7 @@ class X {
|
|
|
1844
1975
|
this.keymap = {}, this.editor = null;
|
|
1845
1976
|
}
|
|
1846
1977
|
}
|
|
1847
|
-
const
|
|
1978
|
+
const A = class A {
|
|
1848
1979
|
constructor() {
|
|
1849
1980
|
this.name = "transaction", this.transactions = [];
|
|
1850
1981
|
}
|
|
@@ -1856,9 +1987,9 @@ const D = class D {
|
|
|
1856
1987
|
effects: [],
|
|
1857
1988
|
annotations: []
|
|
1858
1989
|
};
|
|
1859
|
-
this.transactions.push(i), this.transactions.length >
|
|
1990
|
+
this.transactions.push(i), this.transactions.length > A.MAX_TRANSACTIONS && this.transactions.splice(
|
|
1860
1991
|
0,
|
|
1861
|
-
this.transactions.length -
|
|
1992
|
+
this.transactions.length - A.MAX_TRANSACTIONS
|
|
1862
1993
|
);
|
|
1863
1994
|
});
|
|
1864
1995
|
}
|
|
@@ -1869,9 +2000,9 @@ const D = class D {
|
|
|
1869
2000
|
this.transactions = [];
|
|
1870
2001
|
}
|
|
1871
2002
|
};
|
|
1872
|
-
|
|
1873
|
-
let W =
|
|
1874
|
-
class
|
|
2003
|
+
A.MAX_TRANSACTIONS = 200;
|
|
2004
|
+
let W = A;
|
|
2005
|
+
class ee {
|
|
1875
2006
|
constructor() {
|
|
1876
2007
|
this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
|
|
1877
2008
|
}
|
|
@@ -1900,7 +2031,7 @@ class J {
|
|
|
1900
2031
|
this.lineNumbersElement = null, this.editor = null;
|
|
1901
2032
|
}
|
|
1902
2033
|
}
|
|
1903
|
-
class
|
|
2034
|
+
class te {
|
|
1904
2035
|
constructor() {
|
|
1905
2036
|
this.name = "theme", this.editor = null, this.currentTheme = "dark";
|
|
1906
2037
|
}
|
|
@@ -1925,7 +2056,7 @@ class ee {
|
|
|
1925
2056
|
this.editor = null;
|
|
1926
2057
|
}
|
|
1927
2058
|
}
|
|
1928
|
-
class
|
|
2059
|
+
class ie {
|
|
1929
2060
|
constructor() {
|
|
1930
2061
|
this.name = "read-only", this.editor = null, this.isReadOnly = !1;
|
|
1931
2062
|
}
|
|
@@ -1952,14 +2083,14 @@ class te {
|
|
|
1952
2083
|
this.editor = null;
|
|
1953
2084
|
}
|
|
1954
2085
|
}
|
|
1955
|
-
let
|
|
1956
|
-
const
|
|
2086
|
+
let ne = 0;
|
|
2087
|
+
const x = class x {
|
|
1957
2088
|
constructor(e = {}) {
|
|
1958
2089
|
this.name = "search", this.editor = null, this.searchUI = null, this.isVisible = !1, this.currentResults = [], this.currentIndex = -1, this.searchDebounceTimer = null, this.liveRefreshTimer = null, this.statusResetTimer = null, this.statusFreezeUntil = 0, this.findInput = null, this.replaceInputEl = null, this.statusDiv = null, this.modeDiv = null, this.caseSensitiveInput = null, this.wholeWordInput = null, this.regexInput = null, this.currentQuery = "", this.savedCursor = null, this.editorChangeHandler = null, this.searchOptions = {
|
|
1959
2090
|
caseSensitive: !1,
|
|
1960
2091
|
wholeWord: !1,
|
|
1961
2092
|
regex: !1
|
|
1962
|
-
}, this.trailingMarkerAttr = "data-lce-trailing-newline-marker", this.editorContainerSelector = '[data-lce-editor-container="true"]', this.highlightId = ++
|
|
2093
|
+
}, this.trailingMarkerAttr = "data-lce-trailing-newline-marker", this.editorContainerSelector = '[data-lce-editor-container="true"]', this.highlightId = ++ne, this.highlightMatchName = `editora-search-match-${this.highlightId}`, this.highlightActiveName = `editora-search-active-${this.highlightId}`, this.highlightStyleId = `editora-search-highlight-style-${this.highlightId}`, this.maxCustomHighlightRanges = 2e3, this.virtualMarkerRegex = /[\u200B\uE000]/, this.hasCustomHighlightSupport = !1, this.config = {
|
|
1963
2094
|
replaceAndFindNext: !0,
|
|
1964
2095
|
...e
|
|
1965
2096
|
};
|
|
@@ -1994,67 +2125,67 @@ const y = class y {
|
|
|
1994
2125
|
this.editorContainerSelector
|
|
1995
2126
|
), i = t == null ? void 0 : t.parentElement, n = e.closest(".rte-source-editor-modal") || i || t || e.parentElement;
|
|
1996
2127
|
if (!n) return;
|
|
1997
|
-
window.getComputedStyle(n).position === "static" && (n.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className =
|
|
1998
|
-
<div class="${
|
|
1999
|
-
<input type="text" class="${
|
|
2000
|
-
<button class="${
|
|
2001
|
-
<button class="${
|
|
2002
|
-
<button class="${
|
|
2128
|
+
window.getComputedStyle(n).position === "static" && (n.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = x.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
|
|
2129
|
+
<div class="${x.css.row}">
|
|
2130
|
+
<input type="text" class="${x.css.findInput} ${x.css.inputBase}" placeholder="Find..." />
|
|
2131
|
+
<button class="${x.css.prevButton} ${x.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
|
|
2132
|
+
<button class="${x.css.nextButton} ${x.css.buttonBase}" type="button" aria-label="Next match">↓</button>
|
|
2133
|
+
<button class="${x.css.closeButton} ${x.css.buttonBase}" type="button" aria-label="Close search">×</button>
|
|
2003
2134
|
</div>
|
|
2004
|
-
<div class="${
|
|
2005
|
-
<label class="${
|
|
2006
|
-
<input type="checkbox" class="${
|
|
2135
|
+
<div class="${x.css.options}">
|
|
2136
|
+
<label class="${x.css.optionLabel}" title="Case sensitive">
|
|
2137
|
+
<input type="checkbox" class="${x.css.optionInput} ${x.css.caseSensitive}" />
|
|
2007
2138
|
<span>Aa</span>
|
|
2008
2139
|
</label>
|
|
2009
|
-
<label class="${
|
|
2010
|
-
<input type="checkbox" class="${
|
|
2140
|
+
<label class="${x.css.optionLabel}" title="Whole word">
|
|
2141
|
+
<input type="checkbox" class="${x.css.optionInput} ${x.css.wholeWord}" />
|
|
2011
2142
|
<span>Whole</span>
|
|
2012
2143
|
</label>
|
|
2013
|
-
<label class="${
|
|
2014
|
-
<input type="checkbox" class="${
|
|
2144
|
+
<label class="${x.css.optionLabel}" title="Regular expression">
|
|
2145
|
+
<input type="checkbox" class="${x.css.optionInput} ${x.css.regex}" />
|
|
2015
2146
|
<span>.*</span>
|
|
2016
2147
|
</label>
|
|
2017
2148
|
</div>
|
|
2018
|
-
<div class="${
|
|
2019
|
-
<div class="${
|
|
2020
|
-
<div class="${
|
|
2149
|
+
<div class="${x.css.meta}">
|
|
2150
|
+
<div class="${x.css.status} ${x.css.statusLayout}"></div>
|
|
2151
|
+
<div class="${x.css.mode} ${x.css.modeLayout}" aria-live="polite"></div>
|
|
2021
2152
|
</div>
|
|
2022
|
-
<input type="text" class="${
|
|
2153
|
+
<input type="text" class="${x.css.replaceInput} ${x.css.inputBase} ${x.css.replaceInputLayout}" placeholder="Replace with..." />
|
|
2023
2154
|
`;
|
|
2024
2155
|
const s = this.searchUI.querySelector(
|
|
2025
|
-
`.${
|
|
2156
|
+
`.${x.css.findInput}`
|
|
2026
2157
|
), r = this.searchUI.querySelector(
|
|
2027
|
-
`.${
|
|
2158
|
+
`.${x.css.replaceInput}`
|
|
2028
2159
|
), o = this.searchUI.querySelector(
|
|
2029
|
-
`.${
|
|
2160
|
+
`.${x.css.prevButton}`
|
|
2030
2161
|
), l = this.searchUI.querySelector(
|
|
2031
|
-
`.${
|
|
2162
|
+
`.${x.css.nextButton}`
|
|
2032
2163
|
), a = this.searchUI.querySelector(
|
|
2033
|
-
`.${
|
|
2164
|
+
`.${x.css.closeButton}`
|
|
2034
2165
|
), h = this.searchUI.querySelector(
|
|
2035
|
-
`.${
|
|
2166
|
+
`.${x.css.status}`
|
|
2036
2167
|
), c = this.searchUI.querySelector(
|
|
2037
|
-
`.${
|
|
2038
|
-
), g = this.searchUI.querySelector(
|
|
2039
|
-
`.${y.css.caseSensitive}`
|
|
2040
|
-
), f = this.searchUI.querySelector(
|
|
2041
|
-
`.${y.css.wholeWord}`
|
|
2168
|
+
`.${x.css.mode}`
|
|
2042
2169
|
), d = this.searchUI.querySelector(
|
|
2043
|
-
`.${
|
|
2170
|
+
`.${x.css.caseSensitive}`
|
|
2171
|
+
), f = this.searchUI.querySelector(
|
|
2172
|
+
`.${x.css.wholeWord}`
|
|
2173
|
+
), u = this.searchUI.querySelector(
|
|
2174
|
+
`.${x.css.regex}`
|
|
2044
2175
|
);
|
|
2045
|
-
this.findInput = s, this.replaceInputEl = r, this.statusDiv = h, this.modeDiv = c, this.caseSensitiveInput =
|
|
2176
|
+
this.findInput = s, this.replaceInputEl = r, this.statusDiv = h, this.modeDiv = c, this.caseSensitiveInput = d, this.wholeWordInput = f, this.regexInput = u, d.checked = !!this.searchOptions.caseSensitive, f.checked = !!this.searchOptions.wholeWord, u.checked = !!this.searchOptions.regex, s.addEventListener("input", () => {
|
|
2046
2177
|
this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
|
|
2047
2178
|
const p = s.value;
|
|
2048
2179
|
this.searchDebounceTimer = setTimeout(() => {
|
|
2049
2180
|
this.performSearch(p, !1, !1);
|
|
2050
2181
|
}, 120);
|
|
2051
2182
|
});
|
|
2052
|
-
const
|
|
2053
|
-
this.searchOptions.caseSensitive =
|
|
2183
|
+
const g = () => {
|
|
2184
|
+
this.searchOptions.caseSensitive = d.checked, this.searchOptions.wholeWord = f.checked, this.searchOptions.regex = u.checked;
|
|
2054
2185
|
const p = s.value;
|
|
2055
2186
|
p.trim() ? this.performSearch(p, !1, !1) : this.performSearch("", !1, !1);
|
|
2056
2187
|
};
|
|
2057
|
-
|
|
2188
|
+
d.addEventListener("change", g), f.addEventListener("change", g), u.addEventListener("change", g), s.addEventListener("keydown", (p) => {
|
|
2058
2189
|
p.key === "Enter" ? (p.preventDefault(), p.shiftKey ? this.findPrev() : this.findNext()) : p.key === "Escape" && (p.preventDefault(), this.hideSearch());
|
|
2059
2190
|
}), r.addEventListener("keydown", (p) => {
|
|
2060
2191
|
p.key === "Enter" ? (p.preventDefault(), p.shiftKey ? this.replaceAll(s.value, r.value) : this.replaceCurrent(s.value, r.value)) : p.key === "Escape" && (p.preventDefault(), this.hideSearch());
|
|
@@ -2154,12 +2285,12 @@ const y = class y {
|
|
|
2154
2285
|
if (!l) return;
|
|
2155
2286
|
const a = l.startContainer.nodeType === Node.TEXT_NODE ? l.startContainer.parentElement : l.startContainer, h = this.resolveScrollContainer(i);
|
|
2156
2287
|
if (h) {
|
|
2157
|
-
const c = l.getClientRects()[0] || l.getBoundingClientRect(),
|
|
2158
|
-
let p = t ?
|
|
2159
|
-
const
|
|
2160
|
-
c.right >
|
|
2161
|
-
const
|
|
2162
|
-
if (p = Math.min(
|
|
2288
|
+
const c = l.getClientRects()[0] || l.getBoundingClientRect(), d = h.getBoundingClientRect(), u = h.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, g = 18;
|
|
2289
|
+
let p = t ? u : h.scrollTop, m = h.scrollLeft;
|
|
2290
|
+
const y = h.scrollLeft + (c.left - d.left), T = y + c.width;
|
|
2291
|
+
c.right > d.right - g ? m = T - d.width + g : c.left < d.left + g && (m = Math.max(0, y - g));
|
|
2292
|
+
const S = Math.max(0, h.scrollHeight - h.clientHeight), v = Math.max(0, h.scrollWidth - h.clientWidth);
|
|
2293
|
+
if (p = Math.min(S, Math.max(0, p)), m = Math.min(v, Math.max(0, m)), S === 0 && v === 0) {
|
|
2163
2294
|
a == null || a.scrollIntoView({
|
|
2164
2295
|
block: t ? "center" : "nearest",
|
|
2165
2296
|
inline: "nearest",
|
|
@@ -2306,13 +2437,13 @@ const y = class y {
|
|
|
2306
2437
|
let l = null;
|
|
2307
2438
|
const a = Math.min(this.currentResults.length, this.maxCustomHighlightRanges);
|
|
2308
2439
|
for (let h = 0; h < a; h++) {
|
|
2309
|
-
const c = this.currentResults[h],
|
|
2440
|
+
const c = this.currentResults[h], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
|
|
2310
2441
|
c.range,
|
|
2311
2442
|
i,
|
|
2312
2443
|
n,
|
|
2313
2444
|
s,
|
|
2314
2445
|
r,
|
|
2315
|
-
|
|
2446
|
+
d
|
|
2316
2447
|
);
|
|
2317
2448
|
f && (o.push(f), h === this.currentIndex && (l = f));
|
|
2318
2449
|
}
|
|
@@ -2358,12 +2489,12 @@ const y = class y {
|
|
|
2358
2489
|
var s, r, o, l, a, h;
|
|
2359
2490
|
const i = Math.max(0, e);
|
|
2360
2491
|
for (let c = 0; c < t.length; c++) {
|
|
2361
|
-
const
|
|
2362
|
-
if (i <=
|
|
2363
|
-
const f = Math.max(0, i -
|
|
2492
|
+
const d = t[c];
|
|
2493
|
+
if (i <= d.end) {
|
|
2494
|
+
const f = Math.max(0, i - d.start), u = (o = (r = d.visibleToDom[f]) != null ? r : (s = d.node.textContent) == null ? void 0 : s.length) != null ? o : 0;
|
|
2364
2495
|
return {
|
|
2365
|
-
node:
|
|
2366
|
-
offset:
|
|
2496
|
+
node: d.node,
|
|
2497
|
+
offset: u
|
|
2367
2498
|
};
|
|
2368
2499
|
}
|
|
2369
2500
|
}
|
|
@@ -2377,22 +2508,22 @@ const y = class y {
|
|
|
2377
2508
|
const o = this.positionToOffset(e.start, t, i), l = this.positionToOffset(e.end, t, i);
|
|
2378
2509
|
let a = Math.min(o, l), h = Math.max(o, l);
|
|
2379
2510
|
if (s && r) {
|
|
2380
|
-
const
|
|
2381
|
-
if (
|
|
2511
|
+
const u = r, g = s.slice(a, h);
|
|
2512
|
+
if (g.length === u.length && g.toLowerCase() !== u.toLowerCase()) {
|
|
2382
2513
|
const p = this.findNearestMatchOffset(
|
|
2383
2514
|
s,
|
|
2384
|
-
|
|
2515
|
+
u,
|
|
2385
2516
|
a
|
|
2386
2517
|
);
|
|
2387
|
-
p !== -1 && (a = p, h = p +
|
|
2518
|
+
p !== -1 && (a = p, h = p + u.length);
|
|
2388
2519
|
}
|
|
2389
2520
|
}
|
|
2390
|
-
const c = this.resolveDomPoint(a, n),
|
|
2391
|
-
if (!c || !
|
|
2521
|
+
const c = this.resolveDomPoint(a, n), d = this.resolveDomPoint(h, n);
|
|
2522
|
+
if (!c || !d) return null;
|
|
2392
2523
|
const f = document.createRange();
|
|
2393
2524
|
try {
|
|
2394
|
-
return f.setStart(c.node, c.offset), f.setEnd(
|
|
2395
|
-
} catch (
|
|
2525
|
+
return f.setStart(c.node, c.offset), f.setEnd(d.node, d.offset), f;
|
|
2526
|
+
} catch (u) {
|
|
2396
2527
|
return null;
|
|
2397
2528
|
}
|
|
2398
2529
|
}
|
|
@@ -2503,7 +2634,7 @@ const y = class y {
|
|
|
2503
2634
|
e != null && e.parentNode && e.parentNode.removeChild(e), this.editor = null;
|
|
2504
2635
|
}
|
|
2505
2636
|
};
|
|
2506
|
-
|
|
2637
|
+
x.css = {
|
|
2507
2638
|
root: "lce-search-ui",
|
|
2508
2639
|
row: "lce-search-row",
|
|
2509
2640
|
options: "lce-search-options",
|
|
@@ -2526,8 +2657,8 @@ y.css = {
|
|
|
2526
2657
|
mode: "search-mode",
|
|
2527
2658
|
modeLayout: "lce-search-mode"
|
|
2528
2659
|
};
|
|
2529
|
-
let U =
|
|
2530
|
-
class
|
|
2660
|
+
let U = x, se = 0;
|
|
2661
|
+
class re {
|
|
2531
2662
|
constructor() {
|
|
2532
2663
|
this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
|
|
2533
2664
|
"(": ")",
|
|
@@ -2539,7 +2670,7 @@ class se {
|
|
|
2539
2670
|
"]": "[",
|
|
2540
2671
|
"}": "{",
|
|
2541
2672
|
">": "<"
|
|
2542
|
-
}, this.highlightId = ++
|
|
2673
|
+
}, this.highlightId = ++se, this.highlightName = `editora-bracket-match-${this.highlightId}`, this.highlightStyleId = `editora-bracket-match-style-${this.highlightId}`, this.currentMatch = null, this.hasCustomHighlightSupport = !1, this.observer = null, this.pendingUpdateRaf = null, this.updateRequestVersion = 0, this.cursorHandler = null, this.changeHandler = null;
|
|
2543
2674
|
}
|
|
2544
2675
|
setup(e) {
|
|
2545
2676
|
this.editor = e, this.hasCustomHighlightSupport = this.detectCustomHighlightSupport(), this.hasCustomHighlightSupport && (this.ensureHighlightStyles(), this.observeContentMutations()), this.cursorHandler = () => {
|
|
@@ -2697,7 +2828,7 @@ class se {
|
|
|
2697
2828
|
this.cursorHandler = null, this.changeHandler = null, this.editor = null;
|
|
2698
2829
|
}
|
|
2699
2830
|
}
|
|
2700
|
-
class
|
|
2831
|
+
class oe {
|
|
2701
2832
|
constructor() {
|
|
2702
2833
|
this.name = "code-folding", this.lineHeight = 21, this.voidMarkupTags = /* @__PURE__ */ new Set([
|
|
2703
2834
|
"area",
|
|
@@ -2830,19 +2961,19 @@ class re {
|
|
|
2830
2961
|
i.push({ char: c, line: l, column: h });
|
|
2831
2962
|
continue;
|
|
2832
2963
|
}
|
|
2833
|
-
const
|
|
2834
|
-
if (!
|
|
2964
|
+
const d = r[c];
|
|
2965
|
+
if (!d) continue;
|
|
2835
2966
|
let f = -1;
|
|
2836
2967
|
for (let m = i.length - 1; m >= 0; m--)
|
|
2837
|
-
if (i[m].char ===
|
|
2968
|
+
if (i[m].char === d) {
|
|
2838
2969
|
f = m;
|
|
2839
2970
|
break;
|
|
2840
2971
|
}
|
|
2841
2972
|
if (f === -1) continue;
|
|
2842
|
-
const
|
|
2843
|
-
if (
|
|
2844
|
-
const
|
|
2845
|
-
start: { line:
|
|
2973
|
+
const u = i.splice(f, 1)[0];
|
|
2974
|
+
if (u.line >= l) continue;
|
|
2975
|
+
const g = ((o = t[u.line]) == null ? void 0 : o.length) || 0, p = {
|
|
2976
|
+
start: { line: u.line, column: g },
|
|
2846
2977
|
end: { line: l, column: 0 },
|
|
2847
2978
|
collapsed: !1,
|
|
2848
2979
|
level: f
|
|
@@ -2933,16 +3064,16 @@ class re {
|
|
|
2933
3064
|
return null;
|
|
2934
3065
|
let h = null;
|
|
2935
3066
|
for (; o < e.length; ) {
|
|
2936
|
-
const
|
|
3067
|
+
const g = e[o];
|
|
2937
3068
|
if (h) {
|
|
2938
|
-
|
|
3069
|
+
g === h && (h = null), o += 1;
|
|
2939
3070
|
continue;
|
|
2940
3071
|
}
|
|
2941
|
-
if (
|
|
2942
|
-
h =
|
|
3072
|
+
if (g === '"' || g === "'") {
|
|
3073
|
+
h = g, o += 1;
|
|
2943
3074
|
continue;
|
|
2944
3075
|
}
|
|
2945
|
-
if (
|
|
3076
|
+
if (g === ">")
|
|
2946
3077
|
break;
|
|
2947
3078
|
o += 1;
|
|
2948
3079
|
}
|
|
@@ -2951,13 +3082,13 @@ class re {
|
|
|
2951
3082
|
const c = e.slice(l, a).toLowerCase();
|
|
2952
3083
|
if (!c)
|
|
2953
3084
|
return null;
|
|
2954
|
-
const
|
|
3085
|
+
const d = e.slice(t, o + 1), f = this.offsetToLine(t, i, n), u = this.offsetToLine(o, i, n);
|
|
2955
3086
|
return {
|
|
2956
3087
|
name: c,
|
|
2957
3088
|
isClosing: r,
|
|
2958
|
-
isSelfClosing: !r && /\/\s*>$/.test(
|
|
3089
|
+
isSelfClosing: !r && /\/\s*>$/.test(d),
|
|
2959
3090
|
startLine: f,
|
|
2960
|
-
endLine:
|
|
3091
|
+
endLine: u,
|
|
2961
3092
|
endOffset: o + 1
|
|
2962
3093
|
};
|
|
2963
3094
|
}
|
|
@@ -3103,13 +3234,13 @@ class re {
|
|
|
3103
3234
|
const o = [];
|
|
3104
3235
|
let l = 0;
|
|
3105
3236
|
for (const h of s) {
|
|
3106
|
-
const c = this.positionToOffset(h.start, i, n),
|
|
3107
|
-
r += f, r +=
|
|
3237
|
+
const c = this.positionToOffset(h.start, i, n), d = this.positionToOffset(h.end, i, n), f = e.slice(l, c), u = this.getFoldPlaceholder(h), g = e.slice(c, d);
|
|
3238
|
+
r += f, r += u, f && o.push({ type: "text", text: f }), o.push({
|
|
3108
3239
|
type: "placeholder",
|
|
3109
|
-
text:
|
|
3240
|
+
text: u,
|
|
3110
3241
|
fold: h,
|
|
3111
|
-
hiddenText:
|
|
3112
|
-
}), l =
|
|
3242
|
+
hiddenText: g
|
|
3243
|
+
}), l = d;
|
|
3113
3244
|
}
|
|
3114
3245
|
const a = e.slice(l);
|
|
3115
3246
|
return r += a, a && o.push({ type: "text", text: a }), { text: r, segments: o };
|
|
@@ -3197,28 +3328,28 @@ class re {
|
|
|
3197
3328
|
}
|
|
3198
3329
|
findReplacementFold(e, t, i, n, s) {
|
|
3199
3330
|
const r = this.getFoldKey(e), o = this.foldRegions.find(
|
|
3200
|
-
(
|
|
3331
|
+
(u) => this.getFoldKey(u) === r && !i.has(r)
|
|
3201
3332
|
);
|
|
3202
3333
|
if (o)
|
|
3203
3334
|
return o;
|
|
3204
|
-
const l = e.end.line - e.start.line, a = t != null ? t : this.createFoldSnapshot(e, n, s), c = this.foldRegions.filter((
|
|
3205
|
-
const
|
|
3335
|
+
const l = e.end.line - e.start.line, a = t != null ? t : this.createFoldSnapshot(e, n, s), c = this.foldRegions.filter((u) => !i.has(this.getFoldKey(u))).map((u) => {
|
|
3336
|
+
const g = this.createFoldSnapshot(u, n, s), p = a && (g == null ? void 0 : g.startLineText) === a.startLineText ? 1 : 0, m = a && (g == null ? void 0 : g.endLineText) === a.endLineText ? 1 : 0, y = a && (g == null ? void 0 : g.lineSpan) === a.lineSpan ? 1 : 0;
|
|
3206
3337
|
return {
|
|
3207
|
-
region:
|
|
3208
|
-
overlaps: this.lineRangeOverlap(e,
|
|
3209
|
-
lineDistance: Math.abs(
|
|
3338
|
+
region: u,
|
|
3339
|
+
overlaps: this.lineRangeOverlap(e, u),
|
|
3340
|
+
lineDistance: Math.abs(u.start.line - e.start.line) + Math.abs(u.end.line - e.end.line),
|
|
3210
3341
|
spanDistance: Math.abs(
|
|
3211
|
-
|
|
3342
|
+
u.end.line - u.start.line - l
|
|
3212
3343
|
),
|
|
3213
|
-
columnDistance: Math.abs(
|
|
3214
|
-
hiddenTextMatch: a && (
|
|
3215
|
-
boundaryMatchScore: p + m +
|
|
3344
|
+
columnDistance: Math.abs(u.start.column - e.start.column) + Math.abs(u.end.column - e.end.column),
|
|
3345
|
+
hiddenTextMatch: a && (g == null ? void 0 : g.hiddenText) === a.hiddenText ? 1 : 0,
|
|
3346
|
+
boundaryMatchScore: p + m + y
|
|
3216
3347
|
};
|
|
3217
|
-
}).sort((
|
|
3348
|
+
}).sort((u, g) => u.hiddenTextMatch !== g.hiddenTextMatch ? g.hiddenTextMatch - u.hiddenTextMatch : u.boundaryMatchScore !== g.boundaryMatchScore ? g.boundaryMatchScore - u.boundaryMatchScore : u.overlaps !== g.overlaps ? g.overlaps - u.overlaps : u.lineDistance !== g.lineDistance ? u.lineDistance - g.lineDistance : u.spanDistance !== g.spanDistance ? u.spanDistance - g.spanDistance : u.columnDistance - g.columnDistance)[0];
|
|
3218
3349
|
if (!c)
|
|
3219
3350
|
return null;
|
|
3220
|
-
const
|
|
3221
|
-
return !(c.hiddenTextMatch === 1 || c.boundaryMatchScore >= 2) && !
|
|
3351
|
+
const d = c.lineDistance <= 2 && c.spanDistance <= 1;
|
|
3352
|
+
return !(c.hiddenTextMatch === 1 || c.boundaryMatchScore >= 2) && !d ? null : c.region;
|
|
3222
3353
|
}
|
|
3223
3354
|
lineRangeOverlap(e, t) {
|
|
3224
3355
|
const i = Math.max(e.start.line, t.start.line), n = Math.min(e.end.line, t.end.line);
|
|
@@ -3365,7 +3496,7 @@ class re {
|
|
|
3365
3496
|
this.pendingUpdateRaf !== null && (cancelAnimationFrame(this.pendingUpdateRaf), this.pendingUpdateRaf = null), this.editor && this.changeHandler && this.editor.off("change", this.changeHandler), this.foldingUI && this.foldingUI.parentNode && this.foldingUI.parentNode.removeChild(this.foldingUI), this.restoreFullDisplay(), this.changeHandler = null, this.lastSnapshot = "", this.lastParsedText = null, this.foldingUI = null, this.foldRegions = [], this.cachedLineInfo = null, this.editor = null;
|
|
3366
3497
|
}
|
|
3367
3498
|
}
|
|
3368
|
-
class
|
|
3499
|
+
class le {
|
|
3369
3500
|
constructor() {
|
|
3370
3501
|
this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
|
|
3371
3502
|
}
|
|
@@ -3570,55 +3701,55 @@ class oe {
|
|
|
3570
3701
|
return s >= 2 ? n : null;
|
|
3571
3702
|
}
|
|
3572
3703
|
_highlightHTML(e, t) {
|
|
3573
|
-
const i = t, n = (
|
|
3704
|
+
const i = t, n = (d) => this.escapeHTML(d), s = [], r = this.createTokenStore(s), o = [], l = (d) => {
|
|
3574
3705
|
const f = o.length;
|
|
3575
|
-
return o.push(
|
|
3706
|
+
return o.push(d), `ht${f}`;
|
|
3576
3707
|
};
|
|
3577
3708
|
let a = n(e);
|
|
3578
3709
|
a = a.replace(
|
|
3579
3710
|
/<\/?(?:(?!>)[^\n\r<])*?(?=$|[\n\r])/g,
|
|
3580
|
-
(
|
|
3711
|
+
(d) => l(d)
|
|
3581
3712
|
);
|
|
3582
3713
|
const h = [];
|
|
3583
3714
|
try {
|
|
3584
|
-
e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (
|
|
3585
|
-
} catch (
|
|
3715
|
+
e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (d, f, u) => (h.push({ attrs: String(f || ""), inner: String(u || "") }), d));
|
|
3716
|
+
} catch (d) {
|
|
3586
3717
|
}
|
|
3587
3718
|
let c = 0;
|
|
3588
|
-
return a = a.replace(/(<script\b([^&>]*)>)([\s\S]*?)(<\/script>)/gi, (
|
|
3589
|
-
var
|
|
3590
|
-
const m = (
|
|
3591
|
-
(((
|
|
3592
|
-
const
|
|
3593
|
-
return `${f}${
|
|
3594
|
-
}), a = a.replace(/(<style\b[^&]*>)([\s\S]*?)(<\/style>)/gi, (
|
|
3595
|
-
const p = this._highlightCSS(this.unescapeEntitiesRepeated(
|
|
3596
|
-
return `${f}${p}${
|
|
3719
|
+
return a = a.replace(/(<script\b([^&>]*)>)([\s\S]*?)(<\/script>)/gi, (d, f, u, g, p) => {
|
|
3720
|
+
var T, S, v;
|
|
3721
|
+
const m = (S = (T = h[c++]) == null ? void 0 : T.inner) != null ? S : this.unescapeEntitiesRepeated(g || "");
|
|
3722
|
+
(((v = h[c - 1]) == null ? void 0 : v.attrs) || u || "").toLowerCase();
|
|
3723
|
+
const y = this._highlightJS(m, i);
|
|
3724
|
+
return `${f}${y}${p}`;
|
|
3725
|
+
}), a = a.replace(/(<style\b[^&]*>)([\s\S]*?)(<\/style>)/gi, (d, f, u, g) => {
|
|
3726
|
+
const p = this._highlightCSS(this.unescapeEntitiesRepeated(u), i);
|
|
3727
|
+
return `${f}${p}${g}`;
|
|
3597
3728
|
}), a = a.replace(
|
|
3598
3729
|
/(<!--[\s\S]*?-->)/g,
|
|
3599
|
-
(
|
|
3730
|
+
(d) => r(`<span style="color: ${i.comment};">${d}</span>`)
|
|
3600
3731
|
), a = a.replace(
|
|
3601
3732
|
/(<!DOCTYPE[\s\S]*?>)/i,
|
|
3602
|
-
(
|
|
3603
|
-
), a = a.replace(/(<\/?\s*)([^\s&>\/]+)([^<]*?)(\/?>)/g, (
|
|
3604
|
-
const m = `<span style="color: ${i.tag};">${
|
|
3605
|
-
let
|
|
3606
|
-
return
|
|
3733
|
+
(d) => r(`<span style="color: ${i.doctype};">${d}</span>`)
|
|
3734
|
+
), a = a.replace(/(<\/?\s*)([^\s&>\/]+)([^<]*?)(\/?>)/g, (d, f, u, g, p) => {
|
|
3735
|
+
const m = `<span style="color: ${i.tag};">${u}</span>`;
|
|
3736
|
+
let y = g;
|
|
3737
|
+
return y = y.replace(
|
|
3607
3738
|
/([\w:-]+)(\s*=\s*)(("[\s\S]*?"|'[\s\S]*?'|[^\s&>]+))/g,
|
|
3608
|
-
(
|
|
3609
|
-
const O = String(
|
|
3610
|
-
let I =
|
|
3611
|
-
|
|
3612
|
-
let
|
|
3739
|
+
(T, S, v, C) => {
|
|
3740
|
+
const O = String(S).toLowerCase(), $ = `<span style="color: ${i.attrName};">${S}</span>`;
|
|
3741
|
+
let I = C, M = "";
|
|
3742
|
+
C.startsWith(""") && C.endsWith(""") ? (I = C.slice(6, -6), M = """) : C.startsWith("'") && C.endsWith("'") && (I = C.slice(5, -5), M = "'");
|
|
3743
|
+
let E = C;
|
|
3613
3744
|
if (O === "style") {
|
|
3614
|
-
const N = I.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (
|
|
3615
|
-
|
|
3745
|
+
const N = I.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (F, k, P, H) => `<span style="color: ${i.styleProp};">${k}</span>:<span style="color: ${i.styleVal};">${P}</span>${H}`);
|
|
3746
|
+
M ? E = `${M}${N}${M}` : E = N, E = `<span style="color: ${i.attrValue};">${E}</span>`;
|
|
3616
3747
|
} else
|
|
3617
|
-
|
|
3618
|
-
return `${$}${
|
|
3748
|
+
M && (E = `${M}${I}${M}`), E = `<span style="color: ${i.attrValue};">${E}</span>`;
|
|
3749
|
+
return `${$}${v}${E}`;
|
|
3619
3750
|
}
|
|
3620
|
-
), `${f}${m}${
|
|
3621
|
-
}), a = a.replace(/\u0002ht(\d+)\u0002/g, (
|
|
3751
|
+
), `${f}${m}${y}${p}`;
|
|
3752
|
+
}), a = a.replace(/\u0002ht(\d+)\u0002/g, (d, f) => o[Number(f)] || ""), this.restoreHighlightTokens(a, s);
|
|
3622
3753
|
}
|
|
3623
3754
|
_highlightCSS(e, t) {
|
|
3624
3755
|
const i = this.unescapeEntitiesRepeated(e), n = [], s = this.createTokenStore(n), r = /(\/\*[\s\S]*?\*\/)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
|
|
@@ -3633,7 +3764,7 @@ class oe {
|
|
|
3633
3764
|
(h) => s(`<span style="color: ${t.keyword};">${h}</span>`)
|
|
3634
3765
|
), l = l.replace(
|
|
3635
3766
|
/([A-Za-z_-][\w-]*)(\s*:)/g,
|
|
3636
|
-
(h, c,
|
|
3767
|
+
(h, c, d) => `${s(`<span style="color: ${t.styleProp};">${c}</span>`)}${d}`
|
|
3637
3768
|
), l = l.replace(
|
|
3638
3769
|
/(#(?:[0-9a-fA-F]{3,8})\b)/g,
|
|
3639
3770
|
(h) => s(`<span style="color: ${t.number};">${h}</span>`)
|
|
@@ -3652,8 +3783,8 @@ class oe {
|
|
|
3652
3783
|
s < o.index && (r += this.escapeHTML(i.slice(s, o.index)));
|
|
3653
3784
|
const l = o[0], a = o[1], h = o[2] || "", c = o[3];
|
|
3654
3785
|
if (a) {
|
|
3655
|
-
const
|
|
3656
|
-
r += `<span style="color: ${
|
|
3786
|
+
const d = h ? t.attrName : t.string;
|
|
3787
|
+
r += `<span style="color: ${d};">${this.escapeHTML(a)}</span>${this.escapeHTML(h)}`;
|
|
3657
3788
|
} else c ? r += `<span style="color: ${t.keyword};">${l}</span>` : /^-?\d/.test(l) ? r += `<span style="color: ${t.number};">${l}</span>` : r += `<span style="color: ${t.tag};">${this.escapeHTML(l)}</span>`;
|
|
3658
3789
|
s = n.lastIndex;
|
|
3659
3790
|
}
|
|
@@ -3665,57 +3796,57 @@ class oe {
|
|
|
3665
3796
|
`);
|
|
3666
3797
|
let s = !1, r = "", o = "", l = ((a = n[0]) == null ? void 0 : a.trim()) === "---";
|
|
3667
3798
|
return n.map((h, c) => {
|
|
3668
|
-
const
|
|
3799
|
+
const d = [], f = this.createTokenStore(d);
|
|
3669
3800
|
if (l) {
|
|
3670
|
-
const p = h.trim() === "---",
|
|
3671
|
-
return c > 0 && p && (l = !1),
|
|
3801
|
+
const p = h.trim() === "---", y = `<span style="color: ${p ? t.keyword : t.attrName};">${this.escapeHTML(h)}</span>`;
|
|
3802
|
+
return c > 0 && p && (l = !1), y;
|
|
3672
3803
|
}
|
|
3673
|
-
const
|
|
3674
|
-
if (
|
|
3675
|
-
const p =
|
|
3676
|
-
return s = !(s && p[0] === r[0]), r = s ? p : "", o = s ? this.extractMarkdownFenceLanguage(
|
|
3677
|
-
this.escapeHTML(
|
|
3804
|
+
const u = h.match(/^(\s*)(`{3,}|~{3,})(.*)$/);
|
|
3805
|
+
if (u) {
|
|
3806
|
+
const p = u[2];
|
|
3807
|
+
return s = !(s && p[0] === r[0]), r = s ? p : "", o = s ? this.extractMarkdownFenceLanguage(u[3] || "") : "", [
|
|
3808
|
+
this.escapeHTML(u[1]),
|
|
3678
3809
|
`<span style="color: ${t.keyword}; font-weight: 700;">${this.escapeHTML(p)}</span>`,
|
|
3679
|
-
`<span style="color: ${t.string};">${this.escapeHTML(
|
|
3810
|
+
`<span style="color: ${t.string};">${this.escapeHTML(u[3] || "")}</span>`
|
|
3680
3811
|
].join("");
|
|
3681
3812
|
}
|
|
3682
3813
|
if (s)
|
|
3683
3814
|
return this.highlightMarkdownFenceLine(h, o, t);
|
|
3684
|
-
let
|
|
3815
|
+
let g = this.escapeHTML(h).replace(
|
|
3685
3816
|
/(`[^`]+`)/g,
|
|
3686
3817
|
(p) => f(`<span style="color: ${t.string}; background: rgba(148, 163, 184, 0.16); border-radius: 3px;">${p}</span>`)
|
|
3687
3818
|
).replace(
|
|
3688
3819
|
/(!?\[[^\]\n]*\])(\([^)]+\))/g,
|
|
3689
|
-
(p, m,
|
|
3820
|
+
(p, m, y) => f(`<span style="color: ${t.attrName};">${m}</span><span style="color: ${t.attrValue};">${y}</span>`)
|
|
3690
3821
|
).replace(
|
|
3691
3822
|
/(\*\*|__)(.+?)\1/g,
|
|
3692
|
-
(p, m,
|
|
3823
|
+
(p, m, y) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${y}</span><span style="color: ${t.keyword};">${m}</span>`)
|
|
3693
3824
|
).replace(
|
|
3694
3825
|
/(~~)(.+?)\1/g,
|
|
3695
|
-
(p, m,
|
|
3826
|
+
(p, m, y) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.comment}; text-decoration: line-through;">${y}</span><span style="color: ${t.keyword};">${m}</span>`)
|
|
3696
3827
|
).replace(
|
|
3697
3828
|
/(\*|_)([^*_]+?)\1/g,
|
|
3698
|
-
(p, m,
|
|
3829
|
+
(p, m, y) => f(`<span style="color: ${t.keyword};">${m}</span><span style="color: ${t.styleVal}; font-style: italic;">${y}</span><span style="color: ${t.keyword};">${m}</span>`)
|
|
3699
3830
|
);
|
|
3700
|
-
return
|
|
3831
|
+
return g = g.replace(
|
|
3701
3832
|
/^(\s{0,3}#{1,6})(\s+.*)?$/,
|
|
3702
|
-
(p, m,
|
|
3703
|
-
),
|
|
3833
|
+
(p, m, y = "") => `<span style="color: ${t.keyword}; font-weight: 700;">${m}</span><span style="color: ${t.tag}; font-weight: 700;">${y}</span>`
|
|
3834
|
+
), g = g.replace(
|
|
3704
3835
|
/^(\s{0,3})((?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/,
|
|
3705
|
-
(p, m,
|
|
3706
|
-
),
|
|
3836
|
+
(p, m, y) => `${m}<span style="color: ${t.comment};">${y}</span>`
|
|
3837
|
+
), g = g.replace(
|
|
3707
3838
|
/^(\s{0,3}>)(.*)$/,
|
|
3708
|
-
(p, m,
|
|
3709
|
-
),
|
|
3839
|
+
(p, m, y) => `<span style="color: ${t.comment};">${m}</span>${y}`
|
|
3840
|
+
), g = g.replace(
|
|
3710
3841
|
/^(\s*)([-*+])(\s+\[[ xX]\])(\s+)/,
|
|
3711
|
-
(p, m,
|
|
3712
|
-
),
|
|
3842
|
+
(p, m, y, T, S) => `${m}<span style="color: ${t.keyword};">${y}</span><span style="color: ${t.attrName};">${T}</span>${S}`
|
|
3843
|
+
), g = g.replace(
|
|
3713
3844
|
/^(\s*)([-*+]|\d+\.)(\s+)/,
|
|
3714
|
-
(p, m,
|
|
3715
|
-
),
|
|
3845
|
+
(p, m, y, T) => `${m}<span style="color: ${t.keyword};">${y}</span>${T}`
|
|
3846
|
+
), g = g.replace(
|
|
3716
3847
|
/^(\s*\|.*\|\s*)$/,
|
|
3717
3848
|
(p) => p.replace(/\|/g, (m) => `<span style="color: ${t.keyword};">${m}</span>`)
|
|
3718
|
-
), this.restoreHighlightTokens(
|
|
3849
|
+
), this.restoreHighlightTokens(g, d);
|
|
3719
3850
|
}).join(`
|
|
3720
3851
|
`);
|
|
3721
3852
|
}
|
|
@@ -3738,13 +3869,13 @@ class oe {
|
|
|
3738
3869
|
}
|
|
3739
3870
|
return o < i.length && (l += this.escapeHTML(i.slice(o))), l = l.replace(
|
|
3740
3871
|
/(^|\s)(--?[A-Za-z0-9][\w-]*)(?=\s|=|$)/g,
|
|
3741
|
-
(h, c,
|
|
3872
|
+
(h, c, d) => `${c}${s(`<span style="color: ${t.attrName};">${d}</span>`)}`
|
|
3742
3873
|
), l = l.replace(
|
|
3743
3874
|
/\b(if|then|else|elif|fi|for|while|until|do|done|case|esac|function|export|unset|alias|source|return|in)\b/g,
|
|
3744
3875
|
(h) => s(`<span style="color: ${t.keyword};">${h}</span>`)
|
|
3745
3876
|
), l = l.replace(
|
|
3746
3877
|
/(^|\s)(npm|npx|pnpm|yarn|bun|node|git|cd|mkdir|touch|cp|mv|rm|cat|grep|rg|find|curl|wget|echo|printf|sudo|chmod|chown|docker|kubectl)(?=\s|$)/g,
|
|
3747
|
-
(h, c,
|
|
3878
|
+
(h, c, d) => `${c}${s(`<span style="color: ${t.tag};">${d}</span>`)}`
|
|
3748
3879
|
), this.restoreHighlightTokens(l, n);
|
|
3749
3880
|
}
|
|
3750
3881
|
getLanguageKeywords(e) {
|
|
@@ -3769,19 +3900,19 @@ class oe {
|
|
|
3769
3900
|
let a = 0, h = "", c;
|
|
3770
3901
|
for (; c = l.exec(n); ) {
|
|
3771
3902
|
a < c.index && (h += this.escapeHTML(n.slice(a, c.index)));
|
|
3772
|
-
const f = c[0],
|
|
3773
|
-
h += r(`<span style="color: ${
|
|
3903
|
+
const f = c[0], u = f.startsWith("//") || f.startsWith("/*") || f.startsWith("#") || f.startsWith("--") ? t.comment : t.string;
|
|
3904
|
+
h += r(`<span style="color: ${u};">${this.escapeHTML(f)}</span>`), a = l.lastIndex;
|
|
3774
3905
|
}
|
|
3775
3906
|
a < n.length && (h += this.escapeHTML(n.slice(a)));
|
|
3776
|
-
const
|
|
3777
|
-
if (
|
|
3907
|
+
const d = Array.from(new Set(this.getLanguageKeywords(i)));
|
|
3908
|
+
if (d.length > 0) {
|
|
3778
3909
|
const f = new RegExp(
|
|
3779
|
-
`\\b(${
|
|
3910
|
+
`\\b(${d.map((u) => u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`,
|
|
3780
3911
|
i === "sql" ? "gi" : "g"
|
|
3781
3912
|
);
|
|
3782
3913
|
h = h.replace(
|
|
3783
3914
|
f,
|
|
3784
|
-
(
|
|
3915
|
+
(u) => r(`<span style="color: ${t.keyword};">${u}</span>`)
|
|
3785
3916
|
);
|
|
3786
3917
|
}
|
|
3787
3918
|
return h = h.replace(
|
|
@@ -3824,12 +3955,12 @@ class oe {
|
|
|
3824
3955
|
(s) => {
|
|
3825
3956
|
const r = i.length, o = this.escapeHTML(s).replace(
|
|
3826
3957
|
/(<\/?)([A-Za-z][\w.:-]*)([\s\S]*?)(\/?>)/,
|
|
3827
|
-
(l, a, h, c,
|
|
3958
|
+
(l, a, h, c, d) => {
|
|
3828
3959
|
const f = String(c || "").replace(
|
|
3829
3960
|
/([A-Za-z_:][\w:.-]*)(\s*=\s*)/g,
|
|
3830
3961
|
`<span style="color: ${t.attrName};">$1</span>$2`
|
|
3831
3962
|
);
|
|
3832
|
-
return `${a}<span style="color: ${t.tag};">${h}</span>${f}${
|
|
3963
|
+
return `${a}<span style="color: ${t.tag};">${h}</span>${f}${d}`;
|
|
3833
3964
|
}
|
|
3834
3965
|
);
|
|
3835
3966
|
return i.push(o), `jsx${r}`;
|
|
@@ -3865,14 +3996,14 @@ class oe {
|
|
|
3865
3996
|
const i = this.unescapeEntitiesRepeated(e);
|
|
3866
3997
|
this.escapeHTML(i);
|
|
3867
3998
|
const n = [], s = (f) => {
|
|
3868
|
-
let
|
|
3999
|
+
let u = "", g = f;
|
|
3869
4000
|
do
|
|
3870
|
-
|
|
3871
|
-
while (
|
|
3872
|
-
return
|
|
4001
|
+
u = String.fromCharCode(97 + g % 26) + u, g = Math.floor(g / 26) - 1;
|
|
4002
|
+
while (g >= 0);
|
|
4003
|
+
return u || "a";
|
|
3873
4004
|
}, r = (f) => `\0${s(f)}\0`, o = (f) => {
|
|
3874
|
-
const
|
|
3875
|
-
return n.push(f), r(
|
|
4005
|
+
const u = n.length;
|
|
4006
|
+
return n.push(f), r(u);
|
|
3876
4007
|
};
|
|
3877
4008
|
let l;
|
|
3878
4009
|
const a = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
|
|
@@ -3880,60 +4011,60 @@ class oe {
|
|
|
3880
4011
|
for (; l = a.exec(i); ) {
|
|
3881
4012
|
const f = l.index;
|
|
3882
4013
|
h < f && (c += this.escapeHTML(i.slice(h, f)));
|
|
3883
|
-
const
|
|
3884
|
-
/^\/\*/.test(
|
|
4014
|
+
const u = l[0];
|
|
4015
|
+
/^\/\*/.test(u) || /^\/\//.test(u) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`), h = a.lastIndex;
|
|
3885
4016
|
}
|
|
3886
|
-
return h < i.length && (c += this.escapeHTML(i.slice(h))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (f,
|
|
3887
|
-
const p = c[
|
|
4017
|
+
return h < i.length && (c += this.escapeHTML(i.slice(h))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (f, u, g) => {
|
|
4018
|
+
const p = c[g - 1] || "", m = c[g + f.length] || "";
|
|
3888
4019
|
return p === "&" || p === "#" || m === ";" || m === "#" ? f : `<span style="color: ${t.number};">${f}</span>`;
|
|
3889
|
-
}), c = c.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>`), c.replace(/\u0000([a-z]+)\u0000/g, (f,
|
|
3890
|
-
let
|
|
3891
|
-
for (let p = 0; p <
|
|
3892
|
-
|
|
3893
|
-
return
|
|
4020
|
+
}), c = c.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>`), c.replace(/\u0000([a-z]+)\u0000/g, (f, u) => {
|
|
4021
|
+
let g = 0;
|
|
4022
|
+
for (let p = 0; p < u.length; p++)
|
|
4023
|
+
g = g * 26 + (u.charCodeAt(p) - 97 + 1);
|
|
4024
|
+
return g = g - 1, n[g] || "";
|
|
3894
4025
|
});
|
|
3895
4026
|
}
|
|
3896
4027
|
_highlightPHP(e, t) {
|
|
3897
4028
|
const i = this.unescapeEntitiesRepeated(e);
|
|
3898
4029
|
let n = this.escapeHTML(i);
|
|
3899
|
-
const s = [], r = (
|
|
3900
|
-
let
|
|
4030
|
+
const s = [], r = (u) => {
|
|
4031
|
+
let g = "", p = u;
|
|
3901
4032
|
do
|
|
3902
|
-
|
|
4033
|
+
g = String.fromCharCode(97 + p % 26) + g, p = Math.floor(p / 26) - 1;
|
|
3903
4034
|
while (p >= 0);
|
|
3904
|
-
return
|
|
3905
|
-
}, o = (
|
|
3906
|
-
const
|
|
3907
|
-
return s.push(
|
|
3908
|
-
}, l = (
|
|
3909
|
-
const p = n.indexOf(
|
|
3910
|
-
return p === -1 ? !1 : (n = n.slice(0, p) +
|
|
4035
|
+
return g || "a";
|
|
4036
|
+
}, o = (u) => {
|
|
4037
|
+
const g = s.length;
|
|
4038
|
+
return s.push(u), `\0${r(g)}\0`;
|
|
4039
|
+
}, l = (u, g) => {
|
|
4040
|
+
const p = n.indexOf(u);
|
|
4041
|
+
return p === -1 ? !1 : (n = n.slice(0, p) + g + n.slice(p + u.length), !0);
|
|
3911
4042
|
};
|
|
3912
4043
|
let a;
|
|
3913
|
-
const h = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g,
|
|
4044
|
+
const h = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, f = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
|
|
3914
4045
|
for (; a = h.exec(i); ) {
|
|
3915
|
-
const
|
|
3916
|
-
l(this.escapeHTML(
|
|
4046
|
+
const u = a[0];
|
|
4047
|
+
l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
|
|
3917
4048
|
}
|
|
3918
4049
|
for (; a = c.exec(i); ) {
|
|
3919
|
-
const
|
|
3920
|
-
l(this.escapeHTML(
|
|
4050
|
+
const u = a[0];
|
|
4051
|
+
l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
|
|
3921
4052
|
}
|
|
3922
|
-
for (; a =
|
|
3923
|
-
const
|
|
3924
|
-
l(this.escapeHTML(
|
|
4053
|
+
for (; a = d.exec(i); ) {
|
|
4054
|
+
const u = a[0];
|
|
4055
|
+
l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
|
|
3925
4056
|
}
|
|
3926
4057
|
for (; a = f.exec(i); ) {
|
|
3927
|
-
const
|
|
3928
|
-
l(this.escapeHTML(
|
|
4058
|
+
const u = a[0];
|
|
4059
|
+
l(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
|
|
3929
4060
|
}
|
|
3930
4061
|
return n = n.replace(
|
|
3931
4062
|
/(<\?(?:php\b|=)?|\?>)/gi,
|
|
3932
|
-
(
|
|
3933
|
-
), n = n.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), n = n.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>`), n = n.replace(/\u0000([a-z]+)\u0000/g, (
|
|
4063
|
+
(u) => o(`<span style="color: ${t.keyword};">${u}</span>`)
|
|
4064
|
+
), n = n.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), n = n.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>`), n = n.replace(/\u0000([a-z]+)\u0000/g, (u, g) => {
|
|
3934
4065
|
let p = 0;
|
|
3935
|
-
for (let m = 0; m <
|
|
3936
|
-
p = p * 26 + (
|
|
4066
|
+
for (let m = 0; m < g.length; m++)
|
|
4067
|
+
p = p * 26 + (g.charCodeAt(m) - 97 + 1);
|
|
3937
4068
|
return p = p - 1, s[p] || "";
|
|
3938
4069
|
}), n;
|
|
3939
4070
|
}
|
|
@@ -3945,11 +4076,11 @@ class oe {
|
|
|
3945
4076
|
this.editor = null, this.modes.clear();
|
|
3946
4077
|
}
|
|
3947
4078
|
}
|
|
3948
|
-
function
|
|
4079
|
+
function ae(R, e) {
|
|
3949
4080
|
const t = { ...e };
|
|
3950
|
-
return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new
|
|
4081
|
+
return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new J(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new W()), new V(R, t);
|
|
3951
4082
|
}
|
|
3952
|
-
const z = '[data-theme="dark"], .dark, .editora-theme-dark',
|
|
4083
|
+
const z = '[data-theme="dark"], .dark, .editora-theme-dark', he = `/* Source Editor Dialog Styles */
|
|
3953
4084
|
.rte-source-editor-overlay {
|
|
3954
4085
|
position: fixed !important;
|
|
3955
4086
|
top: 0 !important;
|
|
@@ -4326,7 +4457,7 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4326
4457
|
flex: 1;
|
|
4327
4458
|
text-align: center;
|
|
4328
4459
|
}
|
|
4329
|
-
}`,
|
|
4460
|
+
}`, de = () => ({
|
|
4330
4461
|
name: "code",
|
|
4331
4462
|
// Toolbar button configuration
|
|
4332
4463
|
toolbar: [
|
|
@@ -4394,12 +4525,13 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4394
4525
|
return r.trim();
|
|
4395
4526
|
};
|
|
4396
4527
|
return (() => {
|
|
4528
|
+
document.querySelectorAll(".rte-source-editor-overlay").forEach((b) => b.remove());
|
|
4397
4529
|
const r = i(t);
|
|
4398
|
-
let o = null, l = "dark", a = !1, h = !1, c = !1,
|
|
4399
|
-
const f = !!e.closest(z) || document.body.matches(z) || document.documentElement.matches(z),
|
|
4400
|
-
|
|
4401
|
-
const
|
|
4402
|
-
|
|
4530
|
+
let o = null, l = "dark", a = !1, h = !1, c = !1, d = !1;
|
|
4531
|
+
const f = !!e.closest(z) || document.body.matches(z) || document.documentElement.matches(z), u = document.createElement("div");
|
|
4532
|
+
Q(u), u.className = "rte-source-editor-overlay", f && u.classList.add("rte-theme-dark");
|
|
4533
|
+
const g = document.createElement("div");
|
|
4534
|
+
g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
|
|
4403
4535
|
const p = document.createElement("div");
|
|
4404
4536
|
p.className = "rte-source-editor-header", p.innerHTML = `
|
|
4405
4537
|
<h2 id="source-editor-title">Source Editor</h2>
|
|
@@ -4440,14 +4572,14 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4440
4572
|
`;
|
|
4441
4573
|
const m = document.createElement("div");
|
|
4442
4574
|
m.className = "rte-source-editor-body";
|
|
4443
|
-
const
|
|
4444
|
-
|
|
4445
|
-
const v = document.createElement("div");
|
|
4446
|
-
v.className = "rte-source-editor-warning", v.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
|
|
4575
|
+
const y = document.createElement("div");
|
|
4576
|
+
y.className = "rte-source-editor-content";
|
|
4447
4577
|
const T = document.createElement("div");
|
|
4448
|
-
T.className = "rte-source-editor-
|
|
4578
|
+
T.className = "rte-source-editor-warning", T.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
|
|
4449
4579
|
const S = document.createElement("div");
|
|
4450
|
-
|
|
4580
|
+
S.className = "rte-source-editor-light-editor", S.style.height = "400px", y.appendChild(T), y.appendChild(S), m.appendChild(y);
|
|
4581
|
+
const v = document.createElement("div");
|
|
4582
|
+
if (v.className = "rte-source-editor-footer", v.innerHTML = `
|
|
4451
4583
|
<div class="rte-source-editor-footer-info">
|
|
4452
4584
|
<span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
|
|
4453
4585
|
</div>
|
|
@@ -4455,11 +4587,11 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4455
4587
|
<button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
|
|
4456
4588
|
<button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
|
|
4457
4589
|
</div>
|
|
4458
|
-
`,
|
|
4590
|
+
`, g.appendChild(p), g.appendChild(m), g.appendChild(v), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
|
|
4459
4591
|
const b = document.createElement("style");
|
|
4460
|
-
b.id = "rte-source-editor-styles", b.textContent =
|
|
4592
|
+
b.id = "rte-source-editor-styles", b.textContent = he, document.head.appendChild(b);
|
|
4461
4593
|
}
|
|
4462
|
-
const
|
|
4594
|
+
const C = p.querySelector(
|
|
4463
4595
|
".theme-toggle-btn"
|
|
4464
4596
|
), O = p.querySelector(
|
|
4465
4597
|
".readonly-toggle-btn"
|
|
@@ -4467,28 +4599,28 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4467
4599
|
".rte-source-editor-fullscreen-btn"
|
|
4468
4600
|
), I = p.querySelector(
|
|
4469
4601
|
".rte-source-editor-close-btn"
|
|
4470
|
-
),
|
|
4602
|
+
), M = v.querySelector(
|
|
4471
4603
|
".rte-source-editor-btn-cancel"
|
|
4472
|
-
),
|
|
4604
|
+
), E = v.querySelector(
|
|
4473
4605
|
".rte-source-editor-btn-save"
|
|
4474
|
-
), N =
|
|
4606
|
+
), N = v.querySelector(
|
|
4475
4607
|
".unsaved-changes"
|
|
4476
|
-
),
|
|
4477
|
-
b.addEventListener(
|
|
4478
|
-
() => b.removeEventListener(
|
|
4608
|
+
), F = [], k = (b, L, B, D) => {
|
|
4609
|
+
b.addEventListener(L, B, D), F.push(
|
|
4610
|
+
() => b.removeEventListener(L, B, D)
|
|
4479
4611
|
);
|
|
4480
4612
|
}, P = (b) => {
|
|
4481
4613
|
c !== b && (c = b, N && (N.style.display = c ? "inline" : "none"));
|
|
4482
4614
|
}, H = () => {
|
|
4483
|
-
if (!
|
|
4484
|
-
for (
|
|
4485
|
-
const b =
|
|
4615
|
+
if (!d) {
|
|
4616
|
+
for (d = !0; F.length; ) {
|
|
4617
|
+
const b = F.pop();
|
|
4486
4618
|
b == null || b();
|
|
4487
4619
|
}
|
|
4488
|
-
o && (o.destroy(), o = null),
|
|
4620
|
+
o && (o.destroy(), o = null), u.isConnected && u.remove();
|
|
4489
4621
|
}
|
|
4490
|
-
},
|
|
4491
|
-
l = l === "dark" ? "light" : "dark", o == null || o.setTheme(l),
|
|
4622
|
+
}, _ = () => {
|
|
4623
|
+
l = l === "dark" ? "light" : "dark", o == null || o.setTheme(l), C && (C.innerHTML = l === "light" ? `
|
|
4492
4624
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
4493
4625
|
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
|
|
4494
4626
|
</svg>
|
|
@@ -4519,7 +4651,7 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4519
4651
|
</svg>
|
|
4520
4652
|
`);
|
|
4521
4653
|
}, q = () => {
|
|
4522
|
-
h = !h,
|
|
4654
|
+
h = !h, u.classList.toggle("fullscreen", h), S.style.height = h ? "calc(100vh - 200px)" : "400px", $ && ($.innerHTML = h ? `
|
|
4523
4655
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
4524
4656
|
<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"/>
|
|
4525
4657
|
</svg>
|
|
@@ -4532,10 +4664,10 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4532
4664
|
c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
|
|
4533
4665
|
}, Z = () => {
|
|
4534
4666
|
try {
|
|
4535
|
-
const b = (o == null ? void 0 : o.getValue()) || "",
|
|
4536
|
-
|
|
4667
|
+
const b = (o == null ? void 0 : o.getValue()) || "", L = document.createElement("div");
|
|
4668
|
+
L.innerHTML = b, L.querySelectorAll(
|
|
4537
4669
|
'script, iframe[src^="javascript:"], object, embed'
|
|
4538
|
-
).forEach((
|
|
4670
|
+
).forEach((D) => D.remove()), e.innerHTML = L.innerHTML;
|
|
4539
4671
|
try {
|
|
4540
4672
|
e.dispatchEvent(
|
|
4541
4673
|
new InputEvent("input", {
|
|
@@ -4544,7 +4676,7 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4544
4676
|
inputType: "insertReplacementText"
|
|
4545
4677
|
})
|
|
4546
4678
|
);
|
|
4547
|
-
} catch (
|
|
4679
|
+
} catch (D) {
|
|
4548
4680
|
e.dispatchEvent(
|
|
4549
4681
|
new Event("input", { bubbles: !0 })
|
|
4550
4682
|
);
|
|
@@ -4556,26 +4688,26 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4556
4688
|
alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", b);
|
|
4557
4689
|
}
|
|
4558
4690
|
};
|
|
4559
|
-
|
|
4560
|
-
b.target ===
|
|
4561
|
-
}),
|
|
4562
|
-
const
|
|
4563
|
-
|
|
4564
|
-
}), document.body.appendChild(
|
|
4565
|
-
if (!(
|
|
4691
|
+
C && k(C, "click", _), O && k(O, "click", j), $ && k($, "click", q), I && k(I, "click", H), M && k(M, "click", G), E && k(E, "click", Z), k(u, "click", (b) => {
|
|
4692
|
+
b.target === u && H();
|
|
4693
|
+
}), k(document, "keydown", (b) => {
|
|
4694
|
+
const L = b;
|
|
4695
|
+
L.key === "Escape" && (L.preventDefault(), H());
|
|
4696
|
+
}), document.body.appendChild(u), requestAnimationFrame(() => {
|
|
4697
|
+
if (!(d || !u.isConnected))
|
|
4566
4698
|
try {
|
|
4567
|
-
o =
|
|
4699
|
+
o = ae(S, {
|
|
4568
4700
|
value: r,
|
|
4569
4701
|
theme: "dark",
|
|
4570
4702
|
readOnly: !1,
|
|
4571
4703
|
extensions: [
|
|
4572
|
-
new J(),
|
|
4573
4704
|
new ee(),
|
|
4574
4705
|
new te(),
|
|
4575
|
-
new
|
|
4576
|
-
new U(),
|
|
4706
|
+
new ie(),
|
|
4577
4707
|
new re(),
|
|
4578
|
-
new
|
|
4708
|
+
new U(),
|
|
4709
|
+
new oe(),
|
|
4710
|
+
new le()
|
|
4579
4711
|
]
|
|
4580
4712
|
}), o.on("change", () => {
|
|
4581
4713
|
const b = (o == null ? void 0 : o.getValue()) || "";
|
|
@@ -4595,6 +4727,6 @@ const z = '[data-theme="dark"], .dark, .editora-theme-dark', ae = `/* Source Edi
|
|
|
4595
4727
|
}
|
|
4596
4728
|
});
|
|
4597
4729
|
export {
|
|
4598
|
-
|
|
4730
|
+
de as CodePlugin
|
|
4599
4731
|
};
|
|
4600
|
-
//# sourceMappingURL=CodePlugin.native-
|
|
4732
|
+
//# sourceMappingURL=CodePlugin.native-BH-K4xmW.mjs.map
|