@editora/plugins 1.0.8 → 1.0.10

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 (141) hide show
  1. package/README.md +27 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +447 -0
  11. package/dist/approval-workflow.esm.js +1111 -0
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +442 -0
  16. package/dist/blocks-library.esm.js +1384 -0
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +548 -0
  21. package/dist/citations.esm.js +1530 -0
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +626 -0
  31. package/dist/conditional-content.esm.js +1421 -0
  32. package/dist/content-rules.cjs.js +408 -0
  33. package/dist/content-rules.esm.js +1147 -0
  34. package/dist/data-binding.cjs.js +321 -0
  35. package/dist/data-binding.esm.js +953 -0
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +398 -0
  38. package/dist/doc-schema.esm.js +1378 -0
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -0
  49. package/dist/enterprise.esm.js +58 -0
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +124 -93
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +105 -0
  87. package/dist/mentions.esm.js +774 -0
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +67 -51
  92. package/dist/pii-redaction.cjs.js +436 -0
  93. package/dist/pii-redaction.esm.js +1447 -0
  94. package/dist/preview.cjs.js +3 -3
  95. package/dist/preview.esm.js +37 -32
  96. package/dist/print.cjs.js +4 -4
  97. package/dist/print.esm.js +20 -17
  98. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  99. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  100. package/dist/slash-commands.cjs.js +90 -0
  101. package/dist/slash-commands.esm.js +788 -0
  102. package/dist/smart-paste.cjs.js +398 -0
  103. package/dist/smart-paste.esm.js +1444 -0
  104. package/dist/special-characters.cjs.js +7 -7
  105. package/dist/special-characters.esm.js +69 -61
  106. package/dist/spell-check.cjs.js +5 -5
  107. package/dist/spell-check.esm.js +123 -97
  108. package/dist/strikethrough.cjs.js +1 -1
  109. package/dist/strikethrough.esm.js +19 -14
  110. package/dist/style.css +1 -0
  111. package/dist/table.cjs.js +4 -4
  112. package/dist/table.esm.js +225 -191
  113. package/dist/template.cjs.js +11 -11
  114. package/dist/template.esm.js +153 -124
  115. package/dist/text-alignment.cjs.js +1 -1
  116. package/dist/text-alignment.esm.js +27 -21
  117. package/dist/text-color.cjs.js +3 -3
  118. package/dist/text-color.esm.js +87 -70
  119. package/dist/track-changes.cjs.js +77 -0
  120. package/dist/track-changes.esm.js +817 -0
  121. package/dist/translation-workflow.cjs.js +626 -0
  122. package/dist/translation-workflow.esm.js +1794 -0
  123. package/dist/version-diff.cjs.js +362 -0
  124. package/dist/version-diff.esm.js +797 -0
  125. package/index.d.ts +798 -0
  126. package/package.json +114 -9
  127. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  128. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  129. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  130. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  131. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  132. package/dist/documentManager-Jf0RbSks.js +0 -17
  133. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  134. package/dist/index-CvJk4DKa.js +0 -221
  135. package/dist/index-D3CycEFU.mjs +0 -16543
  136. package/dist/index-tqLTHcO6.js +0 -1
  137. package/dist/index.es-CE_A4QSm.js +0 -5
  138. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  139. package/dist/jspdf.es.min-BoS80556.js +0 -77
  140. package/dist/plugins.css +0 -1
  141. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
package/dist/code.esm.js CHANGED
@@ -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, o = n.substring(e.end.column), l = 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), a = t.split(`
46
46
  `);
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);
47
+ a[0] = r + a[0], a[a.length - 1] = a[a.length - 1] + o, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...a);
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,38 +192,39 @@ 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
- const t = this.getText().split(`
207
- `), s = Math.min(e.line, t.length - 1), i = Math.min(e.column, t[s]?.length || 0);
208
- let n = 0;
209
- for (let h = 0; h < s; h++)
210
- n += t[h].length + 1;
211
- n += i;
212
- const r = document.createRange(), o = window.getSelection(), l = this.resolveOffsetToDomPoint(n);
213
- if (l)
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 l = 0; l < s; l++)
211
+ r += i[l].length + 1;
212
+ r += n;
213
+ const o = document.createRange(), a = window.getSelection(), h = this.resolveOffsetToDomPoint(r);
214
+ if (h)
214
215
  try {
215
- r.setStart(l.node, l.offset), r.setEnd(l.node, l.offset), o?.removeAllRanges(), o?.addRange(r), this.ensureCaretVisible();
216
- } catch (h) {
217
- console.warn("Could not set cursor position:", h);
216
+ o.setStart(h.node, h.offset), o.setEnd(h.node, h.offset), a == null || a.removeAllRanges(), a == null || a.addRange(o), this.ensureCaretVisible();
217
+ } catch (l) {
218
+ console.warn("Could not set cursor position:", l);
218
219
  }
219
220
  else {
220
- const h = this.contentElement.querySelector(
221
+ const l = this.contentElement.querySelector(
221
222
  `[${this.trailingNewlineMarkerAttr}]`
222
223
  );
223
224
  try {
224
- h && h.parentNode === this.contentElement ? r.setStartBefore(h) : (r.selectNodeContents(this.contentElement), r.collapse(!1)), r.collapse(!0), o?.removeAllRanges(), o?.addRange(r), this.ensureCaretVisible();
225
- } catch (a) {
226
- console.warn("Could not set fallback cursor position:", a);
225
+ l && l.parentNode === this.contentElement ? o.setStartBefore(l) : (o.selectNodeContents(this.contentElement), o.collapse(!1)), o.collapse(!0), a == null || a.removeAllRanges(), a == null || a.addRange(o), this.ensureCaretVisible();
226
+ } catch (c) {
227
+ console.warn("Could not set fallback cursor position:", c);
227
228
  }
228
229
  }
229
230
  }
@@ -232,17 +233,17 @@ class Z {
232
233
  const e = window.getSelection();
233
234
  if (!e || e.rangeCount === 0 || e.isCollapsed)
234
235
  return;
235
- const t = e.getRangeAt(0), s = t.cloneRange();
236
- s.selectNodeContents(this.contentElement), s.setEnd(t.startContainer, t.startOffset);
237
- 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(`
238
239
  `), n = t.cloneRange();
239
240
  n.selectNodeContents(this.contentElement), n.setEnd(t.endContainer, t.endOffset);
240
241
  const r = n.toString().replace(/\u200B/g, "").split(`
241
242
  `);
242
243
  return {
243
244
  start: {
244
- line: i.length - 1,
245
- column: i[i.length - 1].length
245
+ line: s.length - 1,
246
+ column: s[s.length - 1].length
246
247
  },
247
248
  end: {
248
249
  line: r.length - 1,
@@ -253,22 +254,23 @@ class Z {
253
254
  // Set selection range
254
255
  setSelectionRange(e) {
255
256
  const t = this.getText().split(`
256
- `), s = (c) => {
257
- const u = 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(
258
259
  0,
259
- Math.min(c.column, t[u] ? t[u].length : 0)
260
+ Math.min(c.column, t[d] ? t[d].length : 0)
260
261
  );
261
- let d = 0;
262
- for (let g = 0; g < u; g++)
263
- d += t[g].length + 1;
264
- return d + f;
265
- }, i = s(e.start), n = s(e.end), [r, o] = i <= n ? [i, n] : [n, i], l = this.resolveOffsetToDomPoint(r), h = this.resolveOffsetToDomPoint(o);
266
- if (!l || !h) return;
267
- const a = document.createRange();
262
+ let u = 0;
263
+ for (let g = 0; g < d; g++)
264
+ u += t[g].length + 1;
265
+ return u + p;
266
+ }, s = i(e.start), n = i(e.end), [r, o] = s <= n ? [s, n] : [n, s], a = this.resolveOffsetToDomPoint(r), h = this.resolveOffsetToDomPoint(o);
267
+ if (!a || !h)
268
+ return;
269
+ const l = document.createRange();
268
270
  try {
269
- a.setStart(l.node, l.offset), a.setEnd(h.node, h.offset);
271
+ l.setStart(a.node, a.offset), l.setEnd(h.node, h.offset);
270
272
  const c = window.getSelection();
271
- c?.removeAllRanges(), c?.addRange(a), this.ensureCaretVisible();
273
+ c == null || c.removeAllRanges(), c == null || c.addRange(l), this.ensureCaretVisible();
272
274
  } catch (c) {
273
275
  console.warn("Could not set selection range:", c);
274
276
  }
@@ -287,8 +289,8 @@ class Z {
287
289
  }
288
290
  // Apply theme
289
291
  applyTheme(e) {
290
- Object.entries(e).forEach(([t, s]) => {
291
- this.container.style.setProperty(`--${t}`, s);
292
+ Object.entries(e).forEach(([t, i]) => {
293
+ this.container.style.setProperty(`--${t}`, i);
292
294
  });
293
295
  }
294
296
  // Scroll to position
@@ -309,7 +311,8 @@ class Z {
309
311
  this.editorContainer.scrollTop = e;
310
312
  }
311
313
  syncTrailingNewlineMarker(e) {
312
- 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;
313
316
  const t = document.createElement("span");
314
317
  t.setAttribute(this.trailingNewlineMarkerAttr, "true"), t.setAttribute("aria-hidden", "true"), t.contentEditable = "false", t.style.cssText = `
315
318
  display: inline-block;
@@ -321,54 +324,59 @@ class Z {
321
324
  }
322
325
  // Ensure caret is visible inside the editor scroll container
323
326
  ensureCaretVisible() {
324
- const e = window.getSelection();
325
- if (!e || e.rangeCount === 0) return;
326
- const t = e.getRangeAt(0).cloneRange();
327
- t.collapse(!1);
328
- let s = t.getClientRects()[0] || t.getBoundingClientRect();
329
- if ((!s || s.width === 0 && s.height === 0) && e.focusNode instanceof Element ? s = e.focusNode.getBoundingClientRect() : (!s || s.width === 0 && s.height === 0) && e.focusNode?.parentElement && (s = e.focusNode.parentElement.getBoundingClientRect()), !s) return;
330
- const i = this.editorContainer.getBoundingClientRect(), n = 12;
331
- 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);
332
338
  }
333
339
  // Destroy the view
334
340
  destroy() {
335
341
  this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
336
342
  }
337
343
  resolveOffsetToDomPoint(e) {
338
- const t = Math.max(0, e);
344
+ var t;
345
+ const i = Math.max(0, e);
339
346
  let s = 0;
340
- const i = document.createTreeWalker(
347
+ const n = document.createTreeWalker(
341
348
  this.contentElement,
342
349
  NodeFilter.SHOW_TEXT,
343
350
  null
344
351
  );
345
- let n = null, r;
346
- for (; r = i.nextNode(); ) {
347
- if (r.parentElement?.hasAttribute(this.trailingNewlineMarkerAttr))
352
+ let r = null, o;
353
+ for (; o = n.nextNode(); ) {
354
+ const a = o.parentElement;
355
+ if (a != null && a.hasAttribute(this.trailingNewlineMarkerAttr))
348
356
  continue;
349
- n = r;
350
- const o = r.textContent || "", l = this.buildVisibleToDomMap(o), h = Math.max(0, l.length - 1);
351
- if (s + h >= t) {
352
- const a = Math.max(0, t - s), c = l[a] ?? o.length;
357
+ r = o;
358
+ const h = o.textContent || "", l = this.buildVisibleToDomMap(h), c = Math.max(0, l.length - 1);
359
+ if (s + c >= i) {
360
+ const d = Math.max(0, i - s), p = l[d] ?? h.length;
353
361
  return {
354
- node: r,
355
- offset: c
362
+ node: o,
363
+ offset: p
356
364
  };
357
365
  }
358
- s += h;
366
+ s += c;
359
367
  }
360
- if (n) {
361
- const o = n.textContent?.length || 0;
362
- return { node: n, offset: o };
368
+ if (r) {
369
+ const a = ((t = r.textContent) == null ? void 0 : t.length) || 0;
370
+ return { node: r, offset: a };
363
371
  }
364
372
  return null;
365
373
  }
366
374
  buildVisibleToDomMap(e) {
367
375
  const t = [0];
368
- let s = 0;
369
- for (let i = 0; i < e.length; i++) {
370
- const n = e[i];
371
- this.virtualMarkerRegex.test(n) || (s += 1, t[s] = i + 1);
376
+ let i = 0;
377
+ for (let s = 0; s < e.length; s++) {
378
+ const n = e[s];
379
+ this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
372
380
  }
373
381
  return t;
374
382
  }
@@ -383,7 +391,7 @@ const F = class L {
383
391
  lineWrapping: !1,
384
392
  lineNumbers: !0,
385
393
  ...t
386
- }, 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();
394
+ }, 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();
387
395
  }
388
396
  // Public accessors for extensions
389
397
  getTextModel() {
@@ -409,21 +417,21 @@ const F = class L {
409
417
  setupEventHandlers() {
410
418
  const e = this.view.getContentElement();
411
419
  e.addEventListener("input", () => {
412
- const t = this.view.getText(), s = this.textModel.getText();
413
- if (t !== s) {
420
+ const t = this.view.getText(), i = this.textModel.getText();
421
+ if (t !== i) {
414
422
  if (!this.suppressHistory) {
415
- const i = this.getCursor().position, n = this.textModel.positionToOffset(i), r = this.getSelection();
416
- let o, l;
417
- r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: s, cursorOffset: n, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
423
+ const s = this.getCursor().position, n = this.textModel.positionToOffset(s), r = this.getSelection();
424
+ let o, a;
425
+ r && (o = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: i, cursorOffset: n, anchorOffset: o, focusOffset: a }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
418
426
  }
419
427
  this.textModel.setText(t), this.view.syncTrailingNewlineMarkerForText(t), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
420
- const i = this.view.getText();
421
- i !== this.textModel.getText() && this.textModel.setText(i), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
422
- }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: s }]);
428
+ const s = this.view.getText();
429
+ s !== this.textModel.getText() && this.textModel.setText(s), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
430
+ }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: i }]);
423
431
  }
424
432
  }), e.addEventListener("selectionchange", () => {
425
- const t = this.getCursor(), s = this.getSelection();
426
- this.emit("cursor", t), s && this.emit("selection", s);
433
+ const t = this.getCursor(), i = this.getSelection();
434
+ this.emit("cursor", t), i && this.emit("selection", i);
427
435
  }), e.addEventListener("keydown", (t) => {
428
436
  if (this.emit("keydown", t), t.key === "Tab") {
429
437
  this.config.readOnly || this.insertTab(), t.preventDefault(), t.stopPropagation();
@@ -431,34 +439,34 @@ const F = class L {
431
439
  }
432
440
  if (t.key === "Enter") {
433
441
  if (!this.config.readOnly) {
434
- const s = window.getSelection();
435
- if (s && s.rangeCount > 0) {
436
- const i = this.getCursor().position, n = this.textModel.positionToOffset(i), r = this.getSelection();
437
- let o, l;
438
- r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end));
439
- const h = r && o !== void 0 && l !== void 0 ? Math.min(o, l) : n;
440
- 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);
441
- const a = s.getRangeAt(0);
442
- a.deleteContents();
442
+ const i = window.getSelection();
443
+ if (i && i.rangeCount > 0) {
444
+ const s = this.getCursor().position, n = this.textModel.positionToOffset(s), r = this.getSelection();
445
+ let o, a;
446
+ r && (o = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end));
447
+ const h = r && o !== void 0 && a !== void 0 ? Math.min(o, a) : n;
448
+ this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: n, anchorOffset: o, focusOffset: a }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
449
+ const l = i.getRangeAt(0);
450
+ l.deleteContents();
443
451
  const c = document.createTextNode(`
444
452
  `);
445
- a.insertNode(c), a.setStartAfter(c), a.collapse(!0), s.removeAllRanges(), s.addRange(a), this.view.ensureCaretVisible();
446
- const u = this.view.getText();
447
- this.textModel.setText(u), this.view.syncTrailingNewlineMarkerForText(u);
448
- const f = Math.min(
453
+ l.insertNode(c), l.setStartAfter(c), l.collapse(!0), i.removeAllRanges(), i.addRange(l), this.view.ensureCaretVisible();
454
+ const d = this.view.getText();
455
+ this.textModel.setText(d), this.view.syncTrailingNewlineMarkerForText(d);
456
+ const p = Math.min(
449
457
  h + 1,
450
458
  this.textModel.getText().length
451
459
  );
452
460
  try {
453
- const d = this.textModel.offsetToPosition(f);
454
- this.setCursor(d), this.view.ensureCaretVisible();
461
+ const u = this.textModel.offsetToPosition(p);
462
+ this.setCursor(u), this.view.ensureCaretVisible();
455
463
  } catch {
456
464
  }
457
465
  this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
458
466
  this.renderTextWithHighlight(this.textModel.getText(), !1), requestAnimationFrame(() => {
459
467
  try {
460
- const d = this.textModel.offsetToPosition(f);
461
- this.setCursor(d), this.view.ensureCaretVisible();
468
+ const u = this.textModel.offsetToPosition(p);
469
+ this.setCursor(u), this.view.ensureCaretVisible();
462
470
  } catch {
463
471
  }
464
472
  }), this.highlightTimeout = null;
@@ -468,15 +476,15 @@ const F = class L {
468
476
  t.preventDefault(), t.stopPropagation();
469
477
  return;
470
478
  }
471
- for (const s of this.extensions.values())
472
- if (s.onKeyDown && s.onKeyDown(t) === !1) {
479
+ for (const i of this.extensions.values())
480
+ if (i.onKeyDown && i.onKeyDown(t) === !1) {
473
481
  t.preventDefault(), t.stopPropagation();
474
482
  return;
475
483
  }
476
484
  }), e.addEventListener("mousedown", (t) => {
477
485
  this.emit("mousedown", t);
478
- for (const s of this.extensions.values())
479
- if (s.onMouseDown && s.onMouseDown(t) === !1) {
486
+ for (const i of this.extensions.values())
487
+ if (i.onMouseDown && i.onMouseDown(t) === !1) {
480
488
  t.preventDefault(), t.stopPropagation();
481
489
  return;
482
490
  }
@@ -503,8 +511,8 @@ const F = class L {
503
511
  }
504
512
  // Emit events to listeners
505
513
  emit(e, ...t) {
506
- const s = this.eventListeners.get(e);
507
- s && s.forEach((i) => i(...t));
514
+ const i = this.eventListeners.get(e);
515
+ i && i.forEach((s) => s(...t));
508
516
  }
509
517
  // State management
510
518
  getValue() {
@@ -552,12 +560,12 @@ const F = class L {
552
560
  "editor-gutter-border": e === "dark" ? "#3e3e42" : "#e1e5e9"
553
561
  };
554
562
  this.view.applyTheme(t);
555
- const s = this.extensions.get("syntax-highlighting");
556
- if (s && typeof s.setTheme == "function")
563
+ const i = this.extensions.get("syntax-highlighting");
564
+ if (i && typeof i.setTheme == "function")
557
565
  try {
558
- s.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
559
- } catch (i) {
560
- console.warn("Error applying theme to syntax-highlighting extension", i);
566
+ i.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
567
+ } catch (s) {
568
+ console.warn("Error applying theme to syntax-highlighting extension", s);
561
569
  }
562
570
  }
563
571
  setReadOnly(e) {
@@ -574,8 +582,8 @@ const F = class L {
574
582
  t && t.destroy && t.destroy(), this.extensions.delete(e);
575
583
  }
576
584
  executeCommand(e, ...t) {
577
- const s = this.commands.get(e);
578
- s ? s(this, ...t) : console.warn(`Command '${e}' not found`);
585
+ const i = this.commands.get(e);
586
+ i ? i(this, ...t) : console.warn(`Command '${e}' not found`);
579
587
  }
580
588
  // Register a command
581
589
  registerCommand(e, t) {
@@ -583,93 +591,94 @@ const F = class L {
583
591
  }
584
592
  // Search & Navigation
585
593
  search(e, t = {}) {
586
- if (!e) return [];
587
- const s = {
594
+ if (!e)
595
+ return [];
596
+ const i = {
588
597
  query: e,
589
598
  caseSensitive: !1,
590
599
  wholeWord: !1,
591
600
  regex: !1,
592
601
  ...t
593
- }, i = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(n), l = s.caseSensitive ? r : r.toLowerCase(), h = s.caseSensitive ? e : e.toLowerCase();
594
- if (s.regex) {
595
- let a;
602
+ }, s = [], n = this.textModel.getText(), { normalizedText: r, normalizedToRawOffsets: o } = this.buildSearchTextAndOffsetMap(n), a = i.caseSensitive ? r : r.toLowerCase(), h = i.caseSensitive ? e : e.toLowerCase();
603
+ if (i.regex) {
604
+ let l;
596
605
  try {
597
- a = new RegExp(e, s.caseSensitive ? "g" : "gi");
606
+ l = new RegExp(e, i.caseSensitive ? "g" : "gi");
598
607
  } catch {
599
608
  return [];
600
609
  }
601
610
  let c;
602
- for (; (c = a.exec(r)) !== null; ) {
603
- const u = c[0] ?? "";
604
- if (u.length === 0) {
605
- a.lastIndex = c.index + 1;
611
+ for (; (c = l.exec(r)) !== null; ) {
612
+ const d = c[0] ?? "";
613
+ if (d.length === 0) {
614
+ l.lastIndex = c.index + 1;
606
615
  continue;
607
616
  }
608
- const f = c.index, d = c.index + u.length;
609
- s.wholeWord && !this.isWholeWordBoundary(r, f, d) || this.pushSearchResultFromOffsets(
610
- i,
611
- f,
612
- d,
617
+ const p = c.index, u = c.index + d.length;
618
+ i.wholeWord && !this.isWholeWordBoundary(r, p, u) || this.pushSearchResultFromOffsets(
619
+ s,
620
+ p,
621
+ u,
613
622
  r,
614
623
  o
615
624
  );
616
625
  }
617
626
  } else {
618
- let a = 0, c = l.indexOf(h, a);
627
+ let l = 0, c = a.indexOf(h, l);
619
628
  for (; c !== -1; ) {
620
- const u = c + h.length;
621
- !s.wholeWord || this.isWholeWordBoundary(r, c, u) ? (this.pushSearchResultFromOffsets(
622
- i,
629
+ const d = c + h.length;
630
+ !i.wholeWord || this.isWholeWordBoundary(r, c, d) ? (this.pushSearchResultFromOffsets(
631
+ s,
623
632
  c,
624
- u,
633
+ d,
625
634
  r,
626
635
  o
627
- ), a = u) : a = c + 1, c = l.indexOf(h, a);
636
+ ), l = d) : l = c + 1, c = a.indexOf(h, l);
628
637
  }
629
638
  }
630
- return i;
639
+ return s;
631
640
  }
632
- pushSearchResultFromOffsets(e, t, s, i, n) {
633
- const r = n[t] ?? t, o = n[s] ?? r, l = this.textModel.offsetToPosition(r), h = this.textModel.offsetToPosition(o);
641
+ pushSearchResultFromOffsets(e, t, i, s, n) {
642
+ const r = n[t] ?? t, o = n[i] ?? r, a = this.textModel.offsetToPosition(r), h = this.textModel.offsetToPosition(o);
634
643
  e.push({
635
- range: { start: l, end: h },
636
- match: i.substring(t, s)
644
+ range: { start: a, end: h },
645
+ match: s.substring(t, i)
637
646
  });
638
647
  }
639
- isWholeWordBoundary(e, t, s) {
640
- const i = t > 0 ? e[t - 1] : "", n = s < e.length ? e[s] : "";
641
- return !this.isWordChar(i) && !this.isWordChar(n);
648
+ isWholeWordBoundary(e, t, i) {
649
+ const s = t > 0 ? e[t - 1] : "", n = i < e.length ? e[i] : "";
650
+ return !this.isWordChar(s) && !this.isWordChar(n);
642
651
  }
643
652
  isWordChar(e) {
644
653
  return /^[A-Za-z0-9_]$/.test(e);
645
654
  }
646
655
  buildSearchTextAndOffsetMap(e) {
647
- const t = [], s = [0];
648
- let i = 0;
656
+ const t = [], i = [0];
657
+ let s = 0;
649
658
  for (let n = 0; n < e.length; n++) {
650
659
  const r = e[n];
651
- r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), i += 1, s[i] = n + 1);
660
+ r === "​" || r === L.CURSOR_SENTINEL || (t.push(r), s += 1, i[s] = n + 1);
652
661
  }
653
- return s[i] = e.length, {
662
+ return i[s] = e.length, {
654
663
  normalizedText: t.join(""),
655
- normalizedToRawOffsets: s
664
+ normalizedToRawOffsets: i
656
665
  };
657
666
  }
658
667
  replace(e, t) {
659
- const s = this.getValue();
668
+ const i = this.getValue();
660
669
  if (!this.suppressHistory) {
661
670
  const n = this.getCursor().position, r = this.textModel.positionToOffset(n), o = this.getSelection();
662
- let l, h;
663
- o && (l = this.textModel.positionToOffset(o.start), h = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: s, cursorOffset: r, anchorOffset: l, focusOffset: h }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
671
+ let a, h;
672
+ o && (a = this.textModel.positionToOffset(o.start), h = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: i, cursorOffset: r, anchorOffset: a, focusOffset: h }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
664
673
  }
665
- const i = this.textModel.replaceRange(e, t);
666
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [i]);
674
+ const s = this.textModel.replaceRange(e, t);
675
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.expectingProgrammaticCursor = !1, this.emit("change", [s]);
667
676
  }
668
- replaceAll(e, t, s = {}) {
669
- const i = this.search(e, s);
677
+ replaceAll(e, t, i = {}) {
678
+ const s = this.search(e, i);
670
679
  let n = 0;
671
- for (let r = i.length - 1; r >= 0; r--)
672
- this.replace(i[r].range, t), n++;
680
+ for (let r = s.length - 1; r >= 0; r--)
681
+ this.replace(s[r].range, t), n++;
673
682
  return n;
674
683
  }
675
684
  // Folding (basic implementation)
@@ -702,42 +711,42 @@ const F = class L {
702
711
  // and restores it after updating the DOM. Callers that will explicitly set the caret
703
712
  // should pass `false` to avoid stomping programmatic cursor changes.
704
713
  renderTextWithHighlight(e, t = !0) {
705
- const s = this.extensions.get("syntax-highlighting");
706
- if (s && typeof s.highlightHTML == "function")
714
+ const i = this.extensions.get("syntax-highlighting");
715
+ if (i && typeof i.highlightHTML == "function")
707
716
  try {
708
- const i = !t && !this.expectingProgrammaticCursor;
709
- let n, r, o, l;
710
- if (t || i) {
717
+ const s = !t && !this.expectingProgrammaticCursor;
718
+ let n, r, o, a;
719
+ if (t || s) {
711
720
  n = this.getSelection();
712
- const u = this.getCollapsedSelectionOffsetInEditor();
713
- if (u !== void 0)
714
- r = u;
721
+ const d = this.getCollapsedSelectionOffsetInEditor();
722
+ if (d !== void 0)
723
+ r = d;
715
724
  else {
716
- const f = this.getCursor().position;
717
- r = this.textModel.positionToOffset(f);
725
+ const p = this.getCursor().position;
726
+ r = this.textModel.positionToOffset(p);
718
727
  }
719
- n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end));
728
+ n && (o = this.textModel.positionToOffset(n.start), a = this.textModel.positionToOffset(n.end));
720
729
  }
721
- const h = (t || i) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), a = h ? this.insertSentinelAtOffset(e, r) : e, c = s.highlightHTML(a);
722
- typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), this.view.syncTrailingNewlineMarkerForText(e), (t || i) && requestAnimationFrame(() => {
730
+ const h = (t || s) && !n && r !== void 0 && this.hasCollapsedSelectionInEditor(), l = h ? this.insertSentinelAtOffset(e, r) : e, c = i.highlightHTML(l);
731
+ typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && requestAnimationFrame(() => {
723
732
  try {
724
733
  if (h && this.restoreCursorFromSentinel()) {
725
734
  this.view.ensureCaretVisible();
726
735
  return;
727
736
  }
728
- if (n && (o !== void 0 || l !== void 0)) {
729
- const u = o !== void 0 ? o : r, f = l !== void 0 ? l : r, d = Math.min(u, f), g = Math.max(u, f), p = this.textModel.offsetToPosition(d), y = this.textModel.offsetToPosition(g);
730
- this.view.setSelectionRange({ start: p, end: y });
737
+ if (n && (o !== void 0 || a !== void 0)) {
738
+ const d = o !== void 0 ? o : r, p = a !== void 0 ? a : r, u = Math.min(d, p), g = Math.max(d, p), f = this.textModel.offsetToPosition(u), y = this.textModel.offsetToPosition(g);
739
+ this.view.setSelectionRange({ start: f, end: y });
731
740
  } else if (r !== void 0) {
732
- const u = this.textModel.offsetToPosition(r);
733
- this.view.setCursorPosition(u);
741
+ const d = this.textModel.offsetToPosition(r);
742
+ this.view.setCursorPosition(d);
734
743
  }
735
744
  } catch {
736
745
  }
737
746
  });
738
747
  return;
739
- } catch (i) {
740
- console.warn("Syntax highlighting failed, falling back to plain text", i);
748
+ } catch (s) {
749
+ console.warn("Syntax highlighting failed, falling back to plain text", s);
741
750
  }
742
751
  this.view.setText(e);
743
752
  }
@@ -752,27 +761,28 @@ const F = class L {
752
761
  const e = window.getSelection();
753
762
  if (!e || e.rangeCount === 0 || !e.isCollapsed)
754
763
  return;
755
- const t = e.getRangeAt(0), s = this.view.getContentElement();
756
- if (!s.contains(t.commonAncestorContainer))
764
+ const t = e.getRangeAt(0), i = this.view.getContentElement();
765
+ if (!i.contains(t.commonAncestorContainer))
757
766
  return;
758
- const i = t.cloneRange();
759
- return i.selectNodeContents(s), i.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(i.toString()).length;
767
+ const s = t.cloneRange();
768
+ return s.selectNodeContents(i), s.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(s.toString()).length;
760
769
  }
761
770
  stripVirtualMarkers(e) {
762
771
  return e.replace(/\u200B/g, "").split(L.CURSOR_SENTINEL).join("");
763
772
  }
764
773
  insertSentinelAtOffset(e, t) {
765
- const s = Math.max(0, Math.min(t, e.length));
766
- return e.slice(0, s) + L.CURSOR_SENTINEL + e.slice(s);
774
+ const i = Math.max(0, Math.min(t, e.length));
775
+ return e.slice(0, i) + L.CURSOR_SENTINEL + e.slice(i);
767
776
  }
768
777
  restoreCursorFromSentinel() {
769
- const e = this.view.getContentElement(), t = window.getSelection(), s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
770
- let i = s.nextNode(), n = null, r = 0;
771
- for (; i; ) {
772
- const o = i.textContent ?? "", l = o.indexOf(L.CURSOR_SENTINEL);
773
- l !== -1 && (n || (n = i, r = l), i.textContent = o.split(L.CURSOR_SENTINEL).join("")), i = s.nextNode();
778
+ const e = this.view.getContentElement(), t = window.getSelection(), i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
779
+ let s = i.nextNode(), n = null, r = 0;
780
+ for (; s; ) {
781
+ const o = s.textContent ?? "", a = o.indexOf(L.CURSOR_SENTINEL);
782
+ a !== -1 && (n || (n = s, r = a), s.textContent = o.split(L.CURSOR_SENTINEL).join("")), s = i.nextNode();
774
783
  }
775
- if (!n || !t) return !1;
784
+ if (!n || !t)
785
+ return !1;
776
786
  try {
777
787
  const o = document.createRange();
778
788
  return o.setStart(n, r), o.collapse(!0), t.removeAllRanges(), t.addRange(o), !0;
@@ -790,20 +800,21 @@ const F = class L {
790
800
  }
791
801
  // History: undo/redo
792
802
  undo() {
793
- if (this.undoStack.length === 0) return;
803
+ if (this.undoStack.length === 0)
804
+ return;
794
805
  const e = this.undoStack.pop(), t = { text: this.getValue(), cursorOffset: this.textModel.positionToOffset(this.getCursor().position) };
795
806
  this.redoStack.push(t);
796
807
  try {
797
808
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
798
- let s, i;
799
- typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
809
+ let i, s;
810
+ typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
800
811
  try {
801
- if (i != null)
812
+ if (s != null)
802
813
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
803
- const n = e.anchorOffset !== void 0 ? e.anchorOffset : i, r = e.focusOffset !== void 0 ? e.focusOffset : i, o = Math.min(n, r), l = Math.max(n, r), h = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
804
- this.setSelection({ start: h, end: a });
814
+ const n = e.anchorOffset !== void 0 ? e.anchorOffset : s, r = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(n, r), a = Math.max(n, r), h = this.textModel.offsetToPosition(o), l = this.textModel.offsetToPosition(a);
815
+ this.setSelection({ start: h, end: l });
805
816
  } else {
806
- const n = this.textModel.offsetToPosition(i);
817
+ const n = this.textModel.offsetToPosition(s);
807
818
  this.setCursor(n);
808
819
  }
809
820
  } catch {
@@ -816,20 +827,21 @@ const F = class L {
816
827
  }
817
828
  }
818
829
  redo() {
819
- if (this.redoStack.length === 0) return;
830
+ if (this.redoStack.length === 0)
831
+ return;
820
832
  const e = this.redoStack.pop(), t = { text: this.getValue(), cursorOffset: this.textModel.positionToOffset(this.getCursor().position) };
821
833
  this.undoStack.push(t);
822
834
  try {
823
835
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
824
- let s, i;
825
- typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
836
+ let i, s;
837
+ typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
826
838
  try {
827
- if (i != null)
839
+ if (s != null)
828
840
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
829
- const n = e.anchorOffset !== void 0 ? e.anchorOffset : i, r = e.focusOffset !== void 0 ? e.focusOffset : i, o = Math.min(n, r), l = Math.max(n, r), h = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
830
- this.setSelection({ start: h, end: a });
841
+ const n = e.anchorOffset !== void 0 ? e.anchorOffset : s, r = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(n, r), a = Math.max(n, r), h = this.textModel.offsetToPosition(o), l = this.textModel.offsetToPosition(a);
842
+ this.setSelection({ start: h, end: l });
831
843
  } else {
832
- const n = this.textModel.offsetToPosition(i);
844
+ const n = this.textModel.offsetToPosition(s);
833
845
  this.setCursor(n);
834
846
  }
835
847
  } catch {
@@ -843,43 +855,46 @@ const F = class L {
843
855
  }
844
856
  // Insert a tab character or spaces at current cursor
845
857
  insertTab() {
846
- if (this.config.readOnly) return;
847
- 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);
858
+ if (this.config.readOnly)
859
+ return;
860
+ 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);
848
861
  if (!this.suppressHistory) {
849
862
  const r = this.getSelection();
850
- let o, l;
851
- 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;
863
+ let o, a;
864
+ r && (o = this.textModel.positionToOffset(r.start), a = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: a }), this.redoStack.length = 0;
852
865
  }
853
866
  this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(n), setTimeout(() => {
854
867
  this.expectingProgrammaticCursor = !1;
855
- }, 20), this.emit("change", [i]);
868
+ }, 20), this.emit("change", [s]);
856
869
  }
857
870
  // Insert a newline at current cursor position
858
871
  insertNewLine() {
859
- if (this.config.readOnly) return;
860
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = this.textModel.insertText(e, `
861
- `), i = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
872
+ if (this.config.readOnly)
873
+ return;
874
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = this.textModel.insertText(e, `
875
+ `), s = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
862
876
  if (!this.suppressHistory) {
863
877
  const n = this.getSelection();
864
878
  let r, o;
865
879
  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;
866
880
  }
867
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(i), setTimeout(() => {
881
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(s), setTimeout(() => {
868
882
  this.expectingProgrammaticCursor = !1;
869
- }, 20), this.emit("change", [s]);
883
+ }, 20), this.emit("change", [i]);
870
884
  }
871
885
  // Events
872
886
  on(e, t) {
873
887
  this.eventListeners.has(e) || this.eventListeners.set(e, []), this.eventListeners.get(e).push(t);
874
888
  }
875
889
  off(e, t) {
876
- if (!this.eventListeners.has(e)) return;
877
- const s = this.eventListeners.get(e);
890
+ if (!this.eventListeners.has(e))
891
+ return;
892
+ const i = this.eventListeners.get(e);
878
893
  if (t) {
879
- const i = s.indexOf(t);
880
- i !== -1 && s.splice(i, 1);
894
+ const s = i.indexOf(t);
895
+ s !== -1 && i.splice(s, 1);
881
896
  } else
882
- s.length = 0;
897
+ i.length = 0;
883
898
  }
884
899
  };
885
900
  F.CURSOR_SENTINEL = "";
@@ -892,17 +907,19 @@ class J {
892
907
  this.editor = e;
893
908
  }
894
909
  handleKeyDown(e) {
895
- if (!this.editor) return;
910
+ if (!this.editor)
911
+ return;
896
912
  const t = this.findMatchingBinding(e);
897
913
  if (t)
898
914
  return this.editor.executeCommand(t.command), e.preventDefault(), e.stopPropagation(), !1;
899
915
  }
900
916
  findMatchingBinding(e) {
901
- const { key: t, ctrlKey: s, altKey: i, shiftKey: n, metaKey: r } = e, o = String(t).toLowerCase(), l = this.keymap[o];
902
- if (!l) return null;
903
- for (const h of l) {
904
- const a = h.ctrlKey === void 0 || h.ctrlKey === s, c = h.altKey === void 0 || h.altKey === i, u = h.shiftKey === void 0 || h.shiftKey === n, f = h.metaKey === void 0 || h.metaKey === r;
905
- if (a && c && u && f)
917
+ const { key: t, ctrlKey: i, altKey: s, shiftKey: n, metaKey: r } = e, o = String(t).toLowerCase(), a = this.keymap[o];
918
+ if (!a)
919
+ return null;
920
+ for (const h of a) {
921
+ const l = 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;
922
+ if (l && c && d && p)
906
923
  return h;
907
924
  }
908
925
  return null;
@@ -915,12 +932,12 @@ class J {
915
932
  const e = {};
916
933
  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;
917
934
  }
918
- addBinding(e, t, s, i) {
935
+ addBinding(e, t, i, s) {
919
936
  const n = t.toLowerCase();
920
937
  e[n] || (e[n] = []), e[n].push({
921
938
  key: n,
922
- command: i,
923
- ...s
939
+ command: s,
940
+ ...i
924
941
  });
925
942
  }
926
943
  // Public API for customizing keymap
@@ -929,23 +946,23 @@ class J {
929
946
  }
930
947
  addKeyBinding(e) {
931
948
  const t = e.key.toLowerCase();
932
- this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((s) => s.command !== e.command), this.keymap[t].push({
949
+ this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((i) => i.command !== e.command), this.keymap[t].push({
933
950
  ...e,
934
951
  key: t
935
952
  });
936
953
  }
937
954
  removeKeyBinding(e, t) {
938
- const s = e.toLowerCase();
939
- 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];
955
+ const i = e.toLowerCase();
956
+ 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];
940
957
  }
941
958
  getKeymap() {
942
959
  return { ...this.keymap };
943
960
  }
944
961
  getBindingsForCommand(e) {
945
962
  const t = [];
946
- for (const s in this.keymap)
947
- for (const i of this.keymap[s])
948
- i.command === e && t.push({ ...i });
963
+ for (const i in this.keymap)
964
+ for (const s of this.keymap[i])
965
+ s.command === e && t.push({ ...s });
949
966
  return t;
950
967
  }
951
968
  getPlatformInfo() {
@@ -964,13 +981,13 @@ class Y {
964
981
  }
965
982
  setup(e) {
966
983
  e.on("change", (t) => {
967
- const s = {
984
+ const i = {
968
985
  changes: t,
969
986
  selection: e.getSelection(),
970
987
  effects: [],
971
988
  annotations: []
972
989
  };
973
- this.transactions.push(s);
990
+ this.transactions.push(i);
974
991
  });
975
992
  }
976
993
  getTransactions() {
@@ -992,18 +1009,21 @@ class G {
992
1009
  }), this.updateLineNumbers();
993
1010
  }
994
1011
  createLineNumbers() {
995
- if (!this.editor) return;
1012
+ if (!this.editor)
1013
+ return;
996
1014
  const e = this.editor.getView().getLineNumbersElement();
997
1015
  e && (this.lineNumbersElement = e);
998
1016
  }
999
1017
  updateLineNumbers() {
1000
- if (!this.lineNumbersElement || !this.editor || !this.isEnabled) return;
1018
+ if (!this.lineNumbersElement || !this.editor || !this.isEnabled)
1019
+ return;
1001
1020
  const e = this.editor.getValue().split(`
1002
- `).length, t = Array.from({ length: Math.max(e, 20) }, (s, i) => i + 1);
1003
- this.lineNumbersElement.innerHTML = t.map((s) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("");
1021
+ `).length, t = Array.from({ length: Math.max(e, 20) }, (i, s) => s + 1);
1022
+ this.lineNumbersElement.innerHTML = t.map((i) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${i}</div>`).join("");
1004
1023
  }
1005
1024
  toggle() {
1006
- if (!this.editor) return;
1025
+ if (!this.editor)
1026
+ return;
1007
1027
  this.isEnabled = !this.isEnabled, this.lineNumbersElement && (this.lineNumbersElement.style.display = this.isEnabled ? "block" : "none");
1008
1028
  const e = this.editor.getView().getContentElement();
1009
1029
  e && (e.style.marginLeft = this.isEnabled ? "60px" : "0"), this.updateLineNumbers();
@@ -1085,8 +1105,8 @@ const W = class m {
1085
1105
  this.findPrev();
1086
1106
  }), e.registerCommand("replace", () => {
1087
1107
  this.showReplace();
1088
- }), e.registerCommand("replaceAll", (t, s) => {
1089
- this.replaceAll(t, s);
1108
+ }), e.registerCommand("replaceAll", (t, i) => {
1109
+ this.replaceAll(t, i);
1090
1110
  }), this.editorChangeHandler = () => {
1091
1111
  !this.isVisible || !this.currentQuery || this.scheduleLiveRefresh(!0);
1092
1112
  }, e.on("change", this.editorChangeHandler);
@@ -1101,12 +1121,14 @@ const W = class m {
1101
1121
  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();
1102
1122
  }
1103
1123
  createSearchUI() {
1104
- if (!this.editor) return;
1124
+ if (!this.editor)
1125
+ return;
1105
1126
  const e = this.editor.getView().getContentElement(), t = e.closest(
1106
1127
  this.editorContainerSelector
1107
- ), s = e.closest(".rte-source-editor-modal") || t || e.parentElement;
1108
- if (!s) return;
1109
- 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 = `
1128
+ ), i = e.closest(".rte-source-editor-modal") || t || e.parentElement;
1129
+ if (!i)
1130
+ return;
1131
+ 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 = `
1110
1132
  <div class="${m.css.row}">
1111
1133
  <input type="text" class="${m.css.findInput} ${m.css.inputBase}" placeholder="Find..." />
1112
1134
  <button class="${m.css.prevButton} ${m.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
@@ -1133,7 +1155,7 @@ const W = class m {
1133
1155
  </div>
1134
1156
  <input type="text" class="${m.css.replaceInput} ${m.css.inputBase} ${m.css.replaceInputLayout}" placeholder="Replace with..." />
1135
1157
  `;
1136
- const i = this.searchUI.querySelector(
1158
+ const s = this.searchUI.querySelector(
1137
1159
  `.${m.css.findInput}`
1138
1160
  ), n = this.searchUI.querySelector(
1139
1161
  `.${m.css.replaceInput}`
@@ -1141,41 +1163,41 @@ const W = class m {
1141
1163
  `.${m.css.prevButton}`
1142
1164
  ), o = this.searchUI.querySelector(
1143
1165
  `.${m.css.nextButton}`
1144
- ), l = this.searchUI.querySelector(
1166
+ ), a = this.searchUI.querySelector(
1145
1167
  `.${m.css.closeButton}`
1146
1168
  ), h = this.searchUI.querySelector(
1147
1169
  `.${m.css.status}`
1148
- ), a = this.searchUI.querySelector(
1170
+ ), l = this.searchUI.querySelector(
1149
1171
  `.${m.css.mode}`
1150
1172
  ), c = this.searchUI.querySelector(
1151
1173
  `.${m.css.caseSensitive}`
1152
- ), u = this.searchUI.querySelector(
1174
+ ), d = this.searchUI.querySelector(
1153
1175
  `.${m.css.wholeWord}`
1154
- ), f = this.searchUI.querySelector(
1176
+ ), p = this.searchUI.querySelector(
1155
1177
  `.${m.css.regex}`
1156
1178
  );
1157
- this.findInput = i, this.replaceInputEl = n, this.statusDiv = h, this.modeDiv = a, this.caseSensitiveInput = c, this.wholeWordInput = u, this.regexInput = f, c.checked = !!this.searchOptions.caseSensitive, u.checked = !!this.searchOptions.wholeWord, f.checked = !!this.searchOptions.regex, i.addEventListener("input", () => {
1179
+ this.findInput = s, this.replaceInputEl = n, this.statusDiv = h, this.modeDiv = l, 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", () => {
1158
1180
  this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
1159
- const g = i.value;
1181
+ const g = s.value;
1160
1182
  this.searchDebounceTimer = setTimeout(() => {
1161
1183
  this.performSearch(g, !1, !1);
1162
1184
  }, 120);
1163
1185
  });
1164
- const d = () => {
1165
- this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = u.checked, this.searchOptions.regex = f.checked;
1166
- const g = i.value;
1186
+ const u = () => {
1187
+ this.searchOptions.caseSensitive = c.checked, this.searchOptions.wholeWord = d.checked, this.searchOptions.regex = p.checked;
1188
+ const g = s.value;
1167
1189
  g.trim() ? this.performSearch(g, !1, !1) : this.performSearch("", !1, !1);
1168
1190
  };
1169
- c.addEventListener("change", d), u.addEventListener("change", d), f.addEventListener("change", d), i.addEventListener("keydown", (g) => {
1191
+ c.addEventListener("change", u), d.addEventListener("change", u), p.addEventListener("change", u), s.addEventListener("keydown", (g) => {
1170
1192
  g.key === "Enter" ? (g.preventDefault(), g.shiftKey ? this.findPrev() : this.findNext()) : g.key === "Escape" && (g.preventDefault(), this.hideSearch());
1171
1193
  }), n.addEventListener("keydown", (g) => {
1172
- 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());
1173
- }), r.addEventListener("click", () => this.findPrev()), o.addEventListener("click", () => this.findNext()), l.addEventListener("click", () => this.hideSearch()), s.appendChild(this.searchUI);
1194
+ 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());
1195
+ }), r.addEventListener("click", () => this.findPrev()), o.addEventListener("click", () => this.findNext()), a.addEventListener("click", () => this.hideSearch()), i.appendChild(this.searchUI);
1174
1196
  }
1175
1197
  updateModeHint(e) {
1176
1198
  this.modeDiv && (this.modeDiv.textContent = e ? `Replace: move next ${this.config.replaceAndFindNext ? "ON" : "OFF"}` : "Find mode");
1177
1199
  }
1178
- performSearch(e, t, s) {
1200
+ performSearch(e, t, i) {
1179
1201
  if (!this.editor || !e.trim()) {
1180
1202
  this.currentQuery = "", this.currentResults = [], this.currentIndex = -1, this.clearHighlights(), this.updateStatus("");
1181
1203
  return;
@@ -1185,12 +1207,12 @@ const W = class m {
1185
1207
  return;
1186
1208
  }
1187
1209
  this.currentQuery = e;
1188
- const i = this.currentIndex, n = this.editor.search(e, this.searchOptions);
1210
+ const s = this.currentIndex, n = this.editor.search(e, this.searchOptions);
1189
1211
  if (this.currentResults = n, n.length === 0) {
1190
1212
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("No matches");
1191
1213
  return;
1192
1214
  }
1193
- t && i >= 0 ? this.currentIndex = Math.min(i, n.length - 1) : this.currentIndex = 0, this.updateHighlights(s);
1215
+ t && s >= 0 ? this.currentIndex = Math.min(s, n.length - 1) : this.currentIndex = 0, this.updateHighlights(i);
1194
1216
  }
1195
1217
  findNext() {
1196
1218
  if (this.currentResults.length === 0) {
@@ -1207,26 +1229,29 @@ const W = class m {
1207
1229
  this.currentIndex = this.currentIndex <= 0 ? this.currentResults.length - 1 : this.currentIndex - 1, this.updateHighlights(!0);
1208
1230
  }
1209
1231
  replaceCurrent(e, t) {
1210
- 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;
1211
- const s = this.currentResults[this.currentIndex];
1212
- if (!s) return;
1213
- const i = this.computeReplacementRange(s.range.start, t);
1214
- if (this.editor.replace(s.range, t), this.config.replaceAndFindNext) {
1232
+ if (!this.editor || !e.trim() || ((this.currentQuery !== e || this.currentResults.length === 0) && this.performSearch(e, !1, !0), this.currentIndex < 0 || this.currentResults.length === 0))
1233
+ return;
1234
+ const i = this.currentResults[this.currentIndex];
1235
+ if (!i)
1236
+ return;
1237
+ const s = this.computeReplacementRange(i.range.start, t);
1238
+ if (this.editor.replace(i.range, t), this.config.replaceAndFindNext) {
1215
1239
  this.currentQuery = e;
1216
1240
  const n = this.editor.search(e, this.searchOptions);
1217
1241
  if (this.currentResults = n, n.length === 0) {
1218
1242
  this.currentIndex = -1, this.clearHighlights(), this.updateStatus("Replaced current occurrence"), this.restoreReplaceInputFocus();
1219
1243
  return;
1220
1244
  }
1221
- this.currentIndex = this.findNextResultIndexAfter(i.end, n), this.updateHighlights(!0);
1245
+ this.currentIndex = this.findNextResultIndexAfter(s.end, n), this.updateHighlights(!0);
1222
1246
  } else
1223
- this.scrollLogicalRangeIntoView(i, !0), this.performSearch(e, !0, !1);
1247
+ this.scrollLogicalRangeIntoView(s, !0), this.performSearch(e, !0, !1);
1224
1248
  this.currentResults.length > 0 || this.showTransientStatus("Replaced current occurrence"), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1225
1249
  }
1226
1250
  replaceAll(e, t) {
1227
- if (!this.editor || !e.trim()) return;
1228
- const s = this.editor.replaceAll(e, t, this.searchOptions);
1229
- this.performSearch(e, !1, !1), this.showTransientStatus(`Replaced ${s} occurrence${s === 1 ? "" : "s"}`), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1251
+ if (!this.editor || !e.trim())
1252
+ return;
1253
+ const i = this.editor.replaceAll(e, t, this.searchOptions);
1254
+ this.performSearch(e, !1, !1), this.showTransientStatus(`Replaced ${i} occurrence${i === 1 ? "" : "s"}`), this.restoreReplaceInputFocus(), this.revealActiveResultAfterFocusRestore();
1230
1255
  }
1231
1256
  updateHighlights(e) {
1232
1257
  if (this.clearHighlights(), this.currentResults.length === 0 || this.currentIndex === -1 || !this.editor)
@@ -1238,19 +1263,21 @@ const W = class m {
1238
1263
  ));
1239
1264
  }
1240
1265
  navigateToResult(e, t) {
1241
- if (!this.editor) return;
1242
- const s = document.activeElement, i = !!s && (s === this.findInput || s === this.replaceInputEl);
1266
+ if (!this.editor)
1267
+ return;
1268
+ const i = document.activeElement, s = !!i && (i === this.findInput || i === this.replaceInputEl);
1243
1269
  t ? (this.editor.setSelection(e.range), this.centerCurrentSelectionInView()) : this.scrollResultIntoView(e);
1244
1270
  const n = this.editor.getView();
1245
- t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && i && s && requestAnimationFrame(() => {
1246
- this.focusWithoutScrolling(s);
1271
+ t && typeof n.ensureCaretVisible == "function" && n.ensureCaretVisible(), t && s && i && requestAnimationFrame(() => {
1272
+ this.focusWithoutScrolling(i);
1247
1273
  });
1248
1274
  }
1249
1275
  clearHighlights() {
1276
+ var e, t;
1250
1277
  if (this.hasCustomHighlightSupport)
1251
1278
  try {
1252
- const e = CSS;
1253
- e.highlights?.delete(this.highlightMatchName), e.highlights?.delete(this.highlightActiveName);
1279
+ const i = CSS;
1280
+ (e = i.highlights) == null || e.delete(this.highlightMatchName), (t = i.highlights) == null || t.delete(this.highlightActiveName);
1254
1281
  } catch {
1255
1282
  }
1256
1283
  }
@@ -1258,34 +1285,37 @@ const W = class m {
1258
1285
  this.scrollLogicalRangeIntoView(e.range, !0);
1259
1286
  }
1260
1287
  scrollLogicalRangeIntoView(e, t) {
1261
- if (!this.editor) return;
1262
- const s = this.editor.getView().getContentElement(), i = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(i), o = this.buildTextNodeIndex(s);
1263
- if (o.length === 0) return;
1264
- const l = this.toDomRange(e, n, r, o);
1265
- if (!l) return;
1266
- const h = l.startContainer.nodeType === Node.TEXT_NODE ? l.startContainer.parentElement : l.startContainer, a = this.resolveScrollContainer(s);
1267
- if (a) {
1268
- const c = l.getClientRects()[0] || l.getBoundingClientRect(), u = a.getBoundingClientRect(), f = a.scrollTop + (c.top - u.top) - u.height / 2 + c.height / 2, d = 18;
1269
- let g = t ? f : a.scrollTop, p = a.scrollLeft;
1270
- const y = a.scrollLeft + (c.left - u.left), k = y + c.width;
1271
- c.right > u.right - d ? p = k - u.width + d : c.left < u.left + d && (p = Math.max(0, y - d));
1272
- const v = Math.max(0, a.scrollHeight - a.clientHeight), C = Math.max(0, a.scrollWidth - a.clientWidth);
1273
- if (g = Math.min(v, Math.max(0, g)), p = Math.min(C, Math.max(0, p)), v === 0 && C === 0) {
1274
- h?.scrollIntoView({
1288
+ if (!this.editor)
1289
+ return;
1290
+ const i = this.editor.getView().getContentElement(), s = this.editor.getValue(), { lineStarts: n, lines: r } = this.buildLineStarts(s), o = this.buildTextNodeIndex(i);
1291
+ if (o.length === 0)
1292
+ return;
1293
+ const a = this.toDomRange(e, n, r, o);
1294
+ if (!a)
1295
+ return;
1296
+ const h = a.startContainer.nodeType === Node.TEXT_NODE ? a.startContainer.parentElement : a.startContainer, l = this.resolveScrollContainer(i);
1297
+ if (l) {
1298
+ const c = a.getClientRects()[0] || a.getBoundingClientRect(), d = l.getBoundingClientRect(), p = l.scrollTop + (c.top - d.top) - d.height / 2 + c.height / 2, u = 18;
1299
+ let g = t ? p : l.scrollTop, f = l.scrollLeft;
1300
+ const y = l.scrollLeft + (c.left - d.left), k = y + c.width;
1301
+ c.right > d.right - u ? f = k - d.width + u : c.left < d.left + u && (f = Math.max(0, y - u));
1302
+ const v = Math.max(0, l.scrollHeight - l.clientHeight), C = Math.max(0, l.scrollWidth - l.clientWidth);
1303
+ if (g = Math.min(v, Math.max(0, g)), f = Math.min(C, Math.max(0, f)), v === 0 && C === 0) {
1304
+ h == null || h.scrollIntoView({
1275
1305
  block: t ? "center" : "nearest",
1276
1306
  inline: "nearest",
1277
1307
  behavior: "smooth"
1278
1308
  });
1279
1309
  return;
1280
1310
  }
1281
- (g !== a.scrollTop || p !== a.scrollLeft) && a.scrollTo({
1311
+ (g !== l.scrollTop || f !== l.scrollLeft) && l.scrollTo({
1282
1312
  top: g,
1283
- left: p,
1313
+ left: f,
1284
1314
  behavior: "smooth"
1285
1315
  });
1286
1316
  return;
1287
1317
  }
1288
- h?.scrollIntoView({
1318
+ h == null || h.scrollIntoView({
1289
1319
  block: t ? "center" : "nearest",
1290
1320
  inline: "nearest",
1291
1321
  behavior: "smooth"
@@ -1303,61 +1333,67 @@ const W = class m {
1303
1333
  });
1304
1334
  }
1305
1335
  centerCurrentSelectionInView() {
1306
- if (!this.editor) return;
1336
+ if (!this.editor)
1337
+ return;
1307
1338
  const e = this.editor.getView().getContentElement(), t = this.resolveScrollContainer(e);
1308
- if (!t) return;
1309
- const s = window.getSelection();
1310
- if (!s || s.rangeCount === 0) return;
1311
- const i = s.getRangeAt(0).cloneRange(), n = i.getClientRects()[0] || i.getBoundingClientRect();
1312
- if (!n) return;
1313
- 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));
1339
+ if (!t)
1340
+ return;
1341
+ const i = window.getSelection();
1342
+ if (!i || i.rangeCount === 0)
1343
+ return;
1344
+ const s = i.getRangeAt(0).cloneRange(), n = s.getClientRects()[0] || s.getBoundingClientRect();
1345
+ if (!n)
1346
+ return;
1347
+ const r = t.getBoundingClientRect(), o = 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, o));
1314
1348
  h !== t.scrollTop && t.scrollTo({
1315
1349
  top: h,
1316
1350
  behavior: "smooth"
1317
1351
  });
1318
1352
  }
1319
1353
  computeReplacementRange(e, t) {
1320
- const s = t.replace(/\r\n?/g, `
1321
- `), i = s.split(`
1354
+ const i = t.replace(/\r\n?/g, `
1355
+ `), s = i.split(`
1322
1356
  `);
1323
1357
  let n;
1324
- return i.length <= 1 ? (n = {
1358
+ return s.length <= 1 ? (n = {
1325
1359
  start: e,
1326
1360
  end: {
1327
1361
  line: e.line,
1328
- column: e.column + s.length
1362
+ column: e.column + i.length
1329
1363
  }
1330
1364
  }, this.clampRangeToDocument(n)) : (n = {
1331
1365
  start: e,
1332
1366
  end: {
1333
- line: e.line + i.length - 1,
1334
- column: i[i.length - 1].length
1367
+ line: e.line + s.length - 1,
1368
+ column: s[s.length - 1].length
1335
1369
  }
1336
1370
  }, this.clampRangeToDocument(n));
1337
1371
  }
1338
1372
  findNextResultIndexAfter(e, t) {
1339
- for (let s = 0; s < t.length; s++)
1340
- if (this.comparePositions(t[s].range.start, e) >= 0)
1341
- return s;
1373
+ for (let i = 0; i < t.length; i++)
1374
+ if (this.comparePositions(t[i].range.start, e) >= 0)
1375
+ return i;
1342
1376
  return 0;
1343
1377
  }
1344
1378
  comparePositions(e, t) {
1345
1379
  return e.line !== t.line ? e.line - t.line : e.column - t.column;
1346
1380
  }
1347
1381
  clampRangeToDocument(e) {
1348
- const t = this.editor;
1349
- if (!t) return e;
1350
- const s = t.getValue().split(`
1351
- `), 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)), o = Math.max(
1382
+ var t, i;
1383
+ const s = this.editor;
1384
+ if (!s)
1385
+ return e;
1386
+ const n = s.getValue().split(`
1387
+ `), r = Math.max(0, n.length - 1), o = Math.max(0, Math.min(e.start.line, r)), a = Math.max(0, Math.min(e.end.line, r)), h = Math.max(
1352
1388
  0,
1353
- Math.min(e.start.column, s[n]?.length || 0)
1389
+ Math.min(e.start.column, ((t = n[o]) == null ? void 0 : t.length) || 0)
1354
1390
  ), l = Math.max(
1355
1391
  0,
1356
- Math.min(e.end.column, s[r]?.length || 0)
1392
+ Math.min(e.end.column, ((i = n[a]) == null ? void 0 : i.length) || 0)
1357
1393
  );
1358
1394
  return {
1359
- start: { line: n, column: o },
1360
- end: { line: r, column: l }
1395
+ start: { line: o, column: h },
1396
+ end: { line: a, column: l }
1361
1397
  };
1362
1398
  }
1363
1399
  focusWithoutScrolling(e) {
@@ -1367,35 +1403,36 @@ const W = class m {
1367
1403
  });
1368
1404
  } catch {
1369
1405
  const t = [];
1370
- let s = e.parentElement;
1371
- for (; s; )
1372
- this.canScroll(s) && t.push({
1373
- el: s,
1374
- top: s.scrollTop,
1375
- left: s.scrollLeft
1376
- }), s = s.parentElement;
1377
- const i = window.scrollX, n = window.scrollY;
1406
+ let i = e.parentElement;
1407
+ for (; i; )
1408
+ this.canScroll(i) && t.push({
1409
+ el: i,
1410
+ top: i.scrollTop,
1411
+ left: i.scrollLeft
1412
+ }), i = i.parentElement;
1413
+ const s = window.scrollX, n = window.scrollY;
1378
1414
  e.focus();
1379
1415
  for (let r = 0; r < t.length; r++) {
1380
1416
  const o = t[r];
1381
1417
  o.el.scrollTop = o.top, o.el.scrollLeft = o.left;
1382
1418
  }
1383
- window.scrollTo(i, n);
1419
+ window.scrollTo(s, n);
1384
1420
  }
1385
1421
  }
1386
1422
  findScrollContainer(e) {
1387
1423
  let t = e;
1388
1424
  for (; t; ) {
1389
- const s = window.getComputedStyle(t).overflowY;
1390
- if ((s === "auto" || s === "scroll") && t.scrollHeight > t.clientHeight)
1425
+ const i = window.getComputedStyle(t).overflowY;
1426
+ if ((i === "auto" || i === "scroll") && t.scrollHeight > t.clientHeight)
1391
1427
  return t;
1392
1428
  t = t.parentElement;
1393
1429
  }
1394
1430
  return null;
1395
1431
  }
1396
1432
  resolveScrollContainer(e) {
1397
- const t = this.editor?.getView()?.getScrollElement?.() || null;
1398
- return t && this.canScroll(t) ? t : this.findScrollContainer(e);
1433
+ var t, i;
1434
+ 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;
1435
+ return n && this.canScroll(n) ? n : this.findScrollContainer(e);
1399
1436
  }
1400
1437
  canScroll(e) {
1401
1438
  return e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth;
@@ -1409,120 +1446,127 @@ const W = class m {
1409
1446
  applyCustomHighlights() {
1410
1447
  if (!this.editor || !this.hasCustomHighlightSupport || this.currentResults.length === 0)
1411
1448
  return;
1412
- const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: s, lines: i } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
1413
- if (n.length === 0) return;
1449
+ const e = this.editor.getView().getContentElement(), t = this.editor.getValue(), { lineStarts: i, lines: s } = this.buildLineStarts(t), n = this.buildTextNodeIndex(e);
1450
+ if (n.length === 0)
1451
+ return;
1414
1452
  const r = this.buildVisibleDocumentText(n), o = [];
1415
- let l = null;
1453
+ let a = null;
1416
1454
  const h = Math.min(this.currentResults.length, this.maxCustomHighlightRanges);
1417
- for (let a = 0; a < h; a++) {
1418
- const c = this.currentResults[a], u = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, f = this.toDomRange(
1455
+ for (let l = 0; l < h; l++) {
1456
+ const c = this.currentResults[l], d = this.searchOptions.regex ? c.match || this.currentQuery : this.currentQuery || c.match, p = this.toDomRange(
1419
1457
  c.range,
1420
- s,
1421
1458
  i,
1459
+ s,
1422
1460
  n,
1423
1461
  r,
1424
- u
1462
+ d
1425
1463
  );
1426
- f && (o.push(f), a === this.currentIndex && (l = f));
1464
+ p && (o.push(p), l === this.currentIndex && (a = p));
1427
1465
  }
1428
1466
  if (o.length !== 0)
1429
1467
  try {
1430
- const a = CSS, c = window.Highlight;
1431
- if (!a.highlights || !c) return;
1432
- a.highlights.set(this.highlightMatchName, new c(...o)), l && a.highlights.set(this.highlightActiveName, new c(l));
1468
+ const l = CSS, c = window.Highlight;
1469
+ if (!l.highlights || !c)
1470
+ return;
1471
+ l.highlights.set(this.highlightMatchName, new c(...o)), a && l.highlights.set(this.highlightActiveName, new c(a));
1433
1472
  } catch {
1434
1473
  }
1435
1474
  }
1436
1475
  buildLineStarts(e) {
1437
1476
  const t = e.split(`
1438
- `), s = new Array(t.length);
1439
- let i = 0;
1477
+ `), i = new Array(t.length);
1478
+ let s = 0;
1440
1479
  for (let n = 0; n < t.length; n++)
1441
- s[n] = i, i += t[n].length + 1;
1442
- return { lineStarts: s, lines: t };
1480
+ i[n] = s, s += t[n].length + 1;
1481
+ return { lineStarts: i, lines: t };
1443
1482
  }
1444
- positionToOffset(e, t, s) {
1445
- const i = Math.max(0, Math.min(e.line, s.length - 1)), n = Math.max(0, Math.min(e.column, s[i]?.length || 0));
1446
- return t[i] + n;
1483
+ positionToOffset(e, t, i) {
1484
+ var s;
1485
+ 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));
1486
+ return t[n] + r;
1447
1487
  }
1448
1488
  buildTextNodeIndex(e) {
1449
- const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), s = [];
1450
- let i = 0, n;
1489
+ const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), i = [];
1490
+ let s = 0, n;
1451
1491
  for (; n = t.nextNode(); ) {
1452
- const r = n;
1453
- if (r.parentElement?.hasAttribute(this.trailingMarkerAttr))
1492
+ const r = n, o = r.parentElement;
1493
+ if (o != null && o.hasAttribute(this.trailingMarkerAttr))
1454
1494
  continue;
1455
- const o = r.textContent || "", l = this.buildVisibleToDomMap(o), h = Math.max(0, l.length - 1);
1456
- h === 0 && o.length === 0 || (s.push({
1495
+ const a = r.textContent || "", h = this.buildVisibleToDomMap(a), l = Math.max(0, h.length - 1);
1496
+ l === 0 && a.length === 0 || (i.push({
1457
1497
  node: r,
1458
- start: i,
1459
- end: i + h,
1460
- visibleToDom: l
1461
- }), i += h);
1498
+ start: s,
1499
+ end: s + l,
1500
+ visibleToDom: h
1501
+ }), s += l);
1462
1502
  }
1463
- return s;
1503
+ return i;
1464
1504
  }
1465
1505
  resolveDomPoint(e, t) {
1466
- const s = Math.max(0, e);
1467
- for (let n = 0; n < t.length; n++) {
1468
- const r = t[n];
1469
- if (s <= r.end) {
1470
- const o = Math.max(0, s - r.start), l = r.visibleToDom[o] ?? r.node.textContent?.length ?? 0;
1506
+ var i, s;
1507
+ const n = Math.max(0, e);
1508
+ for (let o = 0; o < t.length; o++) {
1509
+ const a = t[o];
1510
+ if (n <= a.end) {
1511
+ const h = Math.max(0, n - a.start), l = a.visibleToDom[h] ?? ((i = a.node.textContent) == null ? void 0 : i.length) ?? 0;
1471
1512
  return {
1472
- node: r.node,
1513
+ node: a.node,
1473
1514
  offset: l
1474
1515
  };
1475
1516
  }
1476
1517
  }
1477
- const i = t[t.length - 1];
1478
- return i ? {
1479
- node: i.node,
1480
- offset: i.visibleToDom[i.visibleToDom.length - 1] ?? i.node.textContent?.length ?? 0
1518
+ const r = t[t.length - 1];
1519
+ return r ? {
1520
+ node: r.node,
1521
+ offset: r.visibleToDom[r.visibleToDom.length - 1] ?? ((s = r.node.textContent) == null ? void 0 : s.length) ?? 0
1481
1522
  } : null;
1482
1523
  }
1483
- toDomRange(e, t, s, i, n, r) {
1484
- const o = this.positionToOffset(e.start, t, s), l = this.positionToOffset(e.end, t, s);
1485
- let h = Math.min(o, l), a = Math.max(o, l);
1524
+ toDomRange(e, t, i, s, n, r) {
1525
+ const o = this.positionToOffset(e.start, t, i), a = this.positionToOffset(e.end, t, i);
1526
+ let h = Math.min(o, a), l = Math.max(o, a);
1486
1527
  if (n && r) {
1487
- const d = r, g = n.slice(h, a);
1488
- if (g.length === d.length && g.toLowerCase() !== d.toLowerCase()) {
1489
- const p = this.findNearestMatchOffset(
1528
+ const u = r, g = n.slice(h, l);
1529
+ if (g.length === u.length && g.toLowerCase() !== u.toLowerCase()) {
1530
+ const f = this.findNearestMatchOffset(
1490
1531
  n,
1491
- d,
1532
+ u,
1492
1533
  h
1493
1534
  );
1494
- p !== -1 && (h = p, a = p + d.length);
1535
+ f !== -1 && (h = f, l = f + u.length);
1495
1536
  }
1496
1537
  }
1497
- const c = this.resolveDomPoint(h, i), u = this.resolveDomPoint(a, i);
1498
- if (!c || !u) return null;
1499
- const f = document.createRange();
1538
+ const c = this.resolveDomPoint(h, s), d = this.resolveDomPoint(l, s);
1539
+ if (!c || !d)
1540
+ return null;
1541
+ const p = document.createRange();
1500
1542
  try {
1501
- return f.setStart(c.node, c.offset), f.setEnd(u.node, u.offset), f;
1543
+ return p.setStart(c.node, c.offset), p.setEnd(d.node, d.offset), p;
1502
1544
  } catch {
1503
1545
  return null;
1504
1546
  }
1505
1547
  }
1506
1548
  buildVisibleDocumentText(e) {
1507
1549
  let t = "";
1508
- for (let s = 0; s < e.length; s++) {
1509
- const i = e[s].node.textContent || "";
1510
- for (let n = 0; n < i.length; n++) {
1511
- const r = i[n];
1550
+ for (let i = 0; i < e.length; i++) {
1551
+ const s = e[i].node.textContent || "";
1552
+ for (let n = 0; n < s.length; n++) {
1553
+ const r = s[n];
1512
1554
  this.virtualMarkerRegex.test(r) || (t += r);
1513
1555
  }
1514
1556
  }
1515
1557
  return t;
1516
1558
  }
1517
- findNearestMatchOffset(e, t, s) {
1518
- const i = t.toLowerCase();
1519
- let n = e.toLowerCase().indexOf(i);
1520
- if (n === -1) return -1;
1521
- let r = n, o = Math.abs(n - s);
1559
+ findNearestMatchOffset(e, t, i) {
1560
+ const s = t.toLowerCase();
1561
+ let n = e.toLowerCase().indexOf(s);
1562
+ if (n === -1)
1563
+ return -1;
1564
+ let r = n, o = Math.abs(n - i);
1522
1565
  for (; n !== -1; ) {
1523
- const l = Math.abs(n - s);
1524
- if (l < o && (o = l, r = n), l === 0) return n;
1525
- n = e.toLowerCase().indexOf(i, n + 1);
1566
+ const a = Math.abs(n - i);
1567
+ if (a < o && (o = a, r = n), a === 0)
1568
+ return n;
1569
+ n = e.toLowerCase().indexOf(s, n + 1);
1526
1570
  }
1527
1571
  return r;
1528
1572
  }
@@ -1583,15 +1627,16 @@ const W = class m {
1583
1627
  }
1584
1628
  buildVisibleToDomMap(e) {
1585
1629
  const t = [0];
1586
- let s = 0;
1587
- for (let i = 0; i < e.length; i++) {
1588
- const n = e[i];
1589
- this.virtualMarkerRegex.test(n) || (s += 1, t[s] = i + 1);
1630
+ let i = 0;
1631
+ for (let s = 0; s < e.length; s++) {
1632
+ const n = e[s];
1633
+ this.virtualMarkerRegex.test(n) || (i += 1, t[i] = s + 1);
1590
1634
  }
1591
1635
  return t;
1592
1636
  }
1593
1637
  ensureHighlightStyles() {
1594
- if (document.getElementById(this.highlightStyleId)) return;
1638
+ if (document.getElementById(this.highlightStyleId))
1639
+ return;
1595
1640
  const e = document.createElement("style");
1596
1641
  e.id = this.highlightStyleId, e.textContent = `
1597
1642
  ::highlight(${this.highlightMatchName}) {
@@ -1607,7 +1652,7 @@ const W = class m {
1607
1652
  destroy() {
1608
1653
  this.searchDebounceTimer && (clearTimeout(this.searchDebounceTimer), this.searchDebounceTimer = null), this.liveRefreshTimer && (clearTimeout(this.liveRefreshTimer), this.liveRefreshTimer = null), this.statusResetTimer && (clearTimeout(this.statusResetTimer), this.statusResetTimer = null), this.clearHighlights(), this.searchUI && this.searchUI.parentNode && this.searchUI.parentNode.removeChild(this.searchUI), this.editor && this.editorChangeHandler && this.editor.off("change", this.editorChangeHandler), this.editorChangeHandler = null, this.findInput = null, this.replaceInputEl = null, this.statusDiv = null, this.modeDiv = null, this.caseSensitiveInput = null, this.wholeWordInput = null, this.regexInput = null, this.searchUI = null;
1609
1654
  const e = document.getElementById(this.highlightStyleId);
1610
- e?.parentNode && e.parentNode.removeChild(e), this.editor = null;
1655
+ e != null && e.parentNode && e.parentNode.removeChild(e), this.editor = null;
1611
1656
  }
1612
1657
  };
1613
1658
  W.css = {
@@ -1633,8 +1678,8 @@ W.css = {
1633
1678
  mode: "search-mode",
1634
1679
  modeLayout: "lce-search-mode"
1635
1680
  };
1636
- let se = W;
1637
- class ie {
1681
+ let ie = W;
1682
+ class se {
1638
1683
  constructor() {
1639
1684
  this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
1640
1685
  "(": ")",
@@ -1656,60 +1701,64 @@ class ie {
1656
1701
  });
1657
1702
  }
1658
1703
  updateBracketMatching() {
1659
- if (!this.editor) return;
1704
+ if (!this.editor)
1705
+ return;
1660
1706
  const e = this.editor.getCursor(), t = this.editor.getValue();
1661
1707
  this.clearBracketHighlighting();
1662
- const s = this.getBracketAtPosition(t, e.position);
1663
- if (!s) return;
1664
- const i = this.findMatchingBracket(t, s);
1665
- i && (this.currentMatch = i, this.highlightBrackets(i));
1708
+ const i = this.getBracketAtPosition(t, e.position);
1709
+ if (!i)
1710
+ return;
1711
+ const s = this.findMatchingBracket(t, i);
1712
+ s && (this.currentMatch = s, this.highlightBrackets(s));
1666
1713
  }
1667
1714
  getBracketAtPosition(e, t) {
1668
- const s = e.split(`
1715
+ const i = e.split(`
1669
1716
  `);
1670
- if (t.line >= s.length) return null;
1671
- const i = s[t.line];
1672
- if (t.column >= i.length) return null;
1673
- const n = i[t.column];
1717
+ if (t.line >= i.length)
1718
+ return null;
1719
+ const s = i[t.line];
1720
+ if (t.column >= s.length)
1721
+ return null;
1722
+ const n = s[t.column];
1674
1723
  return this.bracketPairs[n] || this.reverseBracketPairs[n] ? { char: n, position: t } : null;
1675
1724
  }
1676
1725
  findMatchingBracket(e, t) {
1677
- const s = e.split(`
1678
- `), i = t.position.line, n = t.position.column, r = t.char;
1679
- return this.bracketPairs[r] ? this.findClosingBracket(e, s, i, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(e, s, i, n, r) : null;
1726
+ const i = e.split(`
1727
+ `), s = t.position.line, n = t.position.column, r = t.char;
1728
+ return this.bracketPairs[r] ? this.findClosingBracket(e, i, s, n, r) : this.reverseBracketPairs[r] ? this.findOpeningBracket(e, i, s, n, r) : null;
1680
1729
  }
1681
- findClosingBracket(e, t, s, i, n) {
1730
+ findClosingBracket(e, t, i, s, n) {
1682
1731
  const r = this.bracketPairs[n];
1683
1732
  let o = 0;
1684
- for (let l = s; l < t.length; l++) {
1685
- const h = t[l], a = l === s ? i : 0;
1686
- for (let c = a; c < h.length; c++) {
1687
- const u = h[c];
1688
- if (u === n)
1733
+ for (let a = i; a < t.length; a++) {
1734
+ const h = t[a], l = a === i ? s : 0;
1735
+ for (let c = l; c < h.length; c++) {
1736
+ const d = h[c];
1737
+ if (d === n)
1689
1738
  o++;
1690
- else if (u === r && (o--, o === 0))
1739
+ else if (d === r && (o--, o === 0))
1691
1740
  return {
1692
- open: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1693
- close: { start: { line: l, column: c }, end: { line: l, column: c + 1 } },
1741
+ open: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1742
+ close: { start: { line: a, column: c }, end: { line: a, column: c + 1 } },
1694
1743
  type: n
1695
1744
  };
1696
1745
  }
1697
1746
  }
1698
1747
  return null;
1699
1748
  }
1700
- findOpeningBracket(e, t, s, i, n) {
1749
+ findOpeningBracket(e, t, i, s, n) {
1701
1750
  const r = this.reverseBracketPairs[n];
1702
1751
  let o = 0;
1703
- for (let l = s; l >= 0; l--) {
1704
- const h = t[l], a = l === s ? i : h.length - 1;
1705
- for (let c = a; c >= 0; c--) {
1706
- const u = h[c];
1707
- if (u === n)
1752
+ for (let a = i; a >= 0; a--) {
1753
+ const h = t[a], l = a === i ? s : h.length - 1;
1754
+ for (let c = l; c >= 0; c--) {
1755
+ const d = h[c];
1756
+ if (d === n)
1708
1757
  o++;
1709
- else if (u === r && (o--, o === 0))
1758
+ else if (d === r && (o--, o === 0))
1710
1759
  return {
1711
- open: { start: { line: l, column: c }, end: { line: l, column: c + 1 } },
1712
- close: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1760
+ open: { start: { line: a, column: c }, end: { line: a, column: c + 1 } },
1761
+ close: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1713
1762
  type: r
1714
1763
  };
1715
1764
  }
@@ -1746,7 +1795,8 @@ class ne {
1746
1795
  }, e.on("change", this.changeHandler), this.createFoldingUI(), this.scheduleFoldIndicatorUpdate();
1747
1796
  }
1748
1797
  createFoldingUI() {
1749
- if (!this.editor) return;
1798
+ if (!this.editor)
1799
+ return;
1750
1800
  const e = this.editor.getView().getContentElement(), t = e.closest(".rte-source-editor-modal") || e.parentElement;
1751
1801
  t && (this.foldingUI = document.createElement("div"), this.foldingUI.style.cssText = `
1752
1802
  position: absolute;
@@ -1764,22 +1814,24 @@ class ne {
1764
1814
  }));
1765
1815
  }
1766
1816
  updateFoldIndicators() {
1767
- if (!this.editor || !this.foldingUI) return;
1817
+ if (!this.editor || !this.foldingUI)
1818
+ return;
1768
1819
  const e = this.editor.getValue();
1769
- if (e === this.lastSnapshot) return;
1820
+ if (e === this.lastSnapshot)
1821
+ return;
1770
1822
  this.lastSnapshot = e, this.foldingUI.innerHTML = "", this.foldIndicators = [];
1771
1823
  const t = e.split(`
1772
- `), s = this.findFoldableLines(t), i = document.createDocumentFragment();
1773
- s.forEach((n) => {
1824
+ `), i = this.findFoldableLines(t), s = document.createDocumentFragment();
1825
+ i.forEach((n) => {
1774
1826
  const r = this.createFoldIndicator(n);
1775
- i.appendChild(r), this.foldIndicators.push(r);
1776
- }), this.foldingUI.appendChild(i);
1827
+ s.appendChild(r), this.foldIndicators.push(r);
1828
+ }), this.foldingUI.appendChild(s);
1777
1829
  }
1778
1830
  findFoldableLines(e) {
1779
1831
  const t = [];
1780
- for (let s = 0; s < e.length; s++) {
1781
- const i = e[s].trim();
1782
- (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);
1832
+ for (let i = 0; i < e.length; i++) {
1833
+ const s = e[i].trim();
1834
+ (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);
1783
1835
  }
1784
1836
  return t;
1785
1837
  }
@@ -1819,7 +1871,7 @@ class re {
1819
1871
  this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
1820
1872
  }
1821
1873
  setup(e) {
1822
- 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) });
1874
+ 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) });
1823
1875
  }
1824
1876
  // Extension provides methods that can be called by the editor
1825
1877
  setTheme(e) {
@@ -1879,8 +1931,8 @@ class re {
1879
1931
  }
1880
1932
  // Public API: highlight a source string using the chosen mode (or detect html)
1881
1933
  highlight(e, t) {
1882
- const s = this.getSyntaxColors(), i = (t || this.currentLanguage || "html").toLowerCase();
1883
- return (this.modes.get(i) || this.modes.get("html")).highlight(e, s);
1934
+ const i = this.getSyntaxColors(), s = (t || this.currentLanguage || "html").toLowerCase();
1935
+ return (this.modes.get(s) || this.modes.get("html")).highlight(e, i);
1884
1936
  }
1885
1937
  // Backwards-compatible method
1886
1938
  highlightHTML(e) {
@@ -1893,127 +1945,129 @@ class re {
1893
1945
  // Robustly unescape common HTML entities, repeating a few times to handle nested encoding like &amp;amp;...
1894
1946
  unescapeEntitiesRepeated(e) {
1895
1947
  let t = e || "";
1896
- for (let s = 0; s < 5; s++) {
1897
- const i = t;
1898
- if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === i) break;
1948
+ for (let i = 0; i < 5; i++) {
1949
+ const s = t;
1950
+ if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === s)
1951
+ break;
1899
1952
  }
1900
1953
  return t;
1901
1954
  }
1902
1955
  _highlightHTML(e, t) {
1903
- const s = t, i = (h) => this.escapeHTML(h);
1904
- let n = i(e);
1956
+ const i = t, s = (h) => this.escapeHTML(h);
1957
+ let n = s(e);
1905
1958
  const r = (h) => {
1906
- let a = h.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1907
- return a = a.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${s.comment};">$1</span>`), a = a.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (c, u, f, d, g) => {
1908
- const p = String(d).trim(), y = i(p);
1909
- return `<span style="color: ${s.styleProp};">${u}</span>${f}<span style="color: ${s.styleVal};">${y}</span>${g}`;
1910
- }), a;
1959
+ let l = h.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1960
+ return l = l.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${i.comment};">$1</span>`), l = l.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (c, d, p, u, g) => {
1961
+ const f = String(u).trim(), y = s(f);
1962
+ return `<span style="color: ${i.styleProp};">${d}</span>${p}<span style="color: ${i.styleVal};">${y}</span>${g}`;
1963
+ }), l;
1911
1964
  }, o = [];
1912
1965
  try {
1913
- e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (h, a, c) => (o.push({ attrs: String(a || ""), inner: String(c || "") }), h));
1966
+ e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (h, l, c) => (o.push({ attrs: String(l || ""), inner: String(c || "") }), h));
1914
1967
  } catch {
1915
1968
  }
1916
- let l = 0;
1917
- return n = n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (h, a, c, u, f) => {
1918
- const d = o[l++]?.inner ?? this.unescapeEntitiesRepeated(u || "");
1919
- (o[l - 1]?.attrs || c || "").toLowerCase();
1920
- const g = this._highlightJS(d, s);
1921
- return `${a}${g}${f}`;
1922
- }), n = n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (h, a, c, u) => {
1923
- const f = r(c);
1924
- return `${a}${f}${u}`;
1925
- }), 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, a, c, u, f) => {
1926
- const d = `<span style="color: ${s.tag};">${c}</span>`;
1927
- let g = u;
1969
+ let a = 0;
1970
+ return n = n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (h, l, c, d, p) => {
1971
+ var u, g;
1972
+ const f = ((u = o[a++]) == null ? void 0 : u.inner) ?? this.unescapeEntitiesRepeated(d || "");
1973
+ (((g = o[a - 1]) == null ? void 0 : g.attrs) || c || "").toLowerCase();
1974
+ const y = this._highlightJS(f, i);
1975
+ return `${l}${y}${p}`;
1976
+ }), n = n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (h, l, c, d) => {
1977
+ const p = r(c);
1978
+ return `${l}${p}${d}`;
1979
+ }), 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, l, c, d, p) => {
1980
+ const u = `<span style="color: ${i.tag};">${c}</span>`;
1981
+ let g = d;
1928
1982
  return g = g.replace(
1929
1983
  /([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,
1930
- (p, y, k, v) => {
1931
- const C = String(y).toLowerCase(), E = `<span style="color: ${s.attrName};">${y}</span>`;
1984
+ (f, y, k, v) => {
1985
+ const C = String(y).toLowerCase(), E = `<span style="color: ${i.attrName};">${y}</span>`;
1932
1986
  let S = v, b = "";
1933
1987
  v.startsWith("&quot;") && v.endsWith("&quot;") ? (S = v.slice(6, -6), b = "&quot;") : v.startsWith("&#39;") && v.endsWith("&#39;") && (S = v.slice(5, -5), b = "&#39;");
1934
1988
  let T = v;
1935
1989
  if (C === "style") {
1936
- const I = S.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (B, N, $, O) => `<span style="color: ${s.styleProp};">${N}</span>:<span style="color: ${s.styleVal};">${$.trim()}</span>${O}`);
1937
- b ? T = `${b}${I}${b}` : T = I, T = `<span style="color: ${s.attrValue};">${T}</span>`;
1990
+ const I = S.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (B, N, $, O) => `<span style="color: ${i.styleProp};">${N}</span>:<span style="color: ${i.styleVal};">${$.trim()}</span>${O}`);
1991
+ b ? T = `${b}${I}${b}` : T = I, T = `<span style="color: ${i.attrValue};">${T}</span>`;
1938
1992
  } else
1939
- b && (T = `${b}${S}${b}`), T = `<span style="color: ${s.attrValue};">${T}</span>`;
1993
+ b && (T = `${b}${S}${b}`), T = `<span style="color: ${i.attrValue};">${T}</span>`;
1940
1994
  return `${E}${k}${T}`;
1941
1995
  }
1942
- ), `${a}${d}${g}${f}`;
1996
+ ), `${l}${u}${g}${p}`;
1943
1997
  }), n;
1944
1998
  }
1945
1999
  _highlightJS(e, t) {
1946
- const s = this.unescapeEntitiesRepeated(e);
1947
- this.escapeHTML(s);
1948
- const i = [], n = (u) => {
1949
- let f = "", d = u;
2000
+ const i = this.unescapeEntitiesRepeated(e);
2001
+ this.escapeHTML(i);
2002
+ const s = [], n = (d) => {
2003
+ let p = "", u = d;
1950
2004
  do
1951
- f = String.fromCharCode(97 + d % 26) + f, d = Math.floor(d / 26) - 1;
1952
- while (d >= 0);
1953
- return f || "a";
1954
- }, r = (u) => `\0${n(u)}\0`, o = (u) => {
1955
- const f = i.length;
1956
- return i.push(u), r(f);
2005
+ p = String.fromCharCode(97 + u % 26) + p, u = Math.floor(u / 26) - 1;
2006
+ while (u >= 0);
2007
+ return p || "a";
2008
+ }, r = (d) => `\0${n(d)}\0`, o = (d) => {
2009
+ const p = s.length;
2010
+ return s.push(d), r(p);
1957
2011
  };
1958
- let l;
2012
+ let a;
1959
2013
  const h = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
1960
- let a = 0, c = "";
1961
- for (; l = h.exec(s); ) {
1962
- const u = l.index;
1963
- a < u && (c += this.escapeHTML(s.slice(a, u)));
1964
- const f = l[0];
1965
- /^\/\*/.test(f) || /^\/\//.test(f) ? c += o(`<span style="color: ${t.comment};">${this.escapeHTML(f)}</span>`) : c += o(`<span style="color: ${t.string};">${this.escapeHTML(f)}</span>`), a = h.lastIndex;
2014
+ let l = 0, c = "";
2015
+ for (; a = h.exec(i); ) {
2016
+ const d = a.index;
2017
+ l < d && (c += this.escapeHTML(i.slice(l, d)));
2018
+ const p = a[0];
2019
+ /^\/\*/.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>`), l = h.lastIndex;
1966
2020
  }
1967
- return a < s.length && (c += this.escapeHTML(s.slice(a))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (u, f, d) => {
1968
- const g = c[d - 1] || "", p = c[d + u.length] || "";
1969
- return g === "&" || g === "#" || p === ";" || p === "#" ? u : `<span style="color: ${t.number};">${u}</span>`;
1970
- }), 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, (u, f) => {
1971
- let d = 0;
1972
- for (let g = 0; g < f.length; g++)
1973
- d = d * 26 + (f.charCodeAt(g) - 97 + 1);
1974
- return d = d - 1, i[d] || "";
2021
+ return l < i.length && (c += this.escapeHTML(i.slice(l))), c = c.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, p, u) => {
2022
+ const g = c[u - 1] || "", f = c[u + d.length] || "";
2023
+ return g === "&" || g === "#" || f === ";" || f === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
2024
+ }), 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) => {
2025
+ let u = 0;
2026
+ for (let g = 0; g < p.length; g++)
2027
+ u = u * 26 + (p.charCodeAt(g) - 97 + 1);
2028
+ return u = u - 1, s[u] || "";
1975
2029
  });
1976
2030
  }
1977
2031
  _highlightPHP(e, t) {
1978
- const s = this.unescapeEntitiesRepeated(e);
1979
- let i = this.escapeHTML(s);
1980
- const n = [], r = (d) => {
1981
- let g = "", p = d;
2032
+ const i = this.unescapeEntitiesRepeated(e);
2033
+ let s = this.escapeHTML(i);
2034
+ const n = [], r = (u) => {
2035
+ let g = "", f = u;
1982
2036
  do
1983
- g = String.fromCharCode(97 + p % 26) + g, p = Math.floor(p / 26) - 1;
1984
- while (p >= 0);
2037
+ g = String.fromCharCode(97 + f % 26) + g, f = Math.floor(f / 26) - 1;
2038
+ while (f >= 0);
1985
2039
  return g || "a";
1986
- }, o = (d) => {
2040
+ }, o = (u) => {
1987
2041
  const g = n.length;
1988
- return n.push(d), `\0${r(g)}\0`;
1989
- }, l = (d, g) => {
1990
- const p = i.indexOf(d);
1991
- return p === -1 ? !1 : (i = i.slice(0, p) + g + i.slice(p + d.length), !0);
2042
+ return n.push(u), `\0${r(g)}\0`;
2043
+ }, a = (u, g) => {
2044
+ const f = s.indexOf(u);
2045
+ return f === -1 ? !1 : (s = s.slice(0, f) + g + s.slice(f + u.length), !0);
1992
2046
  };
1993
2047
  let h;
1994
- const a = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, u = /\#([^\n\r]*)/g, f = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
1995
- for (; h = a.exec(s); ) {
1996
- const d = h[0];
1997
- l(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
2048
+ const l = /\/\*[\s\S]*?\*\//g, c = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, p = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
2049
+ for (; h = l.exec(i); ) {
2050
+ const u = h[0];
2051
+ a(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
1998
2052
  }
1999
- for (; h = c.exec(s); ) {
2000
- const d = h[0];
2001
- l(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
2053
+ for (; h = c.exec(i); ) {
2054
+ const u = h[0];
2055
+ a(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2002
2056
  }
2003
- for (; h = u.exec(s); ) {
2004
- const d = h[0];
2005
- l(this.escapeHTML(d), o(`<span style="color: ${t.comment};">${this.escapeHTML(d)}</span>`));
2057
+ for (; h = d.exec(i); ) {
2058
+ const u = h[0];
2059
+ a(this.escapeHTML(u), o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`));
2006
2060
  }
2007
- for (; h = f.exec(s); ) {
2008
- const d = h[0];
2009
- l(this.escapeHTML(d), o(`<span style="color: ${t.string};">${this.escapeHTML(d)}</span>`));
2061
+ for (; h = p.exec(i); ) {
2062
+ const u = h[0];
2063
+ a(this.escapeHTML(u), o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`));
2010
2064
  }
2011
- 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, (d, g) => {
2012
- let p = 0;
2065
+ 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) => {
2066
+ let f = 0;
2013
2067
  for (let y = 0; y < g.length; y++)
2014
- p = p * 26 + (g.charCodeAt(y) - 97 + 1);
2015
- return p = p - 1, n[p] || "";
2016
- }), i;
2068
+ f = f * 26 + (g.charCodeAt(y) - 97 + 1);
2069
+ return f = f - 1, n[f] || "";
2070
+ }), s;
2017
2071
  }
2018
2072
  // Method to check if content contains syntax that should be highlighted
2019
2073
  shouldHighlight(e) {
@@ -2025,7 +2079,7 @@ class re {
2025
2079
  }
2026
2080
  function oe(w, e) {
2027
2081
  const t = { ...e };
2028
- 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);
2082
+ 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);
2029
2083
  }
2030
2084
  const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Editor Dialog Styles */
2031
2085
  .rte-source-editor-overlay {
@@ -2424,35 +2478,38 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2424
2478
  */
2425
2479
  toggleSourceView: () => {
2426
2480
  const e = (() => {
2481
+ var o, a, h;
2427
2482
  const n = window.getSelection();
2428
2483
  if (n && n.anchorNode) {
2429
- let o = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
2430
- for (; o; ) {
2431
- if (o.classList?.contains("rte-content"))
2432
- return o;
2433
- o = o.parentElement;
2484
+ let l = n.anchorNode instanceof HTMLElement ? n.anchorNode : n.anchorNode.parentElement;
2485
+ for (; l; ) {
2486
+ if ((o = l.classList) != null && o.contains("rte-content"))
2487
+ return l;
2488
+ l = l.parentElement;
2434
2489
  }
2435
2490
  }
2436
2491
  if (document.activeElement) {
2437
- let o = document.activeElement;
2438
- if (o.classList?.contains("rte-content"))
2439
- return o;
2440
- for (; o && o !== document.body; ) {
2441
- if (o.classList?.contains("rte-content"))
2442
- return o;
2443
- const l = o.querySelector(
2492
+ let l = document.activeElement;
2493
+ if ((a = l.classList) != null && a.contains("rte-content"))
2494
+ return l;
2495
+ for (; l && l !== document.body; ) {
2496
+ if ((h = l.classList) != null && h.contains("rte-content"))
2497
+ return l;
2498
+ const c = l.querySelector(
2444
2499
  ".rte-content"
2445
2500
  );
2446
- if (l) return l;
2447
- o = o.parentElement;
2501
+ if (c)
2502
+ return c;
2503
+ l = l.parentElement;
2448
2504
  }
2449
2505
  }
2450
2506
  const r = document.querySelector("[data-editora-editor]");
2451
2507
  if (r) {
2452
- const o = r.querySelector(
2508
+ const l = r.querySelector(
2453
2509
  ".rte-content"
2454
2510
  );
2455
- if (o) return o;
2511
+ if (l)
2512
+ return l;
2456
2513
  }
2457
2514
  return document.querySelector(".rte-content");
2458
2515
  })();
@@ -2460,25 +2517,25 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2460
2517
  return console.error("[CodePlugin] Editor content area not found"), alert(
2461
2518
  "Editor content area not found. Please click inside the editor first."
2462
2519
  ), !1;
2463
- const t = e.innerHTML, s = (n) => {
2520
+ const t = e.innerHTML, i = (n) => {
2464
2521
  let r = "", o = 0;
2465
- const l = 2, h = n.split(/(<\/?[a-zA-Z][^>]*>)/);
2466
- for (const a of h)
2467
- a.trim() && (a.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), r += `
2468
- ` + " ".repeat(o * l) + a) : a.match(/^<[a-zA-Z]/) && !a.match(/\/>$/) ? (r += `
2469
- ` + " ".repeat(o * l) + a, o++) : a.match(/^<[a-zA-Z].*\/>$/) ? r += `
2470
- ` + " ".repeat(o * l) + a : r += a.trim());
2522
+ const a = 2, h = n.split(/(<\/?[a-zA-Z][^>]*>)/);
2523
+ for (const l of h)
2524
+ l.trim() && (l.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), r += `
2525
+ ` + " ".repeat(o * a) + l) : l.match(/^<[a-zA-Z]/) && !l.match(/\/>$/) ? (r += `
2526
+ ` + " ".repeat(o * a) + l, o++) : l.match(/^<[a-zA-Z].*\/>$/) ? r += `
2527
+ ` + " ".repeat(o * a) + l : r += l.trim());
2471
2528
  return r.trim();
2472
2529
  };
2473
2530
  return (() => {
2474
- const r = s(t);
2475
- let o = null, l = "dark", h = !1, a = !1, c = !1, u = !1;
2476
- const f = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), d = document.createElement("div");
2477
- d.className = "rte-source-editor-overlay", f && d.classList.add("rte-theme-dark");
2531
+ const r = i(t);
2532
+ let o = null, a = "dark", h = !1, l = !1, c = !1, d = !1;
2533
+ const p = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), u = document.createElement("div");
2534
+ u.className = "rte-source-editor-overlay", p && u.classList.add("rte-theme-dark");
2478
2535
  const g = document.createElement("div");
2479
2536
  g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
2480
- const p = document.createElement("div");
2481
- p.className = "rte-source-editor-header", p.innerHTML = `
2537
+ const f = document.createElement("div");
2538
+ f.className = "rte-source-editor-header", f.innerHTML = `
2482
2539
  <h2 id="source-editor-title">Source Editor</h2>
2483
2540
  <div class="rte-source-editor-header-toolbar">
2484
2541
  <button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
@@ -2532,17 +2589,17 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2532
2589
  <button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
2533
2590
  <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
2534
2591
  </div>
2535
- `, g.appendChild(p), g.appendChild(y), g.appendChild(E), d.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
2592
+ `, g.appendChild(f), g.appendChild(y), g.appendChild(E), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
2536
2593
  const x = document.createElement("style");
2537
2594
  x.id = "rte-source-editor-styles", x.textContent = le, document.head.appendChild(x);
2538
2595
  }
2539
- const S = p.querySelector(
2596
+ const S = f.querySelector(
2540
2597
  ".theme-toggle-btn"
2541
- ), b = p.querySelector(
2598
+ ), b = f.querySelector(
2542
2599
  ".readonly-toggle-btn"
2543
- ), T = p.querySelector(
2600
+ ), T = f.querySelector(
2544
2601
  ".rte-source-editor-fullscreen-btn"
2545
- ), I = p.querySelector(
2602
+ ), I = f.querySelector(
2546
2603
  ".rte-source-editor-close-btn"
2547
2604
  ), B = E.querySelector(
2548
2605
  ".rte-source-editor-btn-cancel"
@@ -2557,13 +2614,15 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2557
2614
  }, U = (x) => {
2558
2615
  c !== x && (c = x, $ && ($.style.display = c ? "inline" : "none"));
2559
2616
  }, H = () => {
2560
- if (!u) {
2561
- for (u = !0; O.length; )
2562
- O.pop()?.();
2563
- o && (o.destroy(), o = null), d.isConnected && d.remove();
2617
+ if (!d) {
2618
+ for (d = !0; O.length; ) {
2619
+ const x = O.pop();
2620
+ x == null || x();
2621
+ }
2622
+ o && (o.destroy(), o = null), u.isConnected && u.remove();
2564
2623
  }
2565
2624
  }, K = () => {
2566
- l = l === "dark" ? "light" : "dark", o?.setTheme(l), S && (S.innerHTML = l === "light" ? `
2625
+ a = a === "dark" ? "light" : "dark", o == null || o.setTheme(a), S && (S.innerHTML = a === "light" ? `
2567
2626
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2568
2627
  <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
2569
2628
  </svg>
@@ -2581,7 +2640,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2581
2640
  </svg>
2582
2641
  `);
2583
2642
  }, z = () => {
2584
- h = !h, o?.setReadOnly(h), b && (b.classList.toggle("active", h), b.innerHTML = h ? `
2643
+ h = !h, o == null || o.setReadOnly(h), b && (b.classList.toggle("active", h), b.innerHTML = h ? `
2585
2644
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2586
2645
  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
2587
2646
  <circle cx="12" cy="16" r="1"/>
@@ -2594,7 +2653,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2594
2653
  </svg>
2595
2654
  `);
2596
2655
  }, q = () => {
2597
- a = !a, d.classList.toggle("fullscreen", a), C.style.height = a ? "calc(100vh - 200px)" : "400px", T && (T.innerHTML = a ? `
2656
+ l = !l, u.classList.toggle("fullscreen", l), C.style.height = l ? "calc(100vh - 200px)" : "400px", T && (T.innerHTML = l ? `
2598
2657
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2599
2658
  <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"/>
2600
2659
  </svg>
@@ -2607,7 +2666,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2607
2666
  c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
2608
2667
  }, j = () => {
2609
2668
  try {
2610
- const x = o?.getValue() || "", M = document.createElement("div");
2669
+ const x = (o == null ? void 0 : o.getValue()) || "", M = document.createElement("div");
2611
2670
  M.innerHTML = x, M.querySelectorAll(
2612
2671
  'script, iframe[src^="javascript:"], object, embed'
2613
2672
  ).forEach((A) => A.remove()), e.innerHTML = M.innerHTML;
@@ -2631,13 +2690,13 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2631
2690
  alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", x);
2632
2691
  }
2633
2692
  };
2634
- S && R(S, "click", K), b && R(b, "click", z), T && R(T, "click", q), I && R(I, "click", H), B && R(B, "click", Q), N && R(N, "click", j), R(d, "click", (x) => {
2635
- x.target === d && H();
2693
+ S && R(S, "click", K), b && R(b, "click", z), T && R(T, "click", q), I && R(I, "click", H), B && R(B, "click", Q), N && R(N, "click", j), R(u, "click", (x) => {
2694
+ x.target === u && H();
2636
2695
  }), R(document, "keydown", (x) => {
2637
2696
  const M = x;
2638
2697
  M.key === "Escape" && (M.preventDefault(), H());
2639
- }), document.body.appendChild(d), requestAnimationFrame(() => {
2640
- if (!(u || !d.isConnected))
2698
+ }), document.body.appendChild(u), requestAnimationFrame(() => {
2699
+ if (!(d || !u.isConnected))
2641
2700
  try {
2642
2701
  o = oe(C, {
2643
2702
  value: r,
@@ -2647,15 +2706,15 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', le = `/* Source Edi
2647
2706
  new G(),
2648
2707
  new _(),
2649
2708
  new ee(),
2650
- new ie(),
2651
2709
  new se(),
2710
+ new ie(),
2652
2711
  new ne(),
2653
2712
  new re()
2654
2713
  ]
2655
2714
  }), o.on("change", () => {
2656
- const x = o?.getValue() || "";
2715
+ const x = (o == null ? void 0 : o.getValue()) || "";
2657
2716
  U(x !== r);
2658
- }), requestAnimationFrame(() => o?.focus());
2717
+ }), requestAnimationFrame(() => o == null ? void 0 : o.focus());
2659
2718
  } catch (x) {
2660
2719
  console.error("Failed to initialize code editor:", x);
2661
2720
  }