@editora/core 1.0.4 → 1.0.6

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.
@@ -1,4 +1,4 @@
1
- class R {
1
+ class P {
2
2
  constructor(e = "") {
3
3
  this._lines = [], this._version = 0, this.setText(e);
4
4
  }
@@ -30,28 +30,28 @@ class R {
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), r = i.substring(0, e.start.column) + t + i.substring(e.end.column);
42
+ const s = this.getLine(e.start.line), r = s.substring(0, e.start.column) + t + s.substring(e.end.column);
43
43
  this._lines[e.start.line] = r;
44
44
  } else {
45
- const i = this.getLine(e.start.line), r = this.getLine(e.end.line), o = i.substring(0, e.start.column) + t, n = r.substring(e.end.column), l = t.split(`
45
+ const s = this.getLine(e.start.line), r = this.getLine(e.end.line), n = s.substring(0, e.start.column) + t, o = r.substring(e.end.column), l = t.split(`
46
46
  `);
47
- l[0] = o + l[0], l[l.length - 1] = l[l.length - 1] + n, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...l);
47
+ l[0] = n + l[0], l[l.length - 1] = l[l.length - 1] + o, this._lines.splice(e.start.line, e.end.line - e.start.line + 1, ...l);
48
48
  }
49
- return this._version++, { range: e, text: t, oldText: s };
49
+ return this._version++, { range: e, text: t, oldText: i };
50
50
  }
51
51
  // Insert text at position
52
52
  insertText(e, t) {
53
- const s = { start: e, end: e };
54
- return this.replaceRange(s, t);
53
+ const i = { start: e, end: e };
54
+ return this.replaceRange(i, t);
55
55
  }
56
56
  // Delete text in range
57
57
  deleteRange(e) {
@@ -60,18 +60,18 @@ class R {
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,
@@ -92,13 +92,13 @@ class R {
92
92
  }
93
93
  // Clone the model
94
94
  clone() {
95
- const e = new R();
95
+ const e = new P();
96
96
  return e._lines = [...this._lines], e._version = this._version, e;
97
97
  }
98
98
  }
99
- class A {
99
+ class U {
100
100
  constructor(e) {
101
- this.gutterWidth = 50, this.lineHeight = 21, this.container = e, this.createDOM();
101
+ this.gutterWidth = 50, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.container = e, this.createDOM();
102
102
  }
103
103
  createDOM() {
104
104
  this.container.innerHTML = "";
@@ -149,8 +149,8 @@ class A {
149
149
  }
150
150
  // Update line numbers
151
151
  updateLineNumbers(e) {
152
- const t = Math.max(e, 20), s = Array.from({ length: t }, (i, r) => r + 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, r) => r + 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() {
@@ -162,47 +162,55 @@ class A {
162
162
  }
163
163
  // Get text content
164
164
  getText() {
165
- return this.contentElement.textContent || "";
165
+ const e = this.contentElement.textContent || "";
166
+ return this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`) && e.endsWith("​") ? e.slice(0, -1) : e;
166
167
  }
167
168
  // Set text content
168
169
  setText(e) {
169
- this.contentElement.textContent = e;
170
+ this.contentElement.textContent = e, this.syncTrailingNewlineMarker(e.endsWith(`
171
+ `));
170
172
  const t = e.split(`
171
173
  `).length;
172
174
  this.updateLineNumbers(t);
173
175
  }
174
176
  // Set inner HTML (used for syntax highlighted content)
175
177
  setHTML(e) {
176
- const t = /&lt;|&gt;/.test(e), s = /<span\b/i.test(e), i = /<[^>]+>/.test(e);
177
- t && s ? this.contentElement.innerHTML = e : i && !t ? this.contentElement.textContent = e : this.contentElement.innerHTML = e;
178
- const r = (this.contentElement.textContent || "").split(`
178
+ const t = /\n$/.test(e), i = /&lt;|&gt;/.test(e), s = /<span\b/i.test(e), r = /<[^>]+>/.test(e);
179
+ i && s ? this.contentElement.innerHTML = e : r && !i ? this.contentElement.textContent = e : this.contentElement.innerHTML = e, this.syncTrailingNewlineMarker(t);
180
+ const n = (this.contentElement.textContent || "").split(`
179
181
  `).length;
180
- this.updateLineNumbers(r);
182
+ this.updateLineNumbers(n);
183
+ }
184
+ // Keep trailing-newline caret marker in sync for live contenteditable edits
185
+ // (without forcing a full setText/setHTML render).
186
+ syncTrailingNewlineMarkerForText(e) {
187
+ this.syncTrailingNewlineMarker(e.endsWith(`
188
+ `));
181
189
  }
182
190
  // Get cursor position from DOM selection
183
191
  getCursorPosition() {
184
192
  const e = window.getSelection();
185
193
  if (!e || e.rangeCount === 0)
186
194
  return { line: 0, column: 0 };
187
- const t = e.getRangeAt(0), s = t.cloneRange();
188
- s.selectNodeContents(this.contentElement), s.setEnd(t.endContainer, t.endOffset);
189
- const i = s.toString().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(`
190
198
  `);
191
199
  return {
192
- line: i.length - 1,
193
- column: i[i.length - 1].length
200
+ line: s.length - 1,
201
+ column: s[s.length - 1].length
194
202
  };
195
203
  }
196
204
  // Set cursor position
197
205
  setCursorPosition(e) {
198
206
  var g, h;
199
207
  const t = this.getText().split(`
200
- `), s = Math.min(e.line, t.length - 1), i = Math.min(e.column, ((g = t[s]) == null ? void 0 : g.length) || 0);
208
+ `), i = Math.min(e.line, t.length - 1), s = Math.min(e.column, ((g = t[i]) == null ? void 0 : g.length) || 0);
201
209
  let r = 0;
202
- for (let f = 0; f < s; f++)
210
+ for (let f = 0; f < i; f++)
203
211
  r += t[f].length + 1;
204
- r += i;
205
- const o = document.createRange(), n = window.getSelection();
212
+ r += s;
213
+ const n = document.createRange(), o = window.getSelection();
206
214
  let l = 0, c = null, a = 0;
207
215
  const u = document.createTreeWalker(
208
216
  this.contentElement,
@@ -220,31 +228,41 @@ class A {
220
228
  }
221
229
  if (c)
222
230
  try {
223
- o.setStart(c, a), o.setEnd(c, a), n == null || n.removeAllRanges(), n == null || n.addRange(o);
231
+ n.setStart(c, a), n.setEnd(c, a), o == null || o.removeAllRanges(), o == null || o.addRange(n), this.ensureCaretVisible();
224
232
  } catch (f) {
225
233
  console.warn("Could not set cursor position:", f);
226
234
  }
235
+ else {
236
+ const f = this.contentElement.querySelector(
237
+ `[${this.trailingNewlineMarkerAttr}]`
238
+ );
239
+ try {
240
+ f && f.parentNode === this.contentElement ? n.setStartBefore(f) : (n.selectNodeContents(this.contentElement), n.collapse(!1)), n.collapse(!0), o == null || o.removeAllRanges(), o == null || o.addRange(n), this.ensureCaretVisible();
241
+ } catch (p) {
242
+ console.warn("Could not set fallback cursor position:", p);
243
+ }
244
+ }
227
245
  }
228
246
  // Get selection range
229
247
  getSelectionRange() {
230
248
  const e = window.getSelection();
231
249
  if (!e || e.rangeCount === 0 || e.isCollapsed)
232
250
  return;
233
- const t = e.getRangeAt(0), s = t.cloneRange();
234
- s.selectNodeContents(this.contentElement), s.setEnd(t.startContainer, t.startOffset);
235
- const i = s.toString().split(`
251
+ const t = e.getRangeAt(0), i = t.cloneRange();
252
+ i.selectNodeContents(this.contentElement), i.setEnd(t.startContainer, t.startOffset);
253
+ const s = i.toString().replace(/\u200B/g, "").split(`
236
254
  `), r = t.cloneRange();
237
255
  r.selectNodeContents(this.contentElement), r.setEnd(t.endContainer, t.endOffset);
238
- const o = r.toString().split(`
256
+ const n = r.toString().replace(/\u200B/g, "").split(`
239
257
  `);
240
258
  return {
241
259
  start: {
242
- line: i.length - 1,
243
- column: i[i.length - 1].length
260
+ line: s.length - 1,
261
+ column: s[s.length - 1].length
244
262
  },
245
263
  end: {
246
- line: o.length - 1,
247
- column: o[o.length - 1].length
264
+ line: n.length - 1,
265
+ column: n[n.length - 1].length
248
266
  }
249
267
  };
250
268
  }
@@ -254,7 +272,7 @@ class A {
254
272
  }
255
273
  // Focus the editor
256
274
  focus() {
257
- this.contentElement.focus();
275
+ this.contentElement.focus(), this.ensureCaretVisible();
258
276
  }
259
277
  // Blur the editor
260
278
  blur() {
@@ -266,8 +284,8 @@ class A {
266
284
  }
267
285
  // Apply theme
268
286
  applyTheme(e) {
269
- Object.entries(e).forEach(([t, s]) => {
270
- this.container.style.setProperty(`--${t}`, s);
287
+ Object.entries(e).forEach(([t, i]) => {
288
+ this.container.style.setProperty(`--${t}`, i);
271
289
  });
272
290
  }
273
291
  // Scroll to position
@@ -283,14 +301,37 @@ class A {
283
301
  setScrollTop(e) {
284
302
  this.editorContainer.scrollTop = e;
285
303
  }
304
+ syncTrailingNewlineMarker(e) {
305
+ if (this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach((i) => i.remove()), !e) return;
306
+ const t = document.createElement("span");
307
+ t.setAttribute(this.trailingNewlineMarkerAttr, "true"), t.setAttribute("aria-hidden", "true"), t.contentEditable = "false", t.style.cssText = `
308
+ display: inline-block;
309
+ width: 0;
310
+ overflow: hidden;
311
+ pointer-events: none;
312
+ user-select: none;
313
+ `, t.appendChild(document.createTextNode("​")), this.contentElement.appendChild(t);
314
+ }
315
+ // Ensure caret is visible inside the editor scroll container
316
+ ensureCaretVisible() {
317
+ var n;
318
+ const e = window.getSelection();
319
+ if (!e || e.rangeCount === 0) return;
320
+ const t = e.getRangeAt(0).cloneRange();
321
+ t.collapse(!1);
322
+ let i = t.getClientRects()[0] || t.getBoundingClientRect();
323
+ if ((!i || i.width === 0 && i.height === 0) && e.focusNode instanceof Element ? i = e.focusNode.getBoundingClientRect() : (!i || i.width === 0 && i.height === 0) && ((n = e.focusNode) != null && n.parentElement) && (i = e.focusNode.parentElement.getBoundingClientRect()), !i) return;
324
+ const s = this.editorContainer.getBoundingClientRect(), r = 12;
325
+ i.bottom > s.bottom - r ? this.editorContainer.scrollTop += i.bottom - (s.bottom - r) : i.top < s.top + r && (this.editorContainer.scrollTop -= s.top + r - i.top);
326
+ }
286
327
  // Destroy the view
287
328
  destroy() {
288
329
  this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
289
330
  }
290
331
  }
291
- class V {
332
+ const K = class M {
292
333
  constructor(e, t = {}) {
293
- this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.expectingProgrammaticCursor = !1, this.config = {
334
+ this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.config = {
294
335
  value: "",
295
336
  theme: "default",
296
337
  readOnly: !1,
@@ -298,7 +339,7 @@ class V {
298
339
  lineWrapping: !1,
299
340
  lineNumbers: !0,
300
341
  ...t
301
- }, this.textModel = new R(this.config.value), this.view = new A(e), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((s) => this.addExtension(s)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
342
+ }, this.textModel = new P(this.config.value), this.view = new U(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();
302
343
  }
303
344
  // Public accessors for extensions
304
345
  getTextModel() {
@@ -324,20 +365,21 @@ class V {
324
365
  setupEventHandlers() {
325
366
  const e = this.view.getContentElement();
326
367
  e.addEventListener("input", () => {
327
- const t = this.view.getText(), s = this.textModel.getText();
328
- if (t !== s) {
368
+ const t = this.view.getText(), i = this.textModel.getText();
369
+ if (t !== i) {
329
370
  if (!this.suppressHistory) {
330
- const i = this.getCursor().position, r = this.textModel.positionToOffset(i), o = this.getSelection();
331
- let n, l;
332
- o && (n = this.textModel.positionToOffset(o.start), l = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: s, cursorOffset: r, anchorOffset: n, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
371
+ const s = this.getCursor().position, r = this.textModel.positionToOffset(s), n = this.getSelection();
372
+ let o, l;
373
+ n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: i, cursorOffset: r, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
333
374
  }
334
- this.textModel.setText(t), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
335
- this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
336
- }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: s }]);
375
+ this.textModel.setText(t), this.view.syncTrailingNewlineMarkerForText(t), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
376
+ const s = this.view.getText();
377
+ s !== this.textModel.getText() && this.textModel.setText(s), this.renderTextWithHighlight(this.textModel.getText(), !1), this.highlightTimeout = null;
378
+ }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: t, oldText: i }]);
337
379
  }
338
380
  }), e.addEventListener("selectionchange", () => {
339
- const t = this.getCursor(), s = this.getSelection();
340
- this.emit("cursor", t), s && this.emit("selection", s);
381
+ const t = this.getCursor(), i = this.getSelection();
382
+ this.emit("cursor", t), i && this.emit("selection", i);
341
383
  }), e.addEventListener("keydown", (t) => {
342
384
  if (this.emit("keydown", t), t.key === "Tab") {
343
385
  this.config.readOnly || this.insertTab(), t.preventDefault(), t.stopPropagation();
@@ -345,31 +387,35 @@ class V {
345
387
  }
346
388
  if (t.key === "Enter") {
347
389
  if (!this.config.readOnly) {
348
- const s = window.getSelection();
349
- if (s && s.rangeCount > 0) {
350
- const i = this.getCursor().position, r = this.textModel.positionToOffset(i), o = this.getSelection();
351
- let n, l;
352
- o && (n = this.textModel.positionToOffset(o.start), l = this.textModel.positionToOffset(o.end)), this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: r, anchorOffset: n, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
353
- const c = s.getRangeAt(0);
354
- c.deleteContents();
355
- const a = document.createTextNode(`
390
+ const i = window.getSelection();
391
+ if (i && i.rangeCount > 0) {
392
+ const s = this.getCursor().position, r = this.textModel.positionToOffset(s), n = this.getSelection();
393
+ let o, l;
394
+ n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end));
395
+ const c = n && o !== void 0 && l !== void 0 ? Math.min(o, l) : r;
396
+ this.suppressHistory || (this.undoStack.push({ text: this.textModel.getText(), cursorOffset: r, anchorOffset: o, focusOffset: l }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0);
397
+ const a = i.getRangeAt(0);
398
+ a.deleteContents();
399
+ const u = document.createTextNode(`
356
400
  `);
357
- c.insertNode(a), c.setStartAfter(a), c.collapse(!0), s.removeAllRanges(), s.addRange(c);
358
- const u = this.getCursor().position, d = this.textModel.positionToOffset(u), g = this.getSelection();
359
- let h, f;
360
- g && (h = this.textModel.positionToOffset(g.start), f = this.textModel.positionToOffset(g.end));
361
- const p = this.view.getText();
362
- this.textModel.setText(p), this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
401
+ a.insertNode(u), a.setStartAfter(u), a.collapse(!0), i.removeAllRanges(), i.addRange(a), this.view.ensureCaretVisible();
402
+ const d = this.view.getText();
403
+ this.textModel.setText(d), this.view.syncTrailingNewlineMarkerForText(d);
404
+ const g = Math.min(
405
+ c + 1,
406
+ this.textModel.getText().length
407
+ );
408
+ try {
409
+ const h = this.textModel.offsetToPosition(g);
410
+ this.setCursor(h), this.view.ensureCaretVisible();
411
+ } catch (h) {
412
+ }
413
+ this.highlightTimeout && clearTimeout(this.highlightTimeout), this.highlightTimeout = setTimeout(() => {
363
414
  this.renderTextWithHighlight(this.textModel.getText(), !1), requestAnimationFrame(() => {
364
415
  try {
365
- if (g && (h !== void 0 || f !== void 0)) {
366
- const x = h !== void 0 ? h : d, b = f !== void 0 ? f : d, y = Math.min(x, b), C = Math.max(x, b), L = this.textModel.offsetToPosition(y), w = this.textModel.offsetToPosition(C);
367
- this.setSelection({ start: L, end: w });
368
- } else {
369
- const x = this.textModel.offsetToPosition(d);
370
- this.setCursor(x);
371
- }
372
- } catch (x) {
416
+ const h = this.textModel.offsetToPosition(g);
417
+ this.setCursor(h), this.view.ensureCaretVisible();
418
+ } catch (h) {
373
419
  }
374
420
  }), this.highlightTimeout = null;
375
421
  }, 300), this.updateLineNumbers(), this.emit("change", [{ range: this.getFullRange(), text: this.getValue(), oldText: "" }]);
@@ -378,15 +424,15 @@ class V {
378
424
  t.preventDefault(), t.stopPropagation();
379
425
  return;
380
426
  }
381
- for (const s of this.extensions.values())
382
- if (s.onKeyDown && s.onKeyDown(t) === !1) {
427
+ for (const i of this.extensions.values())
428
+ if (i.onKeyDown && i.onKeyDown(t) === !1) {
383
429
  t.preventDefault(), t.stopPropagation();
384
430
  return;
385
431
  }
386
432
  }), e.addEventListener("mousedown", (t) => {
387
433
  this.emit("mousedown", t);
388
- for (const s of this.extensions.values())
389
- if (s.onMouseDown && s.onMouseDown(t) === !1) {
434
+ for (const i of this.extensions.values())
435
+ if (i.onMouseDown && i.onMouseDown(t) === !1) {
390
436
  t.preventDefault(), t.stopPropagation();
391
437
  return;
392
438
  }
@@ -413,8 +459,8 @@ class V {
413
459
  }
414
460
  // Emit events to listeners
415
461
  emit(e, ...t) {
416
- const s = this.eventListeners.get(e);
417
- s && s.forEach((i) => i(...t));
462
+ const i = this.eventListeners.get(e);
463
+ i && i.forEach((s) => s(...t));
418
464
  }
419
465
  // State management
420
466
  getValue() {
@@ -462,12 +508,12 @@ class V {
462
508
  "editor-gutter-border": e === "dark" ? "#3e3e42" : "#e1e5e9"
463
509
  };
464
510
  this.view.applyTheme(t);
465
- const s = this.extensions.get("syntax-highlighting");
466
- if (s && typeof s.setTheme == "function")
511
+ const i = this.extensions.get("syntax-highlighting");
512
+ if (i && typeof i.setTheme == "function")
467
513
  try {
468
- s.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
469
- } catch (i) {
470
- console.warn("Error applying theme to syntax-highlighting extension", i);
514
+ i.setTheme(e === "dark" ? "dark" : "light"), this.renderTextWithHighlight(this.textModel.getText());
515
+ } catch (s) {
516
+ console.warn("Error applying theme to syntax-highlighting extension", s);
471
517
  }
472
518
  }
473
519
  setReadOnly(e) {
@@ -484,8 +530,8 @@ class V {
484
530
  t && t.destroy && t.destroy(), this.extensions.delete(e);
485
531
  }
486
532
  executeCommand(e, ...t) {
487
- const s = this.commands.get(e);
488
- s ? s(this, ...t) : console.warn(`Command '${e}' not found`);
533
+ const i = this.commands.get(e);
534
+ i ? i(this, ...t) : console.warn(`Command '${e}' not found`);
489
535
  }
490
536
  // Register a command
491
537
  registerCommand(e, t) {
@@ -493,51 +539,51 @@ class V {
493
539
  }
494
540
  // Search & Navigation
495
541
  search(e, t = {}) {
496
- const s = {
542
+ const i = {
497
543
  caseSensitive: !1,
498
544
  regex: !1,
499
545
  ...t
500
- }, i = [], r = this.getValue();
546
+ }, s = [], r = this.getValue();
501
547
  r.split(`
502
548
  `);
503
- let o = s.caseSensitive ? r : r.toLowerCase(), n = s.caseSensitive ? e : e.toLowerCase();
504
- if (s.regex) {
505
- const l = new RegExp(n, s.caseSensitive ? "g" : "gi");
549
+ let n = i.caseSensitive ? r : r.toLowerCase(), o = i.caseSensitive ? e : e.toLowerCase();
550
+ if (i.regex) {
551
+ const l = new RegExp(o, i.caseSensitive ? "g" : "gi");
506
552
  let c;
507
- for (; (c = l.exec(o)) !== null; ) {
553
+ for (; (c = l.exec(n)) !== null; ) {
508
554
  const a = this.textModel.offsetToPosition(c.index), u = this.textModel.offsetToPosition(c.index + c[0].length);
509
- i.push({
555
+ s.push({
510
556
  range: { start: a, end: u },
511
557
  match: c[0]
512
558
  });
513
559
  }
514
560
  } else {
515
- let l = 0, c = o.indexOf(n, l);
561
+ let l = 0, c = n.indexOf(o, l);
516
562
  for (; c !== -1; ) {
517
563
  const a = c + e.length, u = this.textModel.offsetToPosition(c), d = this.textModel.offsetToPosition(a);
518
- i.push({
564
+ s.push({
519
565
  range: { start: u, end: d },
520
566
  match: r.substring(c, a)
521
- }), l = a, c = o.indexOf(n, l);
567
+ }), l = a, c = n.indexOf(o, l);
522
568
  }
523
569
  }
524
- return i;
570
+ return s;
525
571
  }
526
572
  replace(e, t) {
527
- const s = this.getValue();
573
+ const i = this.getValue();
528
574
  if (!this.suppressHistory) {
529
- const r = this.getCursor().position, o = this.textModel.positionToOffset(r), n = this.getSelection();
575
+ const r = this.getCursor().position, n = this.textModel.positionToOffset(r), o = this.getSelection();
530
576
  let l, c;
531
- n && (l = this.textModel.positionToOffset(n.start), c = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: s, cursorOffset: o, anchorOffset: l, focusOffset: c }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
577
+ o && (l = this.textModel.positionToOffset(o.start), c = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: i, cursorOffset: n, anchorOffset: l, focusOffset: c }), this.undoStack.length > 100 && this.undoStack.shift(), this.redoStack.length = 0;
532
578
  }
533
- const i = this.textModel.replaceRange(e, t);
534
- this.renderTextWithHighlight(this.getValue(), !1), this.emit("change", [i]);
579
+ const s = this.textModel.replaceRange(e, t);
580
+ this.renderTextWithHighlight(this.getValue(), !1), this.emit("change", [s]);
535
581
  }
536
- replaceAll(e, t, s = {}) {
537
- const i = this.search(e, s);
582
+ replaceAll(e, t, i = {}) {
583
+ const s = this.search(e, i);
538
584
  let r = 0;
539
- for (let o = i.length - 1; o >= 0; o--)
540
- this.replace(i[o].range, t), r++;
585
+ for (let n = s.length - 1; n >= 0; n--)
586
+ this.replace(s[n].range, t), r++;
541
587
  return r;
542
588
  }
543
589
  // Folding (basic implementation)
@@ -570,35 +616,85 @@ class V {
570
616
  // and restores it after updating the DOM. Callers that will explicitly set the caret
571
617
  // should pass `false` to avoid stomping programmatic cursor changes.
572
618
  renderTextWithHighlight(e, t = !0) {
573
- const s = this.extensions.get("syntax-highlighting");
574
- if (s && typeof s.highlightHTML == "function")
619
+ const i = this.extensions.get("syntax-highlighting");
620
+ if (i && typeof i.highlightHTML == "function")
575
621
  try {
576
- const i = !t && !this.expectingProgrammaticCursor;
577
- let r, o, n, l;
578
- if (t || i) {
622
+ const s = !t && !this.expectingProgrammaticCursor;
623
+ let r, n, o, l;
624
+ if (t || s) {
579
625
  r = this.getSelection();
580
- const a = this.getCursor().position;
581
- o = this.textModel.positionToOffset(a), r && (n = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end));
626
+ const d = this.getCollapsedSelectionOffsetInEditor();
627
+ if (d !== void 0)
628
+ n = d;
629
+ else {
630
+ const g = this.getCursor().position;
631
+ n = this.textModel.positionToOffset(g);
632
+ }
633
+ r && (o = this.textModel.positionToOffset(r.start), l = this.textModel.positionToOffset(r.end));
582
634
  }
583
- const c = s.highlightHTML(e);
584
- typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(c) : this.view.setHTML(c), (t || i) && requestAnimationFrame(() => {
635
+ const c = (t || s) && !r && n !== void 0 && this.hasCollapsedSelectionInEditor(), a = c ? this.insertSentinelAtOffset(e, n) : e, u = i.highlightHTML(a);
636
+ typeof this.view.setHighlightHTML == "function" ? this.view.setHighlightHTML(u) : this.view.setHTML(u), this.view.syncTrailingNewlineMarkerForText(e), (t || s) && requestAnimationFrame(() => {
585
637
  try {
586
- if (r && (n !== void 0 || l !== void 0)) {
587
- const a = n !== void 0 ? n : o, u = l !== void 0 ? l : o, d = Math.min(a, u), g = Math.max(a, u), h = this.textModel.offsetToPosition(d), f = this.textModel.offsetToPosition(g);
588
- this.view.setSelectionRange({ start: h, end: f });
589
- } else if (o !== void 0) {
590
- const a = this.textModel.offsetToPosition(o);
591
- this.view.setCursorPosition(a);
638
+ if (c && this.restoreCursorFromSentinel()) {
639
+ this.view.ensureCaretVisible();
640
+ return;
641
+ }
642
+ if (r && (o !== void 0 || l !== void 0)) {
643
+ const d = o !== void 0 ? o : n, g = l !== void 0 ? l : n, h = Math.min(d, g), f = Math.max(d, g), p = this.textModel.offsetToPosition(h), x = this.textModel.offsetToPosition(f);
644
+ this.view.setSelectionRange({ start: p, end: x });
645
+ } else if (n !== void 0) {
646
+ const d = this.textModel.offsetToPosition(n);
647
+ this.view.setCursorPosition(d);
592
648
  }
593
- } catch (a) {
649
+ } catch (d) {
594
650
  }
595
651
  });
596
652
  return;
597
- } catch (i) {
598
- console.warn("Syntax highlighting failed, falling back to plain text", i);
653
+ } catch (s) {
654
+ console.warn("Syntax highlighting failed, falling back to plain text", s);
599
655
  }
600
656
  this.view.setText(e);
601
657
  }
658
+ hasCollapsedSelectionInEditor() {
659
+ const e = window.getSelection();
660
+ if (!e || e.rangeCount === 0 || !e.isCollapsed)
661
+ return !1;
662
+ const t = e.getRangeAt(0);
663
+ return this.view.getContentElement().contains(t.commonAncestorContainer);
664
+ }
665
+ getCollapsedSelectionOffsetInEditor() {
666
+ const e = window.getSelection();
667
+ if (!e || e.rangeCount === 0 || !e.isCollapsed)
668
+ return;
669
+ const t = e.getRangeAt(0), i = this.view.getContentElement();
670
+ if (!i.contains(t.commonAncestorContainer))
671
+ return;
672
+ const s = t.cloneRange();
673
+ return s.selectNodeContents(i), s.setEnd(t.endContainer, t.endOffset), this.stripVirtualMarkers(s.toString()).length;
674
+ }
675
+ stripVirtualMarkers(e) {
676
+ return e.replace(/\u200B/g, "").split(M.CURSOR_SENTINEL).join("");
677
+ }
678
+ insertSentinelAtOffset(e, t) {
679
+ const i = Math.max(0, Math.min(t, e.length));
680
+ return e.slice(0, i) + M.CURSOR_SENTINEL + e.slice(i);
681
+ }
682
+ restoreCursorFromSentinel() {
683
+ var o;
684
+ const e = this.view.getContentElement(), t = window.getSelection(), i = document.createTreeWalker(e, NodeFilter.SHOW_TEXT);
685
+ let s = i.nextNode(), r = null, n = 0;
686
+ for (; s; ) {
687
+ const l = (o = s.textContent) != null ? o : "", c = l.indexOf(M.CURSOR_SENTINEL);
688
+ c !== -1 && (r || (r = s, n = c), s.textContent = l.split(M.CURSOR_SENTINEL).join("")), s = i.nextNode();
689
+ }
690
+ if (!r || !t) return !1;
691
+ try {
692
+ const l = document.createRange();
693
+ return l.setStart(r, n), l.collapse(!0), t.removeAllRanges(), t.addRange(l), !0;
694
+ } catch (l) {
695
+ return !1;
696
+ }
697
+ }
602
698
  destroy() {
603
699
  if (!this.isDestroyed) {
604
700
  this.isDestroyed = !0;
@@ -614,15 +710,15 @@ class V {
614
710
  this.redoStack.push(t);
615
711
  try {
616
712
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
617
- let s, i;
618
- typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
713
+ let i, s;
714
+ typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
619
715
  try {
620
- if (i != null)
716
+ if (s != null)
621
717
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
622
- const r = e.anchorOffset !== void 0 ? e.anchorOffset : i, o = e.focusOffset !== void 0 ? e.focusOffset : i, n = Math.min(r, o), l = Math.max(r, o), c = this.textModel.offsetToPosition(n), a = this.textModel.offsetToPosition(l);
718
+ const r = e.anchorOffset !== void 0 ? e.anchorOffset : s, n = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(r, n), l = Math.max(r, n), c = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
623
719
  this.setSelection({ start: c, end: a });
624
720
  } else {
625
- const r = this.textModel.offsetToPosition(i);
721
+ const r = this.textModel.offsetToPosition(s);
626
722
  this.setCursor(r);
627
723
  }
628
724
  } catch (r) {
@@ -640,15 +736,15 @@ class V {
640
736
  this.undoStack.push(t);
641
737
  try {
642
738
  this.suppressHistory = !0, this.expectingProgrammaticCursor = !0;
643
- let s, i;
644
- typeof e == "string" ? s = e : (s = e.text, i = e.cursorOffset), this.setValue(s), requestAnimationFrame(() => {
739
+ let i, s;
740
+ typeof e == "string" ? i = e : (i = e.text, s = e.cursorOffset), this.setValue(i), requestAnimationFrame(() => {
645
741
  try {
646
- if (i != null)
742
+ if (s != null)
647
743
  if (typeof e != "string" && (e.anchorOffset !== void 0 || e.focusOffset !== void 0)) {
648
- const r = e.anchorOffset !== void 0 ? e.anchorOffset : i, o = e.focusOffset !== void 0 ? e.focusOffset : i, n = Math.min(r, o), l = Math.max(r, o), c = this.textModel.offsetToPosition(n), a = this.textModel.offsetToPosition(l);
744
+ const r = e.anchorOffset !== void 0 ? e.anchorOffset : s, n = e.focusOffset !== void 0 ? e.focusOffset : s, o = Math.min(r, n), l = Math.max(r, n), c = this.textModel.offsetToPosition(o), a = this.textModel.offsetToPosition(l);
649
745
  this.setSelection({ start: c, end: a });
650
746
  } else {
651
- const r = this.textModel.offsetToPosition(i);
747
+ const r = this.textModel.offsetToPosition(s);
652
748
  this.setCursor(r);
653
749
  }
654
750
  } catch (r) {
@@ -663,29 +759,29 @@ class V {
663
759
  // Insert a tab character or spaces at current cursor
664
760
  insertTab() {
665
761
  if (this.config.readOnly) return;
666
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = " ".repeat(this.config.tabSize || 2), i = this.textModel.insertText(e, s), r = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + s.length);
762
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = " ".repeat(this.config.tabSize || 2), s = this.textModel.insertText(e, i), r = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + i.length);
667
763
  if (!this.suppressHistory) {
668
- const o = this.getSelection();
669
- let n, l;
670
- o && (n = this.textModel.positionToOffset(o.start), l = this.textModel.positionToOffset(o.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: n, focusOffset: l }), this.redoStack.length = 0;
764
+ const n = this.getSelection();
765
+ let o, l;
766
+ n && (o = this.textModel.positionToOffset(n.start), l = this.textModel.positionToOffset(n.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: l }), this.redoStack.length = 0;
671
767
  }
672
768
  this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(r), setTimeout(() => {
673
769
  this.expectingProgrammaticCursor = !1;
674
- }, 20), this.emit("change", [i]);
770
+ }, 20), this.emit("change", [s]);
675
771
  }
676
772
  // Insert a newline at current cursor position
677
773
  insertNewLine() {
678
774
  if (this.config.readOnly) return;
679
- const e = this.getCursor().position, t = this.textModel.positionToOffset(e), s = this.textModel.insertText(e, `
680
- `), i = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
775
+ const e = this.getCursor().position, t = this.textModel.positionToOffset(e), i = this.textModel.insertText(e, `
776
+ `), s = this.textModel.offsetToPosition(this.textModel.positionToOffset(e) + 1);
681
777
  if (!this.suppressHistory) {
682
778
  const r = this.getSelection();
683
- let o, n;
684
- r && (o = this.textModel.positionToOffset(r.start), n = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: o, focusOffset: n }), this.redoStack.length = 0;
779
+ let n, o;
780
+ r && (n = this.textModel.positionToOffset(r.start), o = this.textModel.positionToOffset(r.end)), this.undoStack.push({ text: this.getValue(), cursorOffset: t, anchorOffset: n, focusOffset: o }), this.redoStack.length = 0;
685
781
  }
686
- this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(i), setTimeout(() => {
782
+ this.expectingProgrammaticCursor = !0, this.renderTextWithHighlight(this.getValue(), !1), this.setCursor(s), setTimeout(() => {
687
783
  this.expectingProgrammaticCursor = !1;
688
- }, 20), this.emit("change", [s]);
784
+ }, 20), this.emit("change", [i]);
689
785
  }
690
786
  // Events
691
787
  on(e, t) {
@@ -693,15 +789,17 @@ class V {
693
789
  }
694
790
  off(e, t) {
695
791
  if (!this.eventListeners.has(e)) return;
696
- const s = this.eventListeners.get(e);
792
+ const i = this.eventListeners.get(e);
697
793
  if (t) {
698
- const i = s.indexOf(t);
699
- i !== -1 && s.splice(i, 1);
794
+ const s = i.indexOf(t);
795
+ s !== -1 && i.splice(s, 1);
700
796
  } else
701
- s.length = 0;
797
+ i.length = 0;
702
798
  }
703
- }
704
- class U {
799
+ };
800
+ K.CURSOR_SENTINEL = "";
801
+ let z = K;
802
+ class q {
705
803
  constructor(e) {
706
804
  this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
707
805
  }
@@ -715,10 +813,10 @@ class U {
715
813
  return this.editor.executeCommand(t.command), e.preventDefault(), e.stopPropagation(), !1;
716
814
  }
717
815
  findMatchingBinding(e) {
718
- const { key: t, ctrlKey: s, altKey: i, shiftKey: r, metaKey: o } = e, n = String(t).toLowerCase(), l = this.keymap[n];
816
+ const { key: t, ctrlKey: i, altKey: s, shiftKey: r, metaKey: n } = e, o = String(t).toLowerCase(), l = this.keymap[o];
719
817
  if (!l) return null;
720
818
  for (const c of l) {
721
- const a = c.ctrlKey === void 0 || c.ctrlKey === s, u = c.altKey === void 0 || c.altKey === i, d = c.shiftKey === void 0 || c.shiftKey === r, g = c.metaKey === void 0 || c.metaKey === o;
819
+ const a = c.ctrlKey === void 0 || c.ctrlKey === i, u = c.altKey === void 0 || c.altKey === s, d = c.shiftKey === void 0 || c.shiftKey === r, g = c.metaKey === void 0 || c.metaKey === n;
722
820
  if (a && u && d && g)
723
821
  return c;
724
822
  }
@@ -732,12 +830,12 @@ class U {
732
830
  const e = {};
733
831
  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;
734
832
  }
735
- addBinding(e, t, s, i) {
833
+ addBinding(e, t, i, s) {
736
834
  const r = t.toLowerCase();
737
835
  e[r] || (e[r] = []), e[r].push({
738
836
  key: r,
739
- command: i,
740
- ...s
837
+ command: s,
838
+ ...i
741
839
  });
742
840
  }
743
841
  // Public API for customizing keymap
@@ -746,23 +844,23 @@ class U {
746
844
  }
747
845
  addKeyBinding(e) {
748
846
  const t = e.key.toLowerCase();
749
- this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((s) => s.command !== e.command), this.keymap[t].push({
847
+ this.keymap[t] || (this.keymap[t] = []), this.keymap[t] = this.keymap[t].filter((i) => i.command !== e.command), this.keymap[t].push({
750
848
  ...e,
751
849
  key: t
752
850
  });
753
851
  }
754
852
  removeKeyBinding(e, t) {
755
- const s = e.toLowerCase();
756
- 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];
853
+ const i = e.toLowerCase();
854
+ 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];
757
855
  }
758
856
  getKeymap() {
759
857
  return { ...this.keymap };
760
858
  }
761
859
  getBindingsForCommand(e) {
762
860
  const t = [];
763
- for (const s in this.keymap)
764
- for (const i of this.keymap[s])
765
- i.command === e && t.push({ ...i });
861
+ for (const i in this.keymap)
862
+ for (const s of this.keymap[i])
863
+ s.command === e && t.push({ ...s });
766
864
  return t;
767
865
  }
768
866
  getPlatformInfo() {
@@ -775,19 +873,19 @@ class U {
775
873
  this.keymap = {}, this.editor = null;
776
874
  }
777
875
  }
778
- class z {
876
+ class F {
779
877
  constructor() {
780
878
  this.name = "transaction", this.transactions = [];
781
879
  }
782
880
  setup(e) {
783
881
  e.on("change", (t) => {
784
- const s = {
785
- changes: [t],
882
+ const i = {
883
+ changes: t,
786
884
  selection: e.getSelection(),
787
885
  effects: [],
788
886
  annotations: []
789
887
  };
790
- this.transactions.push(s);
888
+ this.transactions.push(i);
791
889
  });
792
890
  }
793
891
  getTransactions() {
@@ -797,7 +895,7 @@ class z {
797
895
  this.transactions = [];
798
896
  }
799
897
  }
800
- class q {
898
+ class _ {
801
899
  constructor() {
802
900
  this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
803
901
  }
@@ -816,10 +914,11 @@ class q {
816
914
  updateLineNumbers() {
817
915
  if (!this.lineNumbersElement || !this.editor || !this.isEnabled) return;
818
916
  const e = this.editor.getValue().split(`
819
- `).length, t = Array.from({ length: Math.max(e, 20) }, (s, i) => i + 1);
820
- this.lineNumbersElement.innerHTML = t.map((s) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("");
917
+ `).length, t = Array.from({ length: Math.max(e, 20) }, (i, s) => s + 1);
918
+ this.lineNumbersElement.innerHTML = t.map((i) => `<div style="height: 21px; line-height: 21px; padding-right: 12px;">${i}</div>`).join("");
821
919
  }
822
920
  toggle() {
921
+ if (!this.editor) return;
823
922
  this.isEnabled = !this.isEnabled, this.lineNumbersElement && (this.lineNumbersElement.style.display = this.isEnabled ? "block" : "none");
824
923
  const e = this.editor.getView().getContentElement();
825
924
  e && (e.style.marginLeft = this.isEnabled ? "60px" : "0"), this.updateLineNumbers();
@@ -828,7 +927,7 @@ class q {
828
927
  this.lineNumbersElement = null, this.editor = null;
829
928
  }
830
929
  }
831
- class _ {
930
+ class W {
832
931
  constructor() {
833
932
  this.name = "theme", this.editor = null, this.currentTheme = "dark";
834
933
  }
@@ -853,7 +952,7 @@ class _ {
853
952
  this.editor = null;
854
953
  }
855
954
  }
856
- class F {
955
+ class D {
857
956
  constructor() {
858
957
  this.name = "read-only", this.editor = null, this.isReadOnly = !1;
859
958
  }
@@ -880,7 +979,7 @@ class F {
880
979
  this.editor = null;
881
980
  }
882
981
  }
883
- class D {
982
+ class j {
884
983
  constructor() {
885
984
  this.name = "search", this.editor = null, this.searchUI = null, this.isVisible = !1, this.currentResults = [], this.currentIndex = -1;
886
985
  }
@@ -893,8 +992,8 @@ class D {
893
992
  this.findPrev();
894
993
  }), e.registerCommand("replace", () => {
895
994
  this.showReplace();
896
- }), e.registerCommand("replaceAll", (t, s) => {
897
- this.replaceAll(t, s);
995
+ }), e.registerCommand("replaceAll", (t, i) => {
996
+ this.replaceAll(t, i);
898
997
  });
899
998
  }
900
999
  showSearch() {
@@ -905,11 +1004,11 @@ class D {
905
1004
  }
906
1005
  }
907
1006
  showReplace() {
908
- var s, i;
1007
+ var i, s;
909
1008
  this.showSearch();
910
- const e = (s = this.searchUI) == null ? void 0 : s.querySelector(".search-replace-input");
1009
+ const e = (i = this.searchUI) == null ? void 0 : i.querySelector(".search-replace-input");
911
1010
  e && (e.style.display = "block", e.focus());
912
- const t = (i = this.searchUI) == null ? void 0 : i.querySelector(".search-status");
1011
+ const t = (s = this.searchUI) == null ? void 0 : s.querySelector(".search-status");
913
1012
  t && (t.textContent = "Replace mode - Enter to replace, Shift+Enter to replace all");
914
1013
  }
915
1014
  hideSearch() {
@@ -989,35 +1088,35 @@ class D {
989
1088
  margin-top: 4px;
990
1089
  " />
991
1090
  `;
992
- const t = this.searchUI.querySelector("input"), s = this.searchUI.querySelector(".search-replace-input"), i = this.searchUI.querySelector(".search-prev"), r = this.searchUI.querySelector(".search-next"), o = this.searchUI.querySelector(".search-close");
1091
+ const t = this.searchUI.querySelector("input"), i = this.searchUI.querySelector(".search-replace-input"), s = this.searchUI.querySelector(".search-prev"), r = this.searchUI.querySelector(".search-next"), n = this.searchUI.querySelector(".search-close");
993
1092
  t.addEventListener("input", () => {
994
1093
  this.performSearch(t.value);
995
- }), t.addEventListener("keydown", (n) => {
996
- n.key === "Enter" && (n.preventDefault(), n.shiftKey ? this.findPrev() : this.findNext());
997
- }), s.addEventListener("keydown", (n) => {
998
- n.key === "Enter" && (n.preventDefault(), n.shiftKey ? this.replaceAll(t.value, s.value) : this.replaceCurrent(t.value, s.value));
999
- }), i.addEventListener("click", () => this.findPrev()), r.addEventListener("click", () => this.findNext()), o.addEventListener("click", () => this.hideSearch()), e.appendChild(this.searchUI);
1094
+ }), t.addEventListener("keydown", (o) => {
1095
+ o.key === "Enter" && (o.preventDefault(), o.shiftKey ? this.findPrev() : this.findNext());
1096
+ }), i.addEventListener("keydown", (o) => {
1097
+ o.key === "Enter" && (o.preventDefault(), o.shiftKey ? this.replaceAll(t.value, i.value) : this.replaceCurrent(t.value, i.value));
1098
+ }), s.addEventListener("click", () => this.findPrev()), r.addEventListener("click", () => this.findNext()), n.addEventListener("click", () => this.hideSearch()), e.appendChild(this.searchUI);
1000
1099
  }
1001
1100
  performSearch(e) {
1002
1101
  if (!this.editor || !e.trim()) {
1003
1102
  this.clearHighlights(), this.updateStatus("");
1004
1103
  return;
1005
1104
  }
1006
- const t = this.editor.getValue(), s = [];
1007
- let i = t.toLowerCase().indexOf(e.toLowerCase());
1008
- for (; i !== -1; ) {
1009
- const r = this.getPositionFromOffset(t, i), o = this.getPositionFromOffset(t, i + e.length);
1010
- s.push({
1011
- range: { start: r, end: o },
1012
- match: t.substring(i, i + e.length)
1013
- }), i = t.toLowerCase().indexOf(e.toLowerCase(), i + 1);
1105
+ const t = this.editor.getValue(), i = [];
1106
+ let s = t.toLowerCase().indexOf(e.toLowerCase());
1107
+ for (; s !== -1; ) {
1108
+ const r = this.getPositionFromOffset(t, s), n = this.getPositionFromOffset(t, s + e.length);
1109
+ i.push({
1110
+ range: { start: r, end: n },
1111
+ match: t.substring(s, s + e.length)
1112
+ }), s = t.toLowerCase().indexOf(e.toLowerCase(), s + 1);
1014
1113
  }
1015
- this.currentResults = s, this.currentIndex = this.currentResults.length > 0 ? 0 : -1, this.updateHighlights(), this.updateStatus(`${this.currentResults.length} matches`);
1114
+ this.currentResults = i, this.currentIndex = this.currentResults.length > 0 ? 0 : -1, this.updateHighlights(), this.updateStatus(`${this.currentResults.length} matches`);
1016
1115
  }
1017
1116
  getPositionFromOffset(e, t) {
1018
- const s = e.substring(0, t).split(`
1019
- `), i = s.length - 1, r = s[s.length - 1].length;
1020
- return { line: i, column: r };
1117
+ const i = e.substring(0, t).split(`
1118
+ `), s = i.length - 1, r = i[i.length - 1].length;
1119
+ return { line: s, column: r };
1021
1120
  }
1022
1121
  findNext() {
1023
1122
  this.currentResults.length !== 0 && (this.currentIndex = (this.currentIndex + 1) % this.currentResults.length, this.updateHighlights());
@@ -1027,25 +1126,25 @@ class D {
1027
1126
  }
1028
1127
  replaceCurrent(e, t) {
1029
1128
  if (!this.editor || !e.trim() || this.currentIndex === -1) return;
1030
- const s = this.currentResults[this.currentIndex];
1031
- if (!s) return;
1032
- const i = this.editor.getValue(), r = this.getOffsetFromPosition(i, s.range.start), o = i.substring(0, r), n = i.substring(r + e.length), l = o + t + n;
1129
+ const i = this.currentResults[this.currentIndex];
1130
+ if (!i) return;
1131
+ const s = this.editor.getValue(), r = this.getOffsetFromPosition(s, i.range.start), n = s.substring(0, r), o = s.substring(r + e.length), l = n + t + o;
1033
1132
  this.editor.setValue(l), this.performSearch(e), this.updateStatus("Replaced current occurrence");
1034
1133
  }
1035
1134
  replaceAll(e, t) {
1036
1135
  if (!this.editor || !e.trim()) return;
1037
- let s = this.editor.getValue(), i = 0, r = s.toLowerCase().indexOf(e.toLowerCase());
1136
+ let i = this.editor.getValue(), s = 0, r = i.toLowerCase().indexOf(e.toLowerCase());
1038
1137
  for (; r !== -1; )
1039
- s = s.substring(0, r) + t + s.substring(r + e.length), i++, r = s.toLowerCase().indexOf(e.toLowerCase(), r + t.length);
1040
- i > 0 && (this.editor.setValue(s), this.updateStatus(`Replaced ${i} occurrences`));
1138
+ i = i.substring(0, r) + t + i.substring(r + e.length), s++, r = i.toLowerCase().indexOf(e.toLowerCase(), r + t.length);
1139
+ s > 0 && (this.editor.setValue(i), this.updateStatus(`Replaced ${s} occurrences`));
1041
1140
  }
1042
1141
  getOffsetFromPosition(e, t) {
1043
- const s = e.split(`
1142
+ const i = e.split(`
1044
1143
  `);
1045
- let i = 0;
1144
+ let s = 0;
1046
1145
  for (let r = 0; r < t.line; r++)
1047
- i += s[r].length + 1;
1048
- return i += t.column, i;
1146
+ s += i[r].length + 1;
1147
+ return s += t.column, s;
1049
1148
  }
1050
1149
  updateHighlights() {
1051
1150
  this.clearHighlights(), !(this.currentResults.length === 0 || this.currentIndex === -1) && (this.currentResults[this.currentIndex], this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex + 1}/${this.currentResults.length})`));
@@ -1053,15 +1152,15 @@ class D {
1053
1152
  clearHighlights() {
1054
1153
  }
1055
1154
  updateStatus(e) {
1056
- var s;
1057
- const t = (s = this.searchUI) == null ? void 0 : s.querySelector(".search-status");
1155
+ var i;
1156
+ const t = (i = this.searchUI) == null ? void 0 : i.querySelector(".search-status");
1058
1157
  t && (t.textContent = e);
1059
1158
  }
1060
1159
  destroy() {
1061
1160
  this.searchUI && this.searchUI.parentNode && this.searchUI.parentNode.removeChild(this.searchUI), this.searchUI = null, this.editor = null;
1062
1161
  }
1063
1162
  }
1064
- class W {
1163
+ class Z {
1065
1164
  constructor() {
1066
1165
  this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
1067
1166
  "(": ")",
@@ -1086,37 +1185,37 @@ class W {
1086
1185
  if (!this.editor) return;
1087
1186
  const e = this.editor.getCursor(), t = this.editor.getValue();
1088
1187
  this.clearBracketHighlighting();
1089
- const s = this.getBracketAtPosition(t, e.position);
1090
- if (!s) return;
1091
- const i = this.findMatchingBracket(t, s);
1092
- i && (this.currentMatch = i, this.highlightBrackets(i));
1188
+ const i = this.getBracketAtPosition(t, e.position);
1189
+ if (!i) return;
1190
+ const s = this.findMatchingBracket(t, i);
1191
+ s && (this.currentMatch = s, this.highlightBrackets(s));
1093
1192
  }
1094
1193
  getBracketAtPosition(e, t) {
1095
- const s = e.split(`
1194
+ const i = e.split(`
1096
1195
  `);
1097
- if (t.line >= s.length) return null;
1098
- const i = s[t.line];
1099
- if (t.column >= i.length) return null;
1100
- const r = i[t.column];
1196
+ if (t.line >= i.length) return null;
1197
+ const s = i[t.line];
1198
+ if (t.column >= s.length) return null;
1199
+ const r = s[t.column];
1101
1200
  return this.bracketPairs[r] || this.reverseBracketPairs[r] ? { char: r, position: t } : null;
1102
1201
  }
1103
1202
  findMatchingBracket(e, t) {
1104
- const s = e.split(`
1105
- `), i = t.position.line, r = t.position.column, o = t.char;
1106
- return this.bracketPairs[o] ? this.findClosingBracket(e, s, i, r, o) : this.reverseBracketPairs[o] ? this.findOpeningBracket(e, s, i, r, o) : null;
1107
- }
1108
- findClosingBracket(e, t, s, i, r) {
1109
- const o = this.bracketPairs[r];
1110
- let n = 0;
1111
- for (let l = s; l < t.length; l++) {
1112
- const c = t[l], a = l === s ? i : 0;
1203
+ const i = e.split(`
1204
+ `), s = t.position.line, r = t.position.column, n = t.char;
1205
+ return this.bracketPairs[n] ? this.findClosingBracket(e, i, s, r, n) : this.reverseBracketPairs[n] ? this.findOpeningBracket(e, i, s, r, n) : null;
1206
+ }
1207
+ findClosingBracket(e, t, i, s, r) {
1208
+ const n = this.bracketPairs[r];
1209
+ let o = 0;
1210
+ for (let l = i; l < t.length; l++) {
1211
+ const c = t[l], a = l === i ? s : 0;
1113
1212
  for (let u = a; u < c.length; u++) {
1114
1213
  const d = c[u];
1115
1214
  if (d === r)
1116
- n++;
1117
- else if (d === o && (n--, n === 0))
1215
+ o++;
1216
+ else if (d === n && (o--, o === 0))
1118
1217
  return {
1119
- open: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1218
+ open: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1120
1219
  close: { start: { line: l, column: u }, end: { line: l, column: u + 1 } },
1121
1220
  type: r
1122
1221
  };
@@ -1124,20 +1223,20 @@ class W {
1124
1223
  }
1125
1224
  return null;
1126
1225
  }
1127
- findOpeningBracket(e, t, s, i, r) {
1128
- const o = this.reverseBracketPairs[r];
1129
- let n = 0;
1130
- for (let l = s; l >= 0; l--) {
1131
- const c = t[l], a = l === s ? i : c.length - 1;
1226
+ findOpeningBracket(e, t, i, s, r) {
1227
+ const n = this.reverseBracketPairs[r];
1228
+ let o = 0;
1229
+ for (let l = i; l >= 0; l--) {
1230
+ const c = t[l], a = l === i ? s : c.length - 1;
1132
1231
  for (let u = a; u >= 0; u--) {
1133
1232
  const d = c[u];
1134
1233
  if (d === r)
1135
- n++;
1136
- else if (d === o && (n--, n === 0))
1234
+ o++;
1235
+ else if (d === n && (o--, o === 0))
1137
1236
  return {
1138
1237
  open: { start: { line: l, column: u }, end: { line: l, column: u + 1 } },
1139
- close: { start: { line: s, column: i }, end: { line: s, column: i + 1 } },
1140
- type: o
1238
+ close: { start: { line: i, column: s }, end: { line: i, column: s + 1 } },
1239
+ type: n
1141
1240
  };
1142
1241
  }
1143
1242
  }
@@ -1155,7 +1254,7 @@ class W {
1155
1254
  this.clearBracketHighlighting(), this.editor = null;
1156
1255
  }
1157
1256
  }
1158
- class j {
1257
+ class J {
1159
1258
  constructor() {
1160
1259
  this.name = "code-folding", this.editor = null, this.foldIndicators = [], this.foldingUI = null;
1161
1260
  }
@@ -1196,9 +1295,9 @@ class j {
1196
1295
  }
1197
1296
  findFoldableLines(e) {
1198
1297
  const t = [];
1199
- for (let s = 0; s < e.length; s++) {
1200
- const i = e[s].trim();
1201
- (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);
1298
+ for (let i = 0; i < e.length; i++) {
1299
+ const s = e[i].trim();
1300
+ (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);
1202
1301
  }
1203
1302
  return t;
1204
1303
  }
@@ -1234,12 +1333,12 @@ class j {
1234
1333
  this.foldingUI && this.foldingUI.parentNode && this.foldingUI.parentNode.removeChild(this.foldingUI), this.foldingUI = null, this.foldIndicators = [], this.editor = null;
1235
1334
  }
1236
1335
  }
1237
- class Z {
1336
+ class X {
1238
1337
  constructor() {
1239
1338
  this.name = "syntax-highlighting", this.editor = null, this.currentTheme = "dark", this.currentLanguage = null, this.modes = /* @__PURE__ */ new Map();
1240
1339
  }
1241
1340
  setup(e) {
1242
- 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) });
1341
+ 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) });
1243
1342
  }
1244
1343
  // Extension provides methods that can be called by the editor
1245
1344
  setTheme(e) {
@@ -1299,8 +1398,8 @@ class Z {
1299
1398
  }
1300
1399
  // Public API: highlight a source string using the chosen mode (or detect html)
1301
1400
  highlight(e, t) {
1302
- const s = this.getSyntaxColors(), i = (t || this.currentLanguage || "html").toLowerCase();
1303
- return (this.modes.get(i) || this.modes.get("html")).highlight(e, s);
1401
+ const i = this.getSyntaxColors(), s = (t || this.currentLanguage || "html").toLowerCase();
1402
+ return (this.modes.get(s) || this.modes.get("html")).highlight(e, i);
1304
1403
  }
1305
1404
  // Backwards-compatible method
1306
1405
  highlightHTML(e) {
@@ -1313,125 +1412,128 @@ class Z {
1313
1412
  // Robustly unescape common HTML entities, repeating a few times to handle nested encoding like &amp;amp;...
1314
1413
  unescapeEntitiesRepeated(e) {
1315
1414
  let t = e || "";
1316
- for (let s = 0; s < 5; s++) {
1317
- const i = t;
1318
- if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === i) break;
1415
+ for (let i = 0; i < 5; i++) {
1416
+ const s = t;
1417
+ if (t = t.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'"), t === s) break;
1319
1418
  }
1320
1419
  return t;
1321
1420
  }
1322
1421
  _highlightHTML(e, t) {
1323
- const s = t, i = (c) => this.escapeHTML(c);
1324
- let r = i(e);
1325
- const o = (c) => {
1422
+ const i = t, s = (c) => this.escapeHTML(c);
1423
+ let r = s(e);
1424
+ const n = (c) => {
1326
1425
  let a = c.replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1327
- return a = a.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${s.comment};">$1</span>`), a = a.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (u, d, g, h, f) => {
1328
- const p = String(h).trim(), x = i(p);
1329
- return `<span style="color: ${s.styleProp};">${d}</span>${g}<span style="color: ${s.styleVal};">${x}</span>${f}`;
1426
+ return a = a.replace(/(\/\*[\s\S]*?\*\/)/g, `<span style="color: ${i.comment};">$1</span>`), a = a.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g, (u, d, g, h, f) => {
1427
+ const p = String(h).trim(), x = s(p);
1428
+ return `<span style="color: ${i.styleProp};">${d}</span>${g}<span style="color: ${i.styleVal};">${x}</span>${f}`;
1330
1429
  }), a;
1331
- }, n = [];
1430
+ }, o = [];
1332
1431
  try {
1333
- e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (c, a, u) => (n.push({ attrs: String(a || ""), inner: String(u || "") }), c));
1432
+ e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (c, a, u) => (o.push({ attrs: String(a || ""), inner: String(u || "") }), c));
1334
1433
  } catch (c) {
1335
1434
  }
1336
1435
  let l = 0;
1337
1436
  return r = r.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi, (c, a, u, d, g) => {
1338
- var p, x, b;
1339
- const h = (x = (p = n[l++]) == null ? void 0 : p.inner) != null ? x : this.unescapeEntitiesRepeated(d || "");
1340
- (((b = n[l - 1]) == null ? void 0 : b.attrs) || u || "").toLowerCase();
1341
- const f = this._highlightJS(h, s);
1437
+ var p, x, k;
1438
+ const h = (x = (p = o[l++]) == null ? void 0 : p.inner) != null ? x : this.unescapeEntitiesRepeated(d || "");
1439
+ (((k = o[l - 1]) == null ? void 0 : k.attrs) || u || "").toLowerCase();
1440
+ const f = this._highlightJS(h, i);
1342
1441
  return `${a}${f}${g}`;
1343
1442
  }), r = r.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi, (c, a, u, d) => {
1344
- const g = o(u);
1443
+ const g = n(u);
1345
1444
  return `${a}${g}${d}`;
1346
- }), r = r.replace(/(&lt;!--[\s\S]*?--&gt;)/g, `<span style="color: ${s.comment};">$1</span>`), r = r.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i, `<span style="color: ${s.doctype};">$1</span>`), r = r.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g, (c, a, u, d, g) => {
1347
- const h = `<span style="color: ${s.tag};">${u}</span>`;
1445
+ }), r = r.replace(/(&lt;!--[\s\S]*?--&gt;)/g, `<span style="color: ${i.comment};">$1</span>`), r = r.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i, `<span style="color: ${i.doctype};">$1</span>`), r = r.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g, (c, a, u, d, g) => {
1446
+ const h = `<span style="color: ${i.tag};">${u}</span>`;
1348
1447
  let f = d;
1349
- return f = f.replace(/([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g, (p, x, b, y) => {
1350
- const C = String(x).toLowerCase(), L = `<span style="color: ${s.attrName};">${x}</span>`;
1351
- let w = y, v = "";
1352
- y.startsWith("&quot;") && y.endsWith("&quot;") ? (w = y.slice(6, -6), v = "&quot;") : y.startsWith("&#39;") && y.endsWith("&#39;") && (w = y.slice(5, -5), v = "&#39;");
1353
- let T = y;
1354
- if (C === "style") {
1355
- const S = w.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, ($, E, O, H) => `<span style="color: ${s.styleProp};">${E}</span>:<span style="color: ${s.styleVal};">${O.trim()}</span>${H}`);
1356
- v ? T = `${v}${S}${v}` : T = S, T = `<span style="color: ${s.attrValue};">${T}</span>`;
1357
- } else
1358
- v && (T = `${v}${w}${v}`), T = `<span style="color: ${s.attrValue};">${T}</span>`;
1359
- return `${L}${b}${T}`;
1360
- }), `${a}${h}${f}${g}`;
1448
+ return f = f.replace(
1449
+ /([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,
1450
+ (p, x, k, y) => {
1451
+ const R = String(x).toLowerCase(), H = `<span style="color: ${i.attrName};">${x}</span>`;
1452
+ let T = y, b = "";
1453
+ y.startsWith("&quot;") && y.endsWith("&quot;") ? (T = y.slice(6, -6), b = "&quot;") : y.startsWith("&#39;") && y.endsWith("&#39;") && (T = y.slice(5, -5), b = "&#39;");
1454
+ let w = y;
1455
+ if (R === "style") {
1456
+ const S = T.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (N, E, L, O) => `<span style="color: ${i.styleProp};">${E}</span>:<span style="color: ${i.styleVal};">${L.trim()}</span>${O}`);
1457
+ b ? w = `${b}${S}${b}` : w = S, w = `<span style="color: ${i.attrValue};">${w}</span>`;
1458
+ } else
1459
+ b && (w = `${b}${T}${b}`), w = `<span style="color: ${i.attrValue};">${w}</span>`;
1460
+ return `${H}${k}${w}`;
1461
+ }
1462
+ ), `${a}${h}${f}${g}`;
1361
1463
  }), r;
1362
1464
  }
1363
1465
  _highlightJS(e, t) {
1364
- const s = this.unescapeEntitiesRepeated(e);
1365
- this.escapeHTML(s);
1366
- const i = [], r = (d) => {
1466
+ const i = this.unescapeEntitiesRepeated(e);
1467
+ this.escapeHTML(i);
1468
+ const s = [], r = (d) => {
1367
1469
  let g = "", h = d;
1368
1470
  do
1369
1471
  g = String.fromCharCode(97 + h % 26) + g, h = Math.floor(h / 26) - 1;
1370
1472
  while (h >= 0);
1371
1473
  return g || "a";
1372
- }, o = (d) => `\0${r(d)}\0`, n = (d) => {
1373
- const g = i.length;
1374
- return i.push(d), o(g);
1474
+ }, n = (d) => `\0${r(d)}\0`, o = (d) => {
1475
+ const g = s.length;
1476
+ return s.push(d), n(g);
1375
1477
  };
1376
1478
  let l;
1377
1479
  const c = /(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;
1378
1480
  let a = 0, u = "";
1379
- for (; l = c.exec(s); ) {
1481
+ for (; l = c.exec(i); ) {
1380
1482
  const d = l.index;
1381
- a < d && (u += this.escapeHTML(s.slice(a, d)));
1483
+ a < d && (u += this.escapeHTML(i.slice(a, d)));
1382
1484
  const g = l[0];
1383
- /^\/\*/.test(g) || /^\/\//.test(g) ? u += n(`<span style="color: ${t.comment};">${this.escapeHTML(g)}</span>`) : u += n(`<span style="color: ${t.string};">${this.escapeHTML(g)}</span>`), a = c.lastIndex;
1485
+ /^\/\*/.test(g) || /^\/\//.test(g) ? u += o(`<span style="color: ${t.comment};">${this.escapeHTML(g)}</span>`) : u += o(`<span style="color: ${t.string};">${this.escapeHTML(g)}</span>`), a = c.lastIndex;
1384
1486
  }
1385
- return a < s.length && (u += this.escapeHTML(s.slice(a))), u = u.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, g, h) => {
1487
+ return a < i.length && (u += this.escapeHTML(i.slice(a))), u = u.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g, (d, g, h) => {
1386
1488
  const f = u[h - 1] || "", p = u[h + d.length] || "";
1387
1489
  return f === "&" || f === "#" || p === ";" || p === "#" ? d : `<span style="color: ${t.number};">${d}</span>`;
1388
1490
  }), u = u.replace(/\b(const|let|var|function|class|if|else|return|for|while|switch|case|break|import|from|export|extends|new|try|catch|finally|throw|await|async|interface|type)\b/g, `<span style="color: ${t.keyword};">$1</span>`), u.replace(/\u0000([a-z]+)\u0000/g, (d, g) => {
1389
1491
  let h = 0;
1390
1492
  for (let f = 0; f < g.length; f++)
1391
1493
  h = h * 26 + (g.charCodeAt(f) - 97 + 1);
1392
- return h = h - 1, i[h] || "";
1494
+ return h = h - 1, s[h] || "";
1393
1495
  });
1394
1496
  }
1395
1497
  _highlightPHP(e, t) {
1396
- const s = this.unescapeEntitiesRepeated(e);
1397
- let i = this.escapeHTML(s);
1398
- const r = [], o = (h) => {
1498
+ const i = this.unescapeEntitiesRepeated(e);
1499
+ let s = this.escapeHTML(i);
1500
+ const r = [], n = (h) => {
1399
1501
  let f = "", p = h;
1400
1502
  do
1401
1503
  f = String.fromCharCode(97 + p % 26) + f, p = Math.floor(p / 26) - 1;
1402
1504
  while (p >= 0);
1403
1505
  return f || "a";
1404
- }, n = (h) => {
1506
+ }, o = (h) => {
1405
1507
  const f = r.length;
1406
- return r.push(h), `\0${o(f)}\0`;
1508
+ return r.push(h), `\0${n(f)}\0`;
1407
1509
  }, l = (h, f) => {
1408
- const p = i.indexOf(h);
1409
- return p === -1 ? !1 : (i = i.slice(0, p) + f + i.slice(p + h.length), !0);
1510
+ const p = s.indexOf(h);
1511
+ return p === -1 ? !1 : (s = s.slice(0, p) + f + s.slice(p + h.length), !0);
1410
1512
  };
1411
1513
  let c;
1412
1514
  const a = /\/\*[\s\S]*?\*\//g, u = /\/\/[^\n\r]*/g, d = /\#([^\n\r]*)/g, g = /("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;
1413
- for (; c = a.exec(s); ) {
1515
+ for (; c = a.exec(i); ) {
1414
1516
  const h = c[0];
1415
- l(this.escapeHTML(h), n(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
1517
+ l(this.escapeHTML(h), o(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
1416
1518
  }
1417
- for (; c = u.exec(s); ) {
1519
+ for (; c = u.exec(i); ) {
1418
1520
  const h = c[0];
1419
- l(this.escapeHTML(h), n(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
1521
+ l(this.escapeHTML(h), o(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
1420
1522
  }
1421
- for (; c = d.exec(s); ) {
1523
+ for (; c = d.exec(i); ) {
1422
1524
  const h = c[0];
1423
- l(this.escapeHTML(h), n(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
1525
+ l(this.escapeHTML(h), o(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`));
1424
1526
  }
1425
- for (; c = g.exec(s); ) {
1527
+ for (; c = g.exec(i); ) {
1426
1528
  const h = c[0];
1427
- l(this.escapeHTML(h), n(`<span style="color: ${t.string};">${this.escapeHTML(h)}</span>`));
1529
+ l(this.escapeHTML(h), o(`<span style="color: ${t.string};">${this.escapeHTML(h)}</span>`));
1428
1530
  }
1429
- return i = i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g, `<span style="color: ${t.variable};">$1</span>`), i = i.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g, `<span style="color: ${t.keyword};">$1</span>`), i = i.replace(/\u0000([a-z]+)\u0000/g, (h, f) => {
1531
+ 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, (h, f) => {
1430
1532
  let p = 0;
1431
1533
  for (let x = 0; x < f.length; x++)
1432
1534
  p = p * 26 + (f.charCodeAt(x) - 97 + 1);
1433
1535
  return p = p - 1, r[p] || "";
1434
- }), i;
1536
+ }), s;
1435
1537
  }
1436
1538
  // Method to check if content contains syntax that should be highlighted
1437
1539
  shouldHighlight(e) {
@@ -1441,11 +1543,11 @@ class Z {
1441
1543
  this.editor = null, this.modes.clear();
1442
1544
  }
1443
1545
  }
1444
- function J(k, e) {
1546
+ function Y(v, e) {
1445
1547
  const t = { ...e };
1446
- return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new U(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new z()), new V(k, t);
1548
+ return t.extensions || (t.extensions = []), t.extensions.some((i) => i.name === "keymap") || t.extensions.unshift(new q(t.keymap)), t.extensions.some((i) => i.name === "transaction") || t.extensions.unshift(new F()), new z(v, t);
1447
1549
  }
1448
- const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Editor Dialog Styles */
1550
+ const $ = '[data-theme="dark"], .dark, .editora-theme-dark', G = `/* Source Editor Dialog Styles */
1449
1551
  .rte-source-editor-overlay {
1450
1552
  position: fixed !important;
1451
1553
  top: 0 !important;
@@ -1822,15 +1924,15 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
1822
1924
  flex: 1;
1823
1925
  text-align: center;
1824
1926
  }
1825
- }`, G = () => ({
1927
+ }`, ee = () => ({
1826
1928
  name: "code",
1827
1929
  // Toolbar button configuration
1828
1930
  toolbar: [
1829
1931
  {
1830
1932
  label: "Source",
1831
1933
  command: "toggleSourceView",
1832
- type: "button",
1833
- icon: "<>",
1934
+ // type: "button",
1935
+ icon: '<svg width="24" height="24" focusable="false"><g fill-rule="nonzero"><path d="M9.8 15.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0l-4.4-4.1a.8.8 0 0 1 0-1.2l4.4-4.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L6 12l3.8 3.7ZM14.2 15.7c-.3.3-.3.8 0 1 .4.4.9.4 1.2 0l4.4-4.1c.3-.3.3-.9 0-1.2l-4.4-4.2a.8.8 0 0 0-1.2 0c-.3.3-.3.8 0 1.1L18 12l-3.8 3.7Z"></path></g></svg>',
1834
1936
  shortcut: "Mod-Shift-S"
1835
1937
  }
1836
1938
  ],
@@ -1842,12 +1944,12 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
1842
1944
  */
1843
1945
  toggleSourceView: () => {
1844
1946
  const e = (() => {
1845
- var n, l, c;
1947
+ var o, l, c;
1846
1948
  const r = window.getSelection();
1847
1949
  if (r && r.anchorNode) {
1848
1950
  let a = r.anchorNode instanceof HTMLElement ? r.anchorNode : r.anchorNode.parentElement;
1849
1951
  for (; a; ) {
1850
- if ((n = a.classList) != null && n.contains("rte-content"))
1952
+ if ((o = a.classList) != null && o.contains("rte-content"))
1851
1953
  return a;
1852
1954
  a = a.parentElement;
1853
1955
  }
@@ -1859,34 +1961,40 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
1859
1961
  for (; a && a !== document.body; ) {
1860
1962
  if ((c = a.classList) != null && c.contains("rte-content"))
1861
1963
  return a;
1862
- const u = a.querySelector(".rte-content");
1964
+ const u = a.querySelector(
1965
+ ".rte-content"
1966
+ );
1863
1967
  if (u) return u;
1864
1968
  a = a.parentElement;
1865
1969
  }
1866
1970
  }
1867
- const o = document.querySelector("[data-editora-editor]");
1868
- if (o) {
1869
- const a = o.querySelector(".rte-content");
1971
+ const n = document.querySelector("[data-editora-editor]");
1972
+ if (n) {
1973
+ const a = n.querySelector(
1974
+ ".rte-content"
1975
+ );
1870
1976
  if (a) return a;
1871
1977
  }
1872
1978
  return document.querySelector(".rte-content");
1873
1979
  })();
1874
1980
  if (!e)
1875
- return console.error("[CodePlugin] Editor content area not found"), alert("Editor content area not found. Please click inside the editor first."), !1;
1876
- const t = e.innerHTML, s = (r) => {
1877
- let o = "", n = 0;
1981
+ return console.error("[CodePlugin] Editor content area not found"), alert(
1982
+ "Editor content area not found. Please click inside the editor first."
1983
+ ), !1;
1984
+ const t = e.innerHTML, i = (r) => {
1985
+ let n = "", o = 0;
1878
1986
  const l = 2, c = r.split(/(<\/?[a-zA-Z][^>]*>)/);
1879
1987
  for (const a of c)
1880
- a.trim() && (a.match(/^<\/[a-zA-Z]/) ? (n = Math.max(0, n - 1), o += `
1881
- ` + " ".repeat(n * l) + a) : a.match(/^<[a-zA-Z]/) && !a.match(/\/>$/) ? (o += `
1882
- ` + " ".repeat(n * l) + a, n++) : a.match(/^<[a-zA-Z].*\/>$/) ? o += `
1883
- ` + " ".repeat(n * l) + a : o += a.trim());
1884
- return o.trim();
1988
+ a.trim() && (a.match(/^<\/[a-zA-Z]/) ? (o = Math.max(0, o - 1), n += `
1989
+ ` + " ".repeat(o * l) + a) : a.match(/^<[a-zA-Z]/) && !a.match(/\/>$/) ? (n += `
1990
+ ` + " ".repeat(o * l) + a, o++) : a.match(/^<[a-zA-Z].*\/>$/) ? n += `
1991
+ ` + " ".repeat(o * l) + a : n += a.trim());
1992
+ return n.trim();
1885
1993
  };
1886
1994
  return (() => {
1887
- var E, O, H, N, I, B;
1888
- let r = null, o = "dark", n = !1, l = !1, c = !1;
1889
- const a = t, u = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), d = document.createElement("div");
1995
+ var E, L, O, I, A, B;
1996
+ let r = null, n = "dark", o = !1, l = !1, c = !1;
1997
+ const a = t, u = !!e.closest($) || document.body.matches($) || document.documentElement.matches($), d = document.createElement("div");
1890
1998
  d.className = "rte-source-editor-overlay", u && d.classList.add("rte-theme-dark");
1891
1999
  const g = document.createElement("div");
1892
2000
  g.className = "rte-source-editor-modal", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "true"), g.setAttribute("aria-labelledby", "source-editor-title");
@@ -1934,8 +2042,8 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
1934
2042
  p.className = "rte-source-editor-content";
1935
2043
  const x = document.createElement("div");
1936
2044
  x.className = "rte-source-editor-warning", x.textContent = "⚠️ Advanced users only. Invalid HTML may break the editor.";
1937
- const b = document.createElement("div");
1938
- b.className = "rte-source-editor-light-editor", b.style.height = "400px", p.appendChild(x), p.appendChild(b), f.appendChild(p);
2045
+ const k = document.createElement("div");
2046
+ k.className = "rte-source-editor-light-editor", k.style.height = "400px", p.appendChild(x), p.appendChild(k), f.appendChild(p);
1939
2047
  const y = document.createElement("div");
1940
2048
  if (y.className = "rte-source-editor-footer", y.innerHTML = `
1941
2049
  <div class="rte-source-editor-footer-info">
@@ -1947,43 +2055,45 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
1947
2055
  </div>
1948
2056
  `, g.appendChild(h), g.appendChild(f), g.appendChild(y), d.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
1949
2057
  const m = document.createElement("style");
1950
- m.id = "rte-source-editor-styles", m.textContent = Y, document.head.appendChild(m);
2058
+ m.id = "rte-source-editor-styles", m.textContent = G, document.head.appendChild(m);
1951
2059
  }
1952
2060
  document.body.appendChild(d);
1953
2061
  try {
1954
- r = J(b, {
1955
- value: s(t),
2062
+ r = Y(k, {
2063
+ value: i(t),
1956
2064
  theme: "dark",
1957
2065
  readOnly: !1,
1958
2066
  extensions: [
1959
- new q(),
1960
2067
  new _(),
1961
- new F(),
1962
2068
  new W(),
1963
2069
  new D(),
2070
+ new Z(),
1964
2071
  new j(),
1965
- new Z()
2072
+ new J(),
2073
+ new X()
1966
2074
  ]
1967
2075
  }), r.on("change", () => {
1968
- c = ((r == null ? void 0 : r.getValue()) || "") !== s(a);
1969
- const M = y.querySelector(".unsaved-changes");
1970
- M && (M.style.display = c ? "inline" : "none");
2076
+ c = ((r == null ? void 0 : r.getValue()) || "") !== i(a);
2077
+ const C = y.querySelector(
2078
+ ".unsaved-changes"
2079
+ );
2080
+ C && (C.style.display = c ? "inline" : "none");
1971
2081
  }), setTimeout(() => r == null ? void 0 : r.focus(), 100);
1972
2082
  } catch (m) {
1973
2083
  console.error("Failed to initialize code editor:", m);
1974
2084
  }
1975
- const C = () => {
1976
- o = o === "dark" ? "light" : "dark", r == null || r.setTheme(o);
2085
+ const R = () => {
2086
+ n = n === "dark" ? "light" : "dark", r == null || r.setTheme(n);
1977
2087
  const m = h.querySelector(".theme-toggle-btn");
1978
- m && o === "light" && (m.innerHTML = `
2088
+ m && n === "light" && (m.innerHTML = `
1979
2089
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1980
2090
  <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
1981
2091
  </svg>
1982
2092
  `);
1983
- }, L = () => {
1984
- n = !n, r == null || r.setReadOnly(n);
2093
+ }, H = () => {
2094
+ o = !o, r == null || r.setReadOnly(o);
1985
2095
  const m = h.querySelector(".readonly-toggle-btn");
1986
- m && (n ? (m.classList.add("active"), m.innerHTML = `
2096
+ m && (o ? (m.classList.add("active"), m.innerHTML = `
1987
2097
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1988
2098
  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
1989
2099
  <circle cx="12" cy="16" r="1"/>
@@ -1995,9 +2105,11 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
1995
2105
  <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
1996
2106
  </svg>
1997
2107
  `));
1998
- }, w = () => {
1999
- l = !l, l ? (d.classList.add("fullscreen"), b.style.height = "calc(100vh - 200px)") : (d.classList.remove("fullscreen"), b.style.height = "400px");
2000
- const m = h.querySelector(".rte-source-editor-fullscreen-btn");
2108
+ }, T = () => {
2109
+ l = !l, l ? (d.classList.add("fullscreen"), k.style.height = "calc(100vh - 200px)") : (d.classList.remove("fullscreen"), k.style.height = "400px");
2110
+ const m = h.querySelector(
2111
+ ".rte-source-editor-fullscreen-btn"
2112
+ );
2001
2113
  m && (m.innerHTML = l ? `
2002
2114
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2003
2115
  <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"/>
@@ -2007,25 +2119,45 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
2007
2119
  <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
2008
2120
  </svg>
2009
2121
  `);
2010
- }, v = () => {
2122
+ }, b = () => {
2011
2123
  r && (r.destroy(), r = null), document.body.removeChild(d);
2012
- }, T = () => {
2013
- c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || v();
2124
+ }, w = () => {
2125
+ c && !confirm(
2126
+ "You have unsaved changes. Are you sure you want to cancel?"
2127
+ ) || b();
2014
2128
  }, S = () => {
2015
2129
  try {
2016
- const m = (r == null ? void 0 : r.getValue()) || "", M = document.createElement("div");
2017
- M.innerHTML = m, M.querySelectorAll('script, iframe[src^="javascript:"], object, embed').forEach((K) => K.remove()), e.innerHTML = M.innerHTML, c = !1, v();
2130
+ const m = (r == null ? void 0 : r.getValue()) || "", C = document.createElement("div");
2131
+ C.innerHTML = m, C.querySelectorAll(
2132
+ 'script, iframe[src^="javascript:"], object, embed'
2133
+ ).forEach((V) => V.remove()), e.innerHTML = C.innerHTML;
2134
+ try {
2135
+ e.dispatchEvent(
2136
+ new InputEvent("input", {
2137
+ bubbles: !0,
2138
+ cancelable: !1,
2139
+ inputType: "insertReplacementText"
2140
+ })
2141
+ );
2142
+ } catch (V) {
2143
+ e.dispatchEvent(
2144
+ new Event("input", { bubbles: !0 })
2145
+ );
2146
+ }
2147
+ e.dispatchEvent(
2148
+ new Event("change", { bubbles: !0 })
2149
+ ), c = !1, b();
2018
2150
  } catch (m) {
2019
2151
  alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", m);
2020
2152
  }
2021
2153
  };
2022
- (E = h.querySelector(".theme-toggle-btn")) == null || E.addEventListener("click", C), (O = h.querySelector(".readonly-toggle-btn")) == null || O.addEventListener("click", L), (H = h.querySelector(".rte-source-editor-fullscreen-btn")) == null || H.addEventListener("click", w), (N = h.querySelector(".rte-source-editor-close-btn")) == null || N.addEventListener("click", v), (I = y.querySelector(".rte-source-editor-btn-cancel")) == null || I.addEventListener("click", T), (B = y.querySelector(".rte-source-editor-btn-save")) == null || B.addEventListener("click", S), d.addEventListener("click", (m) => {
2023
- m.target === d && v();
2154
+ (E = h.querySelector(".theme-toggle-btn")) == null || E.addEventListener("click", R), (L = h.querySelector(".readonly-toggle-btn")) == null || L.addEventListener("click", H), (O = h.querySelector(".rte-source-editor-fullscreen-btn")) == null || O.addEventListener("click", T), (I = h.querySelector(".rte-source-editor-close-btn")) == null || I.addEventListener("click", b), (A = y.querySelector(".rte-source-editor-btn-cancel")) == null || A.addEventListener("click", w), (B = y.querySelector(".rte-source-editor-btn-save")) == null || B.addEventListener("click", S), d.addEventListener("click", (m) => {
2155
+ m.target === d && b();
2024
2156
  });
2025
- const $ = (m) => {
2026
- m.key === "Escape" && (v(), document.removeEventListener("keydown", $));
2157
+ const N = (m) => {
2158
+ m.key === "Escape" && (b(), document.removeEventListener("keydown", N));
2027
2159
  };
2028
- document.addEventListener("keydown", $);
2160
+ document.addEventListener("keydown", N);
2029
2161
  })(), !0;
2030
2162
  }
2031
2163
  },
@@ -2036,6 +2168,6 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', Y = `/* Source Edit
2036
2168
  }
2037
2169
  });
2038
2170
  export {
2039
- G as CodePlugin
2171
+ ee as CodePlugin
2040
2172
  };
2041
- //# sourceMappingURL=CodePlugin.native-0Zari_zp.mjs.map
2173
+ //# sourceMappingURL=CodePlugin.native-B263UI8O.mjs.map