@editora/core 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +5 -0
  2. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-58d12bed.mjs} +23 -12
  3. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-289a112a.mjs} +112 -102
  4. package/dist/ApprovalWorkflowPlugin.native-449ce66c.mjs +1115 -0
  5. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-8aceb5cc.mjs} +16 -9
  6. package/dist/{BlockquotePlugin.native-JFmOLsxN.mjs → BlockquotePlugin.native-3541c714.mjs} +3 -2
  7. package/dist/BlocksLibraryPlugin.native-1cc51e63.mjs +1386 -0
  8. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-f9d7f8e4.mjs} +1 -1
  9. package/dist/{CapitalizationPlugin.native-DOMsh5R7.mjs → CapitalizationPlugin.native-42c135dc.mjs} +3 -2
  10. package/dist/{ChecklistPlugin.native-nuSSEFNI.mjs → ChecklistPlugin.native-3b397ee9.mjs} +43 -22
  11. package/dist/CitationsPlugin.native-169fb1e8.mjs +1532 -0
  12. package/dist/{ClearFormattingPlugin.native-Bq_XcTh2.mjs → ClearFormattingPlugin.native-77baa514.mjs} +11 -6
  13. package/dist/{CodePlugin.native-DlpTPdkd.mjs → CodePlugin.native-989cf0aa.mjs} +629 -580
  14. package/dist/{CodeSamplePlugin.native-CgGoH-X4.mjs → CodeSamplePlugin.native-6cc0148e.mjs} +19 -10
  15. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-03659874.mjs} +55 -28
  16. package/dist/ConditionalContentPlugin.native-4983143a.mjs +1424 -0
  17. package/dist/ContentRulesPlugin.native-63ed405b.mjs +1149 -0
  18. package/dist/DataBindingPlugin.native-427e9d75.mjs +956 -0
  19. package/dist/{DirectionPlugin.native-CDnbdNyl.mjs → DirectionPlugin.native-4e742f42.mjs} +19 -10
  20. package/dist/DocSchemaPlugin.native-8e41eda0.mjs +1382 -0
  21. package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-e69895ad.mjs} +4 -4
  22. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-55209c87.mjs} +70 -70
  23. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-65c5ac47.mjs} +11 -6
  24. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-f9bc255a.mjs} +7 -4
  25. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-f5647872.mjs} +19 -10
  26. package/dist/{FootnotePlugin.native-D730OGRm.mjs → FootnotePlugin.native-494657b3.mjs} +77 -39
  27. package/dist/{FullscreenPlugin.native-ChXyxeNw.mjs → FullscreenPlugin.native-87ce92e9.mjs} +1 -1
  28. package/dist/{HeadingPlugin.native-DrLYwQnQ.mjs → HeadingPlugin.native-e38c4a16.mjs} +1 -1
  29. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-92ed4be4.mjs} +43 -22
  30. package/dist/{IndentPlugin.native-BHixp8sP.mjs → IndentPlugin.native-e4ee902b.mjs} +23 -12
  31. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-7c95cfbc.mjs} +1 -1
  32. package/dist/{LineHeightPlugin.native-CM7iXdQj.mjs → LineHeightPlugin.native-5668f78c.mjs} +19 -10
  33. package/dist/{LinkPlugin.native-DYCIcdTm.mjs → LinkPlugin.native-6df29111.mjs} +9 -5
  34. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-fe2e115a.mjs} +9 -5
  35. package/dist/{MathPlugin.native-f_mDp8VL.mjs → MathPlugin.native-735bbac2.mjs} +9 -5
  36. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-3cf48a00.mjs} +219 -207
  37. package/dist/MentionPlugin.native-3b1e8c05.mjs +778 -0
  38. package/dist/{MergeTagPlugin.native-C3eOfEgw.mjs → MergeTagPlugin.native-31cf7d48.mjs} +51 -26
  39. package/dist/PIIRedactionPlugin.native-7ab10b9f.mjs +1449 -0
  40. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-1794c5fb.mjs} +67 -52
  41. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-f7b67cc0.mjs} +38 -33
  42. package/dist/{PrintPlugin.native-7qt5v7L5.mjs → PrintPlugin.native-f6a168c2.mjs} +5 -3
  43. package/dist/SlashCommandsPlugin.native-8d45e511.mjs +790 -0
  44. package/dist/SmartPastePlugin.native-a6c5efec.mjs +1447 -0
  45. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-7f06d4ba.mjs} +17 -9
  46. package/dist/{SpellCheckPlugin.native-BZB9AewP.mjs → SpellCheckPlugin.native-04e20834.mjs} +41 -21
  47. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-905e9501.mjs} +9 -5
  48. package/dist/{TablePlugin.native-DrHX-efe.mjs → TablePlugin.native-7d5458c1.mjs} +58 -30
  49. package/dist/{TemplatePlugin.native-CrpfKRJ8.mjs → TemplatePlugin.native-580f0f63.mjs} +32 -17
  50. package/dist/{TextAlignmentPlugin.native-sM_1s00t.mjs → TextAlignmentPlugin.native-9357b3ed.mjs} +11 -6
  51. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-d53ed459.mjs} +26 -14
  52. package/dist/TrackChangesPlugin.native-e96da509.mjs +818 -0
  53. package/dist/TranslationWorkflowPlugin.native-4e711b1e.mjs +1797 -0
  54. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-8080c998.mjs} +1 -1
  55. package/dist/VersionDiffPlugin.native-5bbeff85.mjs +801 -0
  56. package/dist/_commonjsHelpers-69d58be2.mjs +31 -0
  57. package/dist/{anchoredPopover-Bxds0VoB.mjs → anchoredPopover-5cca53ba.mjs} +1 -1
  58. package/dist/documentManager-8327fb6e.mjs +9166 -0
  59. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +3 -2
  60. package/dist/editora.min.js +14 -13
  61. package/dist/editora.umd.js +14 -13
  62. package/dist/{html2canvas.esm-AYkPY5LS.mjs → html2canvas.esm-c51cb3b9.mjs} +978 -894
  63. package/dist/index-072ef022.js +11 -0
  64. package/dist/index-49d31221.mjs +16860 -0
  65. package/dist/{index-yzU4NdPT.mjs → index-7da30697.mjs} +490 -358
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-b47a189f.mjs +5782 -0
  68. package/dist/index.esm.js +12 -7
  69. package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-780c82db.mjs} +4808 -3784
  70. package/dist/plugin-loader.js +77 -40
  71. package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-3bdbcfc5.mjs} +20 -10
  72. package/dist/style.css +1 -0
  73. package/dist/webcomponent-core.js +546 -414
  74. package/dist/webcomponent-core.min.css +1 -1
  75. package/dist/webcomponent-core.min.js +40 -39
  76. package/dist/webcomponent.cjs.js +1 -1
  77. package/dist/webcomponent.esm.js +1 -1
  78. package/dist/webcomponent.js +484 -315
  79. package/dist/webcomponent.min.css +1 -1
  80. package/dist/webcomponent.min.js +6035 -558
  81. package/package.json +11 -5
  82. package/dist/_commonjsHelpers-DOllISpa.mjs +0 -32
  83. package/dist/core.css +0 -1
  84. package/dist/documentManager-vQ1VkbUY.mjs +0 -8418
  85. package/dist/index-BpE6GFbz.js +0 -10
  86. package/dist/index-BslAFzmv.mjs +0 -16544
  87. package/dist/index.es-BYD2KEo6.mjs +0 -6666
@@ -30,28 +30,28 @@ class D {
30
30
  return this.getLine(e.start.line).substring(e.start.column, e.end.column);
31
31
  const t = [];
32
32
  t.push(this.getLine(e.start.line).substring(e.start.column));
33
- for (let s = e.start.line + 1; s < e.end.line; s++)
34
- t.push(this.getLine(s));
33
+ for (let i = e.start.line + 1; i < e.end.line; i++)
34
+ t.push(this.getLine(i));
35
35
  return e.end.line < this.getLineCount() && t.push(this.getLine(e.end.line).substring(0, e.end.column)), t.join(`
36
36
  `);
37
37
  }
38
38
  // Replace text in range
39
39
  replaceRange(e, t) {
40
- const s = this.getTextInRange(e);
40
+ const i = this.getTextInRange(e);
41
41
  if (e.start.line === e.end.line) {
42
- const i = this.getLine(e.start.line), n = i.substring(0, e.start.column) + t + i.substring(e.end.column);
42
+ const s = this.getLine(e.start.line), n = s.substring(0, e.start.column) + t + s.substring(e.end.column);
43
43
  this._lines[e.start.line] = n;
44
44
  } else {
45
- const i = this.getLine(e.start.line), n = this.getLine(e.end.line), r = i.substring(0, e.start.column) + t, l = n.substring(e.end.column), a = t.split(`
45
+ const s = this.getLine(e.start.line), n = this.getLine(e.end.line), r = s.substring(0, e.start.column) + t, o = n.substring(e.end.column), l = t.split(`
46
46
  `);
47
- a[0] = r + a[0], a[a.length - 1] = a[a.length - 1] + l, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...a);
47
+ l[0] = r + l[0], l[l.length - 1] = l[l.length - 1] + o, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...l);
48
48
  }
49
- return this._version++, { range: e, text: t, oldText: s };
49
+ return this._version++, { range: e, text: t, oldText: i };
50
50
  }
51
51
  // Insert text at position
52
52
  insertText(e, t) {
53
- const s = { start: e, end: e };
54
- return this.replaceRange(s, t);
53
+ const i = { start: e, end: e };
54
+ return this.replaceRange(i, t);
55
55
  }
56
56
  // Delete text in range
57
57
  deleteRange(e) {
@@ -60,18 +60,18 @@ class D {
60
60
  // Convert position to offset
61
61
  positionToOffset(e) {
62
62
  let t = 0;
63
- for (let s = 0; s < e.line; s++)
64
- t += this.getLine(s).length + 1;
63
+ for (let i = 0; i < e.line; i++)
64
+ t += this.getLine(i).length + 1;
65
65
  return t += e.column, t;
66
66
  }
67
67
  // Convert offset to position
68
68
  offsetToPosition(e) {
69
69
  let t = e;
70
- for (let s = 0; s < this.getLineCount(); s++) {
71
- const i = this.getLine(s).length;
72
- if (t <= i)
73
- return { line: s, column: t };
74
- t -= i + 1;
70
+ for (let i = 0; i < this.getLineCount(); i++) {
71
+ const s = this.getLine(i).length;
72
+ if (t <= s)
73
+ return { line: i, column: t };
74
+ t -= s + 1;
75
75
  }
76
76
  return {
77
77
  line: this.getLineCount() - 1,
@@ -149,8 +149,8 @@ class Z {
149
149
  }
150
150
  // Update line numbers
151
151
  updateLineNumbers(e) {
152
- const t = Math.max(e, 20), s = Array.from({ length: t }, (i, n) => n + 1);
153
- this.lineNumbersElement.innerHTML = s.map((i) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${i}</div>`).join("");
152
+ const t = Math.max(e, 20), i = Array.from({ length: t }, (s, n) => n + 1);
153
+ this.lineNumbersElement.innerHTML = i.map((s) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${s}</div>`).join("");
154
154
  }
155
155
  // Get content element
156
156
  getContentElement() {
@@ -175,8 +175,8 @@ class Z {
175
175
  }
176
176
  // Set inner HTML (used for syntax highlighted content)
177
177
  setHTML(e) {
178
- const t = /\n$/.test(e), s = /&lt;|&gt;/.test(e), i = /<span\b/i.test(e), n = /<[^>]+>/.test(e);
179
- s && i ? this.contentElement.innerHTML = e : n && !s ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
178
+ const t = /\n$/.test(e), i = /&lt;|&gt;/.test(e), s = /<span\b/i.test(e), n = /<[^>]+>/.test(e);
179
+ i && s ? this.contentElement.innerHTML = e : n && !i ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
180
180
  const r = (this.contentElement.textContent || "").split(`
181
181
  `).length;
182
182
  this.updateLineNumbers(r);
@@ -192,37 +192,37 @@ class Z {
192
192
  const e = window.getSelection();
193
193
  if (!e || e.rangeCount === 0)
194
194
  return { line: 0, column: 0 };
195
- const t = e.getRangeAt(0), s = t.cloneRange();
196
- s.selectNodeContents(this.contentElement), s.setEnd(t.endContainer, t.endOffset);
197
- const i = s.toString().replace(/\u200B/g, "").split(`
195
+ const t = e.getRangeAt(0), i = t.cloneRange();
196
+ i.selectNodeContents(this.contentElement), i.setEnd(t.endContainer, t.endOffset);
197
+ const s = i.toString().replace(/\u200B/g, "").split(`
198
198
  `);
199
199
  return {
200
- line: i.length - 1,
201
- column: i[i.length - 1].length
200
+ line: s.length - 1,
201
+ column: s[s.length - 1].length
202
202
  };
203
203
  }
204
204
  // Set cursor position
205
205
  setCursorPosition(e) {
206
- var h;
207
- const t = this.getText().split(`
208
- `), s = Math.min(e.line, t.length - 1), i = Math.min(e.column, ((h = t[s]) == null ? void 0 : h.length) || 0);
209
- let n = 0;
210
- for (let o = 0; o < s; o++)
211
- n += t[o].length + 1;
212
- n += i;
213
- const r = document.createRange(), l = window.getSelection(), a = this.resolveOffsetToDomPoint(n);
214
- if (a)
206
+ var t;
207
+ const i = this.getText().split(`
208
+ `), s = Math.min(e.line, i.length - 1), n = Math.min(e.column, ((t = i[s]) == null ? void 0 : t.length) || 0);
209
+ let r = 0;
210
+ for (let a = 0; a < s; a++)
211
+ r += i[a].length + 1;
212
+ r += n;
213
+ const o = document.createRange(), l = window.getSelection(), h = this.resolveOffsetToDomPoint(r);
214
+ if (h)
215
215
  try {
216
- r.setStart(a.node, a.offset), r.setEnd(a.node, a.offset), l == null || l.removeAllRanges(), l == null || l.addRange(r), this.ensureCaretVisible();
217
- } catch (o) {
218
- console.warn("Could not set cursor position:", o);
216
+ o.setStart(h.node, h.offset), o.setEnd(h.node, h.offset), l == null || l.removeAllRanges(), l == null || l.addRange(o), this.ensureCaretVisible();
217
+ } catch (a) {
218
+ console.warn("Could not set cursor position:", a);
219
219
  }
220
220
  else {
221
- const o = this.contentElement.querySelector(
221
+ const a = this.contentElement.querySelector(
222
222
  `[${this.trailingNewlineMarkerAttr}]`
223
223
  );
224
224
  try {
225
- o && o.parentNode === this.contentElement ? r.setStartBefore(o) : (r.selectNodeContents(this.contentElement), r.collapse(!1)), r.collapse(!0), l == null || l.removeAllRanges(), l == null || l.addRange(r), this.ensureCaretVisible();
225
+ a && a.parentNode === this.contentElement ? o.setStartBefore(a) : (o.selectNodeContents(this.contentElement), o.collapse(!1)), o.collapse(!0), l == null || l.removeAllRanges(), l == null || l.addRange(o), this.ensureCaretVisible();
226
226
  } catch (c) {
227
227
  console.warn("Could not set fallback cursor position:", c);
228
228
  }
@@ -233,17 +233,17 @@ class Z {
233
233
  const e = window.getSelection();
234
234
  if (!e || e.rangeCount === 0 || e.isCollapsed)
235
235
  return;
236
- const t = e.getRangeAt(0), s = t.cloneRange();
237
- s.selectNodeContents(this.contentElement), s.setEnd(t.startContainer, t.startOffset);
238
- const i = s.toString().replace(/\u200B/g, "").split(`
236
+ const t = e.getRangeAt(0), i = t.cloneRange();
237
+ i.selectNodeContents(this.contentElement), i.setEnd(t.startContainer, t.startOffset);
238
+ const s = i.toString().replace(/\u200B/g, "").split(`
239
239
  `), n = t.cloneRange();
240
240
  n.selectNodeContents(this.contentElement), n.setEnd(t.endContainer, t.endOffset);
241
241
  const r = n.toString().replace(/\u200B/g, "").split(`
242
242
  `);
243
243
  return {
244
244
  start: {
245
- line: i.length - 1,
246
- column: i[i.length - 1].length
245
+ line: s.length - 1,
246
+ column: s[s.length - 1].length
247
247
  },
248
248
  end: {
249
249
  line: r.length - 1,
@@ -254,22 +254,23 @@ class Z {
254
254
  // Set selection range
255
255
  setSelectionRange(e) {
256
256
  const t = this.getText().split(`
257
- `), s = (c) => {
258
- const d = Math.max(0, Math.min(c.line, t.length - 1)), f = Math.max(
257
+ `), i = (c) => {
258
+ const d = Math.max(0, Math.min(c.line, t.length - 1)), p = Math.max(
259
259
  0,
260
260
  Math.min(c.column, t[d] ? t[d].length : 0)
261
261
  );
262
262
  let u = 0;
263
263
  for (let g = 0; g < d; g++)
264
264
  u += t[g].length + 1;
265
- return u + f;
266
- }, i = s(e.start), n = s(e.end), [r, l] = i <= n ? [i, n] : [n, i], a = this.resolveOffsetToDomPoint(r), h = this.resolveOffsetToDomPoint(l);
267
- if (!a || !h) return;
268
- const o = document.createRange();
265
+ return u + p;
266
+ }, s = i(e.start), n = i(e.end), [r, o] = s <= n ? [s, n] : [n, s], l = this.resolveOffsetToDomPoint(r), h = this.resolveOffsetToDomPoint(o);
267
+ if (!l || !h)
268
+ return;
269
+ const a = document.createRange();
269
270
  try {
270
- o.setStart(a.node, a.offset), o.setEnd(h.node, h.offset);
271
+ a.setStart(l.node, l.offset), a.setEnd(h.node, h.offset);
271
272
  const c = window.getSelection();
272
- c == null || c.removeAllRanges(), c == null || c.addRange(o), this.ensureCaretVisible();
273
+ c == null || c.removeAllRanges(), c == null || c.addRange(a), this.ensureCaretVisible();
273
274
  } catch (c) {
274
275
  console.warn("Could not set selection range:", c);
275
276
  }
@@ -288,8 +289,8 @@ class Z {
288
289
  }
289
290
  // Apply theme
290
291
  applyTheme(e) {
291
- Object.entries(e).forEach(([t, s]) => {
292
- this.container.style.setProperty(`--${t}`, s);
292
+ Object.entries(e).forEach(([t, i]) => {
293
+ this.container.style.setProperty(`--${t}`, i);
293
294
  });
294
295
  }
295
296
  // Scroll to position
@@ -310,7 +311,8 @@ class Z {
310
311
  this.editorContainer.scrollTop = e;
311
312
  }
312
313
  syncTrailingNewlineMarker(e) {
313
- if (this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach((s) => s.remove()), !e) return;
314
+ if (this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach((i) => i.remove()), !e)
315
+ return;
314
316
  const t = document.createElement("span");
315
317
  t.setAttribute(this.trailingNewlineMarkerAttr, "true"), t.setAttribute("aria-hidden", "true"), t.contentEditable = "false", t.style.cssText = `
316
318
  display: inline-block;
@@ -322,56 +324,60 @@ class Z {
322
324
  }
323
325
  // Ensure caret is visible inside the editor scroll container
324
326
  ensureCaretVisible() {
325
- var r;
326
- const e = window.getSelection();
327
- if (!e || e.rangeCount === 0) return;
328
- const t = e.getRangeAt(0).cloneRange();
329
- t.collapse(!1);
330
- let s = t.getClientRects()[0] || t.getBoundingClientRect();
331
- if ((!s || s.width === 0 && s.height === 0) && e.focusNode instanceof Element ? s = e.focusNode.getBoundingClientRect() : (!s || s.width === 0 && s.height === 0) && ((r = e.focusNode) != null && r.parentElement) && (s = e.focusNode.parentElement.getBoundingClientRect()), !s) return;
332
- const i = this.editorContainer.getBoundingClientRect(), n = 12;
333
- s.bottom > i.bottom - n ? this.editorContainer.scrollTop += s.bottom - (i.bottom - n) : s.top < i.top + n && (this.editorContainer.scrollTop -= i.top + n - s.top);
327
+ var e;
328
+ const t = window.getSelection();
329
+ if (!t || t.rangeCount === 0)
330
+ return;
331
+ const i = t.getRangeAt(0).cloneRange();
332
+ i.collapse(!1);
333
+ let s = i.getClientRects()[0] || i.getBoundingClientRect();
334
+ if ((!s || s.width === 0 && s.height === 0) && t.focusNode instanceof Element ? s = t.focusNode.getBoundingClientRect() : (!s || s.width === 0 && s.height === 0) && (e = t.focusNode) != null && e.parentElement && (s = t.focusNode.parentElement.getBoundingClientRect()), !s)
335
+ return;
336
+ const n = this.editorContainer.getBoundingClientRect(), r = 12;
337
+ s.bottom > n.bottom - r ? this.editorContainer.scrollTop += s.bottom - (n.bottom - r) : s.top < n.top + r && (this.editorContainer.scrollTop -= n.top + r - s.top);
334
338
  }
335
339
  // Destroy the view
336
340
  destroy() {
337
341
  this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
338
342
  }
339
343
  resolveOffsetToDomPoint(e) {
340
- var l, a, h;
341
- const t = Math.max(0, e);
344
+ var l;
345
+ var t;
346
+ const i = Math.max(0, e);
342
347
  let s = 0;
343
- const i = document.createTreeWalker(
348
+ const n = document.createTreeWalker(
344
349
  this.contentElement,
345
350
  NodeFilter.SHOW_TEXT,
346
351
  null
347
352
  );
348
- let n = null, r;
349
- for (; r = i.nextNode(); ) {
350
- if ((l = r.parentElement) != null && l.hasAttribute(this.trailingNewlineMarkerAttr))
353
+ let r = null, o;
354
+ for (; o = n.nextNode(); ) {
355
+ const h = o.parentElement;
356
+ if (h != null && h.hasAttribute(this.trailingNewlineMarkerAttr))
351
357
  continue;
352
- n = r;
353
- const o = r.textContent || "", c = this.buildVisibleToDomMap(o), d = Math.max(0, c.length - 1);
354
- if (s + d >= t) {
355
- const f = Math.max(0, t - s), u = (a = c[f]) != null ? a : o.length;
358
+ r = o;
359
+ const a = o.textContent || "", c = this.buildVisibleToDomMap(a), d = Math.max(0, c.length - 1);
360
+ if (s + d >= i) {
361
+ const p = Math.max(0, i - s), u = (l = c[p]) != null ? l : a.length;
356
362
  return {
357
- node: r,
363
+ node: o,
358
364
  offset: u
359
365
  };
360
366
  }
361
367
  s += d;
362
368
  }
363
- if (n) {
364
- const o = ((h = n.textContent) == null ? void 0 : h.length) || 0;
365
- return { node: n, offset: o };
369
+ if (r) {
370
+ const h = ((t = r.textContent) == null ? void 0 : t.length) || 0;
371
+ return { node: r, offset: h };
366
372
  }
367
373
  return null;
368
374
  }
369
375
  buildVisibleToDomMap(e) {
370
376
  const t = [0];
371
- let s = 0;
372
- for (let i = 0; i < e.length; i++) {
373
- const n = e[i];
374
- this.virtualMarkerRegex.test(n) || (s += 1, t[s] = i + 1);
377
+ let i = 0;
378
+ for (let s = 0; s < e.length; s++) {
379
+ const n = e[s];
380
+ this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
375
381
  }
376
382
  return t;
377
383
  }
@@ -386,7 +392,7 @@ const F = class L {
386
392
  lineWrapping: !1,
387
393
  lineNumbers: !0,
388
394
  ...t
389
- }, this.textModel = new D(this.config.value), this.view = new Z(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();
395
+ }, this.textModel = new D(this.config.value), this.view = new Z(e), 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();
390
396
  }
391
397
  // Public accessors for extensions
392
398
  getTextModel() {
@@ -412,21 +418,21 @@ const F = class L {
412
418
  setupEventHandlers() {
413
419
  const e = this.view.getContentElement();
414
420
  e.addEventListener("input", () => {
415
- const t = this.view.getText(), s = this.textModel.getText();
416
- if (t !== s) {
421
+ const t = this.view.getText(), i = this.textModel.getText();
422
+ if (t !== i) {
417
423
  if (!this.suppressHistory) {
418
- const i = this.getCursor().position, n = this.textModel.positionToOffset(i), r = this.getSelection();
419
- let l, a;
420
- r && (l = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: s, cursorOffset: n, anchorOffset: l, focusOffset: a }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
424
+ const s = this.getCursor().position, n = this.textModel.positionToOffset(s), r = this.getSelection();
425
+ let o, l;
426
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: i, cursorOffset: n, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
421
427
  }
422
428
  this.textModel.setText(t), this.view.syncTrailingNewlineMarkerForText(t), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
423
- const i = this.view.getText();
424
- i !== this.textModel.getText() && this.textModel.setText(i), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
425
- }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: s }]);
429
+ const s = this.view.getText();
430
+ s !== this.textModel.getText() && this.textModel.setText(s), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
431
+ }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: i }]);
426
432
  }
427
433
  }), e.addEventListener("selectionchange", () => {
428
- const t = this.getCursor(), s = this.getSelection();
429
- this.emit("cursor", t), s && this.emit("selection", s);
434
+ const t = this.getCursor(), i = this.getSelection();
435
+ this.emit("cursor", t), i && this.emit("selection", i);
430
436
  }), e.addEventListener("keydown", (t) => {
431
437
  if (this.emit("keydown", t), t.key === "Tab") {
432
438
  this.config.readOnly || this.insertTab(), t.preventDefault(), t.stopPropagation();
@@ -434,33 +440,33 @@ const F = class L {
434
440
  }
435
441
  if (t.key === "Enter") {
436
442
  if (!this.config.readOnly) {
437
- const s = window.getSelection();
438
- if (s && s.rangeCount > 0) {
439
- const i = this.getCursor().position, n = this.textModel.positionToOffset(i), r = this.getSelection();
440
- let l, a;
441
- r && (l = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end));
442
- const h = r && l !== void 0 && a !== void 0 ? Math.min(l, a) : n;
443
- this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: n, anchorOffset: l, focusOffset: a }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
444
- const o = s.getRangeAt(0);
445
- o.deleteContents();
443
+ const i = window.getSelection();
444
+ if (i && i.rangeCount > 0) {
445
+ const s = this.getCursor().position, n = this.textModel.positionToOffset(s), r = this.getSelection();
446
+ let o, l;
447
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end));
448
+ const h = r && o !== void 0 && l !== void 0 ? Math.min(o, l) : n;
449
+ this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: n, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
450
+ const a = i.getRangeAt(0);
451
+ a.deleteContents();
446
452
  const c = document.createTextNode(`
447
453
  `);
448
- o.insertNode(c), o.setStartAfter(c), o.collapse(!0), s.removeAllRanges(), s.addRange(o), this.view.ensureCaretVisible();
454
+ a.insertNode(c), a.setStartAfter(c), a.collapse(!0), i.removeAllRanges(), i.addRange(a), this.view.ensureCaretVisible();
449
455
  const d = this.view.getText();
450
456
  this.textModel.setText(d), this.view.syncTrailingNewlineMarkerForText(d);
451
- const f = Math.min(
457
+ const p = Math.min(
452
458
  h + 1,
453
459
  this.textModel.getText().length
454
460
  );
455
461
  try {
456
- const u = this.textModel.offsetToPosition(f);
462
+ const u = this.textModel.offsetToPosition(p);
457
463
  this.setCursor(u), this.view.ensureCaretVisible();
458
464
  } catch (u) {
459
465
  }
460
466
  this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
461
467
  this.renderTextWithHighlight(this.textModel.getText(), !1), requestAnimationFrame(() => {
462
468
  try {
463
- const u = this.textModel.offsetToPosition(f);
469
+ const u = this.textModel.offsetToPosition(p);
464
470
  this.setCursor(u), this.view.ensureCaretVisible();
465
471
  } catch (u) {
466
472
  }
@@ -471,15 +477,15 @@ const F = class L {
471
477
  t.preventDefault(), t.stopPropagation();
472
478
  return;
473
479
  }
474
- for (const s of this.extensions.values())
475
- if (s.onKeyDown && s.onKeyDown(t) === !1) {
480
+ for (const i of this.extensions.values())
481
+ if (i.onKeyDown && i.onKeyDown(t) === !1) {
476
482
  t.preventDefault(), t.stopPropagation();
477
483
  return;
478
484
  }
479
485
  }), e.addEventListener("mousedown", (t) => {
480
486
  this.emit("mousedown", t);
481
- for (const s of this.extensions.values())
482
- if (s.onMouseDown && s.onMouseDown(t) === !1) {
487
+ for (const i of this.extensions.values())
488
+ if (i.onMouseDown && i.onMouseDown(t) === !1) {
483
489
  t.preventDefault(), t.stopPropagation();
484
490
  return;
485
491
  }
@@ -506,8 +512,8 @@ const F = class L {
506
512
  }
507
513
  // Emit events to listeners
508
514
  emit(e, ...t) {
509
- const s = this.eventListeners.get(e);
510
- s && s.forEach((i) => i(...t));
515
+ const i = this.eventListeners.get(e);
516
+ i && i.forEach((s) => s(...t));
511
517
  }
512
518
  // State management
513
519
  getValue() {
@@ -555,12 +561,12 @@ const F = class L {
555
561
  "editor-gutter-border": e === "dark" ? "#3e3e42" : "#e1e5e9"
556
562
  };
557
563
  this.view.applyTheme(t);
558
- const s = this.extensions.get("syntax-highlighting");
559
- if (s && typeof s.setTheme == "function")
564
+ const i = this.extensions.get("syntax-highlighting");
565
+ if (i && typeof i.setTheme == "function")
560
566
  try {
561
- s.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
562
- } catch (i) {
563
- console.warn("Error applying theme to syntax-highlighting extension", i);
567
+ i.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
568
+ } catch (s) {
569
+ console.warn("Error applying theme to syntax-highlighting extension", s);
564
570
  }
565
571
  }
566
572
  setReadOnly(e) {
@@ -577,8 +583,8 @@ const F = class L {
577
583
  t && t.destroy && t.destroy(), this.extensions.delete(e);
578
584
  }
579
585
  executeCommand(e, ...t) {
580
- const s = this.commands.get(e);
581
- s ? s(this, ...t) : console.warn(`Command '${e}' not found`);
586
+ const i = this.commands.get(e);
587
+ i ? i(this, ...t) : console.warn(`Command '${e}' not found`);
582
588
  }
583
589
  // Register a command
584
590
  registerCommand(e, t) {
@@ -586,95 +592,96 @@ const F = class L {
586
592
  }
587
593
  // Search & Navigation
588
594
  search(e, t = {}) {
589
- var o;
590
- if (!e) return [];
591
- const s = {
595
+ var a;
596
+ if (!e)
597
+ return [];
598
+ const i = {
592
599
  query: e,
593
600
  caseSensitive: !1,
594
601
  wholeWord: !1,
595
602
  regex: !1,
596
603
  ...t
597
- }, i = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: l } = this.buildSearchTextAndOffsetMap(n), a = s.caseSensitive ? r : r.toLowerCase(), h = s.caseSensitive ? e : e.toLowerCase();
598
- if (s.regex) {
604
+ }, s = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(n), l = i.caseSensitive ? r : r.toLowerCase(), h = i.caseSensitive ? e : e.toLowerCase();
605
+ if (i.regex) {
599
606
  let c;
600
607
  try {
601
- c = new RegExp(e, s.caseSensitive ? "g" : "gi");
602
- } catch (f) {
608
+ c = new RegExp(e, i.caseSensitive ? "g" : "gi");
609
+ } catch (p) {
603
610
  return [];
604
611
  }
605
612
  let d;
606
613
  for (; (d = c.exec(r)) !== null; ) {
607
- const f = (o = d[0]) != null ? o : "";
608
- if (f.length === 0) {
614
+ const p = (a = d[0]) != null ? a : "";
615
+ if (p.length === 0) {
609
616
  c.lastIndex = d.index + 1;
610
617
  continue;
611
618
  }
612
- const u = d.index, g = d.index + f.length;
613
- s.wholeWord && !this.isWholeWordBoundary(r, u, g) || this.pushSearchResultFromOffsets(
614
- i,
619
+ const u = d.index, g = d.index + p.length;
620
+ i.wholeWord && !this.isWholeWordBoundary(r, u, g) || this.pushSearchResultFromOffsets(
621
+ s,
615
622
  u,
616
623
  g,
617
624
  r,
618
- l
625
+ o
619
626
  );
620
627
  }
621
628
  } else {
622
- let c = 0, d = a.indexOf(h, c);
629
+ let c = 0, d = l.indexOf(h, c);
623
630
  for (; d !== -1; ) {
624
- const f = d + h.length;
625
- !s.wholeWord || this.isWholeWordBoundary(r, d, f) ? (this.pushSearchResultFromOffsets(
626
- i,
631
+ const p = d + h.length;
632
+ !i.wholeWord || this.isWholeWordBoundary(r, d, p) ? (this.pushSearchResultFromOffsets(
633
+ s,
627
634
  d,
628
- f,
635
+ p,
629
636
  r,
630
- l
631
- ), c = f) : c = d + 1, d = a.indexOf(h, c);
637
+ o
638
+ ), c = p) : c = d + 1, d = l.indexOf(h, c);
632
639
  }
633
640
  }
634
- return i;
641
+ return s;
635
642
  }
636
- pushSearchResultFromOffsets(e, t, s, i, n) {
637
- var o, c;
638
- const r = (o = n[t]) != null ? o : t, l = (c = n[s]) != null ? c : r, a = this.textModel.offsetToPosition(r), h = this.textModel.offsetToPosition(l);
643
+ pushSearchResultFromOffsets(e, t, i, s, n) {
644
+ var a, c;
645
+ const r = (a = n[t]) != null ? a : t, o = (c = n[i]) != null ? c : r, l = this.textModel.offsetToPosition(r), h = this.textModel.offsetToPosition(o);
639
646
  e.push({
640
- range: { start: a, end: h },
641
- match: i.substring(t, s)
647
+ range: { start: l, end: h },
648
+ match: s.substring(t, i)
642
649
  });
643
650
  }
644
- isWholeWordBoundary(e, t, s) {
645
- const i = t > 0 ? e[t - 1] : "", n = s < e.length ? e[s] : "";
646
- return !this.isWordChar(i) && !this.isWordChar(n);
651
+ isWholeWordBoundary(e, t, i) {
652
+ const s = t > 0 ? e[t - 1] : "", n = i < e.length ? e[i] : "";
653
+ return !this.isWordChar(s) && !this.isWordChar(n);
647
654
  }
648
655
  isWordChar(e) {
649
656
  return /^[A-Za-z0-9_]$/.test(e);
650
657
  }
651
658
  buildSearchTextAndOffsetMap(e) {
652
- const t = [], s = [0];
653
- let i = 0;
659
+ const t = [], i = [0];
660
+ let s = 0;
654
661
  for (let n = 0; n < e.length; n++) {
655
662
  const r = e[n];
656
- r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), i += 1, s[i] = n + 1);
663
+ r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), s += 1, i[s] = n + 1);
657
664
  }
658
- return s[i] = e.length, {
665
+ return i[s] = e.length, {
659
666
  normalizedText: t.join(""),
660
- normalizedToRawOffsets: s
667
+ normalizedToRawOffsets: i
661
668
  };
662
669
  }
663
670
  replace(e, t) {
664
- const s = this.getValue();
671
+ const i = this.getValue();
665
672
  if (!this.suppressHistory) {
666
- const n = this.getCursor().position, r = this.textModel.positionToOffset(n), l = this.getSelection();
667
- let a, h;
668
- l && (a = this.textModel.positionToOffset(l.start), h = this.textModel.positionToOffset(l.end)), this.undoStack.push({ text: s, cursorOffset: r, anchorOffset: a, focusOffset: h }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
673
+ const n = this.getCursor().position, r = this.textModel.positionToOffset(n), o = this.getSelection();
674
+ let l, h;
675
+ o && (l = this.textModel.positionToOffset(o.start), h = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: i, cursorOffset: r, anchorOffset: l, focusOffset: h }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
669
676
  }
670
- const i = this.textModel.replaceRange(e, t);
671
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [i]);
677
+ const s = this.textModel.replaceRange(e, t);
678
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [s]);
672
679
  }
673
- replaceAll(e, t, s = {}) {
674
- const i = this.search(e, s);
680
+ replaceAll(e, t, i = {}) {
681
+ const s = this.search(e, i);
675
682
  let n = 0;
676
- for (let r = i.length - 1; r >= 0; r--)
677
- this.replace(i[r].range, t), n++;
683
+ for (let r = s.length - 1; r >= 0; r--)
684
+ this.replace(s[r].range, t), n++;
678
685
  return n;
679
686
  }
680
687
  // Folding (basic implementation)
@@ -707,32 +714,32 @@ const F = class L {
707
714
  // and restores it after updating the DOM. Callers that will explicitly set the caret
708
715
  // should pass `false` to avoid stomping programmatic cursor changes.
709
716
  renderTextWithHighlight(e, t = !0) {
710
- const s = this.extensions.get("syntax-highlighting");
711
- if (s && typeof s.highlightHTML == "function")
717
+ const i = this.extensions.get("syntax-highlighting");
718
+ if (i && typeof i.highlightHTML == "function")
712
719
  try {
713
- const i = !t && !this.expectingProgrammaticCursor;
714
- let n, r, l, a;
715
- if (t || i) {
720
+ const s = !t && !this.expectingProgrammaticCursor;
721
+ let n, r, o, l;
722
+ if (t || s) {
716
723
  n = this.getSelection();
717
724
  const d = this.getCollapsedSelectionOffsetInEditor();
718
725
  if (d !== void 0)
719
726
  r = d;
720
727
  else {
721
- const f = this.getCursor().position;
722
- r = this.textModel.positionToOffset(f);
728
+ const p = this.getCursor().position;
729
+ r = this.textModel.positionToOffset(p);
723
730
  }
724
- n && (l = this.textModel.positionToOffset(n.start), a = this.textModel.positionToOffset(n.end));
731
+ n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end));
725
732
  }
726
- const h = (t || i) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), o = h ? this.insertSentinelAtOffset(e, r) : e, c = s.highlightHTML(o);
727
- typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), this.view.syncTrailingNewlineMarkerForText(e), (t || i) && requestAnimationFrame(() => {
733
+ const h = (t || s) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), a = h ? this.insertSentinelAtOffset(e, r) : e, c = i.highlightHTML(a);
734
+ typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && requestAnimationFrame(() => {
728
735
  try {
729
736
  if (h && this.restoreCursorFromSentinel()) {
730
737
  this.view.ensureCaretVisible();
731
738
  return;
732
739
  }
733
- if (n && (l !== void 0 || a !== void 0)) {
734
- const d = l !== void 0 ? l : r, f = a !== void 0 ? a : r, u = Math.min(d, f), g = Math.max(d, f), p = this.textModel.offsetToPosition(u), y = this.textModel.offsetToPosition(g);
735
- this.view.setSelectionRange({ start: p, end: y });
740
+ if (n && (o !== void 0 || l !== void 0)) {
741
+ const d = o !== void 0 ? o : r, p = l !== void 0 ? l : r, u = Math.min(d, p), g = Math.max(d, p), f = this.textModel.offsetToPosition(u), y = this.textModel.offsetToPosition(g);
742
+ this.view.setSelectionRange({ start: f, end: y });
736
743
  } else if (r !== void 0) {
737
744
  const d = this.textModel.offsetToPosition(r);
738
745
  this.view.setCursorPosition(d);
@@ -741,8 +748,8 @@ const F = class L {
741
748
  }
742
749
  });
743
750
  return;
744
- } catch (i) {
745
- console.warn("Syntax highlighting failed, falling back to plain text", i);
751
+ } catch (s) {
752
+ console.warn("Syntax highlighting failed, falling back to plain text", s);
746
753
  }
747
754
  this.view.setText(e);
748
755
  }
@@ -757,32 +764,33 @@ const F = class L {
757
764
  const e = window.getSelection();
758
765
  if (!e || e.rangeCount === 0 || !e.isCollapsed)
759
766
  return;
760
- const t = e.getRangeAt(0), s = this.view.getContentElement();
761
- if (!s.contains(t.commonAncestorContainer))
767
+ const t = e.getRangeAt(0), i = this.view.getContentElement();
768
+ if (!i.contains(t.commonAncestorContainer))
762
769
  return;
763
- const i = t.cloneRange();
764
- return i.selectNodeContents(s), i.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(i.toString()).length;
770
+ const s = t.cloneRange();
771
+ return s.selectNodeContents(i), s.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(s.toString()).length;
765
772
  }
766
773
  stripVirtualMarkers(e) {
767
774
  return e.replace(/\u200B/g, "").split(L.CURSOR_SENTINEL).join("");
768
775
  }
769
776
  insertSentinelAtOffset(e, t) {
770
- const s = Math.max(0, Math.min(t, e.length));
771
- return e.slice(0, s) + L.CURSOR_SENTINEL + e.slice(s);
777
+ const i = Math.max(0, Math.min(t, e.length));
778
+ return e.slice(0, i) + L.CURSOR_SENTINEL + e.slice(i);
772
779
  }
773
780
  restoreCursorFromSentinel() {
774
- var l;
775
- const e = this.view.getContentElement(), t = window.getSelection(), s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
776
- let i = s.nextNode(), n = null, r = 0;
777
- for (; i; ) {
778
- const a = (l = i.textContent) != null ? l : "", h = a.indexOf(L.CURSOR_SENTINEL);
779
- h !== -1 && (n || (n = i, r = h), i.textContent = a.split(L.CURSOR_SENTINEL).join("")), i = s.nextNode();
781
+ var o;
782
+ const e = this.view.getContentElement(), t = window.getSelection(), i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
783
+ let s = i.nextNode(), n = null, r = 0;
784
+ for (; s; ) {
785
+ const l = (o = s.textContent) != null ? o : "", h = l.indexOf(L.CURSOR_SENTINEL);
786
+ h !== -1 && (n || (n = s, r = h), s.textContent = l.split(L.CURSOR_SENTINEL).join("")), s = i.nextNode();
780
787
  }
781
- if (!n || !t) return !1;
788
+ if (!n || !t)
789
+ return !1;
782
790
  try {
783
- const a = document.createRange();
784
- return a.setStart(n, r), a.collapse(!0), t.removeAllRanges(), t.addRange(a), !0;
785
- } catch (a) {
791
+ const l = document.createRange();
792
+ return l.setStart(n, r), l.collapse(!0), t.removeAllRanges(), t.addRange(l), !0;
793
+ } catch (l) {
786
794
  return !1;
787
795
  }
788
796
  }
@@ -796,20 +804,21 @@ const F = class L {
796
804
  }
797
805
  // History: undo/redo
798
806
  undo() {
799
- if (this.undoStack.length === 0) return;
807
+ if (this.undoStack.length === 0)
808
+ return;
800
809
  const e = this.undoStack.pop(), t = { text: this.getValue(), cursorOffset: this.textModel.positionToOffset(this.getCursor().position) };
801
810
  this.redoStack.push(t);
802
811
  try {
803
812
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
804
- let s, i;
805
- typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
813
+ let i, s;
814
+ typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
806
815
  try {
807
- if (i != null)
816
+ if (s != null)
808
817
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
809
- const n = e.anchorOffset !== void 0 ? e.anchorOffset : i, r = e.focusOffset !== void 0 ? e.focusOffset : i, l = Math.min(n, r), a = Math.max(n, r), h = this.textModel.offsetToPosition(l), o = this.textModel.offsetToPosition(a);
810
- this.setSelection({ start: h, end: o });
818
+ const n = e.anchorOffset !== void 0 ? e.anchorOffset : s, r = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(n, r), l = Math.max(n, r), h = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
819
+ this.setSelection({ start: h, end: a });
811
820
  } else {
812
- const n = this.textModel.offsetToPosition(i);
821
+ const n = this.textModel.offsetToPosition(s);
813
822
  this.setCursor(n);
814
823
  }
815
824
  } catch (n) {
@@ -822,20 +831,21 @@ const F = class L {
822
831
  }
823
832
  }
824
833
  redo() {
825
- if (this.redoStack.length === 0) return;
834
+ if (this.redoStack.length === 0)
835
+ return;
826
836
  const e = this.redoStack.pop(), t = { text: this.getValue(), cursorOffset: this.textModel.positionToOffset(this.getCursor().position) };
827
837
  this.undoStack.push(t);
828
838
  try {
829
839
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
830
- let s, i;
831
- typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
840
+ let i, s;
841
+ typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
832
842
  try {
833
- if (i != null)
843
+ if (s != null)
834
844
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
835
- const n = e.anchorOffset !== void 0 ? e.anchorOffset : i, r = e.focusOffset !== void 0 ? e.focusOffset : i, l = Math.min(n, r), a = Math.max(n, r), h = this.textModel.offsetToPosition(l), o = this.textModel.offsetToPosition(a);
836
- this.setSelection({ start: h, end: o });
845
+ const n = e.anchorOffset !== void 0 ? e.anchorOffset : s, r = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(n, r), l = Math.max(n, r), h = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
846
+ this.setSelection({ start: h, end: a });
837
847
  } else {
838
- const n = this.textModel.offsetToPosition(i);
848
+ const n = this.textModel.offsetToPosition(s);
839
849
  this.setCursor(n);
840
850
  }
841
851
  } catch (n) {
@@ -849,43 +859,46 @@ const F = class L {
849
859
  }
850
860
  // Insert a tab character or spaces at current cursor
851
861
  insertTab() {
852
- if (this.config.readOnly) return;
853
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = " ".repeat(this.config.tabSize || 2), i = this.textModel.insertText(e, s), n = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + s.length);
862
+ if (this.config.readOnly)
863
+ return;
864
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = " ".repeat(this.config.tabSize || 2), s = this.textModel.insertText(e, i), n = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + i.length);
854
865
  if (!this.suppressHistory) {
855
866
  const r = this.getSelection();
856
- let l, a;
857
- r && (l = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: l, focusOffset: a }), this.redoStack.length = 0;
867
+ let o, l;
868
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: l }), this.redoStack.length = 0;
858
869
  }
859
870
  this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(n), setTimeout(() => {
860
871
  this.expectingProgrammaticCursor = !1;
861
- }, 20), this.emit("change", [i]);
872
+ }, 20), this.emit("change", [s]);
862
873
  }
863
874
  // Insert a newline at current cursor position
864
875
  insertNewLine() {
865
- if (this.config.readOnly) return;
866
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = this.textModel.insertText(e, `
867
- `), i = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
876
+ if (this.config.readOnly)
877
+ return;
878
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = this.textModel.insertText(e, `
879
+ `), s = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
868
880
  if (!this.suppressHistory) {
869
881
  const n = this.getSelection();
870
- let r, l;
871
- n && (r = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: r, focusOffset: l }), this.redoStack.length = 0;
882
+ let r, o;
883
+ n && (r = this.textModel.positionToOffset(n.start), o = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: r, focusOffset: o }), this.redoStack.length = 0;
872
884
  }
873
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(i), setTimeout(() => {
885
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(s), setTimeout(() => {
874
886
  this.expectingProgrammaticCursor = !1;
875
- }, 20), this.emit("change", [s]);
887
+ }, 20), this.emit("change", [i]);
876
888
  }
877
889
  // Events
878
890
  on(e, t) {
879
891
  this.eventListeners.has(e) || this.eventListeners.set(e, []), this.eventListeners.get(e).push(t);
880
892
  }
881
893
  off(e, t) {
882
- if (!this.eventListeners.has(e)) return;
883
- const s = this.eventListeners.get(e);
894
+ if (!this.eventListeners.has(e))
895
+ return;
896
+ const i = this.eventListeners.get(e);
884
897
  if (t) {
885
- const i = s.indexOf(t);
886
- i !== -1 && s.splice(i, 1);
898
+ const s = i.indexOf(t);
899
+ s !== -1 && i.splice(s, 1);
887
900
  } else
888
- s.length = 0;
901
+ i.length = 0;
889
902
  }
890
903
  };
891
904
  F.CURSOR_SENTINEL = "";
@@ -898,17 +911,19 @@ class J {
898
911
  this.editor = e;
899
912
  }
900
913
  handleKeyDown(e) {
901
- if (!this.editor) return;
914
+ if (!this.editor)
915
+ return;
902
916
  const t = this.findMatchingBinding(e);
903
917
  if (t)
904
918
  return this.editor.executeCommand(t.command), e.preventDefault(), e.stopPropagation(), !1;
905
919
  }
906
920
  findMatchingBinding(e) {
907
- const { key: t, ctrlKey: s, altKey: i, shiftKey: n, metaKey: r } = e, l = String(t).toLowerCase(), a = this.keymap[l];
908
- if (!a) return null;
909
- for (const h of a) {
910
- const o = h.ctrlKey === void 0 || h.ctrlKey === s, c = h.altKey === void 0 || h.altKey === i, d = h.shiftKey === void 0 || h.shiftKey === n, f = h.metaKey === void 0 || h.metaKey === r;
911
- if (o && c && d && f)
921
+ const { key: t, ctrlKey: i, altKey: s, shiftKey: n, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
922
+ if (!l)
923
+ return null;
924
+ for (const h of l) {
925
+ const a = h.ctrlKey === void 0 || h.ctrlKey === i, c = h.altKey === void 0 || h.altKey === s, d = h.shiftKey === void 0 || h.shiftKey === n, p = h.metaKey === void 0 || h.metaKey === r;
926
+ if (a && c && d && p)
912
927
  return h;
913
928
  }
914
929
  return null;
@@ -921,12 +936,12 @@ class J {
921
936
  const e = {};
922
937
  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"), e;
923
938
  }
924
- addBinding(e, t, s, i) {
939
+ addBinding(e, t, i, s) {
925
940
  const n = t.toLowerCase();
926
941
  e[n] || (e[n] = []), e[n].push({
927
942
  key: n,
928
- command: i,
929
- ...s
943
+ command: s,
944
+ ...i
930
945
  });
931
946
  }
932
947
  // Public API for customizing keymap
@@ -935,23 +950,23 @@ class J {
935
950
  }
936
951
  addKeyBinding(e) {
937
952
  const t = e.key.toLowerCase();
938
- this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((s) => s.command !== e.command), this.keymap[t].push({
953
+ this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((i) => i.command !== e.command), this.keymap[t].push({
939
954
  ...e,
940
955
  key: t
941
956
  });
942
957
  }
943
958
  removeKeyBinding(e, t) {
944
- const s = e.toLowerCase();
945
- t ? this.keymap[s] && (this.keymap[s] = this.keymap[s].filter((i) => i.command !== t), this.keymap[s].length === 0 && delete this.keymap[s]) : delete this.keymap[s];
959
+ const i = e.toLowerCase();
960
+ t ? this.keymap[i] && (this.keymap[i] = this.keymap[i].filter((s) => s.command !== t), this.keymap[i].length === 0 && delete this.keymap[i]) : delete this.keymap[i];
946
961
  }
947
962
  getKeymap() {
948
963
  return { ...this.keymap };
949
964
  }
950
965
  getBindingsForCommand(e) {
951
966
  const t = [];
952
- for (const s in this.keymap)
953
- for (const i of this.keymap[s])
954
- i.command === e && t.push({ ...i });
967
+ for (const i in this.keymap)
968
+ for (const s of this.keymap[i])
969
+ s.command === e && t.push({ ...s });
955
970
  return t;
956
971
  }
957
972
  getPlatformInfo() {
@@ -970,13 +985,13 @@ class Y {
970
985
  }
971
986
  setup(e) {
972
987
  e.on("change", (t) => {
973
- const s = {
988
+ const i = {
974
989
  changes: t,
975
990
  selection: e.getSelection(),
976
991
  effects: [],
977
992
  annotations: []
978
993
  };
979
- this.transactions.push(s);
994
+ this.transactions.push(i);
980
995
  });
981
996
  }
982
997
  getTransactions() {
@@ -998,18 +1013,21 @@ class G {
998
1013
  }), this.updateLineNumbers();
999
1014
  }
1000
1015
  createLineNumbers() {
1001
- if (!this.editor) return;
1016
+ if (!this.editor)
1017
+ return;
1002
1018
  const e = this.editor.getView().getLineNumbersElement();
1003
1019
  e && (this.lineNumbersElement = e);
1004
1020
  }
1005
1021
  updateLineNumbers() {
1006
- if (!this.lineNumbersElement || !this.editor || !this.isEnabled) return;
1022
+ if (!this.lineNumbersElement || !this.editor || !this.isEnabled)
1023
+ return;
1007
1024
  const e = this.editor.getValue().split(`
1008
- `).length, t = Array.from({ length: Math.max(e, 20) }, (s, i) => i + 1);
1009
- this.lineNumbersElement.innerHTML = t.map((s) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("");
1025
+ `).length, t = Array.from({ length: Math.max(e, 20) }, (i, s) => s + 1);
1026
+ this.lineNumbersElement.innerHTML = t.map((i) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${i}</div>`).join("");
1010
1027
  }
1011
1028
  toggle() {
1012
- if (!this.editor) return;
1029
+ if (!this.editor)
1030
+ return;
1013
1031
  this.isEnabled = !this.isEnabled, this.lineNumbersElement && (this.lineNumbersElement.style.display = this.isEnabled ? "block" : "none");
1014
1032
  const e = this.editor.getView().getContentElement();
1015
1033
  e && (e.style.marginLeft = this.isEnabled ? "60px" : "0"), this.updateLineNumbers();
@@ -1091,8 +1109,8 @@ const W = class m {
1091
1109
  this.findPrev();
1092
1110
  }), e.registerCommand("replace", () => {
1093
1111
  this.showReplace();
1094
- }), e.registerCommand("replaceAll", (t, s) => {
1095
- this.replaceAll(t, s);
1112
+ }), e.registerCommand("replaceAll", (t, i) => {
1113
+ this.replaceAll(t, i);
1096
1114
  }), this.editorChangeHandler = () => {
1097
1115
  !this.isVisible || !this.currentQuery || this.scheduleLiveRefresh(!0);
1098
1116
  }, e.on("change", this.editorChangeHandler);
@@ -1107,12 +1125,14 @@ const W = class m {
1107
1125
  this.isVisible = !1, this.searchUI && (this.searchUI.style.display = "none"), this.replaceInputEl && (this.replaceInputEl.style.display = "none", this.replaceInputEl.value = ""), this.updateModeHint(!1), this.clearHighlights(), this.restoreSelectionState();
1108
1126
  }
1109
1127
  createSearchUI() {
1110
- if (!this.editor) return;
1128
+ if (!this.editor)
1129
+ return;
1111
1130
  const e = this.editor.getView().getContentElement(), t = e.closest(
1112
1131
  this.editorContainerSelector
1113
- ), s = e.closest(".rte-source-editor-modal") || t || e.parentElement;
1114
- if (!s) return;
1115
- window.getComputedStyle(s).position === "static" && (s.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = m.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
1132
+ ), i = e.closest(".rte-source-editor-modal") || t || e.parentElement;
1133
+ if (!i)
1134
+ return;
1135
+ window.getComputedStyle(i).position === "static" && (i.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = m.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
1116
1136
  <div class="${m.css.row}">
1117
1137
  <input type="text" class="${m.css.findInput} ${m.css.inputBase}" placeholder="Find..." />
1118
1138
  <button class="${m.css.prevButton} ${m.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
@@ -1139,49 +1159,49 @@ const W = class m {
1139
1159
  </div>
1140
1160
  <input type="text" class="${m.css.replaceInput} ${m.css.inputBase} ${m.css.replaceInputLayout}" placeholder="Replace with..." />
1141
1161
  `;
1142
- const i = this.searchUI.querySelector(
1162
+ const s = this.searchUI.querySelector(
1143
1163
  `.${m.css.findInput}`
1144
1164
  ), n = this.searchUI.querySelector(
1145
1165
  `.${m.css.replaceInput}`
1146
1166
  ), r = this.searchUI.querySelector(
1147
1167
  `.${m.css.prevButton}`
1148
- ), l = this.searchUI.querySelector(
1168
+ ), o = this.searchUI.querySelector(
1149
1169
  `.${m.css.nextButton}`
1150
- ), a = this.searchUI.querySelector(
1170
+ ), l = this.searchUI.querySelector(
1151
1171
  `.${m.css.closeButton}`
1152
1172
  ), h = this.searchUI.querySelector(
1153
1173
  `.${m.css.status}`
1154
- ), o = this.searchUI.querySelector(
1174
+ ), a = this.searchUI.querySelector(
1155
1175
  `.${m.css.mode}`
1156
1176
  ), c = this.searchUI.querySelector(
1157
1177
  `.${m.css.caseSensitive}`
1158
1178
  ), d = this.searchUI.querySelector(
1159
1179
  `.${m.css.wholeWord}`
1160
- ), f = this.searchUI.querySelector(
1180
+ ), p = this.searchUI.querySelector(
1161
1181
  `.${m.css.regex}`
1162
1182
  );
1163
- this.findInput = i, this.replaceInputEl = n, this.statusDiv = h, this.modeDiv = o, this.caseSensitiveInput = c, this.wholeWordInput = d, this.regexInput = f, c.checked = !!this.searchOptions.caseSensitive, d.checked = !!this.searchOptions.wholeWord, f.checked = !!this.searchOptions.regex, i.addEventListener("input", () => {
1183
+ this.findInput = s, this.replaceInputEl = n, this.statusDiv = h, this.modeDiv = a, this.caseSensitiveInput = c, this.wholeWordInput = d, this.regexInput = p, c.checked = !!this.searchOptions.caseSensitive, d.checked = !!this.searchOptions.wholeWord, p.checked = !!this.searchOptions.regex, s.addEventListener("input", () => {
1164
1184
  this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
1165
- const g = i.value;
1185
+ const g = s.value;
1166
1186
  this.searchDebounceTimer = setTimeout(() => {
1167
1187
  this.performSearch(g, !1, !1);
1168
1188
  }, 120);
1169
1189
  });
1170
1190
  const u = () => {
1171
- this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = d.checked, this.searchOptions.regex = f.checked;
1172
- const g = i.value;
1191
+ this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = d.checked, this.searchOptions.regex = p.checked;
1192
+ const g = s.value;
1173
1193
  g.trim() ? this.performSearch(g, !1, !1) : this.performSearch("", !1, !1);
1174
1194
  };
1175
- c.addEventListener("change", u), d.addEventListener("change", u), f.addEventListener("change", u), i.addEventListener("keydown", (g) => {
1195
+ c.addEventListener("change", u), d.addEventListener("change", u), p.addEventListener("change", u), s.addEventListener("keydown", (g) => {
1176
1196
  g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.findPrev() : this.findNext()) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1177
1197
  }), n.addEventListener("keydown", (g) => {
1178
- g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.replaceAll(i.value, n.value) : this.replaceCurrent(i.value, n.value)) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1179
- }), r.addEventListener("click", () => this.findPrev()), l.addEventListener("click", () => this.findNext()), a.addEventListener("click", () => this.hideSearch()), s.appendChild(this.searchUI);
1198
+ g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.replaceAll(s.value, n.value) : this.replaceCurrent(s.value, n.value)) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1199
+ }), r.addEventListener("click", () => this.findPrev()), o.addEventListener("click", () => this.findNext()), l.addEventListener("click", () => this.hideSearch()), i.appendChild(this.searchUI);
1180
1200
  }
1181
1201
  updateModeHint(e) {
1182
1202
  this.modeDiv && (this.modeDiv.textContent = e ? `Replace: move next ${this.config.replaceAndFindNext ? "ON" : "OFF"}` : "Find mode");
1183
1203
  }
1184
- performSearch(e, t, s) {
1204
+ performSearch(e, t, i) {
1185
1205
  if (!this.editor || !e.trim()) {
1186
1206
  this.currentQuery = "", this.currentResults = [], this.currentIndex = -1, this.clearHighlights(), this.updateStatus("");
1187
1207
  return;
@@ -1191,12 +1211,12 @@ const W = class m {
1191
1211
  return;
1192
1212
  }
1193
1213
  this.currentQuery = e;
1194
- const i = this.currentIndex, n = this.editor.search(e, this.searchOptions);
1214
+ const s = this.currentIndex, n = this.editor.search(e, this.searchOptions);
1195
1215
  if (this.currentResults = n, n.length === 0) {
1196
1216
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("No matches");
1197
1217
  return;
1198
1218
  }
1199
- t && i >= 0 ? this.currentIndex = Math.min(i, n.length - 1) : this.currentIndex = 0, this.updateHighlights(s);
1219
+ t && s >= 0 ? this.currentIndex = Math.min(s, n.length - 1) : this.currentIndex = 0, this.updateHighlights(i);
1200
1220
  }
1201
1221
  findNext() {
1202
1222
  if (this.currentResults.length === 0) {
@@ -1213,26 +1233,29 @@ const W = class m {
1213
1233
  this.currentIndex = this.currentIndex <= 0 ? this.currentResults.length - 1 : this.currentIndex - 1, this.updateHighlights(!0);
1214
1234
  }
1215
1235
  replaceCurrent(e, t) {
1216
- if (!this.editor || !e.trim() || ((this.currentQuery !== e || this.currentResults.length === 0) && this.performSearch(e, !1, !0), this.currentIndex < 0 || this.currentResults.length === 0)) return;
1217
- const s = this.currentResults[this.currentIndex];
1218
- if (!s) return;
1219
- const i = this.computeReplacementRange(s.range.start, t);
1220
- if (this.editor.replace(s.range, t), this.config.replaceAndFindNext) {
1236
+ if (!this.editor || !e.trim() || ((this.currentQuery !== e || this.currentResults.length === 0) && this.performSearch(e, !1, !0), this.currentIndex < 0 || this.currentResults.length === 0))
1237
+ return;
1238
+ const i = this.currentResults[this.currentIndex];
1239
+ if (!i)
1240
+ return;
1241
+ const s = this.computeReplacementRange(i.range.start, t);
1242
+ if (this.editor.replace(i.range, t), this.config.replaceAndFindNext) {
1221
1243
  this.currentQuery = e;
1222
1244
  const n = this.editor.search(e, this.searchOptions);
1223
1245
  if (this.currentResults = n, n.length === 0) {
1224
1246
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("Replaced current occurrence"), this.restoreReplaceInputFocus();
1225
1247
  return;
1226
1248
  }
1227
- this.currentIndex = this.findNextResultIndexAfter(i.end, n), this.updateHighlights(!0);
1249
+ this.currentIndex = this.findNextResultIndexAfter(s.end, n), this.updateHighlights(!0);
1228
1250
  } else
1229
- this.scrollLogicalRangeIntoView(i, !0), this.performSearch(e, !0, !1);
1251
+ this.scrollLogicalRangeIntoView(s, !0), this.performSearch(e, !0, !1);
1230
1252
  this.currentResults.length > 0 || this.showTransientStatus("Replaced current occurrence"), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1231
1253
  }
1232
1254
  replaceAll(e, t) {
1233
- if (!this.editor || !e.trim()) return;
1234
- const s = this.editor.replaceAll(e, t, this.searchOptions);
1235
- this.performSearch(e, !1, !1), this.showTransientStatus(`Replaced ${s} occurrence${s === 1 ? "" : "s"}`), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1255
+ if (!this.editor || !e.trim())
1256
+ return;
1257
+ const i = this.editor.replaceAll(e, t, this.searchOptions);
1258
+ this.performSearch(e, !1, !1), this.showTransientStatus(`Replaced ${i} occurrence${i === 1 ? "" : "s"}`), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1236
1259
  }
1237
1260
  updateHighlights(e) {
1238
1261
  if (this.clearHighlights(), this.currentResults.length === 0 || this.currentIndex === -1 || !this.editor)
@@ -1244,40 +1267,44 @@ const W = class m {
1244
1267
  ));
1245
1268
  }
1246
1269
  navigateToResult(e, t) {
1247
- if (!this.editor) return;
1248
- const s = document.activeElement, i = !!s && (s === this.findInput || s === this.replaceInputEl);
1270
+ if (!this.editor)
1271
+ return;
1272
+ const i = document.activeElement, s = !!i && (i === this.findInput || i === this.replaceInputEl);
1249
1273
  t ? (this.editor.setSelection(e.range), this.centerCurrentSelectionInView()) : this.scrollResultIntoView(e);
1250
1274
  const n = this.editor.getView();
1251
- t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && i && s && requestAnimationFrame(() => {
1252
- this.focusWithoutScrolling(s);
1275
+ t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && s && i && requestAnimationFrame(() => {
1276
+ this.focusWithoutScrolling(i);
1253
1277
  });
1254
1278
  }
1255
1279
  clearHighlights() {
1256
1280
  var e, t;
1257
1281
  if (this.hasCustomHighlightSupport)
1258
1282
  try {
1259
- const s = CSS;
1260
- (e = s.highlights) == null || e.delete(this.highlightMatchName), (t = s.highlights) == null || t.delete(this.highlightActiveName);
1261
- } catch (s) {
1283
+ const i = CSS;
1284
+ (e = i.highlights) == null || e.delete(this.highlightMatchName), (t = i.highlights) == null || t.delete(this.highlightActiveName);
1285
+ } catch (i) {
1262
1286
  }
1263
1287
  }
1264
1288
  scrollResultIntoView(e) {
1265
1289
  this.scrollLogicalRangeIntoView(e.range, !0);
1266
1290
  }
1267
1291
  scrollLogicalRangeIntoView(e, t) {
1268
- if (!this.editor) return;
1269
- const s = this.editor.getView().getContentElement(), i = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(i), l = this.buildTextNodeIndex(s);
1270
- if (l.length === 0) return;
1271
- const a = this.toDomRange(e, n, r, l);
1272
- if (!a) return;
1273
- const h = a.startContainer.nodeType === Node.TEXT_NODE ? a.startContainer.parentElement : a.startContainer, o = this.resolveScrollContainer(s);
1274
- if (o) {
1275
- const c = a.getClientRects()[0] || a.getBoundingClientRect(), d = o.getBoundingClientRect(), f = o.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, u = 18;
1276
- let g = t ? f : o.scrollTop, p = o.scrollLeft;
1277
- const y = o.scrollLeft + (c.left - d.left), C = y + c.width;
1278
- c.right > d.right - u ? p = C - d.width + u : c.left < d.left + u && (p = Math.max(0, y - u));
1279
- const v = Math.max(0, o.scrollHeight - o.clientHeight), S = Math.max(0, o.scrollWidth - o.clientWidth);
1280
- if (g = Math.min(v, Math.max(0, g)), p = Math.min(S, Math.max(0, p)), v === 0 && S === 0) {
1292
+ if (!this.editor)
1293
+ return;
1294
+ const i = this.editor.getView().getContentElement(), s = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(s), o = this.buildTextNodeIndex(i);
1295
+ if (o.length === 0)
1296
+ return;
1297
+ const l = this.toDomRange(e, n, r, o);
1298
+ if (!l)
1299
+ return;
1300
+ const h = l.startContainer.nodeType === Node.TEXT_NODE ? l.startContainer.parentElement : l.startContainer, a = this.resolveScrollContainer(i);
1301
+ if (a) {
1302
+ const c = l.getClientRects()[0] || l.getBoundingClientRect(), d = a.getBoundingClientRect(), p = a.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, u = 18;
1303
+ let g = t ? p : a.scrollTop, f = a.scrollLeft;
1304
+ const y = a.scrollLeft + (c.left - d.left), C = y + c.width;
1305
+ c.right > d.right - u ? f = C - d.width + u : c.left < d.left + u && (f = Math.max(0, y - u));
1306
+ const v = Math.max(0, a.scrollHeight - a.clientHeight), S = Math.max(0, a.scrollWidth - a.clientWidth);
1307
+ if (g = Math.min(v, Math.max(0, g)), f = Math.min(S, Math.max(0, f)), v === 0 && S === 0) {
1281
1308
  h == null || h.scrollIntoView({
1282
1309
  block: t ? "center" : "nearest",
1283
1310
  inline: "nearest",
@@ -1285,9 +1312,9 @@ const W = class m {
1285
1312
  });
1286
1313
  return;
1287
1314
  }
1288
- (g !== o.scrollTop || p !== o.scrollLeft) && o.scrollTo({
1315
+ (g !== a.scrollTop || f !== a.scrollLeft) && a.scrollTo({
1289
1316
  top: g,
1290
- left: p,
1317
+ left: f,
1291
1318
  behavior: "smooth"
1292
1319
  });
1293
1320
  return;
@@ -1305,67 +1332,72 @@ const W = class m {
1305
1332
  const t = e.value.length;
1306
1333
  try {
1307
1334
  e.setSelectionRange(t, t);
1308
- } catch (s) {
1335
+ } catch (i) {
1309
1336
  }
1310
1337
  });
1311
1338
  }
1312
1339
  centerCurrentSelectionInView() {
1313
- if (!this.editor) return;
1340
+ if (!this.editor)
1341
+ return;
1314
1342
  const e = this.editor.getView().getContentElement(), t = this.resolveScrollContainer(e);
1315
- if (!t) return;
1316
- const s = window.getSelection();
1317
- if (!s || s.rangeCount === 0) return;
1318
- const i = s.getRangeAt(0).cloneRange(), n = i.getClientRects()[0] || i.getBoundingClientRect();
1319
- if (!n) return;
1320
- const r = t.getBoundingClientRect(), l = t.scrollTop + (n.top - r.top) - r.height / 2 + n.height / 2, a = Math.max(0, t.scrollHeight - t.clientHeight), h = Math.min(a, Math.max(0, l));
1343
+ if (!t)
1344
+ return;
1345
+ const i = window.getSelection();
1346
+ if (!i || i.rangeCount === 0)
1347
+ return;
1348
+ const s = i.getRangeAt(0).cloneRange(), n = s.getClientRects()[0] || s.getBoundingClientRect();
1349
+ if (!n)
1350
+ return;
1351
+ const r = t.getBoundingClientRect(), o = t.scrollTop + (n.top - r.top) - r.height / 2 + n.height / 2, l = Math.max(0, t.scrollHeight - t.clientHeight), h = Math.min(l, Math.max(0, o));
1321
1352
  h !== t.scrollTop && t.scrollTo({
1322
1353
  top: h,
1323
1354
  behavior: "smooth"
1324
1355
  });
1325
1356
  }
1326
1357
  computeReplacementRange(e, t) {
1327
- const s = t.replace(/\r\n?/g, `
1328
- `), i = s.split(`
1358
+ const i = t.replace(/\r\n?/g, `
1359
+ `), s = i.split(`
1329
1360
  `);
1330
1361
  let n;
1331
- return i.length <= 1 ? (n = {
1362
+ return s.length <= 1 ? (n = {
1332
1363
  start: e,
1333
1364
  end: {
1334
1365
  line: e.line,
1335
- column: e.column + s.length
1366
+ column: e.column + i.length
1336
1367
  }
1337
1368
  }, this.clampRangeToDocument(n)) : (n = {
1338
1369
  start: e,
1339
1370
  end: {
1340
- line: e.line + i.length - 1,
1341
- column: i[i.length - 1].length
1371
+ line: e.line + s.length - 1,
1372
+ column: s[s.length - 1].length
1342
1373
  }
1343
1374
  }, this.clampRangeToDocument(n));
1344
1375
  }
1345
1376
  findNextResultIndexAfter(e, t) {
1346
- for (let s = 0; s < t.length; s++)
1347
- if (this.comparePositions(t[s].range.start, e) >= 0)
1348
- return s;
1377
+ for (let i = 0; i < t.length; i++)
1378
+ if (this.comparePositions(t[i].range.start, e) >= 0)
1379
+ return i;
1349
1380
  return 0;
1350
1381
  }
1351
1382
  comparePositions(e, t) {
1352
1383
  return e.line !== t.line ? e.line - t.line : e.column - t.column;
1353
1384
  }
1354
1385
  clampRangeToDocument(e) {
1355
- var h, o;
1356
- const t = this.editor;
1357
- if (!t) return e;
1358
- const s = t.getValue().split(`
1359
- `), i = Math.max(0, s.length - 1), n = Math.max(0, Math.min(e.start.line, i)), r = Math.max(0, Math.min(e.end.line, i)), l = Math.max(
1386
+ var t, i;
1387
+ const s = this.editor;
1388
+ if (!s)
1389
+ return e;
1390
+ const n = s.getValue().split(`
1391
+ `), r = Math.max(0, n.length - 1), o = Math.max(0, Math.min(e.start.line, r)), l = Math.max(0, Math.min(e.end.line, r)), h = Math.max(
1360
1392
  0,
1361
- Math.min(e.start.column, ((h = s[n]) == null ? void 0 : h.length) || 0)
1393
+ Math.min(e.start.column, ((t = n[o]) == null ? void 0 : t.length) || 0)
1362
1394
  ), a = Math.max(
1363
1395
  0,
1364
- Math.min(e.end.column, ((o = s[r]) == null ? void 0 : o.length) || 0)
1396
+ Math.min(e.end.column, ((i = n[l]) == null ? void 0 : i.length) || 0)
1365
1397
  );
1366
1398
  return {
1367
- start: { line: n, column: l },
1368
- end: { line: r, column: a }
1399
+ start: { line: o, column: h },
1400
+ end: { line: l, column: a }
1369
1401
  };
1370
1402
  }
1371
1403
  focusWithoutScrolling(e) {
@@ -1374,19 +1406,19 @@ const W = class m {
1374
1406
  preventScroll: !0
1375
1407
  });
1376
1408
  } catch (t) {
1377
- const s = [];
1378
- let i = e.parentElement;
1379
- for (; i; )
1380
- this.canScroll(i) && s.push({
1381
- el: i,
1382
- top: i.scrollTop,
1383
- left: i.scrollLeft
1384
- }), i = i.parentElement;
1409
+ const i = [];
1410
+ let s = e.parentElement;
1411
+ for (; s; )
1412
+ this.canScroll(s) && i.push({
1413
+ el: s,
1414
+ top: s.scrollTop,
1415
+ left: s.scrollLeft
1416
+ }), s = s.parentElement;
1385
1417
  const n = window.scrollX, r = window.scrollY;
1386
1418
  e.focus();
1387
- for (let l = 0; l < s.length; l++) {
1388
- const a = s[l];
1389
- a.el.scrollTop = a.top, a.el.scrollLeft = a.left;
1419
+ for (let o = 0; o < i.length; o++) {
1420
+ const l = i[o];
1421
+ l.el.scrollTop = l.top, l.el.scrollLeft = l.left;
1390
1422
  }
1391
1423
  window.scrollTo(n, r);
1392
1424
  }
@@ -1394,17 +1426,17 @@ const W = class m {
1394
1426
  findScrollContainer(e) {
1395
1427
  let t = e;
1396
1428
  for (; t; ) {
1397
- const s = window.getComputedStyle(t).overflowY;
1398
- if ((s === "auto" || s === "scroll") && t.scrollHeight > t.clientHeight)
1429
+ const i = window.getComputedStyle(t).overflowY;
1430
+ if ((i === "auto" || i === "scroll") && t.scrollHeight > t.clientHeight)
1399
1431
  return t;
1400
1432
  t = t.parentElement;
1401
1433
  }
1402
1434
  return null;
1403
1435
  }
1404
1436
  resolveScrollContainer(e) {
1405
- var s, i, n;
1406
- const t = ((n = (i = (s = this.editor) == null ? void 0 : s.getView()) == null ? void 0 : i.getScrollElement) == null ? void 0 : n.call(i)) || null;
1407
- return t && this.canScroll(t) ? t : this.findScrollContainer(e);
1437
+ var t, i;
1438
+ const s = (t = this.editor) == null ? void 0 : t.getView(), n = ((i = s == null ? void 0 : s.getScrollElement) == null ? void 0 : i.call(s)) || null;
1439
+ return n && this.canScroll(n) ? n : this.findScrollContainer(e);
1408
1440
  }
1409
1441
  canScroll(e) {
1410
1442
  return e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth;
@@ -1418,123 +1450,128 @@ const W = class m {
1418
1450
  applyCustomHighlights() {
1419
1451
  if (!this.editor || !this.hasCustomHighlightSupport || this.currentResults.length === 0)
1420
1452
  return;
1421
- const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: s, lines: i } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
1422
- if (n.length === 0) return;
1423
- const r = this.buildVisibleDocumentText(n), l = [];
1424
- let a = null;
1453
+ const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: i, lines: s } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
1454
+ if (n.length === 0)
1455
+ return;
1456
+ const r = this.buildVisibleDocumentText(n), o = [];
1457
+ let l = null;
1425
1458
  const h = Math.min(this.currentResults.length, this.maxCustomHighlightRanges);
1426
- for (let o = 0; o < h; o++) {
1427
- const c = this.currentResults[o], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
1459
+ for (let a = 0; a < h; a++) {
1460
+ const c = this.currentResults[a], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, p = this.toDomRange(
1428
1461
  c.range,
1429
- s,
1430
1462
  i,
1463
+ s,
1431
1464
  n,
1432
1465
  r,
1433
1466
  d
1434
1467
  );
1435
- f && (l.push(f), o === this.currentIndex && (a = f));
1468
+ p && (o.push(p), a === this.currentIndex && (l = p));
1436
1469
  }
1437
- if (l.length !== 0)
1470
+ if (o.length !== 0)
1438
1471
  try {
1439
- const o = CSS, c = window.Highlight;
1440
- if (!o.highlights || !c) return;
1441
- o.highlights.set(this.highlightMatchName, new c(...l)), a && o.highlights.set(this.highlightActiveName, new c(a));
1442
- } catch (o) {
1472
+ const a = CSS, c = window.Highlight;
1473
+ if (!a.highlights || !c)
1474
+ return;
1475
+ a.highlights.set(this.highlightMatchName, new c(...o)), l && a.highlights.set(this.highlightActiveName, new c(l));
1476
+ } catch (a) {
1443
1477
  }
1444
1478
  }
1445
1479
  buildLineStarts(e) {
1446
1480
  const t = e.split(`
1447
- `), s = new Array(t.length);
1448
- let i = 0;
1481
+ `), i = new Array(t.length);
1482
+ let s = 0;
1449
1483
  for (let n = 0; n < t.length; n++)
1450
- s[n] = i, i += t[n].length + 1;
1451
- return { lineStarts: s, lines: t };
1484
+ i[n] = s, s += t[n].length + 1;
1485
+ return { lineStarts: i, lines: t };
1452
1486
  }
1453
- positionToOffset(e, t, s) {
1454
- var r;
1455
- const i = Math.max(0, Math.min(e.line, s.length - 1)), n = Math.max(0, Math.min(e.column, ((r = s[i]) == null ? void 0 : r.length) || 0));
1456
- return t[i] + n;
1487
+ positionToOffset(e, t, i) {
1488
+ var s;
1489
+ const n = Math.max(0, Math.min(e.line, i.length - 1)), r = Math.max(0, Math.min(e.column, ((s = i[n]) == null ? void 0 : s.length) || 0));
1490
+ return t[n] + r;
1457
1491
  }
1458
1492
  buildTextNodeIndex(e) {
1459
- var r;
1460
- const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), s = [];
1461
- let i = 0, n;
1493
+ const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), i = [];
1494
+ let s = 0, n;
1462
1495
  for (; n = t.nextNode(); ) {
1463
- const l = n;
1464
- if ((r = l.parentElement) != null && r.hasAttribute(this.trailingMarkerAttr))
1496
+ const r = n, o = r.parentElement;
1497
+ if (o != null && o.hasAttribute(this.trailingMarkerAttr))
1465
1498
  continue;
1466
- const a = l.textContent || "", h = this.buildVisibleToDomMap(a), o = Math.max(0, h.length - 1);
1467
- o === 0 && a.length === 0 || (s.push({
1468
- node: l,
1469
- start: i,
1470
- end: i + o,
1499
+ const l = r.textContent || "", h = this.buildVisibleToDomMap(l), a = Math.max(0, h.length - 1);
1500
+ a === 0 && l.length === 0 || (i.push({
1501
+ node: r,
1502
+ start: s,
1503
+ end: s + a,
1471
1504
  visibleToDom: h
1472
- }), i += o);
1505
+ }), s += a);
1473
1506
  }
1474
- return s;
1507
+ return i;
1475
1508
  }
1476
1509
  resolveDomPoint(e, t) {
1477
- var n, r, l, a, h, o;
1478
- const s = Math.max(0, e);
1510
+ var o, l, h, a;
1511
+ var i, s;
1512
+ const n = Math.max(0, e);
1479
1513
  for (let c = 0; c < t.length; c++) {
1480
1514
  const d = t[c];
1481
- if (s <= d.end) {
1482
- const f = Math.max(0, s - d.start), u = (l = (r = d.visibleToDom[f]) != null ? r : (n = d.node.textContent) == null ? void 0 : n.length) != null ? l : 0;
1515
+ if (n <= d.end) {
1516
+ const p = Math.max(0, n - d.start), u = (l = (o = d.visibleToDom[p]) != null ? o : (i = d.node.textContent) == null ? void 0 : i.length) != null ? l : 0;
1483
1517
  return {
1484
1518
  node: d.node,
1485
1519
  offset: u
1486
1520
  };
1487
1521
  }
1488
1522
  }
1489
- const i = t[t.length - 1];
1490
- return i ? {
1491
- node: i.node,
1492
- offset: (o = (h = i.visibleToDom[i.visibleToDom.length - 1]) != null ? h : (a = i.node.textContent) == null ? void 0 : a.length) != null ? o : 0
1523
+ const r = t[t.length - 1];
1524
+ return r ? {
1525
+ node: r.node,
1526
+ offset: (a = (h = r.visibleToDom[r.visibleToDom.length - 1]) != null ? h : (s = r.node.textContent) == null ? void 0 : s.length) != null ? a : 0
1493
1527
  } : null;
1494
1528
  }
1495
- toDomRange(e, t, s, i, n, r) {
1496
- const l = this.positionToOffset(e.start, t, s), a = this.positionToOffset(e.end, t, s);
1497
- let h = Math.min(l, a), o = Math.max(l, a);
1529
+ toDomRange(e, t, i, s, n, r) {
1530
+ const o = this.positionToOffset(e.start, t, i), l = this.positionToOffset(e.end, t, i);
1531
+ let h = Math.min(o, l), a = Math.max(o, l);
1498
1532
  if (n && r) {
1499
- const u = r, g = n.slice(h, o);
1533
+ const u = r, g = n.slice(h, a);
1500
1534
  if (g.length === u.length && g.toLowerCase() !== u.toLowerCase()) {
1501
- const p = this.findNearestMatchOffset(
1535
+ const f = this.findNearestMatchOffset(
1502
1536
  n,
1503
1537
  u,
1504
1538
  h
1505
1539
  );
1506
- p !== -1 && (h = p, o = p + u.length);
1540
+ f !== -1 && (h = f, a = f + u.length);
1507
1541
  }
1508
1542
  }
1509
- const c = this.resolveDomPoint(h, i), d = this.resolveDomPoint(o, i);
1510
- if (!c || !d) return null;
1511
- const f = document.createRange();
1543
+ const c = this.resolveDomPoint(h, s), d = this.resolveDomPoint(a, s);
1544
+ if (!c || !d)
1545
+ return null;
1546
+ const p = document.createRange();
1512
1547
  try {
1513
- return f.setStart(c.node, c.offset), f.setEnd(d.node, d.offset), f;
1548
+ return p.setStart(c.node, c.offset), p.setEnd(d.node, d.offset), p;
1514
1549
  } catch (u) {
1515
1550
  return null;
1516
1551
  }
1517
1552
  }
1518
1553
  buildVisibleDocumentText(e) {
1519
1554
  let t = "";
1520
- for (let s = 0; s < e.length; s++) {
1521
- const i = e[s].node.textContent || "";
1522
- for (let n = 0; n < i.length; n++) {
1523
- const r = i[n];
1555
+ for (let i = 0; i < e.length; i++) {
1556
+ const s = e[i].node.textContent || "";
1557
+ for (let n = 0; n < s.length; n++) {
1558
+ const r = s[n];
1524
1559
  this.virtualMarkerRegex.test(r) || (t += r);
1525
1560
  }
1526
1561
  }
1527
1562
  return t;
1528
1563
  }
1529
- findNearestMatchOffset(e, t, s) {
1530
- const i = t.toLowerCase();
1531
- let n = e.toLowerCase().indexOf(i);
1532
- if (n === -1) return -1;
1533
- let r = n, l = Math.abs(n - s);
1564
+ findNearestMatchOffset(e, t, i) {
1565
+ const s = t.toLowerCase();
1566
+ let n = e.toLowerCase().indexOf(s);
1567
+ if (n === -1)
1568
+ return -1;
1569
+ let r = n, o = Math.abs(n - i);
1534
1570
  for (; n !== -1; ) {
1535
- const a = Math.abs(n - s);
1536
- if (a < l && (l = a, r = n), a === 0) return n;
1537
- n = e.toLowerCase().indexOf(i, n + 1);
1571
+ const l = Math.abs(n - i);
1572
+ if (l < o && (o = l, r = n), l === 0)
1573
+ return n;
1574
+ n = e.toLowerCase().indexOf(s, n + 1);
1538
1575
  }
1539
1576
  return r;
1540
1577
  }
@@ -1595,15 +1632,16 @@ const W = class m {
1595
1632
  }
1596
1633
  buildVisibleToDomMap(e) {
1597
1634
  const t = [0];
1598
- let s = 0;
1599
- for (let i = 0; i < e.length; i++) {
1600
- const n = e[i];
1601
- this.virtualMarkerRegex.test(n) || (s += 1, t[s] = i + 1);
1635
+ let i = 0;
1636
+ for (let s = 0; s < e.length; s++) {
1637
+ const n = e[s];
1638
+ this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
1602
1639
  }
1603
1640
  return t;
1604
1641
  }
1605
1642
  ensureHighlightStyles() {
1606
- if (document.getElementById(this.highlightStyleId)) return;
1643
+ if (document.getElementById(this.highlightStyleId))
1644
+ return;
1607
1645
  const e = document.createElement("style");
1608
1646
  e.id = this.highlightStyleId, e.textContent = `
1609
1647
  ::highlight(${this.highlightMatchName}) {
@@ -1645,8 +1683,8 @@ W.css = {
1645
1683
  mode: "search-mode",
1646
1684
  modeLayout: "lce-search-mode"
1647
1685
  };
1648
- let se = W;
1649
- class ie {
1686
+ let ie = W;
1687
+ class se {
1650
1688
  constructor() {
1651
1689
  this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
1652
1690
  "(": ")",
@@ -1668,60 +1706,64 @@ class ie {
1668
1706
  });
1669
1707
  }
1670
1708
  updateBracketMatching() {
1671
- if (!this.editor) return;
1709
+ if (!this.editor)
1710
+ return;
1672
1711
  const e = this.editor.getCursor(), t = this.editor.getValue();
1673
1712
  this.clearBracketHighlighting();
1674
- const s = this.getBracketAtPosition(t, e.position);
1675
- if (!s) return;
1676
- const i = this.findMatchingBracket(t, s);
1677
- i && (this.currentMatch = i, this.highlightBrackets(i));
1713
+ const i = this.getBracketAtPosition(t, e.position);
1714
+ if (!i)
1715
+ return;
1716
+ const s = this.findMatchingBracket(t, i);
1717
+ s && (this.currentMatch = s, this.highlightBrackets(s));
1678
1718
  }
1679
1719
  getBracketAtPosition(e, t) {
1680
- const s = e.split(`
1720
+ const i = e.split(`
1681
1721
  `);
1682
- if (t.line >= s.length) return null;
1683
- const i = s[t.line];
1684
- if (t.column >= i.length) return null;
1685
- const n = i[t.column];
1722
+ if (t.line >= i.length)
1723
+ return null;
1724
+ const s = i[t.line];
1725
+ if (t.column >= s.length)
1726
+ return null;
1727
+ const n = s[t.column];
1686
1728
  return this.bracketPairs[n] || this.reverseBracketPairs[n] ? { char: n, position: t } : null;
1687
1729
  }
1688
1730
  findMatchingBracket(e, t) {
1689
- const s = e.split(`
1690
- `), i = t.position.line, n = t.position.column, r = t.char;
1691
- return this.bracketPairs[r] ? this.findClosingBracket(e, s, i, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(e, s, i, n, r) : null;
1731
+ const i = e.split(`
1732
+ `), s = t.position.line, n = t.position.column, r = t.char;
1733
+ return this.bracketPairs[r] ? this.findClosingBracket(e, i, s, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(e, i, s, n, r) : null;
1692
1734
  }
1693
- findClosingBracket(e, t, s, i, n) {
1735
+ findClosingBracket(e, t, i, s, n) {
1694
1736
  const r = this.bracketPairs[n];
1695
- let l = 0;
1696
- for (let a = s; a < t.length; a++) {
1697
- const h = t[a], o = a === s ? i : 0;
1698
- for (let c = o; c < h.length; c++) {
1737
+ let o = 0;
1738
+ for (let l = i; l < t.length; l++) {
1739
+ const h = t[l], a = l === i ? s : 0;
1740
+ for (let c = a; c < h.length; c++) {
1699
1741
  const d = h[c];
1700
1742
  if (d === n)
1701
- l++;
1702
- else if (d === r && (l--, l === 0))
1743
+ o++;
1744
+ else if (d === r && (o--, o === 0))
1703
1745
  return {
1704
- open: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1705
- close: { start: { line: a, column: c }, end: { line: a, column: c + 1 } },
1746
+ open: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1747
+ close: { start: { line: l, column: c }, end: { line: l, column: c + 1 } },
1706
1748
  type: n
1707
1749
  };
1708
1750
  }
1709
1751
  }
1710
1752
  return null;
1711
1753
  }
1712
- findOpeningBracket(e, t, s, i, n) {
1754
+ findOpeningBracket(e, t, i, s, n) {
1713
1755
  const r = this.reverseBracketPairs[n];
1714
- let l = 0;
1715
- for (let a = s; a >= 0; a--) {
1716
- const h = t[a], o = a === s ? i : h.length - 1;
1717
- for (let c = o; c >= 0; c--) {
1756
+ let o = 0;
1757
+ for (let l = i; l >= 0; l--) {
1758
+ const h = t[l], a = l === i ? s : h.length - 1;
1759
+ for (let c = a; c >= 0; c--) {
1718
1760
  const d = h[c];
1719
1761
  if (d === n)
1720
- l++;
1721
- else if (d === r && (l--, l === 0))
1762
+ o++;
1763
+ else if (d === r && (o--, o === 0))
1722
1764
  return {
1723
- open: { start: { line: a, column: c }, end: { line: a, column: c + 1 } },
1724
- close: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1765
+ open: { start: { line: l, column: c }, end: { line: l, column: c + 1 } },
1766
+ close: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1725
1767
  type: r
1726
1768
  };
1727
1769
  }
@@ -1758,7 +1800,8 @@ class ne {
1758
1800
  }, e.on("change", this.changeHandler), this.createFoldingUI(), this.scheduleFoldIndicatorUpdate();
1759
1801
  }
1760
1802
  createFoldingUI() {
1761
- if (!this.editor) return;
1803
+ if (!this.editor)
1804
+ return;
1762
1805
  const e = this.editor.getView().getContentElement(), t = e.closest(".rte-source-editor-modal") || e.parentElement;
1763
1806
  t && (this.foldingUI = document.createElement("div"), this.foldingUI.style.cssText = `
1764
1807
  position: absolute;
@@ -1776,22 +1819,24 @@ class ne {
1776
1819
  }));
1777
1820
  }
1778
1821
  updateFoldIndicators() {
1779
- if (!this.editor || !this.foldingUI) return;
1822
+ if (!this.editor || !this.foldingUI)
1823
+ return;
1780
1824
  const e = this.editor.getValue();
1781
- if (e === this.lastSnapshot) return;
1825
+ if (e === this.lastSnapshot)
1826
+ return;
1782
1827
  this.lastSnapshot = e, this.foldingUI.innerHTML = "", this.foldIndicators = [];
1783
1828
  const t = e.split(`
1784
- `), s = this.findFoldableLines(t), i = document.createDocumentFragment();
1785
- s.forEach((n) => {
1829
+ `), i = this.findFoldableLines(t), s = document.createDocumentFragment();
1830
+ i.forEach((n) => {
1786
1831
  const r = this.createFoldIndicator(n);
1787
- i.appendChild(r), this.foldIndicators.push(r);
1788
- }), this.foldingUI.appendChild(i);
1832
+ s.appendChild(r), this.foldIndicators.push(r);
1833
+ }), this.foldingUI.appendChild(s);
1789
1834
  }
1790
1835
  findFoldableLines(e) {
1791
1836
  const t = [];
1792
- for (let s = 0; s < e.length; s++) {
1793
- const i = e[s].trim();
1794
- (i.startsWith("{") || i.startsWith("function") || i.startsWith("class") || i.startsWith("if") || i.includes("=>") || i.startsWith("for") || i.startsWith("while") || i.startsWith("try")) && t.push(s);
1837
+ for (let i = 0; i < e.length; i++) {
1838
+ const s = e[i].trim();
1839
+ (s.startsWith("{") || s.startsWith("function") || s.startsWith("class") || s.startsWith("if") || s.includes("=>") || s.startsWith("for") || s.startsWith("while") || s.startsWith("try")) && t.push(i);
1795
1840
  }
1796
1841
  return t;
1797
1842
  }
@@ -1831,7 +1876,7 @@ class re {
1831
1876
  this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
1832
1877
  }
1833
1878
  setup(e) {
1834
- this.editor = e, this.registerMode("html", { name: "html", highlight: (t, s) => this._highlightHTML(t, s) }), this.registerMode("javascript", { name: "javascript", highlight: (t, s) => this._highlightJS(t, s) }), this.registerMode("typescript", { name: "typescript", highlight: (t, s) => this._highlightJS(t, s) }), this.registerMode("php", { name: "php", highlight: (t, s) => this._highlightPHP(t, s) });
1879
+ this.editor = e, this.registerMode("html", { name: "html", highlight: (t, i) => this._highlightHTML(t, i) }), this.registerMode("javascript", { name: "javascript", highlight: (t, i) => this._highlightJS(t, i) }), this.registerMode("typescript", { name: "typescript", highlight: (t, i) => this._highlightJS(t, i) }), this.registerMode("php", { name: "php", highlight: (t, i) => this._highlightPHP(t, i) });
1835
1880
  }
1836
1881
  // Extension provides methods that can be called by the editor
1837
1882
  setTheme(e) {
@@ -1891,8 +1936,8 @@ class re {
1891
1936
  }
1892
1937
  // Public API: highlight a source string using the chosen mode (or detect html)
1893
1938
  highlight(e, t) {
1894
- const s = this.getSyntaxColors(), i = (t || this.currentLanguage || "html").toLowerCase();
1895
- return (this.modes.get(i) || this.modes.get("html")).highlight(e, s);
1939
+ const i = this.getSyntaxColors(), s = (t || this.currentLanguage || "html").toLowerCase();
1940
+ return (this.modes.get(s) || this.modes.get("html")).highlight(e, i);
1896
1941
  }
1897
1942
  // Backwards-compatible method
1898
1943
  highlightHTML(e) {
@@ -1905,128 +1950,130 @@ class re {
1905
1950
  // Robustly unescape common HTML entities, repeating a few times to handle nested encoding like &amp;amp;...
1906
1951
  unescapeEntitiesRepeated(e) {
1907
1952
  let t = e || "";
1908
- for (let s = 0; s < 5; s++) {
1909
- const i = t;
1910
- if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === i) break;
1953
+ for (let i = 0; i < 5; i++) {
1954
+ const s = t;
1955
+ if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === s)
1956
+ break;
1911
1957
  }
1912
1958
  return t;
1913
1959
  }
1914
1960
  _highlightHTML(e, t) {
1915
- const s = t, i = (h) => this.escapeHTML(h);
1916
- let n = i(e);
1961
+ const i = t, s = (h) => this.escapeHTML(h);
1962
+ let n = s(e);
1917
1963
  const r = (h) => {
1918
- let o = h.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1919
- return o = o.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${s.comment};">$1</span>`), o = o.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (c, d, f, u, g) => {
1920
- const p = String(u).trim(), y = i(p);
1921
- return `<span style="color: ${s.styleProp};">${d}</span>${f}<span style="color: ${s.styleVal};">${y}</span>${g}`;
1922
- }), o;
1923
- }, l = [];
1964
+ let a = h.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1965
+ return a = a.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${i.comment};">$1</span>`), a = a.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (c, d, p, u, g) => {
1966
+ const f = String(u).trim(), y = s(f);
1967
+ return `<span style="color: ${i.styleProp};">${d}</span>${p}<span style="color: ${i.styleVal};">${y}</span>${g}`;
1968
+ }), a;
1969
+ }, o = [];
1924
1970
  try {
1925
- e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (h, o, c) => (l.push({ attrs: String(o || ""), inner: String(c || "") }), h));
1971
+ e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (h, a, c) => (o.push({ attrs: String(a || ""), inner: String(c || "") }), h));
1926
1972
  } catch (h) {
1927
1973
  }
1928
- let a = 0;
1929
- return n = n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (h, o, c, d, f) => {
1930
- var p, y, C;
1931
- const u = (y = (p = l[a++]) == null ? void 0 : p.inner) != null ? y : this.unescapeEntitiesRepeated(d || "");
1932
- (((C = l[a - 1]) == null ? void 0 : C.attrs) || c || "").toLowerCase();
1933
- const g = this._highlightJS(u, s);
1934
- return `${o}${g}${f}`;
1935
- }), n = n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (h, o, c, d) => {
1936
- const f = r(c);
1937
- return `${o}${f}${d}`;
1938
- }), n = n.replace(/(&lt;!--[\s\S]*?--&gt;)/g, `<span style="color: ${s.comment};">$1</span>`), n = n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i, `<span style="color: ${s.doctype};">$1</span>`), n = n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g, (h, o, c, d, f) => {
1939
- const u = `<span style="color: ${s.tag};">${c}</span>`;
1974
+ let l = 0;
1975
+ return n = n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (h, a, c, d, p) => {
1976
+ var C;
1977
+ var u, g;
1978
+ const f = (C = (u = o[l++]) == null ? void 0 : u.inner) != null ? C : this.unescapeEntitiesRepeated(d || "");
1979
+ (((g = o[l - 1]) == null ? void 0 : g.attrs) || c || "").toLowerCase();
1980
+ const y = this._highlightJS(f, i);
1981
+ return `${a}${y}${p}`;
1982
+ }), n = n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (h, a, c, d) => {
1983
+ const p = r(c);
1984
+ return `${a}${p}${d}`;
1985
+ }), n = n.replace(/(&lt;!--[\s\S]*?--&gt;)/g, `<span style="color: ${i.comment};">$1</span>`), n = n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i, `<span style="color: ${i.doctype};">$1</span>`), n = n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g, (h, a, c, d, p) => {
1986
+ const u = `<span style="color: ${i.tag};">${c}</span>`;
1940
1987
  let g = d;
1941
1988
  return g = g.replace(
1942
1989
  /([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,
1943
- (p, y, C, v) => {
1944
- const S = String(y).toLowerCase(), E = `<span style="color: ${s.attrName};">${y}</span>`;
1990
+ (f, y, C, v) => {
1991
+ const S = String(y).toLowerCase(), E = `<span style="color: ${i.attrName};">${y}</span>`;
1945
1992
  let M = v, b = "";
1946
1993
  v.startsWith("&quot;") && v.endsWith("&quot;") ? (M = v.slice(6, -6), b = "&quot;") : v.startsWith("&#39;") && v.endsWith("&#39;") && (M = v.slice(5, -5), b = "&#39;");
1947
1994
  let T = v;
1948
1995
  if (S === "style") {
1949
- const I = M.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (B, $, A, O) => `<span style="color: ${s.styleProp};">${$}</span>:<span style="color: ${s.styleVal};">${A.trim()}</span>${O}`);
1950
- b ? T = `${b}${I}${b}` : T = I, T = `<span style="color: ${s.attrValue};">${T}</span>`;
1996
+ const I = M.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (B, $, A, O) => `<span style="color: ${i.styleProp};">${$}</span>:<span style="color: ${i.styleVal};">${A.trim()}</span>${O}`);
1997
+ b ? T = `${b}${I}${b}` : T = I, T = `<span style="color: ${i.attrValue};">${T}</span>`;
1951
1998
  } else
1952
- b && (T = `${b}${M}${b}`), T = `<span style="color: ${s.attrValue};">${T}</span>`;
1999
+ b && (T = `${b}${M}${b}`), T = `<span style="color: ${i.attrValue};">${T}</span>`;
1953
2000
  return `${E}${C}${T}`;
1954
2001
  }
1955
- ), `${o}${u}${g}${f}`;
2002
+ ), `${a}${u}${g}${p}`;
1956
2003
  }), n;
1957
2004
  }
1958
2005
  _highlightJS(e, t) {
1959
- const s = this.unescapeEntitiesRepeated(e);
1960
- this.escapeHTML(s);
1961
- const i = [], n = (d) => {
1962
- let f = "", u = d;
2006
+ const i = this.unescapeEntitiesRepeated(e);
2007
+ this.escapeHTML(i);
2008
+ const s = [], n = (d) => {
2009
+ let p = "", u = d;
1963
2010
  do
1964
- f = String.fromCharCode(97 + u % 26) + f, u = Math.floor(u / 26) - 1;
2011
+ p = String.fromCharCode(97 + u % 26) + p, u = Math.floor(u / 26) - 1;
1965
2012
  while (u >= 0);
1966
- return f || "a";
1967
- }, r = (d) => `\0${n(d)}\0`, l = (d) => {
1968
- const f = i.length;
1969
- return i.push(d), r(f);
2013
+ return p || "a";
2014
+ }, r = (d) => `\0${n(d)}\0`, o = (d) => {
2015
+ const p = s.length;
2016
+ return s.push(d), r(p);
1970
2017
  };
1971
- let a;
2018
+ let l;
1972
2019
  const h = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
1973
- let o = 0, c = "";
1974
- for (; a = h.exec(s); ) {
1975
- const d = a.index;
1976
- o < d && (c += this.escapeHTML(s.slice(o, d)));
1977
- const f = a[0];
1978
- /^\/\*/.test(f) || /^\/\//.test(f) ? c += l(`<span style="color: ${t.comment};">${this.escapeHTML(f)}</span>`) : c += l(`<span style="color: ${t.string};">${this.escapeHTML(f)}</span>`), o = h.lastIndex;
2020
+ let a = 0, c = "";
2021
+ for (; l = h.exec(i); ) {
2022
+ const d = l.index;
2023
+ a < d && (c += this.escapeHTML(i.slice(a, d)));
2024
+ const p = l[0];
2025
+ /^\/\*/.test(p) || /^\/\//.test(p) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(p)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(p)}</span>`), a = h.lastIndex;
1979
2026
  }
1980
- return o < s.length && (c += this.escapeHTML(s.slice(o))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, f, u) => {
1981
- const g = c[u - 1] || "", p = c[u + d.length] || "";
1982
- return g === "&" || g === "#" || p === ";" || p === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
1983
- }), 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, (d, f) => {
2027
+ return a < i.length && (c += this.escapeHTML(i.slice(a))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, p, u) => {
2028
+ const g = c[u - 1] || "", f = c[u + d.length] || "";
2029
+ return g === "&" || g === "#" || f === ";" || f === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
2030
+ }), 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, (d, p) => {
1984
2031
  let u = 0;
1985
- for (let g = 0; g < f.length; g++)
1986
- u = u * 26 + (f.charCodeAt(g) - 97 + 1);
1987
- return u = u - 1, i[u] || "";
2032
+ for (let g = 0; g < p.length; g++)
2033
+ u = u * 26 + (p.charCodeAt(g) - 97 + 1);
2034
+ return u = u - 1, s[u] || "";
1988
2035
  });
1989
2036
  }
1990
2037
  _highlightPHP(e, t) {
1991
- const s = this.unescapeEntitiesRepeated(e);
1992
- let i = this.escapeHTML(s);
2038
+ const i = this.unescapeEntitiesRepeated(e);
2039
+ let s = this.escapeHTML(i);
1993
2040
  const n = [], r = (u) => {
1994
- let g = "", p = u;
2041
+ let g = "", f = u;
1995
2042
  do
1996
- g = String.fromCharCode(97 + p % 26) + g, p = Math.floor(p / 26) - 1;
1997
- while (p >= 0);
2043
+ g = String.fromCharCode(97 + f % 26) + g, f = Math.floor(f / 26) - 1;
2044
+ while (f >= 0);
1998
2045
  return g || "a";
1999
- }, l = (u) => {
2046
+ }, o = (u) => {
2000
2047
  const g = n.length;
2001
2048
  return n.push(u), `\0${r(g)}\0`;
2002
- }, a = (u, g) => {
2003
- const p = i.indexOf(u);
2004
- return p === -1 ? !1 : (i = i.slice(0, p) + g + i.slice(p + u.length), !0);
2049
+ }, l = (u, g) => {
2050
+ const f = s.indexOf(u);
2051
+ return f === -1 ? !1 : (s = s.slice(0, f) + g + s.slice(f + u.length), !0);
2005
2052
  };
2006
2053
  let h;
2007
- const o = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, f = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
2008
- for (; h = o.exec(s); ) {
2054
+ const a = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, p = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
2055
+ for (; h = a.exec(i); ) {
2009
2056
  const u = h[0];
2010
- a(this.escapeHTML(u), l(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2057
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2011
2058
  }
2012
- for (; h = c.exec(s); ) {
2059
+ for (; h = c.exec(i); ) {
2013
2060
  const u = h[0];
2014
- a(this.escapeHTML(u), l(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2061
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2015
2062
  }
2016
- for (; h = d.exec(s); ) {
2063
+ for (; h = d.exec(i); ) {
2017
2064
  const u = h[0];
2018
- a(this.escapeHTML(u), l(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2065
+ l(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2019
2066
  }
2020
- for (; h = f.exec(s); ) {
2067
+ for (; h = p.exec(i); ) {
2021
2068
  const u = h[0];
2022
- a(this.escapeHTML(u), l(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
2069
+ l(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
2023
2070
  }
2024
- 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, (u, g) => {
2025
- let p = 0;
2071
+ return s = s.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), s = s.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>`), s = s.replace(/\u0000([a-z]+)\u0000/g, (u, g) => {
2072
+ let f = 0;
2026
2073
  for (let y = 0; y < g.length; y++)
2027
- p = p * 26 + (g.charCodeAt(y) - 97 + 1);
2028
- return p = p - 1, n[p] || "";
2029
- }), i;
2074
+ f = f * 26 + (g.charCodeAt(y) - 97 + 1);
2075
+ return f = f - 1, n[f] || "";
2076
+ }), s;
2030
2077
  }
2031
2078
  // Method to check if content contains syntax that should be highlighted
2032
2079
  shouldHighlight(e) {
@@ -2038,7 +2085,7 @@ class re {
2038
2085
  }
2039
2086
  function oe(w, e) {
2040
2087
  const t = { ...e };
2041
- 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 Y()), new X(w, t);
2088
+ return t.extensions || (t.extensions = []), t.extensions.some((i) => i.name === "keymap") || t.extensions.unshift(new J(t.keymap)), t.extensions.some((i) => i.name === "transaction") || t.extensions.unshift(new Y()), new X(w, t);
2042
2089
  }
2043
2090
  const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Editor Dialog Styles */
2044
2091
  .rte-source-editor-overlay {
@@ -2437,36 +2484,38 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2437
2484
  */
2438
2485
  toggleSourceView: () => {
2439
2486
  const e = (() => {
2440
- var l, a, h;
2487
+ var o, l, h;
2441
2488
  const n = window.getSelection();
2442
2489
  if (n && n.anchorNode) {
2443
- let o = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
2444
- for (; o; ) {
2445
- if ((l = o.classList) != null && l.contains("rte-content"))
2446
- return o;
2447
- o = o.parentElement;
2490
+ let a = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
2491
+ for (; a; ) {
2492
+ if ((o = a.classList) != null && o.contains("rte-content"))
2493
+ return a;
2494
+ a = a.parentElement;
2448
2495
  }
2449
2496
  }
2450
2497
  if (document.activeElement) {
2451
- let o = document.activeElement;
2452
- if ((a = o.classList) != null && a.contains("rte-content"))
2453
- return o;
2454
- for (; o && o !== document.body; ) {
2455
- if ((h = o.classList) != null && h.contains("rte-content"))
2456
- return o;
2457
- const c = o.querySelector(
2498
+ let a = document.activeElement;
2499
+ if ((l = a.classList) != null && l.contains("rte-content"))
2500
+ return a;
2501
+ for (; a && a !== document.body; ) {
2502
+ if ((h = a.classList) != null && h.contains("rte-content"))
2503
+ return a;
2504
+ const c = a.querySelector(
2458
2505
  ".rte-content"
2459
2506
  );
2460
- if (c) return c;
2461
- o = o.parentElement;
2507
+ if (c)
2508
+ return c;
2509
+ a = a.parentElement;
2462
2510
  }
2463
2511
  }
2464
2512
  const r = document.querySelector("[data-editora-editor]");
2465
2513
  if (r) {
2466
- const o = r.querySelector(
2514
+ const a = r.querySelector(
2467
2515
  ".rte-content"
2468
2516
  );
2469
- if (o) return o;
2517
+ if (a)
2518
+ return a;
2470
2519
  }
2471
2520
  return document.querySelector(".rte-content");
2472
2521
  })();
@@ -2474,25 +2523,25 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2474
2523
  return console.error("[CodePlugin] Editor content area not found"), alert(
2475
2524
  "Editor content area not found. Please click inside the editor first."
2476
2525
  ), !1;
2477
- const t = e.innerHTML, s = (n) => {
2478
- let r = "", l = 0;
2479
- const a = 2, h = n.split(/(<\/?[a-zA-Z][^>]*>)/);
2480
- for (const o of h)
2481
- o.trim() && (o.match(/^<\/[a-zA-Z]/) ? (l = Math.max(0, l - 1), r += `
2482
- ` + " ".repeat(l * a) + o) : o.match(/^<[a-zA-Z]/) && !o.match(/\/>$/) ? (r += `
2483
- ` + " ".repeat(l * a) + o, l++) : o.match(/^<[a-zA-Z].*\/>$/) ? r += `
2484
- ` + " ".repeat(l * a) + o : r += o.trim());
2526
+ const t = e.innerHTML, i = (n) => {
2527
+ let r = "", o = 0;
2528
+ const l = 2, h = n.split(/(<\/?[a-zA-Z][^>]*>)/);
2529
+ for (const a of h)
2530
+ a.trim() && (a.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), r += `
2531
+ ` + " ".repeat(o * l) + a) : a.match(/^<[a-zA-Z]/) && !a.match(/\/>$/) ? (r += `
2532
+ ` + " ".repeat(o * l) + a, o++) : a.match(/^<[a-zA-Z].*\/>$/) ? r += `
2533
+ ` + " ".repeat(o * l) + a : r += a.trim());
2485
2534
  return r.trim();
2486
2535
  };
2487
2536
  return (() => {
2488
- const r = s(t);
2489
- let l = null, a = "dark", h = !1, o = !1, c = !1, d = !1;
2490
- const f = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), u = document.createElement("div");
2491
- u.className = "rte-source-editor-overlay", f && u.classList.add("rte-theme-dark");
2537
+ const r = i(t);
2538
+ let o = null, l = "dark", h = !1, a = !1, c = !1, d = !1;
2539
+ const p = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), u = document.createElement("div");
2540
+ u.className = "rte-source-editor-overlay", p && u.classList.add("rte-theme-dark");
2492
2541
  const g = document.createElement("div");
2493
2542
  g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
2494
- const p = document.createElement("div");
2495
- p.className = "rte-source-editor-header", p.innerHTML = `
2543
+ const f = document.createElement("div");
2544
+ f.className = "rte-source-editor-header", f.innerHTML = `
2496
2545
  <h2 id="source-editor-title">Source Editor</h2>
2497
2546
  <div class="rte-source-editor-header-toolbar">
2498
2547
  <button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
@@ -2546,17 +2595,17 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2546
2595
  <button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
2547
2596
  <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
2548
2597
  </div>
2549
- `, g.appendChild(p), g.appendChild(y), g.appendChild(E), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
2598
+ `, g.appendChild(f), g.appendChild(y), g.appendChild(E), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
2550
2599
  const x = document.createElement("style");
2551
2600
  x.id = "rte-source-editor-styles", x.textContent = le, document.head.appendChild(x);
2552
2601
  }
2553
- const M = p.querySelector(
2602
+ const M = f.querySelector(
2554
2603
  ".theme-toggle-btn"
2555
- ), b = p.querySelector(
2604
+ ), b = f.querySelector(
2556
2605
  ".readonly-toggle-btn"
2557
- ), T = p.querySelector(
2606
+ ), T = f.querySelector(
2558
2607
  ".rte-source-editor-fullscreen-btn"
2559
- ), I = p.querySelector(
2608
+ ), I = f.querySelector(
2560
2609
  ".rte-source-editor-close-btn"
2561
2610
  ), B = E.querySelector(
2562
2611
  ".rte-source-editor-btn-cancel"
@@ -2576,10 +2625,10 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2576
2625
  const x = O.pop();
2577
2626
  x == null || x();
2578
2627
  }
2579
- l && (l.destroy(), l = null), u.isConnected && u.remove();
2628
+ o && (o.destroy(), o = null), u.isConnected && u.remove();
2580
2629
  }
2581
2630
  }, K = () => {
2582
- a = a === "dark" ? "light" : "dark", l == null || l.setTheme(a), M && (M.innerHTML = a === "light" ? `
2631
+ l = l === "dark" ? "light" : "dark", o == null || o.setTheme(l), M && (M.innerHTML = l === "light" ? `
2583
2632
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2584
2633
  <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
2585
2634
  </svg>
@@ -2597,7 +2646,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2597
2646
  </svg>
2598
2647
  `);
2599
2648
  }, z = () => {
2600
- h = !h, l == null || l.setReadOnly(h), b && (b.classList.toggle("active", h), b.innerHTML = h ? `
2649
+ h = !h, o == null || o.setReadOnly(h), b && (b.classList.toggle("active", h), b.innerHTML = h ? `
2601
2650
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2602
2651
  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
2603
2652
  <circle cx="12" cy="16" r="1"/>
@@ -2610,7 +2659,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2610
2659
  </svg>
2611
2660
  `);
2612
2661
  }, q = () => {
2613
- o = !o, u.classList.toggle("fullscreen", o), S.style.height = o ? "calc(100vh - 200px)" : "400px", T && (T.innerHTML = o ? `
2662
+ a = !a, u.classList.toggle("fullscreen", a), S.style.height = a ? "calc(100vh - 200px)" : "400px", T && (T.innerHTML = a ? `
2614
2663
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2615
2664
  <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"/>
2616
2665
  </svg>
@@ -2623,7 +2672,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2623
2672
  c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
2624
2673
  }, j = () => {
2625
2674
  try {
2626
- const x = (l == null ? void 0 : l.getValue()) || "", k = document.createElement("div");
2675
+ const x = (o == null ? void 0 : o.getValue()) || "", k = document.createElement("div");
2627
2676
  k.innerHTML = x, k.querySelectorAll(
2628
2677
  'script, iframe[src^="javascript:"], object, embed'
2629
2678
  ).forEach((N) => N.remove()), e.innerHTML = k.innerHTML;
@@ -2655,7 +2704,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2655
2704
  }), document.body.appendChild(u), requestAnimationFrame(() => {
2656
2705
  if (!(d || !u.isConnected))
2657
2706
  try {
2658
- l = oe(S, {
2707
+ o = oe(S, {
2659
2708
  value: r,
2660
2709
  theme: "dark",
2661
2710
  readOnly: !1,
@@ -2663,15 +2712,15 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2663
2712
  new G(),
2664
2713
  new _(),
2665
2714
  new ee(),
2666
- new ie(),
2667
2715
  new se(),
2716
+ new ie(),
2668
2717
  new ne(),
2669
2718
  new re()
2670
2719
  ]
2671
- }), l.on("change", () => {
2672
- const x = (l == null ? void 0 : l.getValue()) || "";
2720
+ }), o.on("change", () => {
2721
+ const x = (o == null ? void 0 : o.getValue()) || "";
2673
2722
  U(x !== r);
2674
- }), requestAnimationFrame(() => l == null ? void 0 : l.focus());
2723
+ }), requestAnimationFrame(() => o == null ? void 0 : o.focus());
2675
2724
  } catch (x) {
2676
2725
  console.error("Failed to initialize code editor:", x);
2677
2726
  }
@@ -2688,4 +2737,4 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2688
2737
  export {
2689
2738
  ae as CodePlugin
2690
2739
  };
2691
- //# sourceMappingURL=CodePlugin.native-DlpTPdkd.mjs.map
2740
+ //# sourceMappingURL=CodePlugin.native-989cf0aa.mjs.map