@editora/core 1.0.20 → 1.0.22

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,6 +1,6 @@
1
1
  import { i as Q } from "./dialogHelpers-DBf7WqYH.mjs";
2
2
  import { s as Y } from "./sanitizeHtml-DA0ajC6k.mjs";
3
- class W {
3
+ class V {
4
4
  constructor(e = "") {
5
5
  this._lines = [], this._version = 0, this.setText(e);
6
6
  }
@@ -86,7 +86,7 @@ class W {
86
86
  }
87
87
  // Clone the model
88
88
  clone() {
89
- const e = new W();
89
+ const e = new V();
90
90
  return e._lines = [...this._lines], e._version = this._version, e;
91
91
  }
92
92
  normalizeRange(e) {
@@ -101,7 +101,7 @@ class W {
101
101
  }
102
102
  class X {
103
103
  constructor(e) {
104
- this.gutterWidth = 50, this.gutterFoldColumnWidth = 20, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
104
+ this.gutterWidth = 50, this.gutterFoldColumnWidth = 24, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 24, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.lineDecorations = [], this.gutterDecorations = [], this.lineWrapping = !1, this.measuredHeights = null, this.measuredTops = [], this.measuredLines = null, this.measuredSignature = "", this.measureQueued = !1, this.measurer = null, this.resizeObserver = null, this.destroyed = !1, this.container = e, this.createDOM();
105
105
  }
106
106
  createDOM() {
107
107
  this.container.innerHTML = "";
@@ -206,11 +206,121 @@ class X {
206
206
  }
207
207
  // Update line numbers
208
208
  updateLineNumbers(e) {
209
- if (this.updateGutterWidth(e), e === this.lastLineCount)
209
+ this.updateGutterWidth(e), this.queueWrapMeasure(), e !== this.lastLineCount && (this.lastLineCount = e, this.syncGutterRows(Math.max(e, 1)));
210
+ }
211
+ /**
212
+ * One row per line, numbered in order, so a different number of lines only adds rows at the end or takes them
213
+ * away from it. The rows that stay keep their heights (see applyMeasuredHeights).
214
+ */
215
+ syncGutterRows(e) {
216
+ const t = this.lineNumbersContentElement;
217
+ for (; t.children.length > e; )
218
+ t.lastElementChild.remove();
219
+ let i = "";
220
+ for (let n = t.children.length + 1; n <= e; n += 1)
221
+ i += `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${n}</div>`;
222
+ i && t.insertAdjacentHTML("beforeend", i);
223
+ }
224
+ /** Where a line starts, in pixels from the top of the content. */
225
+ lineTop(e) {
226
+ var t;
227
+ return (t = this.measuredTops[e]) != null ? t : e * this.lineHeight;
228
+ }
229
+ /** How tall a line is: one row, or as many as it wraps to. */
230
+ lineHeightAt(e) {
231
+ var t, i;
232
+ return (i = (t = this.measuredHeights) == null ? void 0 : t[e]) != null ? i : this.lineHeight;
233
+ }
234
+ queueWrapMeasure() {
235
+ !this.lineWrapping || this.measureQueued || this.destroyed || (this.measureQueued = !0, Promise.resolve().then(() => {
236
+ this.measureQueued = !1, this.measureWrappedLines();
237
+ }));
238
+ }
239
+ /**
240
+ * Finds out how many rows each line wraps to, by laying the same text out one block per line in a hidden copy
241
+ * of the content, and sizes the line numbers to match. Done in one layout pass: all blocks are built, then all
242
+ * heights are read.
243
+ */
244
+ measureWrappedLines() {
245
+ if (!this.lineWrapping || this.destroyed || !this.contentElement.isConnected) return;
246
+ const e = this.contentElement.__lceFoldPlaceholderSources, t = this.lineNumbersContentElement.children, i = (this.contentElement.textContent || "").split(`
247
+ `), n = this.contentElement.clientWidth;
248
+ if (e && e.size > 0 || t.length !== i.length || n === 0) {
249
+ this.applyMeasuredHeights(null);
210
250
  return;
211
- this.lastLineCount = e;
212
- const t = Math.max(e, 1), i = Array.from({ length: t }, (n, s) => s + 1);
213
- this.lineNumbersContentElement.innerHTML = i.map((n) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${n}</div>`).join("");
251
+ }
252
+ const s = this.wrapSignature(n), r = this.measuredLines, o = this.measuredHeights;
253
+ let l;
254
+ if (r && o && o.length === r.length && s === this.measuredSignature) {
255
+ const a = Math.min(r.length, i.length);
256
+ let h = 0;
257
+ for (; h < a && r[h] === i[h]; ) h += 1;
258
+ let c = 0;
259
+ for (; c < a - h && r[r.length - 1 - c] === i[i.length - 1 - c]; ) c += 1;
260
+ l = o.slice(0, h).concat(this.measureLines(i.slice(h, i.length - c), n), o.slice(o.length - c));
261
+ } else
262
+ l = this.measureLines(i, n);
263
+ this.measuredLines = i, this.measuredSignature = s, this.applyMeasuredHeights(l);
264
+ }
265
+ /** Lays each line out as a block of its own in the hidden copy of the content, and returns how tall each came out. */
266
+ measureLines(e, t) {
267
+ if (e.length === 0) return [];
268
+ const i = this.ensureMeasurer(t);
269
+ i.innerHTML = e.map((s) => `<div>${s === "" ? "&#8203;" : s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</div>`).join("");
270
+ const n = Array.from(i.children, (s) => s.offsetHeight);
271
+ return i.textContent = "", n;
272
+ }
273
+ /** What the height of a line depends on besides its text. When this changes, every line is measured again. */
274
+ wrapSignature(e) {
275
+ const t = getComputedStyle(this.contentElement);
276
+ return [
277
+ e,
278
+ t.fontFamily,
279
+ t.fontSize,
280
+ t.fontWeight,
281
+ t.letterSpacing,
282
+ t.tabSize,
283
+ t.paddingLeft,
284
+ t.paddingRight,
285
+ t.whiteSpace,
286
+ t.overflowWrap,
287
+ t.wordBreak
288
+ ].join("|");
289
+ }
290
+ ensureMeasurer(e) {
291
+ if (!this.measurer) {
292
+ const t = document.createElement("div");
293
+ t.setAttribute("aria-hidden", "true"), t.setAttribute("data-editor-measurer", "true"), this.contentSurface.appendChild(t), this.measurer = t;
294
+ }
295
+ return this.measurer.style.cssText = this.contentElement.style.cssText, Object.assign(this.measurer.style, {
296
+ position: "absolute",
297
+ top: "0",
298
+ left: "0",
299
+ zIndex: "-1",
300
+ visibility: "hidden",
301
+ pointerEvents: "none",
302
+ width: `${e}px`,
303
+ minWidth: "0",
304
+ minHeight: "0",
305
+ height: "auto"
306
+ }), this.measurer;
307
+ }
308
+ applyMeasuredHeights(e) {
309
+ var s, r;
310
+ const t = this.measuredHeights;
311
+ if (t === e || t !== null && e !== null && t.length === e.length && t.every((o, l) => o === e[l])) return;
312
+ if (this.measuredHeights = e, this.measuredTops = [], e) {
313
+ let o = 0;
314
+ for (const l of e)
315
+ this.measuredTops.push(o), o += l;
316
+ } else
317
+ this.measuredLines = null;
318
+ const n = this.lineNumbersContentElement.children;
319
+ for (let o = 0; o < n.length; o += 1) {
320
+ const l = (s = t == null ? void 0 : t[o]) != null ? s : this.lineHeight, a = (r = e == null ? void 0 : e[o]) != null ? r : this.lineHeight;
321
+ l !== a && (n[o].style.height = `${a}px`);
322
+ }
323
+ this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.renderLineDecorations(this.lineDecorations), this.renderGutterDecorations(this.gutterDecorations);
214
324
  }
215
325
  updateGutterWidth(e) {
216
326
  const i = String(Math.max(e, 1)).length * this.gutterDigitWidth + this.gutterLineNumberPaddingLeft + this.gutterLineNumberPaddingRight, n = Math.ceil(
@@ -219,7 +329,7 @@ class X {
219
329
  n !== this.gutterWidth && (this.gutterWidth = n, this.lineNumbersElement.style.display !== "none" && (this.lineNumbersElement.style.width = `${this.gutterWidth}px`, this.lineNumbersElement.style.minWidth = `${this.gutterWidth}px`));
220
330
  }
221
331
  setDecorations(e, t) {
222
- this.renderLineDecorations(e), this.renderGutterDecorations(t);
332
+ this.lineDecorations = e, this.gutterDecorations = t, this.renderLineDecorations(e), this.renderGutterDecorations(t);
223
333
  }
224
334
  clearDecorations() {
225
335
  this.lastLineDecorationSnapshot && (this.lineDecorationsElement.innerHTML = "", this.lastLineDecorationSnapshot = ""), this.lastGutterDecorationSnapshot && (this.gutterDecorationsElement.innerHTML = "", this.lastGutterDecorationSnapshot = "");
@@ -260,7 +370,8 @@ class X {
260
370
  this.updateLineNumbers(i);
261
371
  }
262
372
  setLineWrapping(e) {
263
- this.contentElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.contentElement.style.overflow = "visible", this.contentElement.style.minWidth = e ? "100%" : "max-content", this.contentSurface.style.minWidth = e ? "100%" : "max-content", this.contentElement.style.wordBreak = "normal", this.contentElement.style.overflowWrap = e ? "anywhere" : "normal", this.highlightElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.highlightElement.style.wordBreak = "normal", this.highlightElement.style.overflowWrap = e ? "anywhere" : "normal";
373
+ var t;
374
+ this.lineWrapping = e, e ? (!this.resizeObserver && typeof ResizeObserver != "undefined" && (this.resizeObserver = new ResizeObserver(() => this.queueWrapMeasure()), this.resizeObserver.observe(this.contentElement)), this.queueWrapMeasure()) : ((t = this.resizeObserver) == null || t.disconnect(), this.resizeObserver = null, this.applyMeasuredHeights(null)), this.contentElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.contentElement.style.overflow = "visible", this.contentElement.style.minWidth = e ? "100%" : "max-content", this.contentSurface.style.minWidth = e ? "100%" : "max-content", this.contentElement.style.wordBreak = "normal", this.contentElement.style.overflowWrap = e ? "anywhere" : "normal", this.highlightElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.highlightElement.style.wordBreak = "normal", this.highlightElement.style.overflowWrap = e ? "anywhere" : "normal";
264
375
  }
265
376
  setLineNumbersVisible(e) {
266
377
  this.lineNumbersElement.style.display = e ? "table-cell" : "none", this.lineNumbersElement.style.width = e ? `${this.gutterWidth}px` : "0", this.lineNumbersElement.style.minWidth = e ? `${this.gutterWidth}px` : "0", this.lineNumbersElement.style.borderRightWidth = e ? "1px" : "0", this.scrollWrapper.style.width = "100%", this.scrollWrapper.style.minWidth = "100%";
@@ -461,7 +572,7 @@ class X {
461
572
  }
462
573
  // Scroll to position
463
574
  scrollToPosition(e) {
464
- const n = Math.max(0, Math.floor(e.line) || 0) * this.lineHeight - this.editorContainer.clientHeight / 2 + this.lineHeight / 2;
575
+ const t = Math.max(0, Math.floor(e.line) || 0), n = this.lineTop(t) - this.editorContainer.clientHeight / 2 + this.lineHeight / 2;
465
576
  this.editorContainer.scrollTop = Math.max(0, n);
466
577
  }
467
578
  // Get scroll position
@@ -498,7 +609,8 @@ class X {
498
609
  }
499
610
  // Destroy the view
500
611
  destroy() {
501
- this.clearDecorations(), this.container && (this.container.innerHTML = ""), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
612
+ var e;
613
+ this.destroyed = !0, (e = this.resizeObserver) == null || e.disconnect(), this.resizeObserver = null, this.clearDecorations(), this.container && (this.container.innerHTML = ""), this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = void 0);
502
614
  }
503
615
  resolveOffsetToDomPoint(e) {
504
616
  var s;
@@ -727,8 +839,8 @@ class X {
727
839
  s.className
728
840
  ), r.setAttribute("data-decoration-id", s.id), r.setAttribute("data-decoration-line", String(s.line)), r.style.cssText = this.joinStyleFragments([
729
841
  "position: absolute",
730
- `top: ${s.line * this.lineHeight}px`,
731
- `height: ${this.lineHeight}px`,
842
+ `top: ${this.lineTop(s.line)}px`,
843
+ `height: ${this.lineHeightAt(s.line)}px`,
732
844
  "left: 12px",
733
845
  "right: 12px",
734
846
  "border-radius: 3px",
@@ -751,8 +863,8 @@ class X {
751
863
  s.className
752
864
  ), r.setAttribute("data-decoration-id", s.id), r.setAttribute("data-decoration-line", String(s.line)), r.style.cssText = this.joinStyleFragments([
753
865
  "position: absolute",
754
- `top: ${s.line * this.lineHeight}px`,
755
- `height: ${this.lineHeight}px`,
866
+ `top: ${this.lineTop(s.line)}px`,
867
+ `height: ${this.lineHeightAt(s.line)}px`,
756
868
  "left: 0",
757
869
  "right: 0",
758
870
  "display: flex",
@@ -827,7 +939,7 @@ class X {
827
939
  let J = 0;
828
940
  const w = class w {
829
941
  constructor(e, t = {}) {
830
- this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.lastKnownCursor = { line: 0, column: 0 }, this.editorInstanceId = ++J, this.decorationHighlightStyleId = `editora-decoration-style-${this.editorInstanceId}`, this.decorationHighlightLimit = 1e3, this.decorationLayers = /* @__PURE__ */ new Map(), this.inlineDecorationHighlightNames = /* @__PURE__ */ new Set(), this.decorationRenderRaf = null, this.decorationMutationObserver = null, this.hasCustomDecorationHighlightSupport = !1, this.lastProgrammaticClipboardInsertAt = 0, this.config = {
942
+ this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.lastKnownCursor = { line: 0, column: 0 }, this.editorInstanceId = ++J, this.decorationHighlightStyleId = `editora-decoration-style-${this.editorInstanceId}`, this.decorationHighlightLimit = 1e3, this.decorationLayers = /* @__PURE__ */ new Map(), this.inlineDecorationHighlightNames = /* @__PURE__ */ new Set(), this.decorationRenderRaf = null, this.decorationMutationObserver = null, this.hasCustomDecorationHighlightSupport = !1, this.lastProgrammaticClipboardInsertAt = 0, this.tabReleased = !1, this.config = {
831
943
  value: "",
832
944
  theme: "default",
833
945
  readOnly: !1,
@@ -835,7 +947,7 @@ const w = class w {
835
947
  lineWrapping: !1,
836
948
  lineNumbers: !0,
837
949
  ...t
838
- }, this.textModel = new W(this.config.value), this.view = new X(e), this.view.setTabSize(this.config.tabSize || 2), this.view.setLineWrapping(!!this.config.lineWrapping), this.view.setLineNumbersVisible(this.config.lineNumbers !== !1), this.hasCustomDecorationHighlightSupport = this.detectCustomHighlightSupport(), this.observeDecorationRelevantMutations(), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((i) => this.addExtension(i)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
950
+ }, this.textModel = new V(this.config.value), this.view = new X(e), this.view.setTabSize(this.config.tabSize || 2), this.view.setLineWrapping(!!this.config.lineWrapping), this.view.setLineNumbersVisible(this.config.lineNumbers !== !1), this.hasCustomDecorationHighlightSupport = this.detectCustomHighlightSupport(), this.observeDecorationRelevantMutations(), this.setupEventHandlers(), this.config.extensions && this.config.extensions.forEach((i) => this.addExtension(i)), this.setTheme(this.config.theme), this.view.setReadOnly(this.config.readOnly || !1), this.renderTextWithHighlight(this.textModel.getText()), this.registerBuiltInCommands();
839
951
  }
840
952
  // Public accessors for extensions
841
953
  getTextModel() {
@@ -929,15 +1041,21 @@ const w = class w {
929
1041
  position: i,
930
1042
  anchor: (r = (s = t.range) == null ? void 0 : s.start) != null ? r : i
931
1043
  }), this.emit("selection", t.isCollapsed ? void 0 : t.range);
932
- }, document.addEventListener("selectionchange", this.documentSelectionChangeHandler), e.addEventListener("keydown", (t) => {
933
- this.emit("keydown", t);
1044
+ }, document.addEventListener("selectionchange", this.documentSelectionChangeHandler), e.addEventListener("blur", () => {
1045
+ this.tabReleased = !1;
1046
+ }), e.addEventListener("keydown", (t) => {
1047
+ if (this.emit("keydown", t), t.key === "Tab" && this.tabReleased && !t.ctrlKey && !t.metaKey && !t.altKey) {
1048
+ this.tabReleased = !1;
1049
+ return;
1050
+ }
1051
+ t.key !== "Escape" && t.key !== "Shift" && t.key !== "Control" && t.key !== "Alt" && t.key !== "Meta" && (this.tabReleased = !1);
934
1052
  const i = Array.from(this.extensions.values()).reverse();
935
1053
  for (const r of i)
936
1054
  if (r.onKeyDown && r.onKeyDown(t) === !1) {
937
1055
  t.preventDefault(), t.stopPropagation();
938
1056
  return;
939
1057
  }
940
- if (t.key === "Tab" && !this.config.readOnly) {
1058
+ if (t.key === "Escape" && !t.defaultPrevented && (this.tabReleased = !0), t.key === "Tab" && !this.config.readOnly) {
941
1059
  t.shiftKey ? this.shiftSelectedLines(!0) : this.insertTab(), t.preventDefault(), t.stopPropagation();
942
1060
  return;
943
1061
  }
@@ -1901,7 +2019,7 @@ const w = class w {
1901
2019
  }
1902
2020
  };
1903
2021
  w.CURSOR_SENTINEL = "";
1904
- let B = w;
2022
+ let z = w;
1905
2023
  class ee {
1906
2024
  constructor(e) {
1907
2025
  this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
@@ -1976,7 +2094,7 @@ class ee {
1976
2094
  this.keymap = {}, this.editor = null;
1977
2095
  }
1978
2096
  }
1979
- const D = class D {
2097
+ const N = class N {
1980
2098
  constructor() {
1981
2099
  this.name = "transaction", this.transactions = [];
1982
2100
  }
@@ -1988,9 +2106,9 @@ const D = class D {
1988
2106
  effects: [],
1989
2107
  annotations: []
1990
2108
  };
1991
- this.transactions.push(i), this.transactions.length > D.MAX_TRANSACTIONS && this.transactions.splice(
2109
+ this.transactions.push(i), this.transactions.length > N.MAX_TRANSACTIONS && this.transactions.splice(
1992
2110
  0,
1993
- this.transactions.length - D.MAX_TRANSACTIONS
2111
+ this.transactions.length - N.MAX_TRANSACTIONS
1994
2112
  );
1995
2113
  });
1996
2114
  }
@@ -2001,8 +2119,8 @@ const D = class D {
2001
2119
  this.transactions = [];
2002
2120
  }
2003
2121
  };
2004
- D.MAX_TRANSACTIONS = 200;
2005
- let z = D;
2122
+ N.MAX_TRANSACTIONS = 200;
2123
+ let B = N;
2006
2124
  class te {
2007
2125
  constructor() {
2008
2126
  this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
@@ -2085,7 +2203,7 @@ class ne {
2085
2203
  }
2086
2204
  }
2087
2205
  let se = 0;
2088
- const x = class x {
2206
+ const b = class b {
2089
2207
  constructor(e = {}) {
2090
2208
  this.name = "search", this.editor = null, this.searchUI = null, this.isVisible = !1, this.currentResults = [], this.currentIndex = -1, this.searchDebounceTimer = null, this.liveRefreshTimer = null, this.statusResetTimer = null, this.statusFreezeUntil = 0, this.findInput = null, this.replaceInputEl = null, this.statusDiv = null, this.modeDiv = null, this.caseSensitiveInput = null, this.wholeWordInput = null, this.regexInput = null, this.currentQuery = "", this.savedCursor = null, this.editorChangeHandler = null, this.searchOptions = {
2091
2209
  caseSensitive: !1,
@@ -2126,53 +2244,53 @@ const x = class x {
2126
2244
  this.editorContainerSelector
2127
2245
  ), i = t == null ? void 0 : t.parentElement, n = e.closest(".rte-source-editor-modal") || i || t || e.parentElement;
2128
2246
  if (!n) return;
2129
- window.getComputedStyle(n).position === "static" && (n.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = x.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
2130
- <div class="${x.css.row}">
2131
- <input type="text" class="${x.css.findInput} ${x.css.inputBase}" placeholder="Find..." />
2132
- <button class="${x.css.prevButton} ${x.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
2133
- <button class="${x.css.nextButton} ${x.css.buttonBase}" type="button" aria-label="Next match">↓</button>
2134
- <button class="${x.css.closeButton} ${x.css.buttonBase}" type="button" aria-label="Close search">×</button>
2247
+ window.getComputedStyle(n).position === "static" && (n.style.position = "relative"), this.searchUI = document.createElement("div"), this.searchUI.className = b.css.root, this.searchUI.style.display = "none", this.searchUI.innerHTML = `
2248
+ <div class="${b.css.row}">
2249
+ <input type="text" class="${b.css.findInput} ${b.css.inputBase}" placeholder="Find..." />
2250
+ <button class="${b.css.prevButton} ${b.css.buttonBase}" type="button" aria-label="Previous match">↑</button>
2251
+ <button class="${b.css.nextButton} ${b.css.buttonBase}" type="button" aria-label="Next match">↓</button>
2252
+ <button class="${b.css.closeButton} ${b.css.buttonBase}" type="button" aria-label="Close search">×</button>
2135
2253
  </div>
2136
- <div class="${x.css.options}">
2137
- <label class="${x.css.optionLabel}" title="Case sensitive">
2138
- <input type="checkbox" class="${x.css.optionInput} ${x.css.caseSensitive}" />
2254
+ <div class="${b.css.options}">
2255
+ <label class="${b.css.optionLabel}" title="Case sensitive">
2256
+ <input type="checkbox" class="${b.css.optionInput} ${b.css.caseSensitive}" />
2139
2257
  <span>Aa</span>
2140
2258
  </label>
2141
- <label class="${x.css.optionLabel}" title="Whole word">
2142
- <input type="checkbox" class="${x.css.optionInput} ${x.css.wholeWord}" />
2259
+ <label class="${b.css.optionLabel}" title="Whole word">
2260
+ <input type="checkbox" class="${b.css.optionInput} ${b.css.wholeWord}" />
2143
2261
  <span>Whole</span>
2144
2262
  </label>
2145
- <label class="${x.css.optionLabel}" title="Regular expression">
2146
- <input type="checkbox" class="${x.css.optionInput} ${x.css.regex}" />
2263
+ <label class="${b.css.optionLabel}" title="Regular expression">
2264
+ <input type="checkbox" class="${b.css.optionInput} ${b.css.regex}" />
2147
2265
  <span>.*</span>
2148
2266
  </label>
2149
2267
  </div>
2150
- <div class="${x.css.meta}">
2151
- <div class="${x.css.status} ${x.css.statusLayout}"></div>
2152
- <div class="${x.css.mode} ${x.css.modeLayout}" aria-live="polite"></div>
2268
+ <div class="${b.css.meta}">
2269
+ <div class="${b.css.status} ${b.css.statusLayout}"></div>
2270
+ <div class="${b.css.mode} ${b.css.modeLayout}" aria-live="polite"></div>
2153
2271
  </div>
2154
- <input type="text" class="${x.css.replaceInput} ${x.css.inputBase} ${x.css.replaceInputLayout}" placeholder="Replace with..." />
2272
+ <input type="text" class="${b.css.replaceInput} ${b.css.inputBase} ${b.css.replaceInputLayout}" placeholder="Replace with..." />
2155
2273
  `;
2156
2274
  const s = this.searchUI.querySelector(
2157
- `.${x.css.findInput}`
2275
+ `.${b.css.findInput}`
2158
2276
  ), r = this.searchUI.querySelector(
2159
- `.${x.css.replaceInput}`
2277
+ `.${b.css.replaceInput}`
2160
2278
  ), o = this.searchUI.querySelector(
2161
- `.${x.css.prevButton}`
2279
+ `.${b.css.prevButton}`
2162
2280
  ), l = this.searchUI.querySelector(
2163
- `.${x.css.nextButton}`
2281
+ `.${b.css.nextButton}`
2164
2282
  ), a = this.searchUI.querySelector(
2165
- `.${x.css.closeButton}`
2283
+ `.${b.css.closeButton}`
2166
2284
  ), h = this.searchUI.querySelector(
2167
- `.${x.css.status}`
2285
+ `.${b.css.status}`
2168
2286
  ), c = this.searchUI.querySelector(
2169
- `.${x.css.mode}`
2287
+ `.${b.css.mode}`
2170
2288
  ), d = this.searchUI.querySelector(
2171
- `.${x.css.caseSensitive}`
2289
+ `.${b.css.caseSensitive}`
2172
2290
  ), f = this.searchUI.querySelector(
2173
- `.${x.css.wholeWord}`
2291
+ `.${b.css.wholeWord}`
2174
2292
  ), u = this.searchUI.querySelector(
2175
- `.${x.css.regex}`
2293
+ `.${b.css.regex}`
2176
2294
  );
2177
2295
  this.findInput = s, this.replaceInputEl = r, this.statusDiv = h, this.modeDiv = c, this.caseSensitiveInput = d, this.wholeWordInput = f, this.regexInput = u, d.checked = !!this.searchOptions.caseSensitive, f.checked = !!this.searchOptions.wholeWord, u.checked = !!this.searchOptions.regex, s.addEventListener("input", () => {
2178
2296
  this.searchDebounceTimer && clearTimeout(this.searchDebounceTimer);
@@ -2635,7 +2753,7 @@ const x = class x {
2635
2753
  e != null && e.parentNode && e.parentNode.removeChild(e), this.editor = null;
2636
2754
  }
2637
2755
  };
2638
- x.css = {
2756
+ b.css = {
2639
2757
  root: "lce-search-ui",
2640
2758
  row: "lce-search-row",
2641
2759
  options: "lce-search-options",
@@ -2658,7 +2776,7 @@ x.css = {
2658
2776
  mode: "search-mode",
2659
2777
  modeLayout: "lce-search-mode"
2660
2778
  };
2661
- let V = x, re = 0;
2779
+ let W = b, re = 0;
2662
2780
  class oe {
2663
2781
  constructor() {
2664
2782
  this.name = "bracket-matching", this.editor = null, this.bracketPairs = {
@@ -2831,7 +2949,7 @@ class oe {
2831
2949
  }
2832
2950
  class le {
2833
2951
  constructor() {
2834
- this.name = "code-folding", this.lineHeight = 21, this.voidMarkupTags = /* @__PURE__ */ new Set([
2952
+ this.name = "code-folding", this.lineHeight = 24, this.voidMarkupTags = /* @__PURE__ */ new Set([
2835
2953
  "area",
2836
2954
  "base",
2837
2955
  "br",
@@ -2909,7 +3027,7 @@ class le {
2909
3027
  right: 0;
2910
3028
  top: 0;
2911
3029
  bottom: 0;
2912
- width: 20px;
3030
+ width: 24px;
2913
3031
  pointer-events: none;
2914
3032
  z-index: 3;
2915
3033
  `, e.appendChild(this.foldingUI));
@@ -3137,7 +3255,7 @@ class le {
3137
3255
  position: absolute;
3138
3256
  left: 0;
3139
3257
  top: ${t * this.lineHeight}px;
3140
- width: 20px;
3258
+ width: 24px;
3141
3259
  height: ${this.lineHeight}px;
3142
3260
  display: flex;
3143
3261
  align-items: center;
@@ -3738,16 +3856,16 @@ class ae {
3738
3856
  return y = y.replace(
3739
3857
  /([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,
3740
3858
  (T, S, v, C) => {
3741
- const L = String(S).toLowerCase(), H = `<span style="color: ${i.attrName};">${S}</span>`;
3859
+ const L = String(S).toLowerCase(), I = `<span style="color: ${i.attrName};">${S}</span>`;
3742
3860
  let O = C, M = "";
3743
3861
  C.startsWith("&quot;") && C.endsWith("&quot;") ? (O = C.slice(6, -6), M = "&quot;") : C.startsWith("&#39;") && C.endsWith("&#39;") && (O = C.slice(5, -5), M = "&#39;");
3744
3862
  let E = C;
3745
3863
  if (L === "style") {
3746
- const N = O.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (F, k, A, I) => `<span style="color: ${i.styleProp};">${k}</span>:<span style="color: ${i.styleVal};">${A}</span>${I}`);
3747
- M ? E = `${M}${N}${M}` : E = N, E = `<span style="color: ${i.attrValue};">${E}</span>`;
3864
+ const D = O.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (A, k, F, H) => `<span style="color: ${i.styleProp};">${k}</span>:<span style="color: ${i.styleVal};">${F}</span>${H}`);
3865
+ M ? E = `${M}${D}${M}` : E = D, E = `<span style="color: ${i.attrValue};">${E}</span>`;
3748
3866
  } else
3749
3867
  M && (E = `${M}${O}${M}`), E = `<span style="color: ${i.attrValue};">${E}</span>`;
3750
- return `${H}${v}${E}`;
3868
+ return `${I}${v}${E}`;
3751
3869
  }
3752
3870
  ), `${f}${m}${y}${p}`;
3753
3871
  }), a = a.replace(/\u0002ht(\d+)\u0002/g, (d, f) => o[Number(f)] || ""), this.restoreHighlightTokens(a, s);
@@ -4079,7 +4197,7 @@ class ae {
4079
4197
  }
4080
4198
  function he(R, e) {
4081
4199
  const t = { ...e };
4082
- return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new ee(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new z()), new B(R, t);
4200
+ return t.extensions || (t.extensions = []), t.extensions.some((s) => s.name === "keymap") || t.extensions.unshift(new ee(t.keymap)), t.extensions.some((s) => s.name === "transaction") || t.extensions.unshift(new B()), new z(R, t);
4083
4201
  }
4084
4202
  const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Editor Dialog Styles */
4085
4203
  .rte-source-editor-overlay {
@@ -4526,7 +4644,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4526
4644
  return r.trim();
4527
4645
  };
4528
4646
  return (() => {
4529
- document.querySelectorAll(".rte-source-editor-overlay").forEach((b) => b.remove());
4647
+ document.querySelectorAll(".rte-source-editor-overlay").forEach((x) => x.remove());
4530
4648
  const r = i(t);
4531
4649
  let o = null, l = "dark", a = !1, h = !1, c = !1, d = !1;
4532
4650
  const f = !!e.closest(P) || document.body.matches(P) || document.documentElement.matches(P), u = document.createElement("div");
@@ -4589,14 +4707,14 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4589
4707
  <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
4590
4708
  </div>
4591
4709
  `, g.appendChild(p), g.appendChild(m), g.appendChild(v), u.appendChild(g), !document.getElementById("rte-source-editor-styles")) {
4592
- const b = document.createElement("style");
4593
- b.id = "rte-source-editor-styles", b.textContent = ce, document.head.appendChild(b);
4710
+ const x = document.createElement("style");
4711
+ x.id = "rte-source-editor-styles", x.textContent = ce, document.head.appendChild(x);
4594
4712
  }
4595
4713
  const C = p.querySelector(
4596
4714
  ".theme-toggle-btn"
4597
4715
  ), L = p.querySelector(
4598
4716
  ".readonly-toggle-btn"
4599
- ), H = p.querySelector(
4717
+ ), I = p.querySelector(
4600
4718
  ".rte-source-editor-fullscreen-btn"
4601
4719
  ), O = p.querySelector(
4602
4720
  ".rte-source-editor-close-btn"
@@ -4604,19 +4722,19 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4604
4722
  ".rte-source-editor-btn-cancel"
4605
4723
  ), E = v.querySelector(
4606
4724
  ".rte-source-editor-btn-save"
4607
- ), N = v.querySelector(
4725
+ ), D = v.querySelector(
4608
4726
  ".unsaved-changes"
4609
- ), F = [], k = (b, $, U, K) => {
4610
- b.addEventListener($, U, K), F.push(
4611
- () => b.removeEventListener($, U, K)
4727
+ ), A = [], k = (x, $, U, K) => {
4728
+ x.addEventListener($, U, K), A.push(
4729
+ () => x.removeEventListener($, U, K)
4612
4730
  );
4613
- }, A = (b) => {
4614
- c !== b && (c = b, N && (N.style.display = c ? "inline" : "none"));
4615
- }, I = () => {
4731
+ }, F = (x) => {
4732
+ c !== x && (c = x, D && (D.style.display = c ? "inline" : "none"));
4733
+ }, H = () => {
4616
4734
  if (!d) {
4617
- for (d = !0; F.length; ) {
4618
- const b = F.pop();
4619
- b == null || b();
4735
+ for (d = !0; A.length; ) {
4736
+ const x = A.pop();
4737
+ x == null || x();
4620
4738
  }
4621
4739
  o && (o.destroy(), o = null), u.isConnected && u.remove();
4622
4740
  }
@@ -4652,7 +4770,7 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4652
4770
  </svg>
4653
4771
  `);
4654
4772
  }, q = () => {
4655
- h = !h, u.classList.toggle("fullscreen", h), S.style.height = h ? "calc(100vh - 200px)" : "400px", H && (H.innerHTML = h ? `
4773
+ h = !h, u.classList.toggle("fullscreen", h), S.style.height = h ? "calc(100vh - 200px)" : "400px", I && (I.innerHTML = h ? `
4656
4774
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4657
4775
  <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"/>
4658
4776
  </svg>
@@ -4662,11 +4780,11 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4662
4780
  </svg>
4663
4781
  `);
4664
4782
  }, G = () => {
4665
- c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || I();
4783
+ c && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
4666
4784
  }, Z = () => {
4667
4785
  try {
4668
- const b = (o == null ? void 0 : o.getValue()) || "";
4669
- e.innerHTML = Y(b);
4786
+ const x = (o == null ? void 0 : o.getValue()) || "";
4787
+ e.innerHTML = Y(x);
4670
4788
  try {
4671
4789
  e.dispatchEvent(
4672
4790
  new InputEvent("input", {
@@ -4682,16 +4800,16 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4682
4800
  }
4683
4801
  e.dispatchEvent(
4684
4802
  new Event("change", { bubbles: !0 })
4685
- ), A(!1), I();
4686
- } catch (b) {
4687
- alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", b);
4803
+ ), F(!1), H();
4804
+ } catch (x) {
4805
+ alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", x);
4688
4806
  }
4689
4807
  };
4690
- C && k(C, "click", _), L && k(L, "click", j), H && k(H, "click", q), O && k(O, "click", I), M && k(M, "click", G), E && k(E, "click", Z), k(u, "click", (b) => {
4691
- b.target === u && I();
4692
- }), k(document, "keydown", (b) => {
4693
- const $ = b;
4694
- $.key === "Escape" && ($.preventDefault(), I());
4808
+ C && k(C, "click", _), L && k(L, "click", j), I && k(I, "click", q), O && k(O, "click", H), M && k(M, "click", G), E && k(E, "click", Z), k(u, "click", (x) => {
4809
+ x.target === u && H();
4810
+ }), k(document, "keydown", (x) => {
4811
+ const $ = x;
4812
+ $.key === "Escape" && ($.preventDefault(), H());
4695
4813
  }), document.body.appendChild(u), requestAnimationFrame(() => {
4696
4814
  if (!(d || !u.isConnected))
4697
4815
  try {
@@ -4704,16 +4822,16 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4704
4822
  new ie(),
4705
4823
  new ne(),
4706
4824
  new oe(),
4707
- new V(),
4825
+ new W(),
4708
4826
  new le(),
4709
4827
  new ae()
4710
4828
  ]
4711
4829
  }), o.on("change", () => {
4712
- const b = (o == null ? void 0 : o.getValue()) || "";
4713
- A(b !== r);
4830
+ const x = (o == null ? void 0 : o.getValue()) || "";
4831
+ F(x !== r);
4714
4832
  }), requestAnimationFrame(() => o == null ? void 0 : o.focus());
4715
- } catch (b) {
4716
- console.error("Failed to initialize code editor:", b);
4833
+ } catch (x) {
4834
+ console.error("Failed to initialize code editor:", x);
4717
4835
  }
4718
4836
  });
4719
4837
  })(), !0;
@@ -4728,4 +4846,4 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4728
4846
  export {
4729
4847
  ge as CodePlugin
4730
4848
  };
4731
- //# sourceMappingURL=CodePlugin.native-BcVqm5MS.mjs.map
4849
+ //# sourceMappingURL=CodePlugin.native-CAHk9ecG.mjs.map