@cocoar/vue-script-editor 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExtraLibs.d.ts","sourceRoot":"","sources":["../../src/composables/useExtraLibs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,MAAM,WAAW,wBAAwB;IACvC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,wBAAwB,CAAC;IACzC,IAAI,EAAE,MAAM,SAAS,wBAAwB,EAAE,CAAC;CACjD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useExtraLibs.d.ts","sourceRoot":"","sources":["../../src/composables/useExtraLibs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,MAAM,WAAW,wBAAwB;IACvC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,wBAAwB,CAAC;IACzC,IAAI,EAAE,MAAM,SAAS,wBAAwB,EAAE,CAAC;CACjD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAgE/D"}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { CoarScriptEditorTheme } from '../theme';
|
|
3
3
|
import * as monaco from 'monaco-editor';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Languages the editor recognises. Three groups:
|
|
6
|
+
*
|
|
7
|
+
* - **TS/JS/JSON** — full language-service treatment: type checking,
|
|
8
|
+
* IntelliSense, `extraLibs` for ambient declarations, script-mode
|
|
9
|
+
* diagnostic suppression, JSON schema hooks.
|
|
10
|
+
* - **Markup / config / shell** (yaml, css, html, xml, sql, shell,
|
|
11
|
+
* dockerfile, ini, plaintext) — Monaco's built-in tokenizers; bracket
|
|
12
|
+
* matching + find/replace + multi-cursor without a language service.
|
|
13
|
+
* - **Other source code** (csharp, cpp, java, python, go, rust, …) —
|
|
14
|
+
* same as markup: syntax-highlighting only via Monaco's bundled
|
|
15
|
+
* grammars. No language service — `extraLibs` is ignored.
|
|
16
|
+
*
|
|
17
|
+
* Adding more languages from Monaco's bundle: extend the union, add a file
|
|
18
|
+
* extension to `LANGUAGE_EXTENSIONS` (or omit — the lookup falls back to
|
|
19
|
+
* the language name as the extension).
|
|
20
|
+
*/
|
|
21
|
+
export type CoarScriptEditorLanguage = 'typescript' | 'javascript' | 'json' | 'plaintext' | 'yaml' | 'css' | 'html' | 'xml' | 'sql' | 'shell' | 'dockerfile' | 'ini' | 'markdown' | 'csharp' | 'cpp' | 'c' | 'java' | 'python' | 'go' | 'rust' | 'ruby' | 'php' | 'swift' | 'kotlin' | 'scala' | 'lua' | 'perl' | 'dart' | 'fsharp' | 'vb' | 'r' | 'powershell' | 'objective-c' | 'solidity' | 'protobuf' | 'graphql' | 'razor' | 'pug' | 'handlebars' | 'twig';
|
|
5
22
|
export type CoarScriptEditorVariant = 'editor' | 'inline';
|
|
6
23
|
export interface UseMonacoEditorOptions {
|
|
7
24
|
host: Ref<HTMLElement | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMonacoEditor.d.ts","sourceRoot":"","sources":["../../src/composables/useMonacoEditor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAsC,KAAK,GAAG,EAAE,MAAM,KAAK,C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
|
+
yaml: "yaml",
|
|
78
|
+
shell: "sh",
|
|
79
|
+
markdown: "md",
|
|
80
|
+
csharp: "cs",
|
|
81
|
+
cpp: "cpp",
|
|
82
|
+
c: "c",
|
|
83
|
+
python: "py",
|
|
84
|
+
ruby: "rb",
|
|
85
|
+
rust: "rs",
|
|
86
|
+
kotlin: "kt",
|
|
87
|
+
fsharp: "fs",
|
|
88
|
+
powershell: "ps1",
|
|
89
|
+
"objective-c": "m",
|
|
90
|
+
solidity: "sol",
|
|
91
|
+
protobuf: "proto",
|
|
92
|
+
graphql: "graphql",
|
|
93
|
+
dockerfile: "dockerfile"
|
|
94
|
+
};
|
|
95
|
+
function S(e) {
|
|
96
|
+
return x[e] ?? e;
|
|
97
|
+
}
|
|
98
|
+
var C = [
|
|
77
99
|
1375,
|
|
78
100
|
2695,
|
|
79
101
|
1108,
|
|
80
102
|
7027,
|
|
81
103
|
1208
|
|
82
|
-
],
|
|
83
|
-
function
|
|
84
|
-
if (
|
|
85
|
-
|
|
104
|
+
], w = ["es2024"], T = !1;
|
|
105
|
+
function E() {
|
|
106
|
+
if (T) return;
|
|
107
|
+
T = !0;
|
|
86
108
|
let e = f.typescript.ScriptTarget.ES2020, t = f.typescript.typescriptDefaults, n = f.typescript.javascriptDefaults, r = f.typescript.ScriptTarget, i = {
|
|
87
109
|
target: r.ES2024 ?? r.ES2023 ?? r.ES2022 ?? r.ES2021 ?? r.ES2020 ?? e,
|
|
88
|
-
lib: [...
|
|
110
|
+
lib: [...w],
|
|
89
111
|
allowNonTsExtensions: !0
|
|
90
112
|
};
|
|
91
113
|
t.setCompilerOptions(i), n.setCompilerOptions(i);
|
|
92
114
|
}
|
|
93
|
-
var
|
|
115
|
+
var D = "'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace", O = 13, k = 1.5, A = !0, j = {
|
|
94
116
|
editor: {
|
|
95
117
|
glyphMargin: !0,
|
|
96
118
|
folding: !0,
|
|
@@ -129,7 +151,7 @@ var E = "'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace", D = 1
|
|
|
129
151
|
wordWrap: "on"
|
|
130
152
|
}
|
|
131
153
|
};
|
|
132
|
-
function
|
|
154
|
+
function M(e, t) {
|
|
133
155
|
return t ?? e === "editor" ? {
|
|
134
156
|
lineNumbers: "on",
|
|
135
157
|
lineNumbersMinChars: 3,
|
|
@@ -140,35 +162,35 @@ function A(e, t) {
|
|
|
140
162
|
lineDecorationsWidth: 12
|
|
141
163
|
};
|
|
142
164
|
}
|
|
143
|
-
function
|
|
165
|
+
function N(e) {
|
|
144
166
|
return e ? `${e}\n` : "";
|
|
145
167
|
}
|
|
146
|
-
function
|
|
168
|
+
function ee(e) {
|
|
147
169
|
return e ? e.split("\n").length : 0;
|
|
148
170
|
}
|
|
149
|
-
function N(e, t) {
|
|
150
|
-
return t ? j(t) + e : e;
|
|
151
|
-
}
|
|
152
171
|
function P(e, t) {
|
|
172
|
+
return t ? N(t) + e : e;
|
|
173
|
+
}
|
|
174
|
+
function F(e, t) {
|
|
153
175
|
if (!t) return e;
|
|
154
|
-
let n =
|
|
176
|
+
let n = N(t);
|
|
155
177
|
return e.startsWith(n) ? e.slice(n.length) : e;
|
|
156
178
|
}
|
|
157
|
-
function
|
|
158
|
-
let n =
|
|
179
|
+
function I(e, t) {
|
|
180
|
+
let n = ee(t), r = n === 0 ? [] : [new f.Range(1, 1, n, 2 ** 53 - 1)];
|
|
159
181
|
e.setHiddenAreas(r);
|
|
160
182
|
}
|
|
161
|
-
function
|
|
183
|
+
function L(e, t) {
|
|
162
184
|
if (!t || e !== "typescript" && e !== "javascript") return;
|
|
163
185
|
let n = e === "javascript" ? f.typescript.javascriptDefaults : f.typescript.typescriptDefaults, r = typeof n.getDiagnosticsOptions == "function" ? n.getDiagnosticsOptions() : {}, i = new Set(r.diagnosticCodesToIgnore ?? []);
|
|
164
|
-
for (let e of
|
|
186
|
+
for (let e of C) i.add(e);
|
|
165
187
|
n.setDiagnosticsOptions({
|
|
166
188
|
...r,
|
|
167
189
|
diagnosticCodesToIgnore: Array.from(i)
|
|
168
190
|
});
|
|
169
191
|
}
|
|
170
192
|
function te(e) {
|
|
171
|
-
|
|
193
|
+
E();
|
|
172
194
|
let t = l(null), n = l(null), r = !1, i = null, a = null, s = null, c = null, u = !1;
|
|
173
195
|
function p() {
|
|
174
196
|
return e.variant?.() ?? "editor";
|
|
@@ -182,8 +204,8 @@ function te(e) {
|
|
|
182
204
|
if (u || !e.host.value) return;
|
|
183
205
|
u = !0, g(f);
|
|
184
206
|
let o = e.language(), c = e.preamble?.() ?? "";
|
|
185
|
-
|
|
186
|
-
let l = f.editor.createModel(
|
|
207
|
+
L(o, e.scriptMode?.() ?? !1);
|
|
208
|
+
let l = f.editor.createModel(P(e.initialValue(), c), o, f.Uri.parse(`file:///coar-script-editor/${b()}.${S(o)}`));
|
|
187
209
|
n.value = l;
|
|
188
210
|
let d = e.overflowWidgetsDomNode?.() ?? null, h = f.editor.create(e.host.value, {
|
|
189
211
|
model: l,
|
|
@@ -192,22 +214,22 @@ function te(e) {
|
|
|
192
214
|
minimap: { enabled: e.minimap() },
|
|
193
215
|
automaticLayout: !0,
|
|
194
216
|
scrollBeyondLastLine: !1,
|
|
195
|
-
fontFamily:
|
|
196
|
-
fontSize:
|
|
197
|
-
lineHeight:
|
|
198
|
-
fontLigatures:
|
|
217
|
+
fontFamily: D,
|
|
218
|
+
fontSize: O,
|
|
219
|
+
lineHeight: k,
|
|
220
|
+
fontLigatures: A,
|
|
199
221
|
tabSize: 2,
|
|
200
222
|
fixedOverflowWidgets: !0,
|
|
201
|
-
...
|
|
202
|
-
...
|
|
223
|
+
...j[p()],
|
|
224
|
+
...M(p(), e.lineNumbers?.()),
|
|
203
225
|
...d ? { overflowWidgetsDomNode: d } : {}
|
|
204
226
|
});
|
|
205
|
-
t.value = h,
|
|
227
|
+
t.value = h, I(h, c), m();
|
|
206
228
|
let _ = !1;
|
|
207
229
|
i = h.onDidChangeModelContent((n) => {
|
|
208
230
|
let i = e.preamble?.() ?? "";
|
|
209
231
|
if (i && !n.isFlush && !n.isUndoing) {
|
|
210
|
-
let e =
|
|
232
|
+
let e = N(i).length;
|
|
211
233
|
if (n.changes.some((t) => t.rangeOffset < e)) {
|
|
212
234
|
h.trigger("coar-script-editor-preamble", "undo", null);
|
|
213
235
|
return;
|
|
@@ -216,7 +238,7 @@ function te(e) {
|
|
|
216
238
|
r || _ || (_ = !0, queueMicrotask(() => {
|
|
217
239
|
if (_ = !1, !t.value) return;
|
|
218
240
|
let n = h.getValue();
|
|
219
|
-
e.onContentChange(
|
|
241
|
+
e.onContentChange(F(n, e.preamble?.() ?? ""));
|
|
220
242
|
}));
|
|
221
243
|
}), e.onFocused && (a = h.onDidFocusEditorWidget(() => e.onFocused?.())), e.onBlurred && (s = h.onDidBlurEditorWidget(() => e.onBlurred?.())), e.autofocus?.() && queueMicrotask(() => t.value?.focus()), e.onEditorReady?.(h);
|
|
222
244
|
}
|
|
@@ -231,17 +253,17 @@ function te(e) {
|
|
|
231
253
|
function _(n) {
|
|
232
254
|
let i = t.value;
|
|
233
255
|
if (!i) return;
|
|
234
|
-
let a = e.preamble?.() ?? "", o =
|
|
256
|
+
let a = e.preamble?.() ?? "", o = P(n, a);
|
|
235
257
|
if (i.getValue() !== o) {
|
|
236
258
|
r = !0;
|
|
237
259
|
try {
|
|
238
|
-
i.setValue(o),
|
|
260
|
+
i.setValue(o), I(i, a);
|
|
239
261
|
} finally {
|
|
240
262
|
r = !1;
|
|
241
263
|
}
|
|
242
264
|
}
|
|
243
265
|
}
|
|
244
|
-
function
|
|
266
|
+
function x(e) {
|
|
245
267
|
let t = r;
|
|
246
268
|
r = !0;
|
|
247
269
|
try {
|
|
@@ -252,17 +274,17 @@ function te(e) {
|
|
|
252
274
|
}
|
|
253
275
|
return d(() => e.language(), (t) => {
|
|
254
276
|
let r = n.value;
|
|
255
|
-
r && f.editor.setModelLanguage(r, t),
|
|
277
|
+
r && f.editor.setModelLanguage(r, t), L(t, e.scriptMode?.() ?? !1);
|
|
256
278
|
}), d(() => e.readonly(), (e) => t.value?.updateOptions({ readOnly: e })), d(() => e.minimap(), (e) => t.value?.updateOptions({ minimap: { enabled: e } })), e.variant && d(() => p(), (n) => t.value?.updateOptions({
|
|
257
|
-
...
|
|
258
|
-
...
|
|
259
|
-
})), e.lineNumbers && d(() => e.lineNumbers(), (e) => t.value?.updateOptions(
|
|
279
|
+
...j[n],
|
|
280
|
+
...M(n, e.lineNumbers?.())
|
|
281
|
+
})), e.lineNumbers && d(() => e.lineNumbers(), (e) => t.value?.updateOptions(M(p(), e))), e.scriptMode && d(() => e.scriptMode(), (t) => L(e.language(), t)), e.preamble && d(() => e.preamble(), (e, n) => {
|
|
260
282
|
let i = t.value;
|
|
261
283
|
if (!i) return;
|
|
262
|
-
let a =
|
|
284
|
+
let a = P(F(i.getValue(), n ?? ""), e);
|
|
263
285
|
r = !0;
|
|
264
286
|
try {
|
|
265
|
-
i.setValue(a),
|
|
287
|
+
i.setValue(a), I(i, e);
|
|
266
288
|
} finally {
|
|
267
289
|
r = !1;
|
|
268
290
|
}
|
|
@@ -272,18 +294,22 @@ function te(e) {
|
|
|
272
294
|
editor: t,
|
|
273
295
|
model: n,
|
|
274
296
|
setValue: _,
|
|
275
|
-
withSuppressedChange:
|
|
297
|
+
withSuppressedChange: x
|
|
276
298
|
};
|
|
277
299
|
}
|
|
278
300
|
//#endregion
|
|
279
301
|
//#region src/composables/useExtraLibs.ts
|
|
280
|
-
function
|
|
281
|
-
let t = [], n = /* @__PURE__ */ new Set(), r =
|
|
302
|
+
function R(e) {
|
|
303
|
+
let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
282
304
|
function i() {
|
|
283
305
|
for (; t.length;) t.pop()?.dispose();
|
|
284
306
|
let i = e.language();
|
|
285
|
-
if (i
|
|
286
|
-
e.libs().length > 0 && !r
|
|
307
|
+
if (i !== "typescript" && i !== "javascript") {
|
|
308
|
+
if (e.libs().length > 0 && !r.has(i)) {
|
|
309
|
+
r.add(i);
|
|
310
|
+
let e = i === "json" ? "Use monaco.languages.json.jsonDefaults.setDiagnosticsOptions for JSON schema configuration." : `Monaco has no extra-libs concept for '${i}'. Remove the libs prop or switch to a TS/JS-backed editor.`;
|
|
311
|
+
console.warn(`[coar-script-editor] extraLibs has entries but language is '${i}' — extraLibs are ignored. ${e}`);
|
|
312
|
+
}
|
|
287
313
|
return;
|
|
288
314
|
}
|
|
289
315
|
let a = i === "javascript" ? f.typescript.javascriptDefaults : f.typescript.typescriptDefaults;
|
|
@@ -295,16 +321,16 @@ function L(e) {
|
|
|
295
321
|
}
|
|
296
322
|
//#endregion
|
|
297
323
|
//#region src/constrained/LockedLineScanner.ts
|
|
298
|
-
var
|
|
299
|
-
function V(e) {
|
|
300
|
-
return R.test(e);
|
|
301
|
-
}
|
|
324
|
+
var z = /\/\/\s*@locked\b/, B = /\/\/\s*@locked\b[^\n]*?@slot:([A-Za-z_][A-Za-z0-9_-]*)/, V = "// @locked", ne = B.source;
|
|
302
325
|
function H(e) {
|
|
326
|
+
return z.test(e);
|
|
327
|
+
}
|
|
328
|
+
function U(e) {
|
|
303
329
|
let t = [], n = e.length, r = 0, i = 0;
|
|
304
330
|
for (let a = 0; a <= n; a++) if (a === n || e[a] === "\n") {
|
|
305
331
|
let o = a, s = o > i && e[o - 1] === "\r" ? o - 1 : o, c = e.slice(i, s);
|
|
306
|
-
if (
|
|
307
|
-
let e = c.match(
|
|
332
|
+
if (z.test(c)) {
|
|
333
|
+
let e = c.match(B);
|
|
308
334
|
t.push({
|
|
309
335
|
lineIndex: r,
|
|
310
336
|
lineStart: i,
|
|
@@ -320,7 +346,7 @@ function H(e) {
|
|
|
320
346
|
}
|
|
321
347
|
return t;
|
|
322
348
|
}
|
|
323
|
-
function
|
|
349
|
+
function W(e) {
|
|
324
350
|
if (e.length === 0) return [];
|
|
325
351
|
let t = [...e].sort((e, t) => e.protectedStart - t.protectedStart), n = [], r = {
|
|
326
352
|
start: t[0].protectedStart,
|
|
@@ -339,27 +365,27 @@ function U(e) {
|
|
|
339
365
|
}
|
|
340
366
|
return n.push(r), n;
|
|
341
367
|
}
|
|
342
|
-
function W(e, t) {
|
|
343
|
-
return e.rangeStart <= t.end && e.rangeEnd >= t.start;
|
|
344
|
-
}
|
|
345
368
|
function G(e, t) {
|
|
346
|
-
return t.
|
|
369
|
+
return e.rangeStart <= t.end && e.rangeEnd >= t.start;
|
|
347
370
|
}
|
|
348
371
|
function K(e, t) {
|
|
372
|
+
return t.some((t) => G(e, t));
|
|
373
|
+
}
|
|
374
|
+
function q(e, t) {
|
|
349
375
|
for (let n of t) if (e >= n.start && e <= n.end) {
|
|
350
376
|
let t = n.snapBefore, r = n.snapAfter;
|
|
351
377
|
return t == null && r == null ? 0 : t == null ? r : r == null || e - t < r - e ? t : r;
|
|
352
378
|
}
|
|
353
379
|
return e;
|
|
354
380
|
}
|
|
355
|
-
function q(e) {
|
|
356
|
-
return H(e).length;
|
|
357
|
-
}
|
|
358
381
|
function J(e) {
|
|
359
|
-
return
|
|
382
|
+
return U(e).length;
|
|
360
383
|
}
|
|
361
384
|
function Y(e) {
|
|
362
|
-
|
|
385
|
+
return Q(e).every((e) => e.trim().length > 0);
|
|
386
|
+
}
|
|
387
|
+
function X(e) {
|
|
388
|
+
let t = U(e), n = Q(e), r = [];
|
|
363
389
|
return t.length > 0 && t[0].lineIndex === 0 && r.push("Source starts with a locked line — there is no space above for auto-import or helpers."), t.length > 0 && n.every((e) => e.length === 0) && r.push("Source has locked lines but no editable space between or around them."), {
|
|
364
390
|
ok: r.length === 0,
|
|
365
391
|
lockedLineCount: t.length,
|
|
@@ -367,30 +393,30 @@ function Y(e) {
|
|
|
367
393
|
warnings: r
|
|
368
394
|
};
|
|
369
395
|
}
|
|
370
|
-
function
|
|
396
|
+
function re(e) {
|
|
371
397
|
let t = e.split("\n"), n = 0, r = t.length;
|
|
372
398
|
for (; n < r && t[n].trim() === "";) n++;
|
|
373
399
|
for (; r > n && t[r - 1].trim() === "";) r--;
|
|
374
400
|
return t.slice(n, r).join("\n");
|
|
375
401
|
}
|
|
376
402
|
function Z(e) {
|
|
377
|
-
let t =
|
|
403
|
+
let t = U(e);
|
|
378
404
|
if (t.length === 0) return {};
|
|
379
405
|
let n = e.split("\n"), r = {};
|
|
380
406
|
for (let e = 0; e < t.length; e++) {
|
|
381
407
|
let i = t[e];
|
|
382
408
|
if (!i.slotName || Object.prototype.hasOwnProperty.call(r, i.slotName)) continue;
|
|
383
409
|
let a = i.lineIndex + 1, o = t[e + 1], s = o ? o.lineIndex : n.length, c = n.slice(a, s).join("\n");
|
|
384
|
-
r[i.slotName] =
|
|
410
|
+
r[i.slotName] = re(c);
|
|
385
411
|
}
|
|
386
412
|
return r;
|
|
387
413
|
}
|
|
388
|
-
function
|
|
414
|
+
function ie(e, t) {
|
|
389
415
|
let n = Z(e);
|
|
390
416
|
return Object.prototype.hasOwnProperty.call(n, t) ? n[t] : void 0;
|
|
391
417
|
}
|
|
392
418
|
function Q(e) {
|
|
393
|
-
let t =
|
|
419
|
+
let t = U(e);
|
|
394
420
|
if (t.length === 0) return [e];
|
|
395
421
|
let n = new Set(t.map((e) => e.lineIndex)), r = e.split("\n"), i = [], a = [];
|
|
396
422
|
for (let e = 0; e < r.length; e++) n.has(e) ? a.length > 0 || i.length === 0 ? (i.push(a.join("\n")), a = []) : i.push("") : a.push(r[e]);
|
|
@@ -398,7 +424,7 @@ function Q(e) {
|
|
|
398
424
|
}
|
|
399
425
|
//#endregion
|
|
400
426
|
//#region src/constrained/ChangeGuard.ts
|
|
401
|
-
var
|
|
427
|
+
var ae = class {
|
|
402
428
|
disposables = [];
|
|
403
429
|
lockedLines;
|
|
404
430
|
protectedRanges;
|
|
@@ -406,7 +432,7 @@ var ie = class {
|
|
|
406
432
|
this.editor = e, this.authoring = t, this.callbacks = n;
|
|
407
433
|
let r = e.getModel();
|
|
408
434
|
if (!r) throw Error("ChangeGuard requires the editor to have an attached model");
|
|
409
|
-
this.lockedLines =
|
|
435
|
+
this.lockedLines = U(r.getValue()), this.protectedRanges = W(this.lockedLines), this.disposables.push(r.onDidChangeContent((e) => this.handleChange(e)));
|
|
410
436
|
}
|
|
411
437
|
dispose() {
|
|
412
438
|
for (; this.disposables.length;) this.disposables.pop()?.dispose();
|
|
@@ -419,14 +445,14 @@ var ie = class {
|
|
|
419
445
|
}
|
|
420
446
|
refresh() {
|
|
421
447
|
let e = this.editor.getModel();
|
|
422
|
-
e && (this.lockedLines =
|
|
448
|
+
e && (this.lockedLines = U(e.getValue()), this.protectedRanges = W(this.lockedLines), this.callbacks.onLinesUpdated?.(this.lockedLines));
|
|
423
449
|
}
|
|
424
450
|
handleChange(e) {
|
|
425
451
|
let t = this.editor.getModel();
|
|
426
452
|
if (!t) return;
|
|
427
453
|
let n = e.isFlush || e.isUndoing || this.authoring();
|
|
428
454
|
if (e.isFlush && t.pushStackElement(), !n) {
|
|
429
|
-
let t = e.changes.find((e) =>
|
|
455
|
+
let t = e.changes.find((e) => K({
|
|
430
456
|
rangeStart: e.rangeOffset,
|
|
431
457
|
rangeEnd: e.rangeOffset + e.rangeLength
|
|
432
458
|
}, this.protectedRanges));
|
|
@@ -441,9 +467,9 @@ var ie = class {
|
|
|
441
467
|
return;
|
|
442
468
|
}
|
|
443
469
|
}
|
|
444
|
-
this.lockedLines =
|
|
470
|
+
this.lockedLines = U(t.getValue()), this.protectedRanges = W(this.lockedLines), this.callbacks.onLinesUpdated?.(this.lockedLines), this.callbacks.onContentChanged?.(t.getValue());
|
|
445
471
|
}
|
|
446
|
-
},
|
|
472
|
+
}, oe = class {
|
|
447
473
|
disposables = [];
|
|
448
474
|
correcting = !1;
|
|
449
475
|
constructor(e, t, n) {
|
|
@@ -465,7 +491,7 @@ var ie = class {
|
|
|
465
491
|
if (n.length === 0) return;
|
|
466
492
|
let r = t[0].constructor, i = [], a = !1;
|
|
467
493
|
for (let o of t) {
|
|
468
|
-
let t = e.getOffsetAt(o.getStartPosition()), s = e.getOffsetAt(o.getEndPosition()), c =
|
|
494
|
+
let t = e.getOffsetAt(o.getStartPosition()), s = e.getOffsetAt(o.getEndPosition()), c = q(t, n), l = q(s, n);
|
|
469
495
|
if (c === t && l === s) {
|
|
470
496
|
i.push(o);
|
|
471
497
|
continue;
|
|
@@ -482,7 +508,7 @@ var ie = class {
|
|
|
482
508
|
}
|
|
483
509
|
}
|
|
484
510
|
}
|
|
485
|
-
},
|
|
511
|
+
}, se = class {
|
|
486
512
|
disposables = [];
|
|
487
513
|
filtering = !1;
|
|
488
514
|
constructor(e, t) {
|
|
@@ -503,7 +529,7 @@ var ie = class {
|
|
|
503
529
|
if (this.authoring()) return;
|
|
504
530
|
let e = this.editor.getModel();
|
|
505
531
|
if (!e) return;
|
|
506
|
-
let t = e.getValue(), n = new Set(
|
|
532
|
+
let t = e.getValue(), n = new Set(U(t).map((e) => e.lineIndex + 1));
|
|
507
533
|
if (n.size === 0) return;
|
|
508
534
|
let r = f.editor.getModelMarkers({ resource: e.uri });
|
|
509
535
|
if (r.length === 0) return;
|
|
@@ -537,8 +563,8 @@ var ie = class {
|
|
|
537
563
|
this.filtering = !1;
|
|
538
564
|
}
|
|
539
565
|
}
|
|
540
|
-
},
|
|
541
|
-
function
|
|
566
|
+
}, ce = "coar-script-editor-locked-line", $ = "coar-script-editor-locked-marker", le = /\/\/\s*@locked\b/g;
|
|
567
|
+
function ue(e) {
|
|
542
568
|
let t = null, n = null, r = null, i = null;
|
|
543
569
|
function a() {
|
|
544
570
|
t?.dispose(), t = null, n?.dispose(), n = null, r?.dispose(), r = null, i?.clear(), i = null;
|
|
@@ -557,7 +583,7 @@ function $(e) {
|
|
|
557
583
|
endColumn: i + 1
|
|
558
584
|
},
|
|
559
585
|
options: {
|
|
560
|
-
className:
|
|
586
|
+
className: ce,
|
|
561
587
|
isWholeLine: !0,
|
|
562
588
|
stickiness: 1
|
|
563
589
|
}
|
|
@@ -571,7 +597,7 @@ function $(e) {
|
|
|
571
597
|
endColumn: s.index + s[0].length + 1
|
|
572
598
|
},
|
|
573
599
|
options: {
|
|
574
|
-
inlineClassName:
|
|
600
|
+
inlineClassName: $,
|
|
575
601
|
stickiness: 1,
|
|
576
602
|
hoverMessage: { value: "Locked line marker" }
|
|
577
603
|
}
|
|
@@ -584,14 +610,14 @@ function $(e) {
|
|
|
584
610
|
formatOnType: !1,
|
|
585
611
|
formatOnPaste: !1,
|
|
586
612
|
linkedEditing: !1
|
|
587
|
-
}), t = new
|
|
613
|
+
}), t = new ae(i, e.authoring, {
|
|
588
614
|
onReject: e.onReject,
|
|
589
615
|
onLinesUpdated: (e) => {
|
|
590
616
|
s(i, e), r?.refresh();
|
|
591
617
|
}
|
|
592
|
-
}), n = new
|
|
618
|
+
}), n = new oe(i, () => t?.getProtectedRanges() ?? [], e.authoring), r = new se(i, e.authoring), s(i, t.getLockedLines()), n.snapCurrent();
|
|
593
619
|
}
|
|
594
|
-
d([e.editor, () =>
|
|
620
|
+
d([e.editor, () => H(e.value())], ([e, n]) => {
|
|
595
621
|
if (!e) {
|
|
596
622
|
a();
|
|
597
623
|
return;
|
|
@@ -610,13 +636,13 @@ function $(e) {
|
|
|
610
636
|
}
|
|
611
637
|
//#endregion
|
|
612
638
|
//#region src/composables/useFormFieldContext.ts
|
|
613
|
-
var
|
|
614
|
-
function
|
|
615
|
-
return r(
|
|
639
|
+
var de = Symbol.for("coar:form-field");
|
|
640
|
+
function fe() {
|
|
641
|
+
return r(de, void 0);
|
|
616
642
|
}
|
|
617
643
|
//#endregion
|
|
618
644
|
//#region src/CoarScriptEditor.vue?vue&type=script&setup=true&lang.ts
|
|
619
|
-
var
|
|
645
|
+
var pe = [
|
|
620
646
|
"id",
|
|
621
647
|
"aria-invalid",
|
|
622
648
|
"aria-describedby",
|
|
@@ -624,7 +650,7 @@ var fe = [
|
|
|
624
650
|
"aria-required",
|
|
625
651
|
"data-placeholder",
|
|
626
652
|
"data-name"
|
|
627
|
-
],
|
|
653
|
+
], me = /* @__PURE__ */ n({
|
|
628
654
|
__name: "CoarScriptEditor",
|
|
629
655
|
props: {
|
|
630
656
|
modelValue: { default: "" },
|
|
@@ -682,7 +708,7 @@ var fe = [
|
|
|
682
708
|
"blurred"
|
|
683
709
|
],
|
|
684
710
|
setup(n, { expose: r, emit: o }) {
|
|
685
|
-
let l = n, f = o, p = c(null), m = l.modelValue, h =
|
|
711
|
+
let l = n, f = o, p = c(null), m = l.modelValue, h = fe(), g = `coar-script-editor-${u()}`, _ = e(() => l.id || h?.inputId.value || g), v = e(() => l.error || (h?.hasError.value ?? !1)), y = e(() => h?.messageId.value), b = e(() => l.disabled || (h?.disabled.value ?? !1)), x = c(!1), S = c(l.modelValue.length === 0), C = e(() => ({
|
|
686
712
|
"coar-script-editor": !0,
|
|
687
713
|
"coar-script-editor--authoring": l.authoring,
|
|
688
714
|
"coar-script-editor--inline": l.variant === "inline",
|
|
@@ -715,10 +741,10 @@ var fe = [
|
|
|
715
741
|
x.value = !1, f("blurred");
|
|
716
742
|
}
|
|
717
743
|
});
|
|
718
|
-
return
|
|
744
|
+
return R({
|
|
719
745
|
language: () => l.language,
|
|
720
746
|
libs: () => l.extraLibs
|
|
721
|
-
}),
|
|
747
|
+
}), ue({
|
|
722
748
|
editor: T,
|
|
723
749
|
value: () => l.modelValue,
|
|
724
750
|
authoring: () => l.authoring,
|
|
@@ -741,8 +767,8 @@ var fe = [
|
|
|
741
767
|
"aria-required": n.required ? "true" : void 0,
|
|
742
768
|
"data-placeholder": n.placeholder || void 0,
|
|
743
769
|
"data-name": n.name || void 0
|
|
744
|
-
}, null, 14,
|
|
770
|
+
}, null, 14, pe));
|
|
745
771
|
}
|
|
746
772
|
});
|
|
747
773
|
//#endregion
|
|
748
|
-
export { m as COAR_THEME_DARK, p as COAR_THEME_LIGHT,
|
|
774
|
+
export { m as COAR_THEME_DARK, p as COAR_THEME_LIGHT, me as CoarScriptEditor, V as LOCKED_MARKER_TEXT, ne as SLOT_MARKER_PATTERN, W as computeProtectedRanges, J as countLockedLines, _ as detectAutoTheme, K as editIsProtected, g as ensureCoarThemes, Q as getEditableSegments, ie as getSlot, Z as getSlots, H as hasLockedMarkers, Y as isEverySegmentNonEmpty, G as overlapsProtectedRange, U as scanLockedLines, q as snapOffsetAwayFromLocked, X as validateSource, y as watchAutoTheme };
|