@editora/core 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClearFormattingPlugin.native-DIS6AN2t.mjs → ClearFormattingPlugin.native-B6ro3a1h.mjs} +49 -39
- package/dist/{CodePlugin.native-C5l1IeSS.mjs → CodePlugin.native-veDC_kx5.mjs} +87 -57
- package/dist/FormatPainterPlugin.native-CsMrKfFU.mjs +676 -0
- package/dist/editora.min.js +1 -1
- package/dist/editora.umd.js +1 -1
- package/dist/{index-CPMGUZfB.js → index-B5BzVUdg.js} +2 -2
- package/dist/{index-DBoj6QfW.mjs → index-YZ5TROdg.mjs} +10 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/plugin-loader.js +3 -0
- package/dist/webcomponent-core.js +5 -3
- package/dist/webcomponent-core.min.js +38 -32
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +24 -19
- package/dist/webcomponent.min.js +703 -697
- package/package.json +1 -1
package/dist/{ClearFormattingPlugin.native-DIS6AN2t.mjs → ClearFormattingPlugin.native-B6ro3a1h.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const T = () => ({
|
|
2
2
|
name: "clearFormatting",
|
|
3
3
|
// Toolbar button configuration
|
|
4
4
|
toolbar: [
|
|
@@ -19,10 +19,10 @@ const C = () => ({
|
|
|
19
19
|
if (!t) return !1;
|
|
20
20
|
const e = window.getSelection();
|
|
21
21
|
if (!e || e.rangeCount === 0) return !1;
|
|
22
|
-
const
|
|
23
|
-
if (!t.contains(
|
|
24
|
-
const
|
|
25
|
-
return t.focus({ preventScroll: !0 }),
|
|
22
|
+
const n = e.getRangeAt(0);
|
|
23
|
+
if (!t.contains(n.commonAncestorContainer)) return !1;
|
|
24
|
+
const r = n.cloneRange();
|
|
25
|
+
return t.focus({ preventScroll: !0 }), C(t, r), y(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
// Keyboard shortcuts
|
|
@@ -72,7 +72,7 @@ const C = () => ({
|
|
|
72
72
|
function h() {
|
|
73
73
|
const t = window.getSelection();
|
|
74
74
|
if (t && t.rangeCount > 0) {
|
|
75
|
-
const
|
|
75
|
+
const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, o = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content');
|
|
76
76
|
if (o) return o;
|
|
77
77
|
}
|
|
78
78
|
const e = document.activeElement;
|
|
@@ -82,23 +82,23 @@ function c(t, e) {
|
|
|
82
82
|
try {
|
|
83
83
|
if (typeof t.intersectsNode == "function")
|
|
84
84
|
return t.intersectsNode(e);
|
|
85
|
-
} catch (
|
|
85
|
+
} catch (r) {
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
return e.nodeType === Node.ELEMENT_NODE ?
|
|
87
|
+
const n = document.createRange();
|
|
88
|
+
return e.nodeType === Node.ELEMENT_NODE ? n.selectNodeContents(e) : n.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, n) > 0 && t.compareBoundaryPoints(Range.START_TO_END, n) < 0;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
let e = 0,
|
|
92
|
-
for (;
|
|
93
|
-
e += 1,
|
|
90
|
+
function a(t) {
|
|
91
|
+
let e = 0, n = t;
|
|
92
|
+
for (; n && n.parentNode; )
|
|
93
|
+
e += 1, n = n.parentNode;
|
|
94
94
|
return e;
|
|
95
95
|
}
|
|
96
96
|
function m(t) {
|
|
97
97
|
g.forEach((e) => {
|
|
98
98
|
t.style.removeProperty(e);
|
|
99
|
-
}), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class");
|
|
99
|
+
}), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.contains("rte-format-painted") && t.classList.remove("rte-format-painted"), t.classList.length === 0 && t.removeAttribute("class");
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function i(t) {
|
|
102
102
|
const e = t.parentNode;
|
|
103
103
|
if (e) {
|
|
104
104
|
for (; t.firstChild; )
|
|
@@ -106,27 +106,37 @@ function a(t) {
|
|
|
106
106
|
e.removeChild(t);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function E(t) {
|
|
110
110
|
return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol");
|
|
111
111
|
}
|
|
112
112
|
function l(t) {
|
|
113
113
|
Array.from(t.children).forEach((e) => {
|
|
114
|
-
|
|
114
|
+
E(e) && e.remove();
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
function s(t) {
|
|
118
|
-
l(t),
|
|
118
|
+
l(t), i(t);
|
|
119
119
|
}
|
|
120
120
|
function f(t) {
|
|
121
|
-
var
|
|
121
|
+
var n;
|
|
122
122
|
const e = document.createElement("p");
|
|
123
|
-
for (Array.from(t.attributes).forEach((
|
|
124
|
-
e.setAttribute(
|
|
123
|
+
for (Array.from(t.attributes).forEach((r) => {
|
|
124
|
+
e.setAttribute(r.name, r.value);
|
|
125
125
|
}); t.firstChild; )
|
|
126
126
|
e.appendChild(t.firstChild);
|
|
127
|
-
e.innerHTML.trim() || (e.innerHTML = "<br>"), (
|
|
127
|
+
e.innerHTML.trim() || (e.innerHTML = "<br>"), (n = t.parentNode) == null || n.replaceChild(e, t);
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function p(t) {
|
|
130
|
+
return !/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName) || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, svg, math");
|
|
131
|
+
}
|
|
132
|
+
function N(t) {
|
|
133
|
+
Array.from(
|
|
134
|
+
t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")
|
|
135
|
+
).sort((n, r) => a(r) - a(n)).forEach((n) => {
|
|
136
|
+
n.isConnected && p(n) && n.remove();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function A(t) {
|
|
130
140
|
if (l(t), t.parentElement instanceof HTMLLIElement) {
|
|
131
141
|
s(t);
|
|
132
142
|
return;
|
|
@@ -137,36 +147,36 @@ function E(t) {
|
|
|
137
147
|
}
|
|
138
148
|
f(t);
|
|
139
149
|
}
|
|
140
|
-
function
|
|
150
|
+
function y(t, e) {
|
|
141
151
|
Array.from(
|
|
142
152
|
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
|
|
143
|
-
).forEach((
|
|
144
|
-
if (c(e,
|
|
145
|
-
if (
|
|
146
|
-
|
|
153
|
+
).forEach((r) => {
|
|
154
|
+
if (c(e, r) && d.has(r.tagName)) {
|
|
155
|
+
if (r.tagName === "BLOCKQUOTE") {
|
|
156
|
+
A(r);
|
|
147
157
|
return;
|
|
148
158
|
}
|
|
149
|
-
f(
|
|
159
|
+
f(r);
|
|
150
160
|
}
|
|
151
161
|
});
|
|
152
162
|
}
|
|
153
|
-
function
|
|
154
|
-
const
|
|
163
|
+
function C(t, e) {
|
|
164
|
+
const n = Array.from(
|
|
155
165
|
t.querySelectorAll(
|
|
156
166
|
"a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
|
|
157
167
|
)
|
|
158
168
|
);
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
if (m(
|
|
162
|
-
|
|
169
|
+
n.sort((r, o) => a(o) - a(r)), n.forEach((r) => {
|
|
170
|
+
if (r.isConnected && c(e, r) && !(r.getAttribute("contenteditable") === "false" || r.closest('[contenteditable="false"]'))) {
|
|
171
|
+
if (m(r), u.has(r.tagName)) {
|
|
172
|
+
i(r);
|
|
163
173
|
return;
|
|
164
174
|
}
|
|
165
|
-
|
|
175
|
+
r.tagName === "SPAN" && r.attributes.length === 0 && i(r);
|
|
166
176
|
}
|
|
167
|
-
});
|
|
177
|
+
}), N(t);
|
|
168
178
|
}
|
|
169
179
|
export {
|
|
170
|
-
|
|
180
|
+
T as ClearFormattingPlugin
|
|
171
181
|
};
|
|
172
|
-
//# sourceMappingURL=ClearFormattingPlugin.native-
|
|
182
|
+
//# sourceMappingURL=ClearFormattingPlugin.native-B6ro3a1h.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class V {
|
|
2
2
|
constructor(e = "") {
|
|
3
3
|
this._lines = [], this._version = 0, this.setText(e);
|
|
4
4
|
}
|
|
@@ -84,7 +84,7 @@ class z {
|
|
|
84
84
|
}
|
|
85
85
|
// Clone the model
|
|
86
86
|
clone() {
|
|
87
|
-
const e = new
|
|
87
|
+
const e = new V();
|
|
88
88
|
return e._lines = [...this._lines], e._version = this._version, e;
|
|
89
89
|
}
|
|
90
90
|
normalizeRange(e) {
|
|
@@ -99,7 +99,7 @@ class z {
|
|
|
99
99
|
}
|
|
100
100
|
class Q {
|
|
101
101
|
constructor(e) {
|
|
102
|
-
this.gutterWidth = 50, 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();
|
|
102
|
+
this.gutterWidth = 50, this.gutterFoldColumnWidth = 20, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
|
|
103
103
|
}
|
|
104
104
|
createDOM() {
|
|
105
105
|
this.container.innerHTML = "";
|
|
@@ -114,20 +114,20 @@ class Q {
|
|
|
114
114
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
115
115
|
font-size: 14px;
|
|
116
116
|
line-height: ${this.lineHeight}px;
|
|
117
|
-
|
|
118
|
-
overflow-x: hidden;
|
|
119
|
-
overflow-y: auto;
|
|
117
|
+
overflow: auto;
|
|
120
118
|
`, this.lineNumbersElement = document.createElement("div"), this.lineNumbersElement.setAttribute("data-editor-gutter", "true"), this.lineNumbersElement.style.cssText = `
|
|
121
119
|
display: table-cell;
|
|
122
120
|
vertical-align: top;
|
|
123
121
|
position: sticky;
|
|
124
122
|
left: 0;
|
|
125
123
|
width: ${this.gutterWidth}px;
|
|
124
|
+
min-width: ${this.gutterWidth}px;
|
|
126
125
|
background: var(--editor-gutter-background, #252526);
|
|
127
126
|
color: var(--editor-gutter-foreground, #858585);
|
|
128
|
-
padding: 0
|
|
127
|
+
padding: 0;
|
|
129
128
|
text-align: right;
|
|
130
129
|
border-right: 1px solid var(--editor-gutter-border, #3e3e42);
|
|
130
|
+
box-sizing: border-box;
|
|
131
131
|
background-clip: padding-box;
|
|
132
132
|
user-select: none;
|
|
133
133
|
overflow: hidden;
|
|
@@ -135,6 +135,8 @@ class Q {
|
|
|
135
135
|
`, this.lineNumbersContentElement = document.createElement("div"), this.lineNumbersContentElement.setAttribute("data-editor-gutter-content", "true"), this.lineNumbersContentElement.style.cssText = `
|
|
136
136
|
position: relative;
|
|
137
137
|
z-index: 1;
|
|
138
|
+
box-sizing: border-box;
|
|
139
|
+
padding: 0 ${this.gutterFoldColumnWidth + this.gutterFoldColumnGap}px 0 ${this.gutterLineNumberPaddingLeft}px;
|
|
138
140
|
`, this.gutterDecorationsElement = document.createElement("div"), this.gutterDecorationsElement.setAttribute("data-editor-gutter-decorations", "true"), this.gutterDecorationsElement.setAttribute("aria-hidden", "true"), this.gutterDecorationsElement.style.cssText = `
|
|
139
141
|
position: absolute;
|
|
140
142
|
inset: 0;
|
|
@@ -147,6 +149,7 @@ class Q {
|
|
|
147
149
|
vertical-align: top;
|
|
148
150
|
position: relative;
|
|
149
151
|
width: 100%;
|
|
152
|
+
min-width: max-content;
|
|
150
153
|
min-height: 400px;
|
|
151
154
|
`, this.highlightElement = document.createElement("div"), this.highlightElement.setAttribute("data-editor-highlight", "true"), this.highlightElement.setAttribute("aria-hidden", "true"), this.highlightElement.style.cssText = `
|
|
152
155
|
position: absolute;
|
|
@@ -170,14 +173,16 @@ class Q {
|
|
|
170
173
|
`, this.contentElement = document.createElement("div"), this.contentElement.style.cssText = `
|
|
171
174
|
position: relative;
|
|
172
175
|
z-index: 1;
|
|
176
|
+
display: block;
|
|
177
|
+
box-sizing: border-box;
|
|
173
178
|
padding: 0 12px;
|
|
174
179
|
background: transparent;
|
|
175
180
|
border: none;
|
|
176
181
|
outline: none;
|
|
177
182
|
white-space: pre;
|
|
178
|
-
overflow
|
|
179
|
-
overflow-y: visible;
|
|
183
|
+
overflow: visible;
|
|
180
184
|
width: 100%;
|
|
185
|
+
min-width: max-content;
|
|
181
186
|
min-height: 400px;
|
|
182
187
|
font-family: inherit;
|
|
183
188
|
font-size: inherit;
|
|
@@ -191,18 +196,25 @@ class Q {
|
|
|
191
196
|
this.scrollWrapper = i, i.setAttribute("data-editora-editor", "true"), i.style.cssText = `
|
|
192
197
|
position: relative;
|
|
193
198
|
display: table;
|
|
194
|
-
table-layout:
|
|
199
|
+
table-layout: auto;
|
|
195
200
|
width: 100%;
|
|
201
|
+
min-width: 100%;
|
|
196
202
|
height: 100%;
|
|
197
203
|
`, this.lineNumbersElement.appendChild(this.lineNumbersContentElement), this.lineNumbersElement.appendChild(this.gutterDecorationsElement), i.appendChild(this.lineNumbersElement), t.appendChild(this.lineDecorationsElement), t.appendChild(this.highlightElement), t.appendChild(this.contentElement), i.appendChild(t), e.appendChild(i), this.container.appendChild(e), this.updateLineNumbers(1);
|
|
198
204
|
}
|
|
199
205
|
// Update line numbers
|
|
200
206
|
updateLineNumbers(e) {
|
|
201
|
-
if (e === this.lastLineCount)
|
|
207
|
+
if (this.updateGutterWidth(e), e === this.lastLineCount)
|
|
202
208
|
return;
|
|
203
209
|
this.lastLineCount = e;
|
|
204
210
|
const t = Math.max(e, 1), i = Array.from({ length: t }, (s, n) => n + 1);
|
|
205
|
-
this.lineNumbersContentElement.innerHTML = i.map((s) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;
|
|
211
|
+
this.lineNumbersContentElement.innerHTML = i.map((s) => `<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${s}</div>`).join("");
|
|
212
|
+
}
|
|
213
|
+
updateGutterWidth(e) {
|
|
214
|
+
const t = String(Math.max(e, 1)).length * this.gutterDigitWidth + this.gutterLineNumberPaddingLeft + this.gutterLineNumberPaddingRight, i = Math.ceil(
|
|
215
|
+
t + this.gutterFoldColumnGap + this.gutterFoldColumnWidth
|
|
216
|
+
);
|
|
217
|
+
i !== this.gutterWidth && (this.gutterWidth = i, this.lineNumbersElement.style.display !== "none" && (this.lineNumbersElement.style.width = `${this.gutterWidth}px`, this.lineNumbersElement.style.minWidth = `${this.gutterWidth}px`));
|
|
206
218
|
}
|
|
207
219
|
setDecorations(e, t) {
|
|
208
220
|
this.renderLineDecorations(e), this.renderGutterDecorations(t);
|
|
@@ -246,10 +258,10 @@ class Q {
|
|
|
246
258
|
this.updateLineNumbers(t);
|
|
247
259
|
}
|
|
248
260
|
setLineWrapping(e) {
|
|
249
|
-
this.contentElement.style.whiteSpace = e ? "pre-wrap" : "pre", this.contentElement.style.
|
|
261
|
+
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";
|
|
250
262
|
}
|
|
251
263
|
setLineNumbersVisible(e) {
|
|
252
|
-
this.lineNumbersElement.style.display = e ? "table-cell" : "none", this.lineNumbersElement.style.width = e ? `${this.gutterWidth}px` : "0", this.lineNumbersElement.style.
|
|
264
|
+
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%";
|
|
253
265
|
}
|
|
254
266
|
setTabSize(e) {
|
|
255
267
|
const t = Math.max(1, Math.floor(e) || 2);
|
|
@@ -447,8 +459,8 @@ class Q {
|
|
|
447
459
|
}
|
|
448
460
|
// Scroll to position
|
|
449
461
|
scrollToPosition(e) {
|
|
450
|
-
const t =
|
|
451
|
-
|
|
462
|
+
const t = Math.max(0, Math.floor(e.line) || 0) * this.lineHeight - this.editorContainer.clientHeight / 2 + this.lineHeight / 2;
|
|
463
|
+
this.editorContainer.scrollTop = Math.max(0, t);
|
|
452
464
|
}
|
|
453
465
|
// Get scroll position
|
|
454
466
|
getScrollTop() {
|
|
@@ -480,7 +492,7 @@ class Q {
|
|
|
480
492
|
const t = this.getCaretClientRect(e);
|
|
481
493
|
if (!t) return;
|
|
482
494
|
const i = this.editorContainer.getBoundingClientRect(), s = 12;
|
|
483
|
-
t.bottom > i.bottom - s ? this.editorContainer.scrollTop += t.bottom - (i.bottom - s) : t.top < i.top + s && (this.editorContainer.scrollTop -= i.top + s - t.top);
|
|
495
|
+
t.bottom > i.bottom - s ? this.editorContainer.scrollTop += t.bottom - (i.bottom - s) : t.top < i.top + s && (this.editorContainer.scrollTop -= i.top + s - t.top), t.right > i.right - s ? this.editorContainer.scrollLeft += t.right - (i.right - s) : t.left < i.left + s && (this.editorContainer.scrollLeft -= i.left + s - t.left);
|
|
484
496
|
}
|
|
485
497
|
// Destroy the view
|
|
486
498
|
destroy() {
|
|
@@ -811,7 +823,7 @@ class Q {
|
|
|
811
823
|
}
|
|
812
824
|
}
|
|
813
825
|
let X = 0;
|
|
814
|
-
const
|
|
826
|
+
const W = class O {
|
|
815
827
|
constructor(e, t = {}) {
|
|
816
828
|
this.extensions = /* @__PURE__ */ new Map(), this.commands = /* @__PURE__ */ new Map(), this.eventListeners = /* @__PURE__ */ new Map(), this.folds = [], this.currentTheme = "default", this.isDestroyed = !1, this.undoStack = [], this.redoStack = [], this.suppressHistory = !1, this.highlightTimeout = null, this.expectingProgrammaticCursor = !1, this.lastKnownCursor = { line: 0, column: 0 }, this.editorInstanceId = ++X, this.decorationHighlightStyleId = `editora-decoration-style-${this.editorInstanceId}`, this.decorationHighlightLimit = 1e3, this.decorationLayers = /* @__PURE__ */ new Map(), this.inlineDecorationHighlightNames = /* @__PURE__ */ new Set(), this.decorationRenderRaf = null, this.decorationMutationObserver = null, this.hasCustomDecorationHighlightSupport = !1, this.lastProgrammaticClipboardInsertAt = 0, this.config = {
|
|
817
829
|
value: "",
|
|
@@ -821,7 +833,7 @@ const U = class O {
|
|
|
821
833
|
lineWrapping: !1,
|
|
822
834
|
lineNumbers: !0,
|
|
823
835
|
...t
|
|
824
|
-
}, this.textModel = new
|
|
836
|
+
}, this.textModel = new V(this.config.value), this.view = new Q(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();
|
|
825
837
|
}
|
|
826
838
|
// Public accessors for extensions
|
|
827
839
|
getTextModel() {
|
|
@@ -1755,8 +1767,8 @@ const U = class O {
|
|
|
1755
1767
|
};
|
|
1756
1768
|
}
|
|
1757
1769
|
};
|
|
1758
|
-
|
|
1759
|
-
let Y =
|
|
1770
|
+
W.CURSOR_SENTINEL = "";
|
|
1771
|
+
let Y = W;
|
|
1760
1772
|
class J {
|
|
1761
1773
|
constructor(e) {
|
|
1762
1774
|
this.name = "keymap", this.editor = null, this.keymap = {}, this.isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0, this.keymap = e || this.getDefaultKeymap();
|
|
@@ -1831,7 +1843,7 @@ class J {
|
|
|
1831
1843
|
this.keymap = {}, this.editor = null;
|
|
1832
1844
|
}
|
|
1833
1845
|
}
|
|
1834
|
-
const
|
|
1846
|
+
const U = class z {
|
|
1835
1847
|
constructor() {
|
|
1836
1848
|
this.name = "transaction", this.transactions = [];
|
|
1837
1849
|
}
|
|
@@ -1843,9 +1855,9 @@ const W = class V {
|
|
|
1843
1855
|
effects: [],
|
|
1844
1856
|
annotations: []
|
|
1845
1857
|
};
|
|
1846
|
-
this.transactions.push(i), this.transactions.length >
|
|
1858
|
+
this.transactions.push(i), this.transactions.length > z.MAX_TRANSACTIONS && this.transactions.splice(
|
|
1847
1859
|
0,
|
|
1848
|
-
this.transactions.length -
|
|
1860
|
+
this.transactions.length - z.MAX_TRANSACTIONS
|
|
1849
1861
|
);
|
|
1850
1862
|
});
|
|
1851
1863
|
}
|
|
@@ -1856,8 +1868,8 @@ const W = class V {
|
|
|
1856
1868
|
this.transactions = [];
|
|
1857
1869
|
}
|
|
1858
1870
|
};
|
|
1859
|
-
|
|
1860
|
-
let ee =
|
|
1871
|
+
U.MAX_TRANSACTIONS = 200;
|
|
1872
|
+
let ee = U;
|
|
1861
1873
|
class te {
|
|
1862
1874
|
constructor() {
|
|
1863
1875
|
this.name = "line-numbers", this.editor = null, this.lineNumbersElement = null, this.isEnabled = !0;
|
|
@@ -2759,12 +2771,10 @@ class ae {
|
|
|
2759
2771
|
}
|
|
2760
2772
|
createFoldingUI() {
|
|
2761
2773
|
if (!this.editor) return;
|
|
2762
|
-
const e = this.editor.getView().
|
|
2763
|
-
'[data-lce-editor-container="true"]'
|
|
2764
|
-
);
|
|
2774
|
+
const e = this.editor.getView().getLineNumbersElement();
|
|
2765
2775
|
e && (this.foldingUI = document.createElement("div"), this.foldingUI.setAttribute("data-lce-folding-ui", "true"), this.foldingUI.style.cssText = `
|
|
2766
2776
|
position: absolute;
|
|
2767
|
-
|
|
2777
|
+
right: 0;
|
|
2768
2778
|
top: 0;
|
|
2769
2779
|
bottom: 0;
|
|
2770
2780
|
width: 20px;
|
|
@@ -3015,31 +3025,51 @@ class ae {
|
|
|
3015
3025
|
}), s;
|
|
3016
3026
|
}
|
|
3017
3027
|
toggleFold(e) {
|
|
3018
|
-
this.editor && (this.isFoldActive(e) ? this.editor.unfold(e) : this.editor.fold(e), this.
|
|
3028
|
+
this.editor && (this.isFoldActive(e) ? this.editor.unfold(e) : this.editor.fold(e), this.syncFoldingStatePreservingScroll());
|
|
3019
3029
|
}
|
|
3020
3030
|
foldAtCursor() {
|
|
3021
3031
|
if (!this.editor) return;
|
|
3022
3032
|
const e = this.editor.getCursor().position.line, t = this.findBestRegionForLine(e, !1);
|
|
3023
|
-
t && (this.editor.fold(t), this.
|
|
3033
|
+
t && (this.editor.fold(t), this.syncFoldingStatePreservingScroll());
|
|
3024
3034
|
}
|
|
3025
3035
|
unfoldAtCursor() {
|
|
3026
3036
|
if (!this.editor) return;
|
|
3027
3037
|
const e = this.editor.getCursor().position.line, t = this.findBestRegionForLine(e, !0);
|
|
3028
|
-
t && (this.editor.unfold(t), this.
|
|
3038
|
+
t && (this.editor.unfold(t), this.syncFoldingStatePreservingScroll());
|
|
3029
3039
|
}
|
|
3030
3040
|
foldAll() {
|
|
3031
3041
|
if (!this.editor) return;
|
|
3032
3042
|
const e = this.getTopLevelFoldRegions(this.foldRegions);
|
|
3033
3043
|
for (const t of e)
|
|
3034
3044
|
this.editor.fold(t);
|
|
3035
|
-
this.
|
|
3045
|
+
this.syncFoldingStatePreservingScroll();
|
|
3036
3046
|
}
|
|
3037
3047
|
unfoldAll() {
|
|
3038
3048
|
if (!this.editor) return;
|
|
3039
3049
|
const e = this.getActiveFolds();
|
|
3040
3050
|
for (const t of e)
|
|
3041
3051
|
this.editor.unfold(t);
|
|
3042
|
-
this.
|
|
3052
|
+
this.syncFoldingStatePreservingScroll();
|
|
3053
|
+
}
|
|
3054
|
+
syncFoldingStatePreservingScroll() {
|
|
3055
|
+
this.withPreservedScroll(() => {
|
|
3056
|
+
this.syncFoldingState();
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
withPreservedScroll(e) {
|
|
3060
|
+
var n;
|
|
3061
|
+
const t = (n = this.editor) == null ? void 0 : n.getView().getScrollElement();
|
|
3062
|
+
if (!t) {
|
|
3063
|
+
e();
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
3066
|
+
const i = t.scrollLeft, s = t.scrollTop;
|
|
3067
|
+
e(), this.restoreScrollPosition(t, i, s);
|
|
3068
|
+
}
|
|
3069
|
+
restoreScrollPosition(e, t, i) {
|
|
3070
|
+
e.scrollLeft = t, e.scrollTop = i, requestAnimationFrame(() => {
|
|
3071
|
+
e.isConnected && (e.scrollLeft = t, e.scrollTop = i);
|
|
3072
|
+
});
|
|
3043
3073
|
}
|
|
3044
3074
|
applyFoldedDisplay() {
|
|
3045
3075
|
if (!this.editor) return;
|
|
@@ -3576,16 +3606,16 @@ class he {
|
|
|
3576
3606
|
return x = x.replace(
|
|
3577
3607
|
/([\w:-]+)(\s*=\s*)(("[\s\S]*?"|'[\s\S]*?'|[^\s&>]+))/g,
|
|
3578
3608
|
(v, T, w, S) => {
|
|
3579
|
-
const L = String(T).toLowerCase(),
|
|
3580
|
-
let
|
|
3581
|
-
S.startsWith(""") && S.endsWith(""") ? (
|
|
3609
|
+
const L = String(T).toLowerCase(), I = `<span style="color: ${i.attrName};">${T}</span>`;
|
|
3610
|
+
let $ = S, C = "";
|
|
3611
|
+
S.startsWith(""") && S.endsWith(""") ? ($ = S.slice(6, -6), C = """) : S.startsWith("'") && S.endsWith("'") && ($ = S.slice(5, -5), C = "'");
|
|
3582
3612
|
let M = S;
|
|
3583
3613
|
if (L === "style") {
|
|
3584
|
-
const D =
|
|
3614
|
+
const D = $.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g, (F, k, A, H) => `<span style="color: ${i.styleProp};">${k}</span>:<span style="color: ${i.styleVal};">${A}</span>${H}`);
|
|
3585
3615
|
C ? M = `${C}${D}${C}` : M = D, M = `<span style="color: ${i.attrValue};">${M}</span>`;
|
|
3586
3616
|
} else
|
|
3587
|
-
C && (M = `${C}${
|
|
3588
|
-
return `${
|
|
3617
|
+
C && (M = `${C}${$}${C}`), M = `<span style="color: ${i.attrValue};">${M}</span>`;
|
|
3618
|
+
return `${I}${w}${M}`;
|
|
3589
3619
|
}
|
|
3590
3620
|
), `${u}${m}${x}${p}`;
|
|
3591
3621
|
}), a = a.replace(/\u0002ht(\d+)\u0002/g, (c, u) => o[Number(u)] || ""), this.restoreHighlightTokens(a, n);
|
|
@@ -4433,9 +4463,9 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4433
4463
|
".theme-toggle-btn"
|
|
4434
4464
|
), L = p.querySelector(
|
|
4435
4465
|
".readonly-toggle-btn"
|
|
4436
|
-
), H = p.querySelector(
|
|
4437
|
-
".rte-source-editor-fullscreen-btn"
|
|
4438
4466
|
), I = p.querySelector(
|
|
4467
|
+
".rte-source-editor-fullscreen-btn"
|
|
4468
|
+
), $ = p.querySelector(
|
|
4439
4469
|
".rte-source-editor-close-btn"
|
|
4440
4470
|
), C = w.querySelector(
|
|
4441
4471
|
".rte-source-editor-btn-cancel"
|
|
@@ -4443,16 +4473,16 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4443
4473
|
".rte-source-editor-btn-save"
|
|
4444
4474
|
), D = w.querySelector(
|
|
4445
4475
|
".unsaved-changes"
|
|
4446
|
-
),
|
|
4447
|
-
b.addEventListener(R, P, N),
|
|
4476
|
+
), F = [], k = (b, R, P, N) => {
|
|
4477
|
+
b.addEventListener(R, P, N), F.push(
|
|
4448
4478
|
() => b.removeEventListener(R, P, N)
|
|
4449
4479
|
);
|
|
4450
|
-
},
|
|
4480
|
+
}, A = (b) => {
|
|
4451
4481
|
d !== b && (d = b, D && (D.style.display = d ? "inline" : "none"));
|
|
4452
|
-
},
|
|
4482
|
+
}, H = () => {
|
|
4453
4483
|
if (!c) {
|
|
4454
|
-
for (c = !0;
|
|
4455
|
-
const b =
|
|
4484
|
+
for (c = !0; F.length; ) {
|
|
4485
|
+
const b = F.pop();
|
|
4456
4486
|
b == null || b();
|
|
4457
4487
|
}
|
|
4458
4488
|
o && (o.destroy(), o = null), g.isConnected && g.remove();
|
|
@@ -4489,7 +4519,7 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4489
4519
|
</svg>
|
|
4490
4520
|
`);
|
|
4491
4521
|
}, q = () => {
|
|
4492
|
-
h = !h, g.classList.toggle("fullscreen", h), T.style.height = h ? "calc(100vh - 200px)" : "400px",
|
|
4522
|
+
h = !h, g.classList.toggle("fullscreen", h), T.style.height = h ? "calc(100vh - 200px)" : "400px", I && (I.innerHTML = h ? `
|
|
4493
4523
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
4494
4524
|
<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"/>
|
|
4495
4525
|
</svg>
|
|
@@ -4499,7 +4529,7 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4499
4529
|
</svg>
|
|
4500
4530
|
`);
|
|
4501
4531
|
}, G = () => {
|
|
4502
|
-
d && !confirm("You have unsaved changes. Are you sure you want to cancel?") ||
|
|
4532
|
+
d && !confirm("You have unsaved changes. Are you sure you want to cancel?") || H();
|
|
4503
4533
|
}, Z = () => {
|
|
4504
4534
|
try {
|
|
4505
4535
|
const b = (o == null ? void 0 : o.getValue()) || "", R = document.createElement("div");
|
|
@@ -4521,16 +4551,16 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4521
4551
|
}
|
|
4522
4552
|
e.dispatchEvent(
|
|
4523
4553
|
new Event("change", { bubbles: !0 })
|
|
4524
|
-
),
|
|
4554
|
+
), A(!1), H();
|
|
4525
4555
|
} catch (b) {
|
|
4526
4556
|
alert("Failed to update HTML. Please check your syntax."), console.error("HTML update error:", b);
|
|
4527
4557
|
}
|
|
4528
4558
|
};
|
|
4529
|
-
S && k(S, "click", _), L && k(L, "click", j),
|
|
4530
|
-
b.target === g &&
|
|
4559
|
+
S && k(S, "click", _), L && k(L, "click", j), I && k(I, "click", q), $ && k($, "click", H), C && k(C, "click", G), M && k(M, "click", Z), k(g, "click", (b) => {
|
|
4560
|
+
b.target === g && H();
|
|
4531
4561
|
}), k(document, "keydown", (b) => {
|
|
4532
4562
|
const R = b;
|
|
4533
|
-
R.key === "Escape" && (R.preventDefault(),
|
|
4563
|
+
R.key === "Escape" && (R.preventDefault(), H());
|
|
4534
4564
|
}), document.body.appendChild(g), requestAnimationFrame(() => {
|
|
4535
4565
|
if (!(c || !g.isConnected))
|
|
4536
4566
|
try {
|
|
@@ -4549,7 +4579,7 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4549
4579
|
]
|
|
4550
4580
|
}), o.on("change", () => {
|
|
4551
4581
|
const b = (o == null ? void 0 : o.getValue()) || "";
|
|
4552
|
-
|
|
4582
|
+
A(b !== r);
|
|
4553
4583
|
}), requestAnimationFrame(() => o == null ? void 0 : o.focus());
|
|
4554
4584
|
} catch (b) {
|
|
4555
4585
|
console.error("Failed to initialize code editor:", b);
|
|
@@ -4567,4 +4597,4 @@ const B = '[data-theme="dark"], .dark, .editora-theme-dark', de = `/* Source Edi
|
|
|
4567
4597
|
export {
|
|
4568
4598
|
ue as CodePlugin
|
|
4569
4599
|
};
|
|
4570
|
-
//# sourceMappingURL=CodePlugin.native-
|
|
4600
|
+
//# sourceMappingURL=CodePlugin.native-veDC_kx5.mjs.map
|