@kong-ui-public/monaco-editor 0.24.14 → 0.24.16
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/runtime/monaco-editor.cjs.js +10 -10
- package/dist/runtime/monaco-editor.es.js +529 -509
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { onMounted as
|
|
2
|
-
import { StrikethroughIcon as
|
|
3
|
-
import * as
|
|
4
|
-
import { KeyMod as T, KeyCode as
|
|
5
|
-
import { shikiToMonaco as
|
|
6
|
-
import { getSingletonHighlighter as
|
|
7
|
-
import { createI18n as
|
|
8
|
-
import { d as
|
|
9
|
-
import { getModelContext as
|
|
10
|
-
const
|
|
1
|
+
import { onMounted as Y, nextTick as ee, shallowRef as V, shallowReadonly as Me, getCurrentScope as Ne, onScopeDispose as Ee, getCurrentInstance as Le, toValue as D, computed as M, watch as $, ref as ue, reactive as Oe, onActivated as Ae, onBeforeUnmount as Te, onWatcherCleanup as Re, defineComponent as ae, resolveComponent as q, openBlock as v, createBlock as N, createSlots as me, withCtx as O, resolveDynamicComponent as ge, createVNode as re, createElementVNode as K, normalizeClass as ie, toDisplayString as de, createElementBlock as I, Fragment as _, renderList as B, unref as S, createCommentVNode as G, useTemplateRef as z, withDirectives as $e, createTextVNode as _e, vShow as Be, renderSlot as W, useModel as We, Transition as fe, mergeModels as be } from "vue";
|
|
2
|
+
import { StrikethroughIcon as Pe, ItalicIcon as De, BoldIcon as Fe, CleaningIcon as Ge, ImageIcon as Ke, LinkIcon as Ue, CodeIcon as Ve, TasklistIcon as je, ListOrderedIcon as ze, ListUnorderedIcon as He, TableIcon as qe, BlockquoteIcon as Ye, CodeblockIcon as xe, SearchIcon as Xe, ExpandIcon as Je, MoreIcon as Qe, ProgressIcon as Ze } from "@kong/icons";
|
|
3
|
+
import * as R from "monaco-editor";
|
|
4
|
+
import { KeyMod as T, KeyCode as H } from "monaco-editor";
|
|
5
|
+
import { shikiToMonaco as et } from "@shikijs/monaco";
|
|
6
|
+
import { getSingletonHighlighter as tt, bundledLanguages as nt, bundledThemes as ot } from "shiki";
|
|
7
|
+
import { createI18n as rt, i18nTComponent as it } from "@kong-ui-public/i18n";
|
|
8
|
+
import { d as an, a as ln, c as sn, b as cn, e as dn, u as un } from "./code-lenses-CMLSv617.js";
|
|
9
|
+
import { getModelContext as gn, invalidateModelContexts as fn } from "./singletons.es.js";
|
|
10
|
+
const at = "'JetBrains Mono', Consolas, monospace", lt = "12px", st = "500", ct = "20px", dt = "8px", te = Object.freeze({
|
|
11
11
|
autoClosingQuotes: "always",
|
|
12
12
|
automaticLayout: !0,
|
|
13
13
|
// Auto resize layout
|
|
@@ -16,10 +16,10 @@ const it = "'JetBrains Mono', Consolas, monospace", at = "12px", lt = "500", st
|
|
|
16
16
|
},
|
|
17
17
|
hideCursorInOverviewRuler: !0,
|
|
18
18
|
// hide the cursor position in the minimap TODO: maybe hide it on first line or change it colour
|
|
19
|
-
fontFamily:
|
|
20
|
-
fontSize: Number(
|
|
21
|
-
fontWeight:
|
|
22
|
-
lineHeight: Number(
|
|
19
|
+
fontFamily: at,
|
|
20
|
+
fontSize: Number(lt.replace("px", "")),
|
|
21
|
+
fontWeight: st,
|
|
22
|
+
lineHeight: Number(ct.replace("px", "")),
|
|
23
23
|
formatOnPaste: !0,
|
|
24
24
|
formatOnType: !0,
|
|
25
25
|
// Add to enable automatic formatting as the user types.
|
|
@@ -64,7 +64,7 @@ const it = "'JetBrains Mono', Consolas, monospace", at = "12px", lt = "500", st
|
|
|
64
64
|
addExtraSpaceOnTop: !1
|
|
65
65
|
// we need this set to false to get the correct absolute position, otherwise when the search box opens the content shifts
|
|
66
66
|
}
|
|
67
|
-
}),
|
|
67
|
+
}), he = {
|
|
68
68
|
command: T.CtrlCmd,
|
|
69
69
|
cmd: T.CtrlCmd,
|
|
70
70
|
ctrl: T.CtrlCmd,
|
|
@@ -74,7 +74,7 @@ const it = "'JetBrains Mono', Consolas, monospace", at = "12px", lt = "500", st
|
|
|
74
74
|
option: T.Alt,
|
|
75
75
|
win: T.WinCtrl,
|
|
76
76
|
meta: T.WinCtrl
|
|
77
|
-
},
|
|
77
|
+
}, ut = {
|
|
78
78
|
enter: "Enter",
|
|
79
79
|
esc: "Escape",
|
|
80
80
|
escape: "Escape",
|
|
@@ -96,29 +96,29 @@ const it = "'JetBrains Mono', Consolas, monospace", at = "12px", lt = "500", st
|
|
|
96
96
|
arrowleft: "LeftArrow",
|
|
97
97
|
arrowright: "RightArrow"
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function mt(e) {
|
|
100
100
|
if (!e?.length) return;
|
|
101
101
|
let o = 0, t;
|
|
102
102
|
for (const n of e) {
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
o |=
|
|
103
|
+
const l = n.toLowerCase();
|
|
104
|
+
if (he[l]) {
|
|
105
|
+
o |= he[l];
|
|
106
106
|
continue;
|
|
107
107
|
}
|
|
108
|
-
if (/^f\d+$/.test(
|
|
109
|
-
t =
|
|
108
|
+
if (/^f\d+$/.test(l)) {
|
|
109
|
+
t = H[`F${l.slice(1)}`];
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
|
-
if (/^[a-z]$/.test(
|
|
113
|
-
t =
|
|
112
|
+
if (/^[a-z]$/.test(l)) {
|
|
113
|
+
t = H[`Key${l.toUpperCase()}`];
|
|
114
114
|
continue;
|
|
115
115
|
}
|
|
116
|
-
if (/^\d$/.test(
|
|
117
|
-
t =
|
|
116
|
+
if (/^\d$/.test(l)) {
|
|
117
|
+
t = H[`Digit${l}`];
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
120
|
-
const r =
|
|
121
|
-
r && (t =
|
|
120
|
+
const r = ut[l];
|
|
121
|
+
r && (t = H[r]);
|
|
122
122
|
}
|
|
123
123
|
return t !== void 0 ? o | t : void 0;
|
|
124
124
|
}
|
|
@@ -132,7 +132,7 @@ function J(e, o) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
const
|
|
135
|
+
const gt = /* @__PURE__ */ new Set(["markdown", "mdc"]), ft = [
|
|
136
136
|
// Task list: `- [ ] ` or `- [x] `
|
|
137
137
|
{
|
|
138
138
|
detect: /^(\s*)- \[[ x]\] /,
|
|
@@ -152,31 +152,31 @@ const mt = /* @__PURE__ */ new Set(["markdown", "mdc"]), gt = [
|
|
|
152
152
|
emptyItem: /^(\s*)\d+\. $/
|
|
153
153
|
}
|
|
154
154
|
];
|
|
155
|
-
function
|
|
155
|
+
function bt(e) {
|
|
156
156
|
return e.addAction({
|
|
157
157
|
id: "editor.action.listContinuation",
|
|
158
158
|
label: "Continue List on Enter",
|
|
159
|
-
keybindings: [
|
|
159
|
+
keybindings: [H.Enter],
|
|
160
160
|
// Only trigger when: editor has focus, is not read-only, no suggest/autocomplete widget is visible
|
|
161
161
|
precondition: "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !renameInputVisible && !inSnippetMode && !quickFixWidgetVisible",
|
|
162
162
|
run: (o) => {
|
|
163
163
|
const t = o.getModel(), n = o.getSelection();
|
|
164
|
-
if (!t || !n || !n.isEmpty() || !
|
|
164
|
+
if (!t || !n || !n.isEmpty() || !gt.has(t.getLanguageId())) {
|
|
165
165
|
o.trigger("listContinuation", "type", { text: `
|
|
166
166
|
` });
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
const
|
|
170
|
-
for (const
|
|
171
|
-
const
|
|
172
|
-
if (!
|
|
173
|
-
if (
|
|
169
|
+
const l = n.startLineNumber, r = t.getLineContent(l);
|
|
170
|
+
for (const a of ft) {
|
|
171
|
+
const c = r.match(a.detect);
|
|
172
|
+
if (!c) continue;
|
|
173
|
+
if (a.emptyItem.test(r)) {
|
|
174
174
|
o.executeEdits("listContinuation", [
|
|
175
175
|
{
|
|
176
176
|
range: {
|
|
177
|
-
startLineNumber:
|
|
177
|
+
startLineNumber: l,
|
|
178
178
|
startColumn: 1,
|
|
179
|
-
endLineNumber:
|
|
179
|
+
endLineNumber: l,
|
|
180
180
|
endColumn: r.length + 1
|
|
181
181
|
},
|
|
182
182
|
text: ""
|
|
@@ -184,22 +184,22 @@ function ft(e) {
|
|
|
184
184
|
]);
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
|
-
const s =
|
|
187
|
+
const s = a.nextPrefix(c);
|
|
188
188
|
if (s !== void 0) {
|
|
189
|
-
const
|
|
189
|
+
const d = n.startColumn;
|
|
190
190
|
o.executeEdits("listContinuation", [
|
|
191
191
|
{
|
|
192
192
|
range: {
|
|
193
|
-
startLineNumber:
|
|
194
|
-
startColumn:
|
|
195
|
-
endLineNumber:
|
|
196
|
-
endColumn:
|
|
193
|
+
startLineNumber: l,
|
|
194
|
+
startColumn: d,
|
|
195
|
+
endLineNumber: l,
|
|
196
|
+
endColumn: d
|
|
197
197
|
},
|
|
198
198
|
text: `
|
|
199
199
|
${s}`
|
|
200
200
|
}
|
|
201
201
|
]);
|
|
202
|
-
const g =
|
|
202
|
+
const g = l + 1, i = s.length + 1;
|
|
203
203
|
o.setPosition({ lineNumber: g, column: i }), o.revealLine(g);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
@@ -209,301 +209,321 @@ ${s}`
|
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
return
|
|
212
|
+
function ht(e, o) {
|
|
213
|
+
return Ne() ? (Ee(e, o), !0) : !1;
|
|
214
214
|
}
|
|
215
|
-
const
|
|
215
|
+
const pt = typeof window < "u" && typeof document < "u";
|
|
216
216
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
217
|
-
const
|
|
217
|
+
const F = () => {
|
|
218
218
|
};
|
|
219
|
-
function
|
|
219
|
+
function Ct(e, o) {
|
|
220
220
|
function t(...n) {
|
|
221
|
-
return new Promise((
|
|
221
|
+
return new Promise((l, r) => {
|
|
222
222
|
Promise.resolve(e(() => o.apply(this, n), {
|
|
223
223
|
fn: o,
|
|
224
224
|
thisArg: this,
|
|
225
225
|
args: n
|
|
226
|
-
})).then(
|
|
226
|
+
})).then(l).catch(r);
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
return t
|
|
229
|
+
return "cancel" in e && Object.assign(t, {
|
|
230
|
+
cancel: e.cancel,
|
|
231
|
+
flush: e.flush,
|
|
232
|
+
isPending: e.isPending
|
|
233
|
+
}), t;
|
|
230
234
|
}
|
|
231
|
-
function
|
|
232
|
-
let t, n,
|
|
233
|
-
const
|
|
234
|
-
clearTimeout(
|
|
235
|
-
};
|
|
236
|
-
let l;
|
|
237
|
-
return (s) => {
|
|
238
|
-
const c = P(e), g = P(o.maxWait);
|
|
239
|
-
return t && r(t), c <= 0 || g !== void 0 && g <= 0 ? (n && (r(n), n = void 0), Promise.resolve(s())) : new Promise((i, p) => {
|
|
240
|
-
a = o.rejectOnCancel ? p : i, l = s, g && !n && (n = setTimeout(() => {
|
|
241
|
-
t && r(t), n = void 0, i(l());
|
|
242
|
-
}, g)), t = setTimeout(() => {
|
|
243
|
-
n && r(n), n = void 0, i(s());
|
|
244
|
-
}, c);
|
|
245
|
-
});
|
|
235
|
+
function vt(e, o = {}) {
|
|
236
|
+
let t, n, l = F, r = F;
|
|
237
|
+
const a = V(!1), c = (g) => {
|
|
238
|
+
clearTimeout(g), l(), l = F;
|
|
246
239
|
};
|
|
240
|
+
let s;
|
|
241
|
+
return Object.assign((g) => {
|
|
242
|
+
const i = D(e), f = D(o.maxWait);
|
|
243
|
+
return t && c(t), i <= 0 || f !== void 0 && f <= 0 ? (n && (c(n), n = void 0), a.value = !1, Promise.resolve(g())) : (a.value = !0, new Promise((u, m) => {
|
|
244
|
+
l = o.rejectOnCancel ? m : u, r = u, s = g, f && !n && (n = setTimeout(() => {
|
|
245
|
+
t && c(t), n = void 0, a.value = !1, u(s());
|
|
246
|
+
}, f)), t = setTimeout(() => {
|
|
247
|
+
n && c(n), n = void 0, a.value = !1, u(g());
|
|
248
|
+
}, i);
|
|
249
|
+
}));
|
|
250
|
+
}, {
|
|
251
|
+
cancel: () => {
|
|
252
|
+
t && (c(t), t = void 0), n && (c(n), n = void 0), a.value = !1, r = F;
|
|
253
|
+
},
|
|
254
|
+
flush: () => {
|
|
255
|
+
if (a.value) {
|
|
256
|
+
t && (clearTimeout(t), t = void 0), n && (clearTimeout(n), n = void 0), a.value = !1;
|
|
257
|
+
const g = r;
|
|
258
|
+
l = F, r = F, g(s());
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
isPending: Me(a)
|
|
262
|
+
});
|
|
247
263
|
}
|
|
248
|
-
function
|
|
264
|
+
function yt(e) {
|
|
249
265
|
return Array.isArray(e) ? e : [e];
|
|
250
266
|
}
|
|
251
|
-
function
|
|
267
|
+
function Lt(e) {
|
|
252
268
|
return Le();
|
|
253
269
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return pt(Ct(o, t), e);
|
|
270
|
+
function xt(e, o = 200, t = {}) {
|
|
271
|
+
return Ct(vt(o, t), e);
|
|
257
272
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
273
|
+
function kt(e, o = !0, t) {
|
|
274
|
+
Lt() ? Y(e, t) : o ? e() : ee(e);
|
|
260
275
|
}
|
|
261
|
-
const ke =
|
|
262
|
-
function
|
|
276
|
+
const ke = pt ? window : void 0;
|
|
277
|
+
function U(e) {
|
|
263
278
|
var o;
|
|
264
|
-
const t =
|
|
279
|
+
const t = D(e);
|
|
265
280
|
return (o = t?.$el) !== null && o !== void 0 ? o : t;
|
|
266
281
|
}
|
|
267
282
|
// @__NO_SIDE_EFFECTS__
|
|
268
|
-
function
|
|
269
|
-
const e =
|
|
270
|
-
return o &&
|
|
283
|
+
function wt() {
|
|
284
|
+
const e = V(!1), o = Le();
|
|
285
|
+
return o && Y(() => {
|
|
271
286
|
e.value = !0;
|
|
272
287
|
}, o), e;
|
|
273
288
|
}
|
|
274
289
|
// @__NO_SIDE_EFFECTS__
|
|
275
|
-
function
|
|
276
|
-
const o = /* @__PURE__ */
|
|
290
|
+
function St(e) {
|
|
291
|
+
const o = /* @__PURE__ */ wt();
|
|
277
292
|
return M(() => (o.value, !!e()));
|
|
278
293
|
}
|
|
279
|
-
function
|
|
280
|
-
const { window: n = ke, ...
|
|
294
|
+
function It(e, o, t = {}) {
|
|
295
|
+
const { window: n = ke, ...l } = t;
|
|
281
296
|
let r;
|
|
282
|
-
const
|
|
297
|
+
const a = /* @__PURE__ */ St(() => n && "ResizeObserver" in n), c = () => {
|
|
283
298
|
r && (r.disconnect(), r = void 0);
|
|
284
|
-
}, s =
|
|
285
|
-
const g =
|
|
286
|
-
return Array.isArray(g) ? g.map((i) =>
|
|
299
|
+
}, s = $(M(() => {
|
|
300
|
+
const g = D(e);
|
|
301
|
+
return Array.isArray(g) ? g.map((i) => U(i)) : [U(g)];
|
|
287
302
|
}), (g) => {
|
|
288
|
-
if (
|
|
303
|
+
if (c(), a.value && n) {
|
|
289
304
|
r = new ResizeObserver(o);
|
|
290
|
-
for (const i of g) i && r.observe(i,
|
|
305
|
+
for (const i of g) i && r.observe(i, l);
|
|
291
306
|
}
|
|
292
307
|
}, {
|
|
293
308
|
immediate: !0,
|
|
294
309
|
flush: "post"
|
|
295
|
-
}),
|
|
296
|
-
|
|
310
|
+
}), d = () => {
|
|
311
|
+
c(), s();
|
|
297
312
|
};
|
|
298
|
-
return
|
|
299
|
-
isSupported:
|
|
300
|
-
stop:
|
|
313
|
+
return ht(d), {
|
|
314
|
+
isSupported: a,
|
|
315
|
+
stop: d
|
|
301
316
|
};
|
|
302
317
|
}
|
|
303
318
|
function Q(e, o = {
|
|
304
319
|
width: 0,
|
|
305
320
|
height: 0
|
|
306
321
|
}, t = {}) {
|
|
307
|
-
const { window: n = ke, box:
|
|
322
|
+
const { window: n = ke, box: l = "content-box" } = t, r = M(() => {
|
|
308
323
|
var i;
|
|
309
|
-
return (i =
|
|
310
|
-
}),
|
|
311
|
-
const
|
|
324
|
+
return (i = U(e)) === null || i === void 0 || (i = i.namespaceURI) === null || i === void 0 ? void 0 : i.includes("svg");
|
|
325
|
+
}), a = V(o.width), c = V(o.height), { stop: s } = It(e, ([i]) => {
|
|
326
|
+
const f = l === "border-box" ? i.borderBoxSize : l === "content-box" ? i.contentBoxSize : i.devicePixelContentBoxSize;
|
|
312
327
|
if (n && r.value) {
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
316
|
-
|
|
328
|
+
const u = U(e);
|
|
329
|
+
if (u) {
|
|
330
|
+
const m = u.getBoundingClientRect();
|
|
331
|
+
a.value = m.width, c.value = m.height;
|
|
317
332
|
}
|
|
318
|
-
} else if (
|
|
319
|
-
const
|
|
320
|
-
|
|
333
|
+
} else if (f) {
|
|
334
|
+
const u = yt(f);
|
|
335
|
+
a.value = u.reduce((m, { inlineSize: p }) => m + p, 0), c.value = u.reduce((m, { blockSize: p }) => m + p, 0);
|
|
321
336
|
} else
|
|
322
|
-
|
|
337
|
+
a.value = i.contentRect.width, c.value = i.contentRect.height;
|
|
323
338
|
}, t);
|
|
324
|
-
|
|
325
|
-
const i =
|
|
326
|
-
i &&
|
|
339
|
+
kt(() => {
|
|
340
|
+
const i = U(e);
|
|
341
|
+
if (i && "offsetWidth" in i) if (l === "content-box" && n) {
|
|
342
|
+
const f = n.getComputedStyle(i), u = Number.parseFloat(f.paddingLeft) + Number.parseFloat(f.paddingRight), m = Number.parseFloat(f.paddingTop) + Number.parseFloat(f.paddingBottom), p = Number.parseFloat(f.borderLeftWidth) + Number.parseFloat(f.borderRightWidth), h = Number.parseFloat(f.borderTopWidth) + Number.parseFloat(f.borderBottomWidth);
|
|
343
|
+
a.value = i.offsetWidth - u - p, c.value = i.offsetHeight - m - h;
|
|
344
|
+
} else
|
|
345
|
+
a.value = i.offsetWidth, c.value = i.offsetHeight;
|
|
346
|
+
else i && (a.value = o.width, c.value = o.height);
|
|
327
347
|
});
|
|
328
|
-
const
|
|
329
|
-
|
|
348
|
+
const d = $(() => U(e), (i) => {
|
|
349
|
+
a.value = i ? o.width : 0, c.value = i ? o.height : 0;
|
|
330
350
|
});
|
|
331
351
|
function g() {
|
|
332
|
-
s(),
|
|
352
|
+
s(), d();
|
|
333
353
|
}
|
|
334
354
|
return {
|
|
335
|
-
width:
|
|
336
|
-
height:
|
|
355
|
+
width: a,
|
|
356
|
+
height: c,
|
|
337
357
|
stop: g
|
|
338
358
|
};
|
|
339
359
|
}
|
|
340
|
-
const we =
|
|
341
|
-
let
|
|
342
|
-
async function
|
|
343
|
-
return
|
|
360
|
+
const we = ue(!1);
|
|
361
|
+
let j = null;
|
|
362
|
+
async function Mt() {
|
|
363
|
+
return j || (j = (async () => {
|
|
344
364
|
try {
|
|
345
|
-
(
|
|
346
|
-
const o = await
|
|
365
|
+
(R.json?.jsonDefaults || R.languages.json?.jsonDefaults)?.setModeConfiguration({ tokens: !1 });
|
|
366
|
+
const o = await tt(
|
|
347
367
|
{
|
|
348
|
-
themes: Object.values(
|
|
349
|
-
langs: Object.values(
|
|
368
|
+
themes: Object.values(ot),
|
|
369
|
+
langs: Object.values(nt)
|
|
350
370
|
}
|
|
351
371
|
);
|
|
352
372
|
o.getLoadedLanguages().forEach((t) => {
|
|
353
|
-
|
|
354
|
-
}),
|
|
373
|
+
R.languages.register({ id: t });
|
|
374
|
+
}), et(o, R), we.value = !0;
|
|
355
375
|
} catch (e) {
|
|
356
|
-
throw
|
|
376
|
+
throw j = null, e;
|
|
357
377
|
}
|
|
358
|
-
})(),
|
|
378
|
+
})(), j);
|
|
359
379
|
}
|
|
360
|
-
function
|
|
361
|
-
const t =
|
|
362
|
-
let n,
|
|
363
|
-
const
|
|
380
|
+
function Nt(e, o) {
|
|
381
|
+
const t = V();
|
|
382
|
+
let n, l = !1, r = !1;
|
|
383
|
+
const a = Oe({
|
|
364
384
|
editorStatus: "loading",
|
|
365
385
|
searchBoxIsRevealed: !1,
|
|
366
386
|
hasContent: !1,
|
|
367
387
|
theme: o.theme || "light",
|
|
368
388
|
currentLanguage: o.language || ""
|
|
369
|
-
}),
|
|
370
|
-
!
|
|
371
|
-
}, s = (
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
}, i = (
|
|
389
|
+
}), c = (h) => {
|
|
390
|
+
!l || !t.value || t.value.setValue(h);
|
|
391
|
+
}, s = (h) => t.value?.updateOptions({ readOnly: h }), d = () => t.value?.focus(), g = (h) => {
|
|
392
|
+
const b = t.value?.getModel();
|
|
393
|
+
b && R.editor.setModelLanguage(b, h);
|
|
394
|
+
}, i = (h) => {
|
|
375
395
|
try {
|
|
376
|
-
if (!t.value || !
|
|
377
|
-
t.value.focus(), t.value.trigger("keyboard",
|
|
378
|
-
} catch (
|
|
379
|
-
console.error(`useMonacoEditor: Failed to trigger command: ${
|
|
396
|
+
if (!t.value || !h) return;
|
|
397
|
+
t.value.focus(), t.value.trigger("keyboard", h, null);
|
|
398
|
+
} catch (b) {
|
|
399
|
+
console.error(`useMonacoEditor: Failed to trigger command: ${h}`, b);
|
|
380
400
|
}
|
|
381
|
-
},
|
|
401
|
+
}, f = () => {
|
|
382
402
|
try {
|
|
383
403
|
if (!t.value) return;
|
|
384
|
-
if (
|
|
404
|
+
if (a.searchBoxIsRevealed)
|
|
385
405
|
return t.value.getContribution("editor.contrib.findController")?.closeFindWidget();
|
|
386
406
|
i("actions.find");
|
|
387
|
-
} catch (
|
|
388
|
-
console.error("useMonacoEditor: Failed to close findController.",
|
|
407
|
+
} catch (h) {
|
|
408
|
+
console.error("useMonacoEditor: Failed to close findController.", h);
|
|
389
409
|
}
|
|
390
|
-
},
|
|
391
|
-
!t.value || !
|
|
392
|
-
if (!(!
|
|
410
|
+
}, u = xt(() => R.editor.remeasureFonts(), 200), m = (h) => {
|
|
411
|
+
!t.value || !h?.length || h.forEach((b) => {
|
|
412
|
+
if (!(!b.id || !b.action))
|
|
393
413
|
try {
|
|
394
414
|
const L = {
|
|
395
|
-
id:
|
|
396
|
-
label:
|
|
397
|
-
keybindings:
|
|
398
|
-
contextMenuGroupId:
|
|
399
|
-
contextMenuOrder:
|
|
415
|
+
id: b.id,
|
|
416
|
+
label: b.label || b.id,
|
|
417
|
+
keybindings: b.keybindings ? [mt(b.keybindings)].filter((k) => k !== void 0) : void 0,
|
|
418
|
+
contextMenuGroupId: b.showInContextMenu ? b.contextMenuGroupId || "basic" : void 0,
|
|
419
|
+
contextMenuOrder: b.contextMenuOrder ?? 1.5,
|
|
400
420
|
run: (k) => {
|
|
401
|
-
if (typeof
|
|
402
|
-
|
|
421
|
+
if (typeof b.action == "function")
|
|
422
|
+
b.action({
|
|
403
423
|
editor: t,
|
|
404
|
-
editorStates:
|
|
405
|
-
setContent:
|
|
424
|
+
editorStates: a,
|
|
425
|
+
setContent: c,
|
|
406
426
|
setReadOnly: s,
|
|
407
|
-
focus:
|
|
427
|
+
focus: d,
|
|
408
428
|
setLanguage: g,
|
|
409
|
-
remeasureFonts:
|
|
410
|
-
toggleSearchWidget:
|
|
429
|
+
remeasureFonts: u,
|
|
430
|
+
toggleSearchWidget: f,
|
|
411
431
|
triggerKeyboardCommand: i,
|
|
412
|
-
registerActions:
|
|
432
|
+
registerActions: m
|
|
413
433
|
});
|
|
414
|
-
else if (typeof
|
|
415
|
-
const
|
|
416
|
-
|
|
434
|
+
else if (typeof b.action == "string") {
|
|
435
|
+
const C = k.getAction(b.action);
|
|
436
|
+
C ? C.run() : i(b.action);
|
|
417
437
|
}
|
|
418
438
|
}
|
|
419
439
|
};
|
|
420
440
|
t.value?.addAction(L);
|
|
421
441
|
} catch (L) {
|
|
422
|
-
console.error(`useMonacoEditor: Failed to register action: ${
|
|
442
|
+
console.error(`useMonacoEditor: Failed to register action: ${b.id}`, L);
|
|
423
443
|
}
|
|
424
444
|
});
|
|
425
445
|
};
|
|
426
|
-
return
|
|
427
|
-
const k =
|
|
428
|
-
if (!(k instanceof HTMLElement) || !
|
|
429
|
-
|
|
446
|
+
return Mt(), $([we, () => D(e)], ([h, b], [, L]) => {
|
|
447
|
+
const k = D(b), C = D(L);
|
|
448
|
+
if (!(k instanceof HTMLElement) || !h) {
|
|
449
|
+
l = !1;
|
|
430
450
|
return;
|
|
431
451
|
}
|
|
432
|
-
if (!(
|
|
452
|
+
if (!(l && C === k)) {
|
|
433
453
|
if (n)
|
|
434
454
|
n.setValue(o.code.value);
|
|
435
455
|
else {
|
|
436
|
-
const x =
|
|
437
|
-
n =
|
|
456
|
+
const x = R.Uri.parse(`inmemory://model/${o.language}-${crypto.randomUUID()}`);
|
|
457
|
+
n = R.editor.createModel(o.code.value, o.language, x);
|
|
438
458
|
}
|
|
439
|
-
t.value =
|
|
440
|
-
...
|
|
459
|
+
t.value = R.editor.create(k, {
|
|
460
|
+
...te,
|
|
441
461
|
readOnly: o.readOnly || !1,
|
|
442
462
|
language: o.language,
|
|
443
|
-
theme:
|
|
463
|
+
theme: a.theme === "light" ? "catppuccin-latte" : "material-theme-darker",
|
|
444
464
|
model: n,
|
|
445
465
|
editContext: !1,
|
|
446
466
|
...o.monacoOptions
|
|
447
|
-
}),
|
|
448
|
-
|
|
467
|
+
}), l = !0, a.editorStatus = "ready", a.hasContent = !!o.code.value, a.currentLanguage = n.getLanguageId(), n.onDidChangeLanguage((x) => {
|
|
468
|
+
a.currentLanguage = x.newLanguage;
|
|
449
469
|
}), t.value.onDidChangeModelContent(() => {
|
|
450
470
|
if (r) return;
|
|
451
471
|
const x = t.value.getValue();
|
|
452
|
-
|
|
453
|
-
}), o.actions?.length &&
|
|
472
|
+
a.hasContent = !!x.length, o.code.value = x;
|
|
473
|
+
}), o.actions?.length && m(o.actions), bt(t.value), o.onReady?.(t.value), u();
|
|
454
474
|
try {
|
|
455
475
|
const A = t.value.getContribution("editor.contrib.findController")?.getState();
|
|
456
476
|
A?.onFindReplaceStateChange(() => {
|
|
457
|
-
|
|
477
|
+
a.searchBoxIsRevealed = A.isRevealed;
|
|
458
478
|
});
|
|
459
479
|
} catch (x) {
|
|
460
480
|
console.error("useMonacoEditor: Failed to get the state of findController", x);
|
|
461
481
|
}
|
|
462
|
-
|
|
482
|
+
Re(() => {
|
|
463
483
|
t.value?.dispose();
|
|
464
484
|
});
|
|
465
485
|
}
|
|
466
486
|
}, {
|
|
467
487
|
immediate: !0,
|
|
468
488
|
flush: "post"
|
|
469
|
-
}),
|
|
470
|
-
if (!t.value || !n || !
|
|
471
|
-
const
|
|
472
|
-
|
|
489
|
+
}), $(o.code, (h) => {
|
|
490
|
+
if (!t.value || !n || !l) return;
|
|
491
|
+
const b = n.getValue();
|
|
492
|
+
h !== b && (r = !0, t.value.executeEdits("external", [
|
|
473
493
|
{
|
|
474
494
|
range: n.getFullModelRange(),
|
|
475
|
-
text:
|
|
495
|
+
text: h
|
|
476
496
|
}
|
|
477
|
-
]), t.value.pushUndoStop(),
|
|
478
|
-
}),
|
|
497
|
+
]), t.value.pushUndoStop(), a.hasContent = !!h.length, r = !1);
|
|
498
|
+
}), Y(u), Ae(u), Te(() => {
|
|
479
499
|
if (!t.value) return;
|
|
480
|
-
const
|
|
481
|
-
t.value.dispose(),
|
|
500
|
+
const h = t.value.getModel();
|
|
501
|
+
t.value.dispose(), h && h.dispose();
|
|
482
502
|
}), {
|
|
483
503
|
editor: t,
|
|
484
|
-
editorStates:
|
|
485
|
-
setContent:
|
|
504
|
+
editorStates: a,
|
|
505
|
+
setContent: c,
|
|
486
506
|
setReadOnly: s,
|
|
487
|
-
focus:
|
|
507
|
+
focus: d,
|
|
488
508
|
setLanguage: g,
|
|
489
|
-
remeasureFonts:
|
|
490
|
-
registerActions:
|
|
491
|
-
toggleSearchWidget:
|
|
509
|
+
remeasureFonts: u,
|
|
510
|
+
registerActions: m,
|
|
511
|
+
toggleSearchWidget: f,
|
|
492
512
|
triggerKeyboardCommand: i
|
|
493
513
|
};
|
|
494
514
|
}
|
|
495
|
-
const
|
|
496
|
-
editor:
|
|
515
|
+
const Et = { labels: { action_search: "Search", action_bold: "Bold", action_italic: "Italic", action_strikethrough: "Strikethrough", action_inline_code: "Code", action_link: "Link", action_image: "Image", action_unordered_list: "Unordered list", action_ordered_list: "Ordered list", action_task_list: "Task list", action_codeblock: "Code block", action_blockquote: "Blockquote", action_table: "Table", action_search_label: "Search document", action_format: "Format", action_format_label: "Format document", action_fullscreen: "Full Screen", action_fullscreen_label: "Toggle full screen mode", action_more: "More", key: "Key: {key}" }, messages: { empty_message: "The editor is currently empty. Start typing to add content.", empty_title: "No content available", loading_message: "Please wait while the {type} content is loaded.", loading_title: "{type} editor" } }, Ot = {
|
|
516
|
+
editor: Et
|
|
497
517
|
};
|
|
498
|
-
function
|
|
499
|
-
const e =
|
|
518
|
+
function le() {
|
|
519
|
+
const e = rt("en-us", Ot);
|
|
500
520
|
return {
|
|
501
521
|
i18n: e,
|
|
502
|
-
i18nT:
|
|
522
|
+
i18nT: it(e)
|
|
503
523
|
// Translation component <i18n-t>
|
|
504
524
|
};
|
|
505
525
|
}
|
|
506
|
-
const
|
|
526
|
+
const At = /* @__PURE__ */ ae({
|
|
507
527
|
__name: "MonacoEditorStatusOverlay",
|
|
508
528
|
props: {
|
|
509
529
|
title: {},
|
|
@@ -512,31 +532,31 @@ const Ot = /* @__PURE__ */ ie({
|
|
|
512
532
|
},
|
|
513
533
|
setup(e) {
|
|
514
534
|
return (o, t) => {
|
|
515
|
-
const n =
|
|
535
|
+
const n = q("KEmptyState");
|
|
516
536
|
return v(), N(n, {
|
|
517
537
|
class: "monaco-editor-status-overlay",
|
|
518
538
|
message: e.message,
|
|
519
539
|
title: e.title
|
|
520
|
-
},
|
|
540
|
+
}, me({ _: 2 }, [
|
|
521
541
|
e.icon ? {
|
|
522
542
|
name: "icon",
|
|
523
543
|
fn: O(() => [
|
|
524
|
-
(v(), N(
|
|
544
|
+
(v(), N(ge(e.icon), { decorative: "" }))
|
|
525
545
|
]),
|
|
526
546
|
key: "0"
|
|
527
547
|
} : void 0
|
|
528
548
|
]), 1032, ["message", "title"]);
|
|
529
549
|
};
|
|
530
550
|
}
|
|
531
|
-
}),
|
|
551
|
+
}), se = (e, o) => {
|
|
532
552
|
const t = e.__vccOpts || e;
|
|
533
|
-
for (const [n,
|
|
534
|
-
t[n] =
|
|
553
|
+
for (const [n, l] of o)
|
|
554
|
+
t[n] = l;
|
|
535
555
|
return t;
|
|
536
|
-
}, pe = /* @__PURE__ */
|
|
556
|
+
}, pe = /* @__PURE__ */ se(At, [["__scopeId", "data-v-062eadb5"]]), Tt = {
|
|
537
557
|
key: 0,
|
|
538
558
|
class: "keys"
|
|
539
|
-
},
|
|
559
|
+
}, Rt = ["aria-label", "data-testid", "textContent"], $t = /* @__PURE__ */ ae({
|
|
540
560
|
__name: "ToolbarActionButton",
|
|
541
561
|
props: {
|
|
542
562
|
item: {},
|
|
@@ -544,8 +564,8 @@ const Ot = /* @__PURE__ */ ie({
|
|
|
544
564
|
placement: { default: "bottom-end" }
|
|
545
565
|
},
|
|
546
566
|
setup(e) {
|
|
547
|
-
const { i18n: o } =
|
|
548
|
-
const s =
|
|
567
|
+
const { i18n: o } = le(), t = M(() => !!e.item.keybindings?.length), n = ue(!1), l = (c) => {
|
|
568
|
+
const s = c.toLowerCase();
|
|
549
569
|
return {
|
|
550
570
|
command: n.value ? "Command" : "Ctrl",
|
|
551
571
|
cmd: n.value ? "Command" : "Ctrl",
|
|
@@ -555,21 +575,21 @@ const Ot = /* @__PURE__ */ ie({
|
|
|
555
575
|
option: n.value ? "Option" : "Alt",
|
|
556
576
|
opt: n.value ? "Option" : "Alt",
|
|
557
577
|
alt: "Alt"
|
|
558
|
-
}[s] ||
|
|
559
|
-
}, r = (
|
|
560
|
-
const s =
|
|
578
|
+
}[s] || c.toUpperCase();
|
|
579
|
+
}, r = (c) => ["command", "cmd", "ctrl", "control", "shift", "option", "opt", "alt"].includes(c.toLowerCase()), a = (c) => {
|
|
580
|
+
const s = c.toLowerCase();
|
|
561
581
|
return ["command", "cmd", "ctrl", "control"].includes(s) ? "meta-key" : s === "shift" ? "shift-key" : ["option", "opt", "alt"].includes(s) ? "option-key" : "";
|
|
562
582
|
};
|
|
563
|
-
return
|
|
583
|
+
return Y(() => {
|
|
564
584
|
n.value = /Mac|iPhone|iPod|iPad/i.test(navigator?.platform) || /macOS|Mac|iPhone|iPod|iPad/i.test(navigator?.userAgentData?.platform);
|
|
565
|
-
}), (
|
|
566
|
-
const
|
|
585
|
+
}), (c, s) => {
|
|
586
|
+
const d = q("KButton"), g = q("KTooltip");
|
|
567
587
|
return v(), N(g, {
|
|
568
588
|
"data-testid": `editor-toolbar-mdc-action-${e.item.id}-tooltip`,
|
|
569
589
|
placement: e.placement
|
|
570
|
-
},
|
|
590
|
+
}, me({
|
|
571
591
|
default: O(() => [
|
|
572
|
-
|
|
592
|
+
re(d, {
|
|
573
593
|
appearance: "none",
|
|
574
594
|
"aria-label": e.item.ariaLabel || e.item.label,
|
|
575
595
|
class: "toolbar-action-button",
|
|
@@ -579,7 +599,7 @@ const Ot = /* @__PURE__ */ ie({
|
|
|
579
599
|
onClick: e.item.action
|
|
580
600
|
}, {
|
|
581
601
|
default: O(() => [
|
|
582
|
-
(v(), N(
|
|
602
|
+
(v(), N(ge(e.item.icon), { decorative: "" }))
|
|
583
603
|
]),
|
|
584
604
|
_: 1
|
|
585
605
|
}, 8, ["aria-label", "data-testid", "disabled", "onClick"])
|
|
@@ -589,20 +609,20 @@ const Ot = /* @__PURE__ */ ie({
|
|
|
589
609
|
e.item.label ? {
|
|
590
610
|
name: "content",
|
|
591
611
|
fn: O(() => [
|
|
592
|
-
|
|
593
|
-
class:
|
|
594
|
-
},
|
|
595
|
-
t.value ? (v(), I("div",
|
|
596
|
-
(v(!0), I(
|
|
612
|
+
K("div", {
|
|
613
|
+
class: ie(["shortcut-text", { "has-keys": t.value }])
|
|
614
|
+
}, de(e.item.label), 3),
|
|
615
|
+
t.value ? (v(), I("div", Tt, [
|
|
616
|
+
(v(!0), I(_, null, B(e.item.keybindings, (i) => (v(), I("kbd", {
|
|
597
617
|
key: i,
|
|
598
|
-
"aria-label": S(o).t("editor.labels.key", { key:
|
|
599
|
-
class:
|
|
618
|
+
"aria-label": S(o).t("editor.labels.key", { key: l(i) }),
|
|
619
|
+
class: ie([
|
|
600
620
|
{ mac: n.value },
|
|
601
|
-
|
|
621
|
+
a(i)
|
|
602
622
|
]),
|
|
603
|
-
"data-testid": `editor-toolbar-mdc-${r(i) ?
|
|
604
|
-
textContent:
|
|
605
|
-
}, null, 10,
|
|
623
|
+
"data-testid": `editor-toolbar-mdc-${r(i) ? a(i) : `${i.toLowerCase()}-key`}`,
|
|
624
|
+
textContent: de(r(i) ? "" : i)
|
|
625
|
+
}, null, 10, Rt))), 128))
|
|
606
626
|
])) : G("", !0)
|
|
607
627
|
]),
|
|
608
628
|
key: "0"
|
|
@@ -610,243 +630,243 @@ const Ot = /* @__PURE__ */ ie({
|
|
|
610
630
|
]), 1032, ["data-testid", "placement"]);
|
|
611
631
|
};
|
|
612
632
|
}
|
|
613
|
-
}),
|
|
614
|
-
function
|
|
633
|
+
}), Z = /* @__PURE__ */ se($t, [["__scopeId", "data-v-c588b09b"]]);
|
|
634
|
+
function ne(e, o) {
|
|
615
635
|
return (t) => {
|
|
616
636
|
const n = t.editor.value;
|
|
617
637
|
if (!n) return;
|
|
618
|
-
const
|
|
619
|
-
if (!
|
|
620
|
-
const
|
|
621
|
-
if (!
|
|
622
|
-
const L = r.getValueInRange(
|
|
638
|
+
const l = n.getSelection(), r = n.getModel();
|
|
639
|
+
if (!l || !r) return;
|
|
640
|
+
const a = e.length, c = l.isEmpty(), s = l.startLineNumber, d = l.startColumn, g = l.endLineNumber, i = l.endColumn;
|
|
641
|
+
if (!c) {
|
|
642
|
+
const L = r.getValueInRange(l), k = {
|
|
623
643
|
startLineNumber: s,
|
|
624
|
-
startColumn: Math.max(1,
|
|
644
|
+
startColumn: Math.max(1, d - a),
|
|
625
645
|
endLineNumber: s,
|
|
626
|
-
endColumn:
|
|
627
|
-
},
|
|
646
|
+
endColumn: d
|
|
647
|
+
}, C = {
|
|
628
648
|
startLineNumber: g,
|
|
629
649
|
startColumn: i,
|
|
630
650
|
endLineNumber: g,
|
|
631
|
-
endColumn: i +
|
|
651
|
+
endColumn: i + a
|
|
632
652
|
};
|
|
633
|
-
r.getValueInRange(k) === e && r.getValueInRange(
|
|
634
|
-
{ range:
|
|
653
|
+
r.getValueInRange(k) === e && r.getValueInRange(C) === e ? (n.executeEdits(o, [
|
|
654
|
+
{ range: C, text: "" },
|
|
635
655
|
{ range: k, text: "" }
|
|
636
656
|
]), n.setSelection({
|
|
637
657
|
startLineNumber: s,
|
|
638
|
-
startColumn:
|
|
658
|
+
startColumn: d - a,
|
|
639
659
|
endLineNumber: g,
|
|
640
|
-
endColumn: i -
|
|
660
|
+
endColumn: i - a
|
|
641
661
|
})) : (n.executeEdits(o, [
|
|
642
|
-
{ range:
|
|
662
|
+
{ range: l, text: `${e}${L}${e}` }
|
|
643
663
|
]), n.setSelection({
|
|
644
664
|
startLineNumber: s,
|
|
645
|
-
startColumn:
|
|
665
|
+
startColumn: d + a,
|
|
646
666
|
endLineNumber: g,
|
|
647
|
-
endColumn: i +
|
|
667
|
+
endColumn: i + a
|
|
648
668
|
})), n.focus();
|
|
649
669
|
return;
|
|
650
670
|
}
|
|
651
|
-
const
|
|
652
|
-
if (
|
|
653
|
-
const L =
|
|
671
|
+
const f = r.getLineContent(s), u = f.slice(0, d - 1), m = f.slice(d - 1), p = u.lastIndexOf(e), h = m.indexOf(e);
|
|
672
|
+
if (p !== -1 && h !== -1) {
|
|
673
|
+
const L = p + 1, k = d + h, C = {
|
|
654
674
|
startLineNumber: s,
|
|
655
675
|
startColumn: L,
|
|
656
676
|
endLineNumber: s,
|
|
657
|
-
endColumn: L +
|
|
677
|
+
endColumn: L + a
|
|
658
678
|
}, x = {
|
|
659
679
|
startLineNumber: s,
|
|
660
680
|
startColumn: k,
|
|
661
681
|
endLineNumber: s,
|
|
662
|
-
endColumn: k +
|
|
682
|
+
endColumn: k + a
|
|
663
683
|
};
|
|
664
684
|
n.executeEdits(o, [
|
|
665
685
|
{ range: x, text: "" },
|
|
666
|
-
{ range:
|
|
686
|
+
{ range: C, text: "" }
|
|
667
687
|
]), n.setPosition({
|
|
668
688
|
lineNumber: s,
|
|
669
|
-
column:
|
|
689
|
+
column: d - a
|
|
670
690
|
});
|
|
671
691
|
} else
|
|
672
692
|
n.executeEdits(o, [
|
|
673
693
|
{
|
|
674
|
-
range:
|
|
694
|
+
range: l,
|
|
675
695
|
text: `${e}${e}`
|
|
676
696
|
}
|
|
677
697
|
]), n.setPosition({
|
|
678
698
|
lineNumber: s,
|
|
679
|
-
column:
|
|
699
|
+
column: d + a
|
|
680
700
|
});
|
|
681
701
|
n.focus();
|
|
682
702
|
};
|
|
683
703
|
}
|
|
684
704
|
function Ce(e, o, t, n) {
|
|
685
|
-
return (
|
|
686
|
-
const r =
|
|
705
|
+
return (l) => {
|
|
706
|
+
const r = l.editor.value;
|
|
687
707
|
if (!r) return;
|
|
688
|
-
const
|
|
689
|
-
if (!
|
|
690
|
-
const s = e.length,
|
|
708
|
+
const a = r.getSelection(), c = r.getModel();
|
|
709
|
+
if (!a || !c) return;
|
|
710
|
+
const s = e.length, d = o.length, g = a.isEmpty(), i = a.startLineNumber, f = a.startColumn, u = a.endLineNumber, m = a.endColumn;
|
|
691
711
|
if (!g) {
|
|
692
|
-
const
|
|
693
|
-
if (i ===
|
|
694
|
-
const
|
|
712
|
+
const h = c.getValueInRange(a);
|
|
713
|
+
if (i === u) {
|
|
714
|
+
const C = c.getLineContent(i), x = C.substring(0, f - 1), A = C.substring(m - 1);
|
|
695
715
|
if (x.endsWith("](") && A.startsWith(")")) {
|
|
696
|
-
const
|
|
716
|
+
const P = x.length - 2, w = C.substring(0, P), E = w.lastIndexOf(e);
|
|
697
717
|
if (E !== -1) {
|
|
698
|
-
const y = w.substring(E + s),
|
|
718
|
+
const y = w.substring(E + s), X = E + 1, Ie = m + 1;
|
|
699
719
|
r.executeEdits(t, [{
|
|
700
720
|
range: {
|
|
701
721
|
startLineNumber: i,
|
|
702
|
-
startColumn:
|
|
722
|
+
startColumn: X,
|
|
703
723
|
endLineNumber: i,
|
|
704
724
|
endColumn: Ie
|
|
705
725
|
},
|
|
706
726
|
text: y
|
|
707
727
|
}]), y ? r.setSelection({
|
|
708
728
|
startLineNumber: i,
|
|
709
|
-
startColumn:
|
|
729
|
+
startColumn: X,
|
|
710
730
|
endLineNumber: i,
|
|
711
|
-
endColumn:
|
|
731
|
+
endColumn: X + y.length
|
|
712
732
|
}) : r.setPosition({
|
|
713
733
|
lineNumber: i,
|
|
714
|
-
column:
|
|
734
|
+
column: X
|
|
715
735
|
}), r.focus();
|
|
716
736
|
return;
|
|
717
737
|
}
|
|
718
738
|
}
|
|
719
739
|
}
|
|
720
|
-
const
|
|
740
|
+
const b = {
|
|
721
741
|
startLineNumber: i,
|
|
722
|
-
startColumn: Math.max(1,
|
|
742
|
+
startColumn: Math.max(1, f - s),
|
|
723
743
|
endLineNumber: i,
|
|
724
|
-
endColumn:
|
|
744
|
+
endColumn: f
|
|
725
745
|
}, L = {
|
|
726
|
-
startLineNumber:
|
|
727
|
-
startColumn:
|
|
728
|
-
endLineNumber:
|
|
729
|
-
endColumn:
|
|
746
|
+
startLineNumber: u,
|
|
747
|
+
startColumn: m,
|
|
748
|
+
endLineNumber: u,
|
|
749
|
+
endColumn: m + d
|
|
730
750
|
};
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
751
|
+
if (c.getValueInRange(b) === e && c.getValueInRange(L) === o) {
|
|
752
|
+
const C = {
|
|
733
753
|
startLineNumber: i,
|
|
734
|
-
startColumn:
|
|
735
|
-
endLineNumber:
|
|
736
|
-
endColumn:
|
|
754
|
+
startColumn: f - s,
|
|
755
|
+
endLineNumber: u,
|
|
756
|
+
endColumn: m + d
|
|
737
757
|
};
|
|
738
758
|
r.executeEdits(t, [
|
|
739
|
-
{ range:
|
|
759
|
+
{ range: C, text: "" }
|
|
740
760
|
]), r.setPosition({
|
|
741
761
|
lineNumber: i,
|
|
742
|
-
column:
|
|
762
|
+
column: f - s
|
|
743
763
|
});
|
|
744
764
|
} else {
|
|
745
765
|
r.executeEdits(t, [
|
|
746
|
-
{ range:
|
|
766
|
+
{ range: a, text: `${e}${h}${o}` }
|
|
747
767
|
]);
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
750
|
-
const x =
|
|
768
|
+
const C = o.indexOf(n);
|
|
769
|
+
if (C !== -1 && n && i === u) {
|
|
770
|
+
const x = m + s + C;
|
|
751
771
|
r.setSelection({
|
|
752
|
-
startLineNumber:
|
|
772
|
+
startLineNumber: u,
|
|
753
773
|
startColumn: x,
|
|
754
|
-
endLineNumber:
|
|
774
|
+
endLineNumber: u,
|
|
755
775
|
endColumn: x + n.length
|
|
756
776
|
});
|
|
757
777
|
} else
|
|
758
778
|
r.setSelection({
|
|
759
779
|
startLineNumber: i,
|
|
760
|
-
startColumn:
|
|
761
|
-
endLineNumber:
|
|
762
|
-
endColumn:
|
|
780
|
+
startColumn: f + s,
|
|
781
|
+
endLineNumber: u,
|
|
782
|
+
endColumn: m + s
|
|
763
783
|
});
|
|
764
784
|
}
|
|
765
785
|
r.focus();
|
|
766
786
|
return;
|
|
767
787
|
}
|
|
768
|
-
const
|
|
788
|
+
const p = t;
|
|
769
789
|
r.executeEdits(t, [
|
|
770
790
|
{
|
|
771
|
-
range:
|
|
772
|
-
text: `${e}${
|
|
791
|
+
range: a,
|
|
792
|
+
text: `${e}${p}${o}`
|
|
773
793
|
}
|
|
774
794
|
]), r.setSelection({
|
|
775
795
|
startLineNumber: i,
|
|
776
|
-
startColumn:
|
|
796
|
+
startColumn: f + s,
|
|
777
797
|
endLineNumber: i,
|
|
778
|
-
endColumn:
|
|
798
|
+
endColumn: f + s + p.length
|
|
779
799
|
}), r.focus();
|
|
780
800
|
};
|
|
781
801
|
}
|
|
782
|
-
function
|
|
783
|
-
const n = typeof e == "string" ? () => e : e,
|
|
802
|
+
function oe(e, o, t) {
|
|
803
|
+
const n = typeof e == "string" ? () => e : e, l = t ?? (typeof e == "string" ? new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`) : null);
|
|
784
804
|
return (r) => {
|
|
785
|
-
const
|
|
786
|
-
if (!
|
|
787
|
-
const
|
|
788
|
-
if (!
|
|
789
|
-
const
|
|
790
|
-
for (let
|
|
791
|
-
i.push(s.getLineContent(
|
|
792
|
-
const
|
|
793
|
-
if (
|
|
794
|
-
for (let
|
|
795
|
-
const
|
|
796
|
-
let
|
|
797
|
-
if (
|
|
798
|
-
const L =
|
|
799
|
-
L && (
|
|
805
|
+
const a = r.editor.value;
|
|
806
|
+
if (!a) return;
|
|
807
|
+
const c = a.getSelection(), s = a.getModel();
|
|
808
|
+
if (!c || !s) return;
|
|
809
|
+
const d = c.startLineNumber, g = c.endLineNumber, i = [];
|
|
810
|
+
for (let m = d; m <= g; m++)
|
|
811
|
+
i.push(s.getLineContent(m));
|
|
812
|
+
const f = i.every((m) => l ? l.test(m) : /^\d+\.\s/.test(m) || m.startsWith(n(1))), u = [];
|
|
813
|
+
if (f)
|
|
814
|
+
for (let m = i.length - 1; m >= 0; m--) {
|
|
815
|
+
const p = d + m, h = i[m];
|
|
816
|
+
let b = 0;
|
|
817
|
+
if (l) {
|
|
818
|
+
const L = h.match(l);
|
|
819
|
+
L && (b = L[0].length);
|
|
800
820
|
} else {
|
|
801
|
-
const L = n(
|
|
802
|
-
|
|
821
|
+
const L = n(m + 1);
|
|
822
|
+
h.startsWith(L) && (b = L.length);
|
|
803
823
|
}
|
|
804
|
-
|
|
824
|
+
b > 0 && u.push({
|
|
805
825
|
range: {
|
|
806
|
-
startLineNumber:
|
|
826
|
+
startLineNumber: p,
|
|
807
827
|
startColumn: 1,
|
|
808
|
-
endLineNumber:
|
|
809
|
-
endColumn: 1 +
|
|
828
|
+
endLineNumber: p,
|
|
829
|
+
endColumn: 1 + b
|
|
810
830
|
},
|
|
811
831
|
text: ""
|
|
812
832
|
});
|
|
813
833
|
}
|
|
814
834
|
else
|
|
815
|
-
for (let
|
|
816
|
-
const
|
|
817
|
-
if (!(
|
|
818
|
-
const L = n(
|
|
819
|
-
|
|
835
|
+
for (let m = i.length - 1; m >= 0; m--) {
|
|
836
|
+
const p = d + m, h = i[m];
|
|
837
|
+
if (!(l ? l.test(h) : h.startsWith(n(m + 1)))) {
|
|
838
|
+
const L = n(m + 1);
|
|
839
|
+
u.push({
|
|
820
840
|
range: {
|
|
821
|
-
startLineNumber:
|
|
841
|
+
startLineNumber: p,
|
|
822
842
|
startColumn: 1,
|
|
823
|
-
endLineNumber:
|
|
843
|
+
endLineNumber: p,
|
|
824
844
|
endColumn: 1
|
|
825
845
|
},
|
|
826
846
|
text: L
|
|
827
847
|
});
|
|
828
848
|
}
|
|
829
849
|
}
|
|
830
|
-
|
|
850
|
+
u.length > 0 && a.executeEdits(o, u), a.focus();
|
|
831
851
|
};
|
|
832
852
|
}
|
|
833
853
|
function _t(e) {
|
|
834
854
|
return (o) => {
|
|
835
855
|
const t = o.editor.value;
|
|
836
856
|
if (!t) return;
|
|
837
|
-
const n = t.getSelection(),
|
|
838
|
-
if (!n || !
|
|
839
|
-
const r = n.startLineNumber,
|
|
840
|
-
if (!Se(
|
|
841
|
-
for (let s = r; s <=
|
|
842
|
-
if (
|
|
843
|
-
if (
|
|
844
|
-
const
|
|
857
|
+
const n = t.getSelection(), l = t.getModel();
|
|
858
|
+
if (!n || !l) return;
|
|
859
|
+
const r = n.startLineNumber, a = n.endLineNumber, c = n.isEmpty();
|
|
860
|
+
if (!Se(l, r, a)) {
|
|
861
|
+
for (let s = r; s <= a; s++)
|
|
862
|
+
if (l.getLineContent(s).includes("```")) return;
|
|
863
|
+
if (c) {
|
|
864
|
+
const d = l.getValueInRange({
|
|
845
865
|
startLineNumber: r,
|
|
846
866
|
startColumn: 1,
|
|
847
867
|
endLineNumber: r,
|
|
848
868
|
endColumn: n.startColumn
|
|
849
|
-
}).trim().length > 0, g =
|
|
869
|
+
}).trim().length > 0, g = d ? `
|
|
850
870
|
` : "";
|
|
851
871
|
t.executeEdits(e, [
|
|
852
872
|
{
|
|
@@ -856,7 +876,7 @@ function _t(e) {
|
|
|
856
876
|
\`\`\``
|
|
857
877
|
}
|
|
858
878
|
]);
|
|
859
|
-
const i =
|
|
879
|
+
const i = d ? r + 1 : r;
|
|
860
880
|
t.setSelection({
|
|
861
881
|
startLineNumber: i,
|
|
862
882
|
startColumn: 4,
|
|
@@ -865,15 +885,15 @@ function _t(e) {
|
|
|
865
885
|
endColumn: 12
|
|
866
886
|
});
|
|
867
887
|
} else {
|
|
868
|
-
const s = r > 1 ?
|
|
869
|
-
if (s.trimEnd().startsWith("```") &&
|
|
888
|
+
const s = r > 1 ? l.getLineContent(r - 1) : "", d = a < l.getLineCount() ? l.getLineContent(a + 1) : "";
|
|
889
|
+
if (s.trimEnd().startsWith("```") && d.trimEnd() === "```")
|
|
870
890
|
t.executeEdits(e, [
|
|
871
891
|
{
|
|
872
892
|
range: {
|
|
873
|
-
startLineNumber:
|
|
893
|
+
startLineNumber: a + 1,
|
|
874
894
|
startColumn: 1,
|
|
875
|
-
endLineNumber:
|
|
876
|
-
endColumn:
|
|
895
|
+
endLineNumber: a + 1,
|
|
896
|
+
endColumn: l.getLineContent(a + 1).length + 1
|
|
877
897
|
},
|
|
878
898
|
text: null
|
|
879
899
|
},
|
|
@@ -882,35 +902,35 @@ function _t(e) {
|
|
|
882
902
|
startLineNumber: r - 1,
|
|
883
903
|
startColumn: 1,
|
|
884
904
|
endLineNumber: r - 1,
|
|
885
|
-
endColumn:
|
|
905
|
+
endColumn: l.getLineContent(r - 1).length + 1
|
|
886
906
|
},
|
|
887
907
|
text: null
|
|
888
908
|
}
|
|
889
909
|
]), t.setSelection({
|
|
890
910
|
startLineNumber: r - 1,
|
|
891
911
|
startColumn: 1,
|
|
892
|
-
endLineNumber:
|
|
893
|
-
endColumn:
|
|
912
|
+
endLineNumber: a - 1,
|
|
913
|
+
endColumn: l.getLineContent(a - 1).length + 1
|
|
894
914
|
});
|
|
895
915
|
else {
|
|
896
|
-
const i =
|
|
916
|
+
const i = l.getValueInRange(n), u = l.getValueInRange({
|
|
897
917
|
startLineNumber: r,
|
|
898
918
|
startColumn: 1,
|
|
899
919
|
endLineNumber: r,
|
|
900
920
|
endColumn: n.startColumn
|
|
901
|
-
}).trim().length > 0,
|
|
921
|
+
}).trim().length > 0, m = u ? `
|
|
902
922
|
` : "";
|
|
903
923
|
t.executeEdits(e, [
|
|
904
|
-
{ range: n, text: `${
|
|
924
|
+
{ range: n, text: `${m}\`\`\`markdown
|
|
905
925
|
${i}
|
|
906
926
|
\`\`\`` }
|
|
907
927
|
]);
|
|
908
|
-
const
|
|
928
|
+
const p = u ? r + 1 : r;
|
|
909
929
|
t.setSelection({
|
|
910
|
-
startLineNumber:
|
|
930
|
+
startLineNumber: p,
|
|
911
931
|
startColumn: 4,
|
|
912
932
|
// after ```
|
|
913
|
-
endLineNumber:
|
|
933
|
+
endLineNumber: p,
|
|
914
934
|
endColumn: 12
|
|
915
935
|
});
|
|
916
936
|
}
|
|
@@ -919,15 +939,15 @@ ${i}
|
|
|
919
939
|
}
|
|
920
940
|
};
|
|
921
941
|
}
|
|
922
|
-
function
|
|
942
|
+
function Bt(e) {
|
|
923
943
|
return (o) => {
|
|
924
944
|
const t = o.editor.value;
|
|
925
945
|
if (!t) return;
|
|
926
|
-
const n = t.getSelection(),
|
|
927
|
-
if (!n || !
|
|
928
|
-
const r = n.startLineNumber,
|
|
929
|
-
if (Se(
|
|
930
|
-
const
|
|
946
|
+
const n = t.getSelection(), l = t.getModel();
|
|
947
|
+
if (!n || !l) return;
|
|
948
|
+
const r = n.startLineNumber, a = n.endLineNumber;
|
|
949
|
+
if (Se(l, r, a)) return;
|
|
950
|
+
const c = [
|
|
931
951
|
"| Header | Header | Header |",
|
|
932
952
|
"| ------ | ------ | ------ |",
|
|
933
953
|
"| Cell | Cell | Cell |",
|
|
@@ -935,7 +955,7 @@ function Rt(e) {
|
|
|
935
955
|
].join(`
|
|
936
956
|
`);
|
|
937
957
|
t.executeEdits(e, [
|
|
938
|
-
{ range: n, text:
|
|
958
|
+
{ range: n, text: c + `
|
|
939
959
|
` }
|
|
940
960
|
]);
|
|
941
961
|
const s = r + 4;
|
|
@@ -946,16 +966,16 @@ function Rt(e) {
|
|
|
946
966
|
};
|
|
947
967
|
}
|
|
948
968
|
function Se(e, o, t) {
|
|
949
|
-
let n = 0,
|
|
969
|
+
let n = 0, l = 0;
|
|
950
970
|
for (let r = o - 1; r >= 1; r--)
|
|
951
|
-
e.getLineContent(r).trimEnd().startsWith("```") && (
|
|
971
|
+
e.getLineContent(r).trimEnd().startsWith("```") && (l++, l % 2 === 1 && (n = r));
|
|
952
972
|
if (n === 0) return !1;
|
|
953
973
|
for (let r = t + 1; r <= e.getLineCount(); r++)
|
|
954
974
|
if (e.getLineContent(r).trimEnd().startsWith("```"))
|
|
955
975
|
return !0;
|
|
956
976
|
return !1;
|
|
957
977
|
}
|
|
958
|
-
const
|
|
978
|
+
const Wt = {
|
|
959
979
|
format: {
|
|
960
980
|
id: "editor.action.format",
|
|
961
981
|
icon: Ge,
|
|
@@ -971,9 +991,9 @@ const Bt = {
|
|
|
971
991
|
},
|
|
972
992
|
bold: {
|
|
973
993
|
id: "editor.action.bold",
|
|
974
|
-
icon:
|
|
994
|
+
icon: Fe,
|
|
975
995
|
label: "editor.labels.action_bold",
|
|
976
|
-
action:
|
|
996
|
+
action: ne("**", "bold"),
|
|
977
997
|
keybindings: ["Command", "B"],
|
|
978
998
|
placement: "left",
|
|
979
999
|
group: 2,
|
|
@@ -987,7 +1007,7 @@ const Bt = {
|
|
|
987
1007
|
id: "editor.action.italic",
|
|
988
1008
|
icon: De,
|
|
989
1009
|
label: "editor.labels.action_italic",
|
|
990
|
-
action:
|
|
1010
|
+
action: ne("_", "italic"),
|
|
991
1011
|
keybindings: ["Command", "I"],
|
|
992
1012
|
placement: "left",
|
|
993
1013
|
group: 2,
|
|
@@ -999,9 +1019,9 @@ const Bt = {
|
|
|
999
1019
|
},
|
|
1000
1020
|
strikethrough: {
|
|
1001
1021
|
id: "editor.action.strikethrough",
|
|
1002
|
-
icon:
|
|
1022
|
+
icon: Pe,
|
|
1003
1023
|
label: "editor.labels.action_strikethrough",
|
|
1004
|
-
action:
|
|
1024
|
+
action: ne("~~", "strikethrough"),
|
|
1005
1025
|
keybindings: ["Command", "Shift", "X"],
|
|
1006
1026
|
placement: "left",
|
|
1007
1027
|
group: 2,
|
|
@@ -1011,12 +1031,12 @@ const Bt = {
|
|
|
1011
1031
|
contextMenuOrder: 4,
|
|
1012
1032
|
languages: ["markdown", "mdc"]
|
|
1013
1033
|
}
|
|
1014
|
-
},
|
|
1034
|
+
}, Pt = {
|
|
1015
1035
|
inlineCode: {
|
|
1016
1036
|
id: "editor.action.inlineCode",
|
|
1017
|
-
icon:
|
|
1037
|
+
icon: Ve,
|
|
1018
1038
|
label: "editor.labels.action_inline_code",
|
|
1019
|
-
action:
|
|
1039
|
+
action: ne("`", "inlineCode"),
|
|
1020
1040
|
keybindings: ["Command", "E"],
|
|
1021
1041
|
placement: "left",
|
|
1022
1042
|
group: 3,
|
|
@@ -1028,7 +1048,7 @@ const Bt = {
|
|
|
1028
1048
|
},
|
|
1029
1049
|
link: {
|
|
1030
1050
|
id: "editor.action.link",
|
|
1031
|
-
icon:
|
|
1051
|
+
icon: Ue,
|
|
1032
1052
|
label: "editor.labels.action_link",
|
|
1033
1053
|
action: Ce("[", "](url)", "link", "url"),
|
|
1034
1054
|
keybindings: ["Command", "K"],
|
|
@@ -1042,7 +1062,7 @@ const Bt = {
|
|
|
1042
1062
|
},
|
|
1043
1063
|
image: {
|
|
1044
1064
|
id: "editor.action.image",
|
|
1045
|
-
icon:
|
|
1065
|
+
icon: Ke,
|
|
1046
1066
|
label: "editor.labels.action_image",
|
|
1047
1067
|
action: Ce("", "image", "url"),
|
|
1048
1068
|
keybindings: ["Command", "Shift", "I"],
|
|
@@ -1057,9 +1077,9 @@ const Bt = {
|
|
|
1057
1077
|
}, Dt = {
|
|
1058
1078
|
unorderedList: {
|
|
1059
1079
|
id: "editor.action.unorderedList",
|
|
1060
|
-
icon:
|
|
1080
|
+
icon: He,
|
|
1061
1081
|
label: "editor.labels.action_unordered_list",
|
|
1062
|
-
action:
|
|
1082
|
+
action: oe("- ", "unorderedList"),
|
|
1063
1083
|
keybindings: [],
|
|
1064
1084
|
placement: "left",
|
|
1065
1085
|
group: 4,
|
|
@@ -1071,9 +1091,9 @@ const Bt = {
|
|
|
1071
1091
|
},
|
|
1072
1092
|
orderedList: {
|
|
1073
1093
|
id: "editor.action.orderedList",
|
|
1074
|
-
icon:
|
|
1094
|
+
icon: ze,
|
|
1075
1095
|
label: "editor.labels.action_ordered_list",
|
|
1076
|
-
action:
|
|
1096
|
+
action: oe(
|
|
1077
1097
|
(e) => `${e}. `,
|
|
1078
1098
|
"orderedList",
|
|
1079
1099
|
/^\d+\.\s/
|
|
@@ -1089,9 +1109,9 @@ const Bt = {
|
|
|
1089
1109
|
},
|
|
1090
1110
|
taskList: {
|
|
1091
1111
|
id: "editor.action.taskList",
|
|
1092
|
-
icon:
|
|
1112
|
+
icon: je,
|
|
1093
1113
|
label: "editor.labels.action_task_list",
|
|
1094
|
-
action:
|
|
1114
|
+
action: oe("- [ ] ", "taskList"),
|
|
1095
1115
|
keybindings: [],
|
|
1096
1116
|
placement: "left",
|
|
1097
1117
|
group: 4,
|
|
@@ -1101,7 +1121,7 @@ const Bt = {
|
|
|
1101
1121
|
contextMenuOrder: 3,
|
|
1102
1122
|
languages: ["markdown", "mdc"]
|
|
1103
1123
|
}
|
|
1104
|
-
},
|
|
1124
|
+
}, Ft = {
|
|
1105
1125
|
codeblock: {
|
|
1106
1126
|
id: "editor.action.codeblock",
|
|
1107
1127
|
icon: xe,
|
|
@@ -1118,9 +1138,9 @@ const Bt = {
|
|
|
1118
1138
|
},
|
|
1119
1139
|
blockquote: {
|
|
1120
1140
|
id: "editor.action.blockquote",
|
|
1121
|
-
icon:
|
|
1141
|
+
icon: Ye,
|
|
1122
1142
|
label: "editor.labels.action_blockquote",
|
|
1123
|
-
action:
|
|
1143
|
+
action: oe("> ", "blockquote"),
|
|
1124
1144
|
keybindings: [],
|
|
1125
1145
|
placement: "left",
|
|
1126
1146
|
group: 5,
|
|
@@ -1132,9 +1152,9 @@ const Bt = {
|
|
|
1132
1152
|
},
|
|
1133
1153
|
table: {
|
|
1134
1154
|
id: "editor.action.table",
|
|
1135
|
-
icon:
|
|
1155
|
+
icon: qe,
|
|
1136
1156
|
label: "editor.labels.action_table",
|
|
1137
|
-
action:
|
|
1157
|
+
action: Bt("table"),
|
|
1138
1158
|
keybindings: [],
|
|
1139
1159
|
placement: "left",
|
|
1140
1160
|
group: 5,
|
|
@@ -1147,7 +1167,7 @@ const Bt = {
|
|
|
1147
1167
|
}, Gt = {
|
|
1148
1168
|
search: {
|
|
1149
1169
|
id: "editor.action.find",
|
|
1150
|
-
icon:
|
|
1170
|
+
icon: Xe,
|
|
1151
1171
|
label: "editor.labels.action_search",
|
|
1152
1172
|
action: (e) => e.toggleSearchWidget(),
|
|
1153
1173
|
keybindings: ["Command", "F"],
|
|
@@ -1158,7 +1178,7 @@ const Bt = {
|
|
|
1158
1178
|
contextMenuGroupId: "navigation",
|
|
1159
1179
|
contextMenuOrder: 1
|
|
1160
1180
|
}
|
|
1161
|
-
},
|
|
1181
|
+
}, Kt = {
|
|
1162
1182
|
fullScreen: {
|
|
1163
1183
|
id: "editor.action.fullScreen",
|
|
1164
1184
|
icon: Je,
|
|
@@ -1173,101 +1193,101 @@ const Bt = {
|
|
|
1173
1193
|
contextMenuOrder: 1
|
|
1174
1194
|
}
|
|
1175
1195
|
}, ve = {
|
|
1176
|
-
...Bt,
|
|
1177
1196
|
...Wt,
|
|
1178
|
-
...Dt,
|
|
1179
1197
|
...Pt,
|
|
1198
|
+
...Dt,
|
|
1199
|
+
...Ft,
|
|
1180
1200
|
...Gt,
|
|
1181
|
-
...
|
|
1182
|
-
}, ye = "left",
|
|
1183
|
-
function
|
|
1184
|
-
const { i18n: t } =
|
|
1185
|
-
const
|
|
1186
|
-
for (const [s,
|
|
1201
|
+
...Kt
|
|
1202
|
+
}, ye = "left", ce = 100, Ut = "default";
|
|
1203
|
+
function Vt(e, o) {
|
|
1204
|
+
const { i18n: t } = le(), n = e && typeof e == "object" ? e.actions ?? {} : {}, l = M(() => {
|
|
1205
|
+
const a = [], c = S(o);
|
|
1206
|
+
for (const [s, d] of Object.entries(ve)) {
|
|
1187
1207
|
const g = n[s];
|
|
1188
|
-
g !== !1 && (
|
|
1189
|
-
...
|
|
1190
|
-
label: t.t(
|
|
1208
|
+
g !== !1 && (d.languages && c && !d.languages.includes(c) || a.push({
|
|
1209
|
+
...d,
|
|
1210
|
+
label: t.t(d.label),
|
|
1191
1211
|
...typeof g == "object" ? g : {}
|
|
1192
1212
|
}));
|
|
1193
1213
|
}
|
|
1194
|
-
for (const [s,
|
|
1195
|
-
if (s in ve ||
|
|
1214
|
+
for (const [s, d] of Object.entries(n)) {
|
|
1215
|
+
if (s in ve || d === !1 || d == null) continue;
|
|
1196
1216
|
const g = {
|
|
1197
1217
|
id: s,
|
|
1198
|
-
label: typeof
|
|
1218
|
+
label: typeof d == "object" && d.label ? d.label : s,
|
|
1199
1219
|
placement: ye,
|
|
1200
|
-
order:
|
|
1201
|
-
}, i = typeof
|
|
1202
|
-
i.icon && i.action &&
|
|
1220
|
+
order: ce
|
|
1221
|
+
}, i = typeof d == "object" ? { ...g, ...d } : g;
|
|
1222
|
+
i.icon && i.action && a.push(i);
|
|
1203
1223
|
}
|
|
1204
|
-
return
|
|
1224
|
+
return a;
|
|
1205
1225
|
});
|
|
1206
|
-
function r(
|
|
1207
|
-
const
|
|
1208
|
-
return
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
}), Array.from(
|
|
1226
|
+
function r(a) {
|
|
1227
|
+
const c = /* @__PURE__ */ new Map();
|
|
1228
|
+
return l.value.filter((s) => (s.placement ?? ye) === a).sort((s, d) => (s.order ?? ce) - (d.order ?? ce)).forEach((s) => {
|
|
1229
|
+
const d = String(s.group ?? Ut);
|
|
1230
|
+
c.has(d) || c.set(d, []), c.get(d).push(s);
|
|
1231
|
+
}), Array.from(c.values());
|
|
1212
1232
|
}
|
|
1213
1233
|
return {
|
|
1214
|
-
commands:
|
|
1234
|
+
commands: l,
|
|
1215
1235
|
leftGroups: M(() => r("left")),
|
|
1216
1236
|
centerGroups: M(() => r("center")),
|
|
1217
1237
|
rightGroups: M(() => r("right"))
|
|
1218
1238
|
};
|
|
1219
1239
|
}
|
|
1220
|
-
const
|
|
1240
|
+
const jt = {
|
|
1221
1241
|
class: "monaco-editor-ui-toolbar-action-group",
|
|
1222
1242
|
"data-testid": "toolbar-overflow-group"
|
|
1223
|
-
},
|
|
1243
|
+
}, zt = 5, Ht = /* @__PURE__ */ ae({
|
|
1224
1244
|
__name: "MonacoEditorToolbar",
|
|
1225
1245
|
props: {
|
|
1226
1246
|
editor: { default: null },
|
|
1227
1247
|
settings: { type: [Boolean, Object] }
|
|
1228
1248
|
},
|
|
1229
1249
|
setup(e) {
|
|
1230
|
-
const { i18n: o } =
|
|
1231
|
-
(
|
|
1250
|
+
const { i18n: o } = le(), t = z("toolbarEl"), n = z("leftSlotEl"), l = z("centerSlotEl"), r = z("rightSlotEl"), a = Q(t), c = Q(n), s = Q(l), d = Q(r), g = M(() => e.editor?.editorStates.currentLanguage ?? ""), { commands: i, leftGroups: f, centerGroups: u, rightGroups: m } = Vt(e.settings, g), p = V([]), h = ue(0), b = [], L = M(() => f.value.slice(p.value.length).flatMap(
|
|
1251
|
+
(C, x) => C.map((A, P) => ({
|
|
1232
1252
|
...A,
|
|
1233
|
-
hasDivider: x > 0 &&
|
|
1253
|
+
hasDivider: x > 0 && P === 0
|
|
1234
1254
|
}))
|
|
1235
1255
|
));
|
|
1236
|
-
|
|
1237
|
-
|
|
1256
|
+
$(f, (C) => {
|
|
1257
|
+
p.value = [...C], b.length = 0;
|
|
1238
1258
|
}, { immediate: !0 });
|
|
1239
1259
|
function k() {
|
|
1240
|
-
const
|
|
1241
|
-
if (
|
|
1242
|
-
const x = n.value?.getBoundingClientRect().width ?? 0, A =
|
|
1243
|
-
|
|
1244
|
-
...
|
|
1245
|
-
|
|
1246
|
-
],
|
|
1260
|
+
const C = t.value?.getBoundingClientRect().width ?? 0;
|
|
1261
|
+
if (C === 0) return;
|
|
1262
|
+
const x = n.value?.getBoundingClientRect().width ?? 0, A = l.value?.getBoundingClientRect().width ?? 0, P = r.value?.getBoundingClientRect().width ?? 0, w = x + A + P + 50;
|
|
1263
|
+
C < w && p.value.length > 0 ? (b.push(w), p.value = p.value.slice(0, -1), h.value++, ee(k)) : b.length > 0 && p.value.length < f.value.length && C > b[b.length - 1] + zt && (b.pop(), p.value = [
|
|
1264
|
+
...p.value,
|
|
1265
|
+
f.value[p.value.length]
|
|
1266
|
+
], ee(k));
|
|
1247
1267
|
}
|
|
1248
|
-
return
|
|
1249
|
-
|
|
1268
|
+
return $(() => e.editor?.editorStates.editorStatus, (C) => {
|
|
1269
|
+
C === "ready" && e.editor && i.value.length > 0 && e.editor.registerActions(i.value);
|
|
1250
1270
|
}, {
|
|
1251
1271
|
immediate: !0
|
|
1252
|
-
}),
|
|
1253
|
-
const A =
|
|
1272
|
+
}), $([a.width, c.width, s.width, d.width], k), Y(async () => await ee(k)), (C, x) => {
|
|
1273
|
+
const A = q("KDropdownItem"), P = q("KDropdown");
|
|
1254
1274
|
return v(), I("div", {
|
|
1255
1275
|
ref_key: "toolbarEl",
|
|
1256
1276
|
ref: t,
|
|
1257
1277
|
class: "monaco-editor-ui-toolbar",
|
|
1258
1278
|
"data-testid": "monaco-editor-toolbar"
|
|
1259
1279
|
}, [
|
|
1260
|
-
|
|
1280
|
+
K("div", {
|
|
1261
1281
|
ref_key: "leftSlotEl",
|
|
1262
1282
|
ref: n,
|
|
1263
1283
|
class: "monaco-editor-ui-toolbar-left",
|
|
1264
1284
|
"data-testid": "monaco-editor-toolbar-left"
|
|
1265
1285
|
}, [
|
|
1266
|
-
(v(!0), I(
|
|
1286
|
+
(v(!0), I(_, null, B(p.value, (w, E) => (v(), I("div", {
|
|
1267
1287
|
key: E,
|
|
1268
1288
|
class: "monaco-editor-ui-toolbar-action-group"
|
|
1269
1289
|
}, [
|
|
1270
|
-
(v(!0), I(
|
|
1290
|
+
(v(!0), I(_, null, B(w, (y) => (v(), N(Z, {
|
|
1271
1291
|
key: y.id,
|
|
1272
1292
|
active: e.editor?.editorStates.editorStatus === "ready",
|
|
1273
1293
|
item: {
|
|
@@ -1280,27 +1300,27 @@ const Vt = {
|
|
|
1280
1300
|
placement: E === 0 ? "bottom-start" : "bottom"
|
|
1281
1301
|
}, null, 8, ["active", "item", "placement"]))), 128))
|
|
1282
1302
|
]))), 128)),
|
|
1283
|
-
$e(
|
|
1284
|
-
(v(), N(
|
|
1285
|
-
key:
|
|
1286
|
-
class:
|
|
1303
|
+
$e(K("div", jt, [
|
|
1304
|
+
(v(), N(P, {
|
|
1305
|
+
key: h.value,
|
|
1306
|
+
class: ie({ "is-disabled": e.editor?.editorStates.editorStatus !== "ready" })
|
|
1287
1307
|
}, {
|
|
1288
1308
|
items: O(() => [
|
|
1289
|
-
(v(!0), I(
|
|
1309
|
+
(v(!0), I(_, null, B(L.value, (w) => (v(), N(A, {
|
|
1290
1310
|
key: w.id,
|
|
1291
1311
|
"data-testid": `overflow-item-${w.id}`,
|
|
1292
1312
|
"has-divider": w.hasDivider,
|
|
1293
1313
|
onClick: (E) => S(J)(w, e.editor)
|
|
1294
1314
|
}, {
|
|
1295
1315
|
default: O(() => [
|
|
1296
|
-
(v(), N(
|
|
1297
|
-
_e(" " +
|
|
1316
|
+
(v(), N(ge(w.icon), { decorative: "" })),
|
|
1317
|
+
_e(" " + de(w.label), 1)
|
|
1298
1318
|
]),
|
|
1299
1319
|
_: 2
|
|
1300
1320
|
}, 1032, ["data-testid", "has-divider", "onClick"]))), 128))
|
|
1301
1321
|
]),
|
|
1302
1322
|
default: O(() => [
|
|
1303
|
-
|
|
1323
|
+
re(Z, {
|
|
1304
1324
|
active: e.editor?.editorStates.editorStatus === "ready",
|
|
1305
1325
|
item: {
|
|
1306
1326
|
id: "more",
|
|
@@ -1313,21 +1333,21 @@ const Vt = {
|
|
|
1313
1333
|
_: 1
|
|
1314
1334
|
}, 8, ["class"]))
|
|
1315
1335
|
], 512), [
|
|
1316
|
-
[
|
|
1336
|
+
[Be, L.value.length]
|
|
1317
1337
|
]),
|
|
1318
|
-
W(
|
|
1338
|
+
W(C.$slots, "toolbar-left", {}, void 0, !0)
|
|
1319
1339
|
], 512),
|
|
1320
|
-
|
|
1340
|
+
K("div", {
|
|
1321
1341
|
ref_key: "centerSlotEl",
|
|
1322
|
-
ref:
|
|
1342
|
+
ref: l,
|
|
1323
1343
|
class: "monaco-editor-ui-toolbar-center",
|
|
1324
1344
|
"data-testid": "monaco-editor-toolbar-center"
|
|
1325
1345
|
}, [
|
|
1326
|
-
(v(!0), I(
|
|
1346
|
+
(v(!0), I(_, null, B(S(u), (w, E) => (v(), I("div", {
|
|
1327
1347
|
key: E,
|
|
1328
1348
|
class: "monaco-editor-ui-toolbar-action-group"
|
|
1329
1349
|
}, [
|
|
1330
|
-
(v(!0), I(
|
|
1350
|
+
(v(!0), I(_, null, B(w, (y) => (v(), N(Z, {
|
|
1331
1351
|
key: y.id,
|
|
1332
1352
|
active: e.editor?.editorStates.editorStatus === "ready",
|
|
1333
1353
|
item: {
|
|
@@ -1340,19 +1360,19 @@ const Vt = {
|
|
|
1340
1360
|
placement: "bottom"
|
|
1341
1361
|
}, null, 8, ["active", "item"]))), 128))
|
|
1342
1362
|
]))), 128)),
|
|
1343
|
-
W(
|
|
1363
|
+
W(C.$slots, "toolbar-center", {}, void 0, !0)
|
|
1344
1364
|
], 512),
|
|
1345
|
-
|
|
1365
|
+
K("div", {
|
|
1346
1366
|
ref_key: "rightSlotEl",
|
|
1347
1367
|
ref: r,
|
|
1348
1368
|
class: "monaco-editor-ui-toolbar-right",
|
|
1349
1369
|
"data-testid": "monaco-editor-toolbar-right"
|
|
1350
1370
|
}, [
|
|
1351
|
-
(v(!0), I(
|
|
1371
|
+
(v(!0), I(_, null, B(S(m), (w, E) => (v(), I("div", {
|
|
1352
1372
|
key: E,
|
|
1353
1373
|
class: "monaco-editor-ui-toolbar-action-group"
|
|
1354
1374
|
}, [
|
|
1355
|
-
(v(!0), I(
|
|
1375
|
+
(v(!0), I(_, null, B(w, (y) => (v(), N(Z, {
|
|
1356
1376
|
key: y.id,
|
|
1357
1377
|
active: e.editor?.editorStates.editorStatus === "ready",
|
|
1358
1378
|
item: {
|
|
@@ -1362,17 +1382,17 @@ const Vt = {
|
|
|
1362
1382
|
keybindings: y.keybindings,
|
|
1363
1383
|
action: () => S(J)(y, e.editor)
|
|
1364
1384
|
},
|
|
1365
|
-
placement: E === S(
|
|
1385
|
+
placement: E === S(m).length - 1 ? "bottom-end" : "bottom"
|
|
1366
1386
|
}, null, 8, ["active", "item", "placement"]))), 128))
|
|
1367
1387
|
]))), 128)),
|
|
1368
|
-
W(
|
|
1388
|
+
W(C.$slots, "toolbar-right", {}, void 0, !0)
|
|
1369
1389
|
], 512)
|
|
1370
1390
|
], 512);
|
|
1371
1391
|
};
|
|
1372
1392
|
}
|
|
1373
|
-
}),
|
|
1393
|
+
}), qt = /* @__PURE__ */ se(Ht, [["__scopeId", "data-v-b6dd2107"]]), Yt = /* @__PURE__ */ ae({
|
|
1374
1394
|
__name: "MonacoEditor",
|
|
1375
|
-
props: /* @__PURE__ */
|
|
1395
|
+
props: /* @__PURE__ */ be({
|
|
1376
1396
|
appearance: { default: "embedded" },
|
|
1377
1397
|
theme: { default: "light" },
|
|
1378
1398
|
language: { default: "markdown" },
|
|
@@ -1389,11 +1409,11 @@ const Vt = {
|
|
|
1389
1409
|
},
|
|
1390
1410
|
modelModifiers: {}
|
|
1391
1411
|
}),
|
|
1392
|
-
emits: /* @__PURE__ */
|
|
1412
|
+
emits: /* @__PURE__ */ be(["ready"], ["update:modelValue"]),
|
|
1393
1413
|
setup(e, { expose: o, emit: t }) {
|
|
1394
|
-
const n = parseInt(
|
|
1414
|
+
const n = parseInt(dt, 10), l = t, r = We(e, "modelValue"), { i18n: a } = le(), c = z("editorRef"), s = M(() => e.theme === "dark" ? "dark" : "light"), d = M(() => {
|
|
1395
1415
|
if (e.appearance === "standalone") {
|
|
1396
|
-
const
|
|
1416
|
+
const u = String(r.value.split(`
|
|
1397
1417
|
`).length).length;
|
|
1398
1418
|
return {
|
|
1399
1419
|
...e.options,
|
|
@@ -1402,103 +1422,103 @@ const Vt = {
|
|
|
1402
1422
|
padding: { top: n, bottom: n },
|
|
1403
1423
|
// Horizontal padding is not supported, so we increase the minimum chars for line numbers
|
|
1404
1424
|
// to create some space on the left when standalone.
|
|
1405
|
-
lineNumbersMinChars: Math.max(
|
|
1425
|
+
lineNumbersMinChars: Math.max(te.lineNumbersMinChars, u) + 2
|
|
1406
1426
|
};
|
|
1407
1427
|
}
|
|
1408
1428
|
return {
|
|
1409
1429
|
// Ensure standalone padding is cleared when switching back to embedded.
|
|
1410
|
-
padding: { ...
|
|
1411
|
-
lineNumbersMinChars:
|
|
1430
|
+
padding: { ...te.padding },
|
|
1431
|
+
lineNumbersMinChars: te.lineNumbersMinChars,
|
|
1412
1432
|
// Embedded allows user overrides.
|
|
1413
1433
|
...e.options
|
|
1414
1434
|
};
|
|
1415
|
-
}), g =
|
|
1435
|
+
}), g = Nt(c, {
|
|
1416
1436
|
language: e.language,
|
|
1417
1437
|
code: r,
|
|
1418
1438
|
theme: s.value,
|
|
1419
|
-
monacoOptions:
|
|
1420
|
-
onReady: (
|
|
1421
|
-
|
|
1439
|
+
monacoOptions: d.value,
|
|
1440
|
+
onReady: (u) => {
|
|
1441
|
+
l("ready", u);
|
|
1422
1442
|
}
|
|
1423
|
-
}), i = M(() => e.loading || g.editorStates.editorStatus === "loading"),
|
|
1443
|
+
}), i = M(() => e.loading || g.editorStates.editorStatus === "loading"), f = M(() => !i.value && g.editorStates.editorStatus === "ready" && !g.editorStates.hasContent);
|
|
1424
1444
|
return o({
|
|
1425
1445
|
monacoEditor: g
|
|
1426
|
-
}),
|
|
1427
|
-
|
|
1428
|
-
}),
|
|
1429
|
-
|
|
1446
|
+
}), $(() => e.language, (u, m) => {
|
|
1447
|
+
u !== m && g.setLanguage(u);
|
|
1448
|
+
}), $([g.editor, d], ([u, m]) => {
|
|
1449
|
+
u && m && u.updateOptions(m);
|
|
1430
1450
|
}, {
|
|
1431
1451
|
deep: !0
|
|
1432
|
-
}), (
|
|
1433
|
-
class:
|
|
1452
|
+
}), (u, m) => (v(), I("div", {
|
|
1453
|
+
class: ie(["monaco-editor-container", [
|
|
1434
1454
|
e.appearance,
|
|
1435
1455
|
s.value,
|
|
1436
1456
|
{ loading: i.value }
|
|
1437
1457
|
]]),
|
|
1438
1458
|
"data-testid": "monaco-editor-container"
|
|
1439
1459
|
}, [
|
|
1440
|
-
e.toolbar ? (v(), N(
|
|
1460
|
+
e.toolbar ? (v(), N(qt, {
|
|
1441
1461
|
key: 0,
|
|
1442
1462
|
editor: S(g),
|
|
1443
1463
|
settings: e.toolbar
|
|
1444
|
-
},
|
|
1445
|
-
|
|
1464
|
+
}, me({ _: 2 }, [
|
|
1465
|
+
u.$slots["toolbar-left"] ? {
|
|
1446
1466
|
name: "toolbar-left",
|
|
1447
1467
|
fn: O(() => [
|
|
1448
|
-
W(
|
|
1468
|
+
W(u.$slots, "toolbar-left", {}, void 0, !0)
|
|
1449
1469
|
]),
|
|
1450
1470
|
key: "0"
|
|
1451
1471
|
} : void 0,
|
|
1452
|
-
|
|
1472
|
+
u.$slots["toolbar-center"] ? {
|
|
1453
1473
|
name: "toolbar-center",
|
|
1454
1474
|
fn: O(() => [
|
|
1455
|
-
W(
|
|
1475
|
+
W(u.$slots, "toolbar-center", {}, void 0, !0)
|
|
1456
1476
|
]),
|
|
1457
1477
|
key: "1"
|
|
1458
1478
|
} : void 0,
|
|
1459
|
-
|
|
1479
|
+
u.$slots["toolbar-right"] ? {
|
|
1460
1480
|
name: "toolbar-right",
|
|
1461
1481
|
fn: O(() => [
|
|
1462
|
-
W(
|
|
1482
|
+
W(u.$slots, "toolbar-right", {}, void 0, !0)
|
|
1463
1483
|
]),
|
|
1464
1484
|
key: "2"
|
|
1465
1485
|
} : void 0
|
|
1466
1486
|
]), 1032, ["editor", "settings"])) : G("", !0),
|
|
1467
|
-
|
|
1487
|
+
K("div", {
|
|
1468
1488
|
ref_key: "editorRef",
|
|
1469
|
-
ref:
|
|
1489
|
+
ref: c,
|
|
1470
1490
|
class: "monaco-editor-target",
|
|
1471
1491
|
"data-testid": "monaco-editor-target"
|
|
1472
1492
|
}, null, 512),
|
|
1473
|
-
e.showLoadingState ? W(
|
|
1493
|
+
e.showLoadingState ? W(u.$slots, "state-loading", {
|
|
1474
1494
|
key: 1,
|
|
1475
1495
|
isLoading: i.value
|
|
1476
1496
|
}, () => [
|
|
1477
|
-
|
|
1497
|
+
re(fe, { name: "fade" }, {
|
|
1478
1498
|
default: O(() => [
|
|
1479
1499
|
i.value ? (v(), N(pe, {
|
|
1480
1500
|
key: 0,
|
|
1481
1501
|
"data-testid": "monaco-editor-status-overlay-loading",
|
|
1482
|
-
icon: S(
|
|
1483
|
-
message: S(
|
|
1484
|
-
title: S(
|
|
1502
|
+
icon: S(Ze),
|
|
1503
|
+
message: S(a).t("editor.messages.loading_message", { type: e.language }),
|
|
1504
|
+
title: S(a).t("editor.messages.loading_title", { type: e.language })
|
|
1485
1505
|
}, null, 8, ["icon", "message", "title"])) : G("", !0)
|
|
1486
1506
|
]),
|
|
1487
1507
|
_: 1
|
|
1488
1508
|
})
|
|
1489
1509
|
], !0) : G("", !0),
|
|
1490
|
-
e.showEmptyState ? W(
|
|
1510
|
+
e.showEmptyState ? W(u.$slots, "state-empty", {
|
|
1491
1511
|
key: 2,
|
|
1492
|
-
isEmpty:
|
|
1512
|
+
isEmpty: f.value
|
|
1493
1513
|
}, () => [
|
|
1494
|
-
|
|
1514
|
+
re(fe, { name: "fade" }, {
|
|
1495
1515
|
default: O(() => [
|
|
1496
|
-
|
|
1516
|
+
f.value ? (v(), N(pe, {
|
|
1497
1517
|
key: 0,
|
|
1498
1518
|
"data-testid": "monaco-editor-status-overlay-empty",
|
|
1499
1519
|
icon: S(xe),
|
|
1500
|
-
message: S(
|
|
1501
|
-
title: S(
|
|
1520
|
+
message: S(a).t("editor.messages.empty_message"),
|
|
1521
|
+
title: S(a).t("editor.messages.empty_title")
|
|
1502
1522
|
}, null, 8, ["icon", "message", "title"])) : G("", !0)
|
|
1503
1523
|
]),
|
|
1504
1524
|
_: 1
|
|
@@ -1506,18 +1526,18 @@ const Vt = {
|
|
|
1506
1526
|
], !0) : G("", !0)
|
|
1507
1527
|
], 2));
|
|
1508
1528
|
}
|
|
1509
|
-
}),
|
|
1529
|
+
}), nn = /* @__PURE__ */ se(Yt, [["__scopeId", "data-v-3f4acd16"]]);
|
|
1510
1530
|
export {
|
|
1511
|
-
|
|
1531
|
+
nn as MonacoEditor,
|
|
1512
1532
|
pe as MonacoEditorStatusOverlay,
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1533
|
+
an as collectCodeLensProviders,
|
|
1534
|
+
ln as collectCodeLenses,
|
|
1535
|
+
sn as createCopyUUIDCodeLens,
|
|
1536
|
+
cn as createCopyValueCodeLens,
|
|
1537
|
+
ne as createWrapAction,
|
|
1538
|
+
dn as emptyCodeLensList,
|
|
1539
|
+
gn as getModelContext,
|
|
1540
|
+
fn as invalidateModelContexts,
|
|
1541
|
+
Nt as useMonacoEditor,
|
|
1542
|
+
un as uuidRe
|
|
1523
1543
|
};
|