@sheetxl/scripting-react 0.8.0-beta.11 → 0.8.0-beta.13
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/browser/esm/{DwNnhfNV7R5zmBKY.mjs → BqjEx77-e6CucA90.mjs} +1 -1
- package/browser/esm/{ddwGYO4BGXOrUsl5.mjs → CFf-YW7MbQqrQ-GM.mjs} +2 -2
- package/browser/esm/{todJqKpTFkpVOUC0.mjs → D4hxu3BqCT2WwE6L.mjs} +1 -1
- package/browser/esm/index.mjs +271 -276
- package/node/esm/index.mjs +255 -263
- package/package.json +6 -6
package/node/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.
|
|
2
|
+
* @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.13
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -11,10 +11,10 @@ import { useMergeRefs as l } from "react-merge-refs";
|
|
|
11
11
|
import { CommonUtils as u, TimerUtils as d, defineLazyModule as p, messageKey as m } from "@sheetxl/utils";
|
|
12
12
|
import { DocTags as g } from "@sheetxl/scripting";
|
|
13
13
|
import { IScript as f } from "@sheetxl/sdk";
|
|
14
|
-
import { Command as
|
|
14
|
+
import { Command as h, lazyComponent as y, useCallbackRef as b, useCommands as x, useImperativeElement as w, useLazyRetry as v, useNotifier as k, useTranslator as S } from "@sheetxl/utils-react";
|
|
15
15
|
import { jsx as C, jsxs as N } from "react/jsx-runtime";
|
|
16
16
|
import { DefaultTaskPaneRegistry as E, useModelListener as L, useTaskPaneArea as M, useWorkbook as O } from "@sheetxl/react";
|
|
17
|
-
var
|
|
17
|
+
var I = {
|
|
18
18
|
defaultToken: "invalid",
|
|
19
19
|
tokenPostfix: ".ts",
|
|
20
20
|
keywords: [
|
|
@@ -355,11 +355,11 @@ var D = {
|
|
|
355
355
|
{ include: "common" }
|
|
356
356
|
]
|
|
357
357
|
}
|
|
358
|
-
},
|
|
358
|
+
}, D = /(?:\s|\/\/[^\n]*|\/\*[\s\S]*?\*\/)*/y, $ = /(import\b\s*(?:type\s+(?!from\b))?)(?:([^'";]*?)\s*\bfrom\s*)?(['"])([^'"\n]+)\3[ \t]*;?/y, R = (e) => e.replace(/\s+/g, " ").trim(), T = (e) => {
|
|
359
359
|
const t = [];
|
|
360
360
|
let n = 0;
|
|
361
361
|
for (;;) {
|
|
362
|
-
|
|
362
|
+
D.lastIndex = n, D.exec(e), $.lastIndex = D.lastIndex;
|
|
363
363
|
const r = $.exec(e);
|
|
364
364
|
if (!r) return t;
|
|
365
365
|
const o = r[2] ?? "", i = r.index + r[1].length, s = o.indexOf("{"), a = o.lastIndexOf("}"), c = s >= 0 && a > s, l = c ? o.slice(0, s) + o.slice(a + 1) : o;
|
|
@@ -370,18 +370,18 @@ var D = {
|
|
|
370
370
|
module: r[4],
|
|
371
371
|
quote: r[3],
|
|
372
372
|
typeOnly: /\btype\s+$/.test(r[1]),
|
|
373
|
-
binding:
|
|
374
|
-
names: c ? o.slice(s + 1, a).split(",").map(
|
|
373
|
+
binding: R(l).replace(/\s*,$/, ""),
|
|
374
|
+
names: c ? o.slice(s + 1, a).split(",").map(R).filter(Boolean) : null,
|
|
375
375
|
namesStart: i + s + 1,
|
|
376
376
|
namesEnd: i + a
|
|
377
377
|
}), n = $.lastIndex;
|
|
378
378
|
}
|
|
379
|
-
},
|
|
379
|
+
}, A = (e) => [
|
|
380
380
|
e.typeOnly,
|
|
381
381
|
e.binding,
|
|
382
382
|
e.names?.join(","),
|
|
383
383
|
e.module
|
|
384
|
-
].join("|"),
|
|
384
|
+
].join("|"), P = (e) => `${e.typeOnly ? "type " : ""}${e.module}`, F = (e, t, n) => {
|
|
385
385
|
const r = e.slice(t.namesStart, t.namesEnd), o = r.trimEnd();
|
|
386
386
|
if ("" === o.trim()) return {
|
|
387
387
|
offset: t.namesStart,
|
|
@@ -460,32 +460,38 @@ var D = {
|
|
|
460
460
|
wordWrapColumn: 80,
|
|
461
461
|
wordWrapMinified: !0,
|
|
462
462
|
wrappingIndent: "none"
|
|
463
|
-
}, W = "_script-editor_1kuph_5",
|
|
463
|
+
}, W = "_script-editor_1kuph_5", j = (e) => {
|
|
464
464
|
const t = e?.getModules();
|
|
465
465
|
return t ? (t.getByName(f.DEFAULT_MODULE), f.DEFAULT_MODULE) : f.DEFAULT_MODULE;
|
|
466
|
-
},
|
|
467
|
-
var B, H = p("scripting-react:monaco", async () =>
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
e(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
|
|
466
|
+
}, V = (e) => e?.getModules()?.getByName(j(e)) ?? null;
|
|
467
|
+
var B, H = p("scripting-react:monaco", async () => {
|
|
468
|
+
(function() {
|
|
469
|
+
if ("undefined" == typeof window) return;
|
|
470
|
+
const e = window;
|
|
471
|
+
if (e.__sxlDefineShim) return;
|
|
472
|
+
e.__sxlDefineShim = !0;
|
|
473
|
+
const t = [];
|
|
474
|
+
let n = null;
|
|
475
|
+
const r = (...e) => {
|
|
476
|
+
"function" == typeof n ? n(...e) : t.push(e);
|
|
477
|
+
};
|
|
478
|
+
Object.defineProperty(e, "define", {
|
|
479
|
+
configurable: !1,
|
|
480
|
+
enumerable: !0,
|
|
481
|
+
get: () => "function" == typeof n ? n : r,
|
|
482
|
+
set(e) {
|
|
483
|
+
if ("function" == typeof e) for (n = e; t.length;) try {
|
|
484
|
+
e(...t.shift());
|
|
485
|
+
} catch {}
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
})();
|
|
489
|
+
const [e] = await Promise.all([import("@monaco-editor/react"), Y().catch((e) => {
|
|
490
|
+
console.warn("cant load types", e);
|
|
491
|
+
})]);
|
|
492
|
+
return e;
|
|
493
|
+
}, { prefetch: !1 }), U = ({ error: e }) => {
|
|
494
|
+
const t = v(), n = S();
|
|
489
495
|
return N("div", {
|
|
490
496
|
style: {
|
|
491
497
|
display: "flex",
|
|
@@ -501,13 +507,15 @@ var B, H = p("scripting-react:monaco", async () => (function() {
|
|
|
501
507
|
children: n("scriptEditor.retry")
|
|
502
508
|
}) : null]
|
|
503
509
|
});
|
|
504
|
-
}, q =
|
|
510
|
+
}, q = y(H.load, { renderError: ({ error: e }) => C(U, { error: e }) }), K = ["define", "require"], z = !1, G = "@0.8.0-beta.13";
|
|
505
511
|
"@local" !== G && "@0.0.0" !== G || (G = "");
|
|
506
|
-
var
|
|
512
|
+
var J = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${G}/types/scripting.d.ts`, X = null, Z = null, Y = () => (Z || (Z = (async () => await (await fetch(J)).text())().then((e) => (X = e, e))).catch(() => {
|
|
513
|
+
Z = null;
|
|
514
|
+
}), Z), Q = (e) => {
|
|
507
515
|
try {
|
|
508
|
-
e.languages.setMonarchTokensProvider("typescript",
|
|
516
|
+
e.languages.setMonarchTokensProvider("typescript", I);
|
|
509
517
|
} catch (e) {}
|
|
510
|
-
},
|
|
518
|
+
}, ee = !1, te = async (e, t, n) => {
|
|
511
519
|
const r = e.getModel();
|
|
512
520
|
if (!r) return;
|
|
513
521
|
const o = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), i = e.getPosition();
|
|
@@ -515,11 +523,11 @@ var Z = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${G}/types/scripting.d.ts`, J
|
|
|
515
523
|
s.lineNumber = 1, s.column = 1;
|
|
516
524
|
let a = !1;
|
|
517
525
|
for (let e = i.lineNumber; e >= 1; e--) if ("" === r.getLineContent(e).trim()) {
|
|
518
|
-
const t =
|
|
526
|
+
const t = oe(o, r.getOffsetAt({
|
|
519
527
|
lineNumber: e,
|
|
520
528
|
column: 1
|
|
521
529
|
}), "function");
|
|
522
|
-
if (!t ||
|
|
530
|
+
if (!t || ie(t)) {
|
|
523
531
|
a = !0, s.lineNumber = e + 1;
|
|
524
532
|
break;
|
|
525
533
|
}
|
|
@@ -540,8 +548,8 @@ var Z = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${G}/types/scripting.d.ts`, J
|
|
|
540
548
|
i = (i + t.slice(s)).replace(/^(?:[ \t]*\r?\n)+/, "");
|
|
541
549
|
const a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
542
550
|
for (const e of n) {
|
|
543
|
-
if (a.add(
|
|
544
|
-
const t =
|
|
551
|
+
if (a.add(A(e)), !e.names) continue;
|
|
552
|
+
const t = P(e);
|
|
545
553
|
l.has(t) || l.set(t, e);
|
|
546
554
|
let n = c.get(t);
|
|
547
555
|
n || c.set(t, n = /* @__PURE__ */ new Set());
|
|
@@ -550,12 +558,12 @@ var Z = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${G}/types/scripting.d.ts`, J
|
|
|
550
558
|
const u = /* @__PURE__ */ new Map(), d = [], p = /* @__PURE__ */ new Map();
|
|
551
559
|
for (const e of o) {
|
|
552
560
|
if (!e.names || e.binding) {
|
|
553
|
-
const t =
|
|
561
|
+
const t = A(e);
|
|
554
562
|
if (a.has(t)) continue;
|
|
555
563
|
a.add(t), d.push(e.text);
|
|
556
564
|
continue;
|
|
557
565
|
}
|
|
558
|
-
const t =
|
|
566
|
+
const t = P(e);
|
|
559
567
|
let n = c.get(t);
|
|
560
568
|
n || c.set(t, n = /* @__PURE__ */ new Set());
|
|
561
569
|
const r = e.typeOnly ? c.get(e.module) : void 0, o = e.names.filter((e) => !n.has(e) && !r?.has(e));
|
|
@@ -579,7 +587,7 @@ var Z = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${G}/types/scripting.d.ts`, J
|
|
|
579
587
|
p.set(t, m), d.push(m);
|
|
580
588
|
}
|
|
581
589
|
const m = [];
|
|
582
|
-
for (const [t, n] of u) m.push(
|
|
590
|
+
for (const [t, n] of u) m.push(F(e, t, n));
|
|
583
591
|
if (m.sort((e, t) => e.offset - t.offset), d.length > 0) {
|
|
584
592
|
const t = d.map((e) => {
|
|
585
593
|
if ("string" == typeof e) return e;
|
|
@@ -614,19 +622,19 @@ var Z = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${G}/types/scripting.d.ts`, J
|
|
|
614
622
|
text: e.text
|
|
615
623
|
});
|
|
616
624
|
}
|
|
617
|
-
const
|
|
625
|
+
const h = d.split("\n").length - 1, y = [{
|
|
618
626
|
range: g,
|
|
619
627
|
text: `${d}${u}`
|
|
620
628
|
}, ...f];
|
|
621
629
|
let b = null;
|
|
622
|
-
r.pushEditOperations([],
|
|
630
|
+
r.pushEditOperations([], y, (e) => (b = e[0].range, h > 0 && (b.startLineNumber += h, b.startColumn = 1), p && b.endLineNumber--, [new t.Selection(b.startLineNumber, b.startColumn, b.endLineNumber, b.endColumn)])), e.setSelection({
|
|
623
631
|
startLineNumber: b.endLineNumber,
|
|
624
632
|
startColumn: b.endColumn,
|
|
625
633
|
endLineNumber: b.startLineNumber,
|
|
626
634
|
endColumn: b.startColumn
|
|
627
635
|
});
|
|
628
636
|
};
|
|
629
|
-
function
|
|
637
|
+
function ne(e, t) {
|
|
630
638
|
let n = null;
|
|
631
639
|
const r = e.length;
|
|
632
640
|
for (let o = 0; !n && o < r; o++) {
|
|
@@ -635,48 +643,64 @@ function Q(e, t) {
|
|
|
635
643
|
}
|
|
636
644
|
return n ? n.getContext() : "formula";
|
|
637
645
|
}
|
|
638
|
-
function
|
|
646
|
+
function re(e, t, n, r, o = []) {
|
|
639
647
|
if ("function" === r.kind && "export" === r.kindModifiers) {
|
|
640
648
|
const t = r.spans[0].start, i = e.getPositionAt(t);
|
|
641
649
|
o.push({
|
|
642
650
|
name: r.text,
|
|
643
|
-
type:
|
|
651
|
+
type: ne(n, r),
|
|
644
652
|
lineNumber: i.lineNumber
|
|
645
653
|
});
|
|
646
654
|
}
|
|
647
|
-
if (r.childItems) for (const i of r.childItems)
|
|
655
|
+
if (r.childItems) for (const i of r.childItems) re(e, t, n, i, o);
|
|
648
656
|
return o;
|
|
649
657
|
}
|
|
650
|
-
function
|
|
658
|
+
function oe(e, t, n = "function", r) {
|
|
651
659
|
const o = e.spans, i = o.length;
|
|
652
660
|
for (let s = 0; s < i; s++) {
|
|
653
661
|
const i = o[s];
|
|
654
662
|
if (i.start <= t && t < i.start + i.length) {
|
|
655
663
|
if (e.kind === n && (!r || e.kindModifiers === r)) return e;
|
|
656
664
|
for (const o of e.childItems || []) {
|
|
657
|
-
const e =
|
|
665
|
+
const e = oe(o, t, n, r);
|
|
658
666
|
if (e) return e;
|
|
659
667
|
}
|
|
660
668
|
}
|
|
661
669
|
return null;
|
|
662
670
|
}
|
|
663
671
|
}
|
|
664
|
-
function
|
|
672
|
+
function ie(e) {
|
|
665
673
|
return "comment" === e.kind;
|
|
666
674
|
}
|
|
667
|
-
var
|
|
668
|
-
|
|
675
|
+
var se = null, ae = null, ce = null, le = null, ue = !1, de = !1, pe = !1, me = { current: null }, ge = (e, t) => {
|
|
676
|
+
ae = {
|
|
669
677
|
editor: e,
|
|
670
678
|
monaco: t
|
|
671
|
-
},
|
|
672
|
-
},
|
|
673
|
-
if (
|
|
674
|
-
|
|
675
|
-
|
|
679
|
+
}, ce && (le = ce(e, t));
|
|
680
|
+
}, fe = (e) => {
|
|
681
|
+
if (pe) return;
|
|
682
|
+
pe = !0;
|
|
683
|
+
const t = e.languages.typescript;
|
|
684
|
+
t.typescriptDefaults.setCompilerOptions({
|
|
685
|
+
...t.typescriptDefaults.getCompilerOptions(),
|
|
686
|
+
target: t.ScriptTarget.ES2020,
|
|
687
|
+
lib: [
|
|
688
|
+
"webworker",
|
|
689
|
+
"es2020",
|
|
690
|
+
"esnext.asynciterable"
|
|
691
|
+
],
|
|
692
|
+
strict: !0,
|
|
693
|
+
downlevelIteration: !0,
|
|
694
|
+
moduleResolution: t.ModuleResolutionKind.NodeJs,
|
|
695
|
+
allowSyntheticDefaultImports: !0,
|
|
696
|
+
baseUrl: "inmemory://model/",
|
|
697
|
+
allowNonTsExtensions: !0
|
|
698
|
+
}), t.typescriptDefaults.setDiagnosticsOptions({
|
|
699
|
+
noSemanticValidation: !1,
|
|
676
700
|
noSyntaxValidation: !1,
|
|
677
701
|
diagnosticCodesToIgnore: [2307]
|
|
678
|
-
}),
|
|
679
|
-
|
|
702
|
+
}), t.typescriptDefaults.setEagerModelSync(!0), null !== X && (t.typescriptDefaults.addExtraLib(X, "inmemory://model/sheetxl.d.ts"), t.typescriptDefaults.addExtraLib("declare module '@sheetxl/primitives' { export = SheetXL; }\n", "inmemory://model/sheetxl-module-shims.d.ts")), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), Q(e), ((e) => {
|
|
703
|
+
ee || (ee = !0, e.languages.registerCompletionItemProvider("typescript", {
|
|
680
704
|
triggerCharacters: ["@"],
|
|
681
705
|
provideCompletionItems: (t, n) => {
|
|
682
706
|
const r = t.getValueInRange({
|
|
@@ -750,91 +774,53 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
750
774
|
}
|
|
751
775
|
],
|
|
752
776
|
colors: {}
|
|
753
|
-
})
|
|
754
|
-
|
|
755
|
-
let
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
const r = [], o = { links: r }, i = t.getLinesContent(), s = i.length;
|
|
766
|
-
for (let n = 1; n <= s; n++) {
|
|
767
|
-
const o = i[n - 1], s = e.editor.tokenize(o, "typescript"), a = s[0].length;
|
|
768
|
-
for (let i = 0; i < a; i++) {
|
|
769
|
-
const a = s[0]?.[i];
|
|
770
|
-
if (a && a.type.startsWith("string")) {
|
|
771
|
-
let c = a.offset, l = s[0]?.[i + 1]?.offset ?? o.length, u = new e.Range(n, c + 1, n, l + 1), d = t.getValueInRange(u);
|
|
772
|
-
const p = d[0];
|
|
773
|
-
"`" !== p && "'" !== p && "\"" !== p || (c++, d = d.substring(1));
|
|
774
|
-
const m = d[d.length - 1];
|
|
775
|
-
"`" !== m && "'" !== m && "\"" !== m || (c++, d = d.substring(0, d.length - 1));
|
|
776
|
-
try {
|
|
777
|
-
ue.current?.getRanges(d) && r.push({
|
|
778
|
-
range: {
|
|
779
|
-
endColumn: l,
|
|
780
|
-
endLineNumber: n,
|
|
781
|
-
startColumn: c,
|
|
782
|
-
startLineNumber: n
|
|
783
|
-
},
|
|
784
|
-
tooltip: `Goto range '${d}'`,
|
|
785
|
-
url: `/range/${d}`
|
|
786
|
-
});
|
|
787
|
-
} catch (e) {}
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
return o;
|
|
792
|
-
} }), e.editor.registerLinkOpener({ open(e) {
|
|
793
|
-
if (e?.path?.startsWith("/range/")) {
|
|
777
|
+
}), e.languages.registerLinkProvider("*", { provideLinks: (t, n) => {
|
|
778
|
+
const r = [], o = { links: r }, i = t.getLinesContent(), s = i.length;
|
|
779
|
+
for (let n = 1; n <= s; n++) {
|
|
780
|
+
const o = i[n - 1], s = e.editor.tokenize(o, "typescript"), a = s[0].length;
|
|
781
|
+
for (let i = 0; i < a; i++) {
|
|
782
|
+
const a = s[0]?.[i];
|
|
783
|
+
if (a && a.type.startsWith("string")) {
|
|
784
|
+
let c = a.offset, l = s[0]?.[i + 1]?.offset ?? o.length, u = new e.Range(n, c + 1, n, l + 1), d = t.getValueInRange(u);
|
|
785
|
+
const p = d[0];
|
|
786
|
+
"`" !== p && "'" !== p && "\"" !== p || (c++, d = d.substring(1));
|
|
787
|
+
const m = d[d.length - 1];
|
|
788
|
+
"`" !== m && "'" !== m && "\"" !== m || (c++, d = d.substring(0, d.length - 1));
|
|
794
789
|
try {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
790
|
+
me.current?.getRanges(d) && r.push({
|
|
791
|
+
range: {
|
|
792
|
+
endColumn: l,
|
|
793
|
+
endLineNumber: n,
|
|
794
|
+
startColumn: c,
|
|
795
|
+
startLineNumber: n
|
|
796
|
+
},
|
|
797
|
+
tooltip: `Goto range '${d}'`,
|
|
798
|
+
url: `/range/${d}`
|
|
799
|
+
});
|
|
800
|
+
} catch (e) {}
|
|
800
801
|
}
|
|
801
|
-
return !1;
|
|
802
|
-
} }), !t) {
|
|
803
|
-
const t = e.languages.typescript.typescriptDefaults.getCompilerOptions();
|
|
804
|
-
e.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
805
|
-
...t,
|
|
806
|
-
target: e.languages.typescript.ScriptTarget.ES2020,
|
|
807
|
-
lib: [
|
|
808
|
-
"webworker",
|
|
809
|
-
"es2020",
|
|
810
|
-
"esnext.asynciterable"
|
|
811
|
-
],
|
|
812
|
-
strict: !0,
|
|
813
|
-
downlevelIteration: !0,
|
|
814
|
-
moduleResolution: e.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
815
|
-
allowSyntheticDefaultImports: !0,
|
|
816
|
-
baseUrl: "inmemory://model/",
|
|
817
|
-
allowNonTsExtensions: !0
|
|
818
|
-
});
|
|
819
802
|
}
|
|
820
|
-
} finally {
|
|
821
|
-
(() => {
|
|
822
|
-
const t = e.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
|
|
823
|
-
e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
824
|
-
...t,
|
|
825
|
-
noSemanticValidation: !1
|
|
826
|
-
});
|
|
827
|
-
})();
|
|
828
803
|
}
|
|
829
|
-
|
|
830
|
-
},
|
|
804
|
+
return o;
|
|
805
|
+
} }), e.editor.registerLinkOpener({ open(e) {
|
|
806
|
+
if (e?.path?.startsWith("/range/")) {
|
|
807
|
+
try {
|
|
808
|
+
me.current?.getRanges(e.path.substring(7))?.select();
|
|
809
|
+
} catch (e) {
|
|
810
|
+
console.warn("invalid range", e);
|
|
811
|
+
}
|
|
812
|
+
return !0;
|
|
813
|
+
}
|
|
814
|
+
return !1;
|
|
815
|
+
} });
|
|
816
|
+
}, he = (e) => {
|
|
831
817
|
let t = !1;
|
|
832
818
|
const n = e ? e.length : 0;
|
|
833
819
|
for (let r = 0; !t && r < n; r++) 8 === e[r].severity && (t = !0);
|
|
834
|
-
},
|
|
835
|
-
const [t, n] = s(() =>
|
|
836
|
-
return r(() => (
|
|
837
|
-
|
|
820
|
+
}, ye = () => {
|
|
821
|
+
const [t, n] = s(() => se.props);
|
|
822
|
+
return r(() => (se && (se.setProps = n), () => {
|
|
823
|
+
se && (se.setProps = null);
|
|
838
824
|
}), []), C("div", {
|
|
839
825
|
style: {
|
|
840
826
|
display: "flex",
|
|
@@ -849,11 +835,11 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
849
835
|
value: t.value,
|
|
850
836
|
onValidate: t.onValidate,
|
|
851
837
|
beforeMount: t.beforeMount,
|
|
852
|
-
onMount:
|
|
838
|
+
onMount: ge
|
|
853
839
|
}) })
|
|
854
840
|
});
|
|
855
|
-
},
|
|
856
|
-
const { className: n, style: p, readOnly: g = !1, darkMode: f, loadingPanel:
|
|
841
|
+
}, be = n(t((e, t) => {
|
|
842
|
+
const { className: n, style: p, readOnly: g = !1, darkMode: f, loadingPanel: y, autoFocus: v = !0, frame: E, scripts: M, onStatusChange: I, ...D } = e, $ = S(), R = i(null), [T, A] = s(!1), P = O(), [F] = x(["insertFunction"]), [H, U] = s({
|
|
857
843
|
message: "Loading",
|
|
858
844
|
cursor: "",
|
|
859
845
|
dirty: !1
|
|
@@ -862,55 +848,55 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
862
848
|
compiling: !1,
|
|
863
849
|
errors: [],
|
|
864
850
|
warnings: []
|
|
865
|
-
}),
|
|
851
|
+
}), J = b((e) => {
|
|
866
852
|
U((t) => {
|
|
867
853
|
const n = {
|
|
868
854
|
...t,
|
|
869
855
|
...e
|
|
870
856
|
};
|
|
871
|
-
return u.deepEqual(n, t) ? t : (
|
|
857
|
+
return u.deepEqual(n, t) ? t : (A(n.dirty ?? !1), n);
|
|
872
858
|
});
|
|
873
|
-
}, [
|
|
859
|
+
}, [I]);
|
|
874
860
|
r(() => {
|
|
875
|
-
|
|
876
|
-
}, [
|
|
877
|
-
const X =
|
|
861
|
+
I?.(H);
|
|
862
|
+
}, [I, H]);
|
|
863
|
+
const X = k(), Z = b(async (e) => {
|
|
878
864
|
let t = null, n = null;
|
|
879
865
|
try {
|
|
880
|
-
e && (n = await X.showBusy($("scriptEditor.saving")), t = await M.createModule({ source: e })), M.addModule(
|
|
866
|
+
e && (n = await X.showBusy($("scriptEditor.saving")), t = await M.createModule({ source: e })), M.addModule(j(M), t, { replace: !0 }), n?.();
|
|
881
867
|
} catch (e) {
|
|
882
868
|
n?.(), console.warn("Unable to compile", e), X.showError(e);
|
|
883
869
|
}
|
|
884
870
|
return t;
|
|
885
|
-
}, [M]),
|
|
886
|
-
if (!
|
|
887
|
-
const e =
|
|
871
|
+
}, [M]), Y = b(async () => {
|
|
872
|
+
if (!R.current || g) return;
|
|
873
|
+
const e = R.current.editor;
|
|
888
874
|
let t;
|
|
889
875
|
if (H.dirty) {
|
|
890
876
|
const n = e.getValue();
|
|
891
|
-
await
|
|
877
|
+
await Z(n), t = V(M);
|
|
892
878
|
const r = t?.getSource(), o = e.getValue(), i = (r?.length ?? 0) !== n.length || r !== o;
|
|
893
|
-
|
|
894
|
-
} else t =
|
|
879
|
+
J({ dirty: i });
|
|
880
|
+
} else t = V(M);
|
|
895
881
|
return t;
|
|
896
882
|
}, [H, M]);
|
|
897
883
|
r(() => {
|
|
898
|
-
const e = E?.addListener({ onBeforeHide: async () => (await
|
|
884
|
+
const e = E?.addListener({ onBeforeHide: async () => (await Y(), !0) });
|
|
899
885
|
return () => {
|
|
900
886
|
e?.();
|
|
901
887
|
};
|
|
902
888
|
}, [E]), r(() => {
|
|
903
|
-
if (M) return M.addListeners({ onBeforeSearch: () =>
|
|
904
|
-
}, [M]), L(
|
|
889
|
+
if (M) return M.addListeners({ onBeforeSearch: () => Y() });
|
|
890
|
+
}, [M]), L(P, {
|
|
905
891
|
onBeforeSave: async () => {
|
|
906
|
-
await
|
|
892
|
+
await Y();
|
|
907
893
|
},
|
|
908
894
|
onLoad: () => {
|
|
909
|
-
const e =
|
|
910
|
-
e && e.setValue(
|
|
895
|
+
const e = R.current?.editor;
|
|
896
|
+
e && e.setValue(V(M)?.getSource() ?? "");
|
|
911
897
|
}
|
|
912
898
|
});
|
|
913
|
-
const
|
|
899
|
+
const ee = b(async (e) => {
|
|
914
900
|
if (!M) return;
|
|
915
901
|
const t = "string" == typeof e ? { functionName: e } : e ?? {};
|
|
916
902
|
let n = null;
|
|
@@ -926,9 +912,9 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
926
912
|
} catch (e) {
|
|
927
913
|
X.showError(e);
|
|
928
914
|
}
|
|
929
|
-
}, [M, X]), [
|
|
930
|
-
if (!
|
|
931
|
-
const e =
|
|
915
|
+
}, [M, X]), [ne, ie] = s(!1), pe = b(async () => {
|
|
916
|
+
if (!R.current) return null;
|
|
917
|
+
const e = R.current, t = e.editor;
|
|
932
918
|
if (!t) return null;
|
|
933
919
|
const r = await (async (e, t, n = "export") => {
|
|
934
920
|
const r = e.getModel();
|
|
@@ -938,7 +924,7 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
938
924
|
if (!s) return null;
|
|
939
925
|
const a = s.startLineNumber === s.endLineNumber && s.startColumn === s.endColumn ? r.getLineCount() : Math.min(s.endLineNumber, r.getLineCount());
|
|
940
926
|
for (let e = s.startLineNumber; !i && e <= a; e++) {
|
|
941
|
-
const t =
|
|
927
|
+
const t = oe(o, r.getOffsetAt({
|
|
942
928
|
lineNumber: e,
|
|
943
929
|
column: 1
|
|
944
930
|
}), "function", n);
|
|
@@ -946,13 +932,13 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
946
932
|
}
|
|
947
933
|
return i;
|
|
948
934
|
})(t, e.monaco);
|
|
949
|
-
return
|
|
935
|
+
return J({ message: (r ?? "").toUpperCase() }), r ? {
|
|
950
936
|
source: t.getValue(),
|
|
951
937
|
name: r
|
|
952
938
|
} : null;
|
|
953
939
|
}, []);
|
|
954
|
-
b(d.debounce(
|
|
955
|
-
const
|
|
940
|
+
b(d.debounce(Y, 200), []);
|
|
941
|
+
const ge = b(async (e, t, n) => {
|
|
956
942
|
G((e) => ({
|
|
957
943
|
...e,
|
|
958
944
|
compiling: !0
|
|
@@ -980,7 +966,7 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
980
966
|
});
|
|
981
967
|
t.editor.setModelMarkers(e, "sheetxl", r);
|
|
982
968
|
})(e, t, o), async function(e, t, n, r) {
|
|
983
|
-
const o =
|
|
969
|
+
const o = re(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
|
|
984
970
|
let n = null, r = null;
|
|
985
971
|
return "formula" === e.type ? (n = "formula.margin-icon", r = $("scriptEditor.glyph.formula")) : "macro" === e.type ? (n = "macro.margin-icon", r = $("scriptEditor.glyph.macro")) : "autoRun" === e.type && (n = "autorun.margin-icon", r = $("scriptEditor.glyph.autoRun")), {
|
|
986
972
|
range: new t.Range(e.lineNumber, 1, e.lineNumber, 1),
|
|
@@ -999,26 +985,26 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
999
985
|
errors: o.filter((e) => "error" === e.severity).map((e) => `${e.code}: ${e.message}`),
|
|
1000
986
|
warnings: o.filter((e) => "warning" === e.severity).map((e) => `${e.code}: ${e.message}`)
|
|
1001
987
|
}));
|
|
1002
|
-
}, [M]), be = b(d.debounce(
|
|
1003
|
-
if (!
|
|
1004
|
-
const t =
|
|
1005
|
-
void 0 !== e && (n.message = e),
|
|
988
|
+
}, [M]), be = b(d.debounce(ge, 580), []), xe = b(async (e) => {
|
|
989
|
+
if (!R.current) return;
|
|
990
|
+
const t = R.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
|
|
991
|
+
void 0 !== e && (n.message = e), J(n);
|
|
1006
992
|
}, []);
|
|
1007
993
|
r(() => {}, [q]);
|
|
1008
|
-
const we = i(null),
|
|
1009
|
-
await
|
|
1010
|
-
}, [E]),
|
|
1011
|
-
const t =
|
|
994
|
+
const we = i(null), ve = b(async () => {
|
|
995
|
+
await Y(), E?.close();
|
|
996
|
+
}, [E]), ke = b((e) => {
|
|
997
|
+
const t = R.current?.editor;
|
|
1012
998
|
return !!t && (t.focus(e), !0);
|
|
1013
999
|
}, [H]), Se = b(async () => {
|
|
1014
|
-
const e =
|
|
1000
|
+
const e = R.current?.editor, t = e?.getModel(), n = e?.getSelection();
|
|
1015
1001
|
if (!t || !n) return;
|
|
1016
1002
|
const r = n.isEmpty() ? t.getLineContent(n.positionLineNumber) + "\n" : t.getValueInRange(n);
|
|
1017
1003
|
try {
|
|
1018
1004
|
await navigator.clipboard?.writeText(r);
|
|
1019
1005
|
} catch {}
|
|
1020
1006
|
}, []), Ce = b(async () => {
|
|
1021
|
-
const e =
|
|
1007
|
+
const e = R.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
|
|
1022
1008
|
if (!n || !r) return;
|
|
1023
1009
|
const o = r.isEmpty() ? new e.monaco.Range(r.positionLineNumber, 1, r.positionLineNumber + 1, 1) : r, i = n.getValueInRange(o);
|
|
1024
1010
|
try {
|
|
@@ -1032,7 +1018,7 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1032
1018
|
forceMoveMarkers: !0
|
|
1033
1019
|
}]), t.pushUndoStop(), t.focus();
|
|
1034
1020
|
}, []), Ne = b(async () => {
|
|
1035
|
-
const e =
|
|
1021
|
+
const e = R.current?.editor;
|
|
1036
1022
|
if (!e) return;
|
|
1037
1023
|
let t;
|
|
1038
1024
|
try {
|
|
@@ -1048,22 +1034,28 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1048
1034
|
forceMoveMarkers: !0
|
|
1049
1035
|
}]), e.pushUndoStop(), e.focus();
|
|
1050
1036
|
}, []), Ee = i(null), Le = b((e, t) => {
|
|
1051
|
-
|
|
1037
|
+
R.current = {
|
|
1052
1038
|
monaco: t,
|
|
1053
1039
|
editor: e
|
|
1054
|
-
},
|
|
1040
|
+
}, me.current = P ?? null;
|
|
1055
1041
|
const n = e.getModel(), r = [];
|
|
1056
|
-
|
|
1057
|
-
const o =
|
|
1058
|
-
return e.getValue() !== o && e.setValue(o),
|
|
1059
|
-
xe("")
|
|
1042
|
+
ie(!0);
|
|
1043
|
+
const o = V(M)?.getSource() ?? "";
|
|
1044
|
+
return e.getValue() !== o && e.setValue(o), ue ? (xe(""), be(n, t, e), Q(t)) : (ue = !0, xe("Loading Types"), import("monaco-editor-auto-typings/custom-editor.js").then(async (n) => {
|
|
1045
|
+
xe("");
|
|
1046
|
+
const r = n.AutoTypings, o = new n.JsDelivrSourceResolver(), i = (e) => e.startsWith("@sheetxl/") || e.startsWith("@types/sheetxl__");
|
|
1047
|
+
r.create(e, {
|
|
1048
|
+
sourceResolver: {
|
|
1049
|
+
resolvePackageJson: (e, t, n) => i(e) ? Promise.resolve(void 0) : o.resolvePackageJson(e, t, n),
|
|
1050
|
+
resolveSourceFile: (e, t, n) => i(e) ? Promise.resolve(void 0) : o.resolveSourceFile(e, t, n)
|
|
1051
|
+
},
|
|
1060
1052
|
shareCache: !0,
|
|
1061
1053
|
dontAdaptEditorOptions: !0,
|
|
1062
1054
|
monaco: t,
|
|
1063
1055
|
onUpdate: (e, n) => {
|
|
1064
|
-
if ("LookedUpPackage" === e.type &&
|
|
1056
|
+
if ("LookedUpPackage" === e.type && !0 === e.success) {
|
|
1065
1057
|
const e = t.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
|
|
1066
|
-
t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
1058
|
+
e.diagnosticCodesToIgnore?.length && t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
1067
1059
|
...e,
|
|
1068
1060
|
diagnosticCodesToIgnore: []
|
|
1069
1061
|
});
|
|
@@ -1092,11 +1084,11 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1092
1084
|
e(t, B[t]);
|
|
1093
1085
|
}
|
|
1094
1086
|
B = void 0, z = !0;
|
|
1095
|
-
})(),
|
|
1087
|
+
})(), Q(t);
|
|
1096
1088
|
});
|
|
1097
1089
|
}).catch((e) => {
|
|
1098
|
-
|
|
1099
|
-
})),
|
|
1090
|
+
ue = !1, xe(""), console.warn("Auto typings could not be loaded:", e);
|
|
1091
|
+
})), de || (de = !0, function(e, t) {
|
|
1100
1092
|
t.languages.registerInlayHintsProvider("typescript", { provideInlayHints(e, n, r) {
|
|
1101
1093
|
const o = [];
|
|
1102
1094
|
for (let n = 1; n < e.getLineCount() + 1; n++) {
|
|
@@ -1125,40 +1117,40 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1125
1117
|
label: "Execute",
|
|
1126
1118
|
keybindings: [t.KeyCode.F8],
|
|
1127
1119
|
run: async (e) => {
|
|
1128
|
-
const t = await
|
|
1129
|
-
|
|
1120
|
+
const t = await pe();
|
|
1121
|
+
ee(t);
|
|
1130
1122
|
}
|
|
1131
1123
|
})), r.push(e.addAction({
|
|
1132
1124
|
id: "saveScript",
|
|
1133
1125
|
label: "Save Script",
|
|
1134
1126
|
keybindings: [t.KeyMod.CtrlCmd | t.KeyCode.KeyS],
|
|
1135
1127
|
run: (e) => {
|
|
1136
|
-
|
|
1128
|
+
Y();
|
|
1137
1129
|
}
|
|
1138
1130
|
})), r.push(e.onMouseDown(async (e) => {
|
|
1139
1131
|
if (e.target.type === t.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
|
|
1140
1132
|
e.event.browserEvent.preventDefault();
|
|
1141
|
-
const r = e.target.position.lineNumber, o = await (await (await t.languages.typescript.getTypeScriptWorker())(n.uri)).getNavigationTree(n.uri.toString()), i = await
|
|
1133
|
+
const r = e.target.position.lineNumber, o = await (await (await t.languages.typescript.getTypeScriptWorker())(n.uri)).getNavigationTree(n.uri.toString()), i = await Y();
|
|
1142
1134
|
if (!i) return;
|
|
1143
|
-
const s = i.getFunctions().getItems({ includeHidden: !0 }), a =
|
|
1135
|
+
const s = i.getFunctions().getItems({ includeHidden: !0 }), a = re(n, t, s, o).find((e) => e.lineNumber === r);
|
|
1144
1136
|
if (a) {
|
|
1145
1137
|
const t = e.event.browserEvent.button;
|
|
1146
1138
|
if (0 === t) {
|
|
1147
|
-
if ("macro" === a.type || "autoRun" === a.type)
|
|
1139
|
+
if ("macro" === a.type || "autoRun" === a.type) ee({ functionName: a.name });
|
|
1148
1140
|
else if ("formula" === a.type) {
|
|
1149
1141
|
const e = s?.find((e) => e.getName() === a.name);
|
|
1150
|
-
e &&
|
|
1142
|
+
e && F?.execute(e);
|
|
1151
1143
|
}
|
|
1152
1144
|
} else 2 === t && (console.log("Context menu for function:", a.name), e.event.browserEvent.preventDefault());
|
|
1153
1145
|
}
|
|
1154
1146
|
}
|
|
1155
1147
|
})), r.push(e.onDidChangeModelContent(() => {
|
|
1156
|
-
|
|
1148
|
+
J({ dirty: !0 }), be(n, t, e);
|
|
1157
1149
|
})), r.push(t.editor.onDidChangeMarkers((e) => {
|
|
1158
1150
|
e.some((e) => e.toString() === n.uri.toString());
|
|
1159
1151
|
})), r.push(n.onDidChangeContent((t) => {
|
|
1160
|
-
const n =
|
|
1161
|
-
|
|
1152
|
+
const n = V(M)?.getSource(), r = e.getValue(), o = (n?.length ?? 0) !== r.length || n !== r;
|
|
1153
|
+
J({ dirty: o });
|
|
1162
1154
|
})), r.push(e.onDidChangeCursorPosition((e) => {
|
|
1163
1155
|
xe();
|
|
1164
1156
|
})), () => {
|
|
@@ -1166,28 +1158,28 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1166
1158
|
e.dispose();
|
|
1167
1159
|
} catch {}
|
|
1168
1160
|
};
|
|
1169
|
-
}, [M,
|
|
1161
|
+
}, [M, P]), Me = o(() => ne ? null : y || C("div", {
|
|
1170
1162
|
style: {
|
|
1171
1163
|
position: "absolute",
|
|
1172
1164
|
width: "100%",
|
|
1173
1165
|
height: "100%"
|
|
1174
1166
|
},
|
|
1175
1167
|
children: $("scriptEditor.loading")
|
|
1176
|
-
}), [
|
|
1168
|
+
}), [ne, y]), Oe = o(() => ({
|
|
1177
1169
|
..._,
|
|
1178
1170
|
fixedOverflowWidgets: !1,
|
|
1179
1171
|
contextmenu: !1,
|
|
1180
1172
|
readOnly: g
|
|
1181
|
-
}), [g]),
|
|
1173
|
+
}), [g]), Ie = i(null);
|
|
1182
1174
|
r(() => {
|
|
1183
1175
|
const e = {
|
|
1184
1176
|
theme: f ? "extended-dark" : "extended",
|
|
1185
1177
|
options: Oe,
|
|
1186
|
-
value:
|
|
1187
|
-
beforeMount:
|
|
1188
|
-
onValidate:
|
|
1178
|
+
value: V(M)?.getSource() ?? "",
|
|
1179
|
+
beforeMount: fe,
|
|
1180
|
+
onValidate: he
|
|
1189
1181
|
}, t = ((e) => {
|
|
1190
|
-
if (
|
|
1182
|
+
if (se) return se;
|
|
1191
1183
|
if (!B) {
|
|
1192
1184
|
B = {};
|
|
1193
1185
|
const e = K.length;
|
|
@@ -1201,33 +1193,33 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1201
1193
|
const n = document.createElement("div");
|
|
1202
1194
|
n.style.width = "100%", n.style.height = "100%", n.style.display = "flex", n.style.flex = "1 1 100%", t.appendChild(n), document.body.appendChild(t);
|
|
1203
1195
|
const r = a(n);
|
|
1204
|
-
return
|
|
1196
|
+
return se = {
|
|
1205
1197
|
root: r,
|
|
1206
1198
|
hostEl: n,
|
|
1207
1199
|
stashEl: t,
|
|
1208
1200
|
props: e,
|
|
1209
1201
|
setProps: null
|
|
1210
|
-
}, r.render(C(
|
|
1202
|
+
}, r.render(C(ye, {})), se;
|
|
1211
1203
|
})(e);
|
|
1212
|
-
return t.props = e, t.setProps?.(e),
|
|
1213
|
-
|
|
1204
|
+
return t.props = e, t.setProps?.(e), ce = (e, t) => Le(e, t), Ie.current?.appendChild(t.hostEl), ae && (le = Le(ae.editor, ae.monaco)), () => {
|
|
1205
|
+
le?.(), le = null, ce = null, R.current = null, se?.stashEl.appendChild(se.hostEl);
|
|
1214
1206
|
};
|
|
1215
1207
|
}, []), r(() => {
|
|
1216
|
-
if (!
|
|
1208
|
+
if (!se) return;
|
|
1217
1209
|
const e = {
|
|
1218
|
-
...
|
|
1210
|
+
...se.props,
|
|
1219
1211
|
theme: f ? "extended-dark" : "extended",
|
|
1220
1212
|
options: Oe
|
|
1221
1213
|
};
|
|
1222
|
-
|
|
1214
|
+
se.props = e, se.setProps?.(e);
|
|
1223
1215
|
}, [f, Oe]), r(() => {
|
|
1224
|
-
const e =
|
|
1216
|
+
const e = R.current, t = e?.editor;
|
|
1225
1217
|
if (!t) return;
|
|
1226
|
-
|
|
1227
|
-
const n =
|
|
1228
|
-
t.getValue() !== n && (t.setValue(n), be(t.getModel(), e.monaco, t),
|
|
1229
|
-
}, [M,
|
|
1230
|
-
const
|
|
1218
|
+
me.current = P ?? null;
|
|
1219
|
+
const n = V(M)?.getSource() ?? "";
|
|
1220
|
+
t.getValue() !== n && (t.setValue(n), be(t.getModel(), e.monaco, t), J({ dirty: !1 }));
|
|
1221
|
+
}, [M, P]);
|
|
1222
|
+
const De = N("div", {
|
|
1231
1223
|
style: {
|
|
1232
1224
|
display: "flex",
|
|
1233
1225
|
flex: "1 1 100%",
|
|
@@ -1237,7 +1229,7 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1237
1229
|
boxSizing: "border-box"
|
|
1238
1230
|
},
|
|
1239
1231
|
children: [C("div", {
|
|
1240
|
-
ref:
|
|
1232
|
+
ref: Ie,
|
|
1241
1233
|
style: {
|
|
1242
1234
|
display: "flex",
|
|
1243
1235
|
flex: "1 1 100%",
|
|
@@ -1248,30 +1240,30 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1248
1240
|
}), $e = w(t, () => ({
|
|
1249
1241
|
isScriptEditorElement: () => !0,
|
|
1250
1242
|
showCommandPalette: () => {
|
|
1251
|
-
|
|
1243
|
+
R.current?.editor && R.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
|
|
1252
1244
|
},
|
|
1253
1245
|
getScripts: () => M,
|
|
1254
1246
|
focus: (e) => {
|
|
1255
|
-
|
|
1247
|
+
ke(e);
|
|
1256
1248
|
},
|
|
1257
|
-
close: () =>
|
|
1258
|
-
insertSnippet: (e) =>
|
|
1249
|
+
close: () => ve(),
|
|
1250
|
+
insertSnippet: (e) => R.current?.editor ? te(R.current.editor, R.current.monaco, e) : Promise.resolve(),
|
|
1259
1251
|
saveSource: async () => {
|
|
1260
|
-
await
|
|
1252
|
+
await Y();
|
|
1261
1253
|
},
|
|
1262
1254
|
runAction: (e) => {
|
|
1263
|
-
const t =
|
|
1255
|
+
const t = R.current?.editor;
|
|
1264
1256
|
t && (t.focus(), t.trigger("source", e, null));
|
|
1265
1257
|
},
|
|
1266
1258
|
copy: () => Se(),
|
|
1267
1259
|
cut: () => Ce(),
|
|
1268
1260
|
paste: () => Ne()
|
|
1269
|
-
}), [
|
|
1261
|
+
}), [P]), [Re, Te] = s(null), Ae = b((e) => {
|
|
1270
1262
|
null !== e && Te(e);
|
|
1271
|
-
}, []),
|
|
1263
|
+
}, []), Pe = h.useCommandScope();
|
|
1272
1264
|
r(() => {
|
|
1273
|
-
if (!
|
|
1274
|
-
const e =
|
|
1265
|
+
if (!Pe || !Re) return;
|
|
1266
|
+
const e = Pe.contribution();
|
|
1275
1267
|
return function(e, t) {
|
|
1276
1268
|
const n = t.scriptEditor, r = t;
|
|
1277
1269
|
e.updateCommand("scriptingHelp", { callback: () => {
|
|
@@ -1290,25 +1282,25 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1290
1282
|
}
|
|
1291
1283
|
}), e.updateCommand("copy", { callback: () => n.copy() }), e.updateCommand("cut", { callback: () => n.cut() }), e.updateCommand("paste", { callback: () => n.paste() }), e.updateCommand("selectAll", { callback: () => n.runAction("editor.action.selectAll") }), e.updateCommand("find", { callback: () => n.runAction("actions.find") }), e.updateCommand("findReplace", { callback: () => n.runAction("editor.action.startFindReplaceAction") }), e.updateCommand("goto", { callback: () => n.runAction("editor.action.gotoLine") });
|
|
1292
1284
|
}(e, {
|
|
1293
|
-
scriptEditor:
|
|
1285
|
+
scriptEditor: Re,
|
|
1294
1286
|
isDirty: T,
|
|
1295
1287
|
readOnly: g
|
|
1296
1288
|
}), () => {
|
|
1297
1289
|
e.remove();
|
|
1298
1290
|
};
|
|
1299
1291
|
}, [
|
|
1300
|
-
|
|
1301
|
-
|
|
1292
|
+
Pe,
|
|
1293
|
+
Re,
|
|
1302
1294
|
T,
|
|
1303
1295
|
g
|
|
1304
|
-
]), r(() => (
|
|
1296
|
+
]), r(() => (v && requestAnimationFrame(() => {
|
|
1305
1297
|
$e.current?.focus();
|
|
1306
1298
|
}), () => {
|
|
1307
|
-
|
|
1299
|
+
R.current?.editor && requestAnimationFrame(() => {
|
|
1308
1300
|
$e.current?.contains(document.activeElement) && $e.current?.focus();
|
|
1309
1301
|
});
|
|
1310
1302
|
}), []);
|
|
1311
|
-
const
|
|
1303
|
+
const Fe = l([$e, Ae]);
|
|
1312
1304
|
return C("div", {
|
|
1313
1305
|
className: c("script-editor", W, n),
|
|
1314
1306
|
style: {
|
|
@@ -1318,14 +1310,14 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1318
1310
|
position: "relative",
|
|
1319
1311
|
...p
|
|
1320
1312
|
},
|
|
1321
|
-
ref:
|
|
1322
|
-
...
|
|
1323
|
-
children:
|
|
1313
|
+
ref: Fe,
|
|
1314
|
+
...D,
|
|
1315
|
+
children: De
|
|
1324
1316
|
});
|
|
1325
|
-
})),
|
|
1326
|
-
|
|
1327
|
-
},
|
|
1328
|
-
const { scope: t, data: n } = e, { workbook: o } = n, i =
|
|
1317
|
+
})), xe = null, we = (e) => {
|
|
1318
|
+
xe = e;
|
|
1319
|
+
}, ve = () => xe, ke = n((e) => {
|
|
1320
|
+
const { scope: t, data: n } = e, { workbook: o } = n, i = k(), s = M(), a = s.getOpen(), c = b(async (e) => {
|
|
1329
1321
|
if (!o) return;
|
|
1330
1322
|
let t = null;
|
|
1331
1323
|
const n = o.getScripts();
|
|
@@ -1343,7 +1335,7 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1343
1335
|
return;
|
|
1344
1336
|
}
|
|
1345
1337
|
}, [o, i]), l = b(() => {
|
|
1346
|
-
const e =
|
|
1338
|
+
const e = ve();
|
|
1347
1339
|
e ? o && e({ workbook: o }) : s.getOpen().includes("scriptEditor") ? s.close("scriptEditor") : s.activate("scriptEditor", {});
|
|
1348
1340
|
}, [o, s]), u = a.includes("scriptEditor");
|
|
1349
1341
|
return r(() => {
|
|
@@ -1367,8 +1359,8 @@ var re = null, oe = null, ie = null, se = null, ae = !1, ce = !1, le = !1, ue =
|
|
|
1367
1359
|
o?.getScripts().start();
|
|
1368
1360
|
} }), null;
|
|
1369
1361
|
});
|
|
1370
|
-
|
|
1371
|
-
var
|
|
1362
|
+
ke.displayName = "WorkbookScriptCommands";
|
|
1363
|
+
var Se = {
|
|
1372
1364
|
"reason.noChangesToSave": "No changes to save",
|
|
1373
1365
|
"reason.scriptsReadOnly": "Scripts can't be changed while the workbook structure is protected.",
|
|
1374
1366
|
"scriptEditor.glyph.autoRun": "Auto Run",
|
|
@@ -1377,7 +1369,7 @@ var we = {
|
|
|
1377
1369
|
"scriptEditor.loading": "Loading...",
|
|
1378
1370
|
"scriptEditor.retry": "Retry",
|
|
1379
1371
|
"scriptEditor.saving": "Saving Scripts..."
|
|
1380
|
-
},
|
|
1372
|
+
}, Ce = [
|
|
1381
1373
|
{
|
|
1382
1374
|
sourceId: "groups",
|
|
1383
1375
|
catalog: {
|
|
@@ -1459,30 +1451,30 @@ var we = {
|
|
|
1459
1451
|
}
|
|
1460
1452
|
}
|
|
1461
1453
|
}
|
|
1462
|
-
], { DefaultCommandCatalogService:
|
|
1463
|
-
var
|
|
1454
|
+
], { DefaultCommandCatalogService: Ne } = h, Ee = !1;
|
|
1455
|
+
var Le = (e) => {
|
|
1464
1456
|
const { model: t, entryKey: n, frame: r, ref: o, ...i } = e;
|
|
1465
|
-
return C(
|
|
1457
|
+
return C(be, {
|
|
1466
1458
|
ref: o,
|
|
1467
1459
|
frame: r,
|
|
1468
1460
|
scripts: t?.getScripts(),
|
|
1469
1461
|
...i
|
|
1470
1462
|
});
|
|
1471
|
-
},
|
|
1463
|
+
}, Me = () => {
|
|
1472
1464
|
E.registerTaskPane({
|
|
1473
1465
|
key: "scriptEditor",
|
|
1474
1466
|
getTitle: () => "Script (Typescript)",
|
|
1475
1467
|
getIcon: () => "ScriptRun",
|
|
1476
|
-
component:
|
|
1468
|
+
component: Le,
|
|
1477
1469
|
keepMounted: !0
|
|
1478
1470
|
}, !0), function() {
|
|
1479
|
-
if (
|
|
1480
|
-
|
|
1481
|
-
const e =
|
|
1471
|
+
if (Ee) return;
|
|
1472
|
+
Ee = !0;
|
|
1473
|
+
const e = Ne;
|
|
1482
1474
|
e.registerFromManifest("@sheetxl/scripting-react", import.meta.url, {
|
|
1483
|
-
messages:
|
|
1484
|
-
catalogs:
|
|
1475
|
+
messages: Se,
|
|
1476
|
+
catalogs: Ce
|
|
1485
1477
|
}), e.prefetch();
|
|
1486
|
-
}(),
|
|
1478
|
+
}(), h.DefaultCommandRegistry.registerDynamic("workbook", ke);
|
|
1487
1479
|
};
|
|
1488
|
-
export {
|
|
1480
|
+
export { be as ScriptEditor, Me as ScriptingReactPlugin, ke as WorkbookScriptCommands, ve as getScriptEditorOpener, we as setScriptEditorOpener };
|