@sheetxl/scripting-react 0.8.0-beta.1 → 0.8.0-beta.3
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/cjs/index.cjs +3 -3
- package/browser/esm/{DVwFOTQu-orFdbBG.mjs → ByQ00IVdf-MhieaE.mjs} +1 -1
- package/browser/esm/{B_Y2Mt7_n3R6KUaa.mjs → C-pWSiDCyb8QdSfE.mjs} +1 -1
- package/browser/esm/{Cls8yeIK4VLB6jx7.mjs → CeNZ9Uv3ijh9YRlu.mjs} +2 -2
- package/browser/esm/index.mjs +265 -232
- package/node/esm/index.mjs +270 -237
- package/package.json +6 -6
- package/resources/locales/de/ui.msg.json +1 -0
- package/resources/locales/en/ui.msg.json +2 -0
- package/types/src/ScriptEditorCommands.d.ts +2 -0
package/node/esm/index.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
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.3
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
import { Suspense as e, forwardRef as t,
|
|
8
|
-
import { createRoot as
|
|
9
|
-
import
|
|
10
|
-
import { mergeRefs as
|
|
11
|
-
import { CommonUtils as
|
|
7
|
+
import { Suspense as e, forwardRef as t, memo as n, useEffect as r, useMemo as o, useRef as i, useState as s } from "react";
|
|
8
|
+
import { createRoot as a } from "react-dom/client";
|
|
9
|
+
import c from "clsx";
|
|
10
|
+
import { mergeRefs as l } from "react-merge-refs";
|
|
11
|
+
import { CommonUtils as u, TimerUtils as d, defineLazyModule as p, messageKey as g } from "@sheetxl/utils";
|
|
12
12
|
import { DocTags as m } from "@sheetxl/scripting";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { jsx as
|
|
16
|
-
|
|
13
|
+
import { IScript as f } from "@sheetxl/sdk";
|
|
14
|
+
import { Command as y, lazyComponent as h, useCallbackRef as b, useCommands as w, useImperativeElement as k, useLazyRetry as x, useNotifier as v, useTranslator as S } from "@sheetxl/utils-react";
|
|
15
|
+
import { jsx as C, jsxs as N } from "react/jsx-runtime";
|
|
16
|
+
import { DefaultTaskPaneRegistry as E, useModelListener as L, useTaskPaneArea as M, useWorkbook as D } from "@sheetxl/react";
|
|
17
|
+
var O = {
|
|
17
18
|
defaultToken: "invalid",
|
|
18
19
|
tokenPostfix: ".ts",
|
|
19
20
|
keywords: [
|
|
@@ -354,7 +355,7 @@ var L = {
|
|
|
354
355
|
{ include: "common" }
|
|
355
356
|
]
|
|
356
357
|
}
|
|
357
|
-
},
|
|
358
|
+
}, T = {
|
|
358
359
|
lightbulb: { enabled: !1 },
|
|
359
360
|
tabSize: 2,
|
|
360
361
|
acceptSuggestionOnCommitCharacter: !0,
|
|
@@ -417,8 +418,11 @@ var L = {
|
|
|
417
418
|
wordWrapColumn: 80,
|
|
418
419
|
wordWrapMinified: !0,
|
|
419
420
|
wrappingIndent: "none"
|
|
420
|
-
},
|
|
421
|
-
|
|
421
|
+
}, A = "_script-editor_1kuph_5", R = (e) => {
|
|
422
|
+
const t = e?.getModules();
|
|
423
|
+
return t ? (t.getByName(f.DEFAULT_MODULE), f.DEFAULT_MODULE) : f.DEFAULT_MODULE;
|
|
424
|
+
}, I = (e) => e?.getModules()?.getByName(R(e)) ?? null;
|
|
425
|
+
var F, P = p("scripting-react:monaco", async () => (function() {
|
|
422
426
|
if ("undefined" == typeof window) return;
|
|
423
427
|
const e = window;
|
|
424
428
|
if (e.__sxlDefineShim) return;
|
|
@@ -438,14 +442,31 @@ var D, T = n(async () => (function() {
|
|
|
438
442
|
} catch {}
|
|
439
443
|
}
|
|
440
444
|
});
|
|
441
|
-
}(), import("@monaco-editor/react"))
|
|
442
|
-
|
|
443
|
-
|
|
445
|
+
}(), import("@monaco-editor/react")), { prefetch: !1 }), _ = ({ error: e }) => {
|
|
446
|
+
const t = x(), n = S();
|
|
447
|
+
return N("div", {
|
|
448
|
+
style: {
|
|
449
|
+
display: "flex",
|
|
450
|
+
flexDirection: "column",
|
|
451
|
+
alignItems: "center",
|
|
452
|
+
justifyContent: "center",
|
|
453
|
+
gap: "8px",
|
|
454
|
+
flex: "1 1 100%"
|
|
455
|
+
},
|
|
456
|
+
children: [C("span", { children: e instanceof Error ? e.message : String(e) }), t ? C("button", {
|
|
457
|
+
type: "button",
|
|
458
|
+
onClick: t,
|
|
459
|
+
children: n("scriptEditor.retry")
|
|
460
|
+
}) : null]
|
|
461
|
+
});
|
|
462
|
+
}, $ = h(P.load, { renderError: (e) => C(_, { error: e }) }), W = ["define", "require"], V = !1, B = "@0.8.0-beta.3";
|
|
463
|
+
"@local" !== B && "@0.0.0" !== B || (B = "");
|
|
464
|
+
var U = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${B}/types/scripting.d.ts`, j = (e) => {
|
|
444
465
|
try {
|
|
445
|
-
e.languages.setMonarchTokensProvider("typescript",
|
|
466
|
+
e.languages.setMonarchTokensProvider("typescript", O);
|
|
446
467
|
} catch (e) {}
|
|
447
|
-
},
|
|
448
|
-
function
|
|
468
|
+
}, H = !1;
|
|
469
|
+
function K(e, t) {
|
|
449
470
|
let n = null;
|
|
450
471
|
const r = e.length;
|
|
451
472
|
for (let o = 0; !n && o < r; o++) {
|
|
@@ -454,48 +475,48 @@ function W(e, t) {
|
|
|
454
475
|
}
|
|
455
476
|
return n ? n.getContext() : "formula";
|
|
456
477
|
}
|
|
457
|
-
function
|
|
478
|
+
function q(e, t, n, r, o = []) {
|
|
458
479
|
if ("function" === r.kind && "export" === r.kindModifiers) {
|
|
459
480
|
const t = r.spans[0].start, i = e.getPositionAt(t);
|
|
460
481
|
o.push({
|
|
461
482
|
name: r.text,
|
|
462
|
-
type:
|
|
483
|
+
type: K(n, r),
|
|
463
484
|
lineNumber: i.lineNumber
|
|
464
485
|
});
|
|
465
486
|
}
|
|
466
|
-
if (r.childItems) for (const i of r.childItems)
|
|
487
|
+
if (r.childItems) for (const i of r.childItems) q(e, t, n, i, o);
|
|
467
488
|
return o;
|
|
468
489
|
}
|
|
469
|
-
function
|
|
490
|
+
function z(e, t, n = "function", r) {
|
|
470
491
|
const o = e.spans, i = o.length;
|
|
471
492
|
for (let s = 0; s < i; s++) {
|
|
472
493
|
const i = o[s];
|
|
473
494
|
if (i.start <= t && t < i.start + i.length) {
|
|
474
495
|
if (e.kind === n && (!r || e.kindModifiers === r)) return e;
|
|
475
496
|
for (const o of e.childItems || []) {
|
|
476
|
-
const e =
|
|
497
|
+
const e = z(o, t, n, r);
|
|
477
498
|
if (e) return e;
|
|
478
499
|
}
|
|
479
500
|
}
|
|
480
501
|
return null;
|
|
481
502
|
}
|
|
482
503
|
}
|
|
483
|
-
function
|
|
504
|
+
function G(e) {
|
|
484
505
|
return "comment" === e.kind;
|
|
485
506
|
}
|
|
486
|
-
var
|
|
487
|
-
|
|
507
|
+
var Z = null, J = null, X = null, Y = null, Q = !1, ee = !1, te = !1, ne = { current: null }, re = (e, t) => {
|
|
508
|
+
J = {
|
|
488
509
|
editor: e,
|
|
489
510
|
monaco: t
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
if (
|
|
493
|
-
|
|
511
|
+
}, X && (Y = X(e, t));
|
|
512
|
+
}, oe = (e) => {
|
|
513
|
+
if (te) return;
|
|
514
|
+
te = !0, e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
494
515
|
noSemanticValidation: !0,
|
|
495
516
|
noSyntaxValidation: !1,
|
|
496
517
|
diagnosticCodesToIgnore: [2307]
|
|
497
|
-
}), e.languages.typescript.typescriptDefaults.setEagerModelSync(!0), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }),
|
|
498
|
-
|
|
518
|
+
}), e.languages.typescript.typescriptDefaults.setEagerModelSync(!0), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), j(e), ((e) => {
|
|
519
|
+
H || (H = !0, e.languages.registerCompletionItemProvider("typescript", {
|
|
499
520
|
triggerCharacters: ["@"],
|
|
500
521
|
provideCompletionItems: (t, n) => {
|
|
501
522
|
const r = t.getValueInRange({
|
|
@@ -573,7 +594,7 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
573
594
|
(async () => {
|
|
574
595
|
let t = !1;
|
|
575
596
|
try {
|
|
576
|
-
const n = await (async () => await (await fetch(
|
|
597
|
+
const n = await (async () => await (await fetch(U)).text())(), r = e.Uri.parse("inmemory://model/\"sheetxl-models\".d.ts");
|
|
577
598
|
let o = e.editor.getModel(r);
|
|
578
599
|
o ? t = !0 : o = e.editor.createModel(n, "typescript", r), e.editor.setModelMarkers(o, "default", []);
|
|
579
600
|
} catch (e) {
|
|
@@ -593,7 +614,7 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
593
614
|
const g = d[d.length - 1];
|
|
594
615
|
"`" !== g && "'" !== g && "\"" !== g || (c++, d = d.substring(0, d.length - 1));
|
|
595
616
|
try {
|
|
596
|
-
|
|
617
|
+
ne.current?.getRanges(d) && r.push({
|
|
597
618
|
range: {
|
|
598
619
|
endColumn: l,
|
|
599
620
|
endLineNumber: n,
|
|
@@ -611,7 +632,7 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
611
632
|
} }), e.editor.registerLinkOpener({ open(e) {
|
|
612
633
|
if (e?.path?.startsWith("/range/")) {
|
|
613
634
|
try {
|
|
614
|
-
|
|
635
|
+
ne.current?.getRanges(e.path.substring(7))?.select();
|
|
615
636
|
} catch (e) {
|
|
616
637
|
console.warn("invalid range", e);
|
|
617
638
|
}
|
|
@@ -628,6 +649,7 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
628
649
|
"es2020",
|
|
629
650
|
"esnext.asynciterable"
|
|
630
651
|
],
|
|
652
|
+
strict: !0,
|
|
631
653
|
downlevelIteration: !0,
|
|
632
654
|
moduleResolution: e.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
633
655
|
allowSyntheticDefaultImports: !0,
|
|
@@ -645,105 +667,105 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
645
667
|
})();
|
|
646
668
|
}
|
|
647
669
|
})();
|
|
648
|
-
},
|
|
670
|
+
}, ie = (e) => {
|
|
649
671
|
let t = !1;
|
|
650
672
|
const n = e ? e.length : 0;
|
|
651
673
|
for (let r = 0; !t && r < n; r++) 8 === e[r].severity && (t = !0);
|
|
652
|
-
},
|
|
653
|
-
const [t, n] =
|
|
654
|
-
return
|
|
655
|
-
|
|
656
|
-
}), []),
|
|
674
|
+
}, se = () => {
|
|
675
|
+
const [t, n] = s(() => Z.props);
|
|
676
|
+
return r(() => (Z && (Z.setProps = n), () => {
|
|
677
|
+
Z && (Z.setProps = null);
|
|
678
|
+
}), []), C("div", {
|
|
657
679
|
style: {
|
|
658
680
|
display: "flex",
|
|
659
681
|
flex: "1 1 100%",
|
|
660
682
|
width: "100%",
|
|
661
683
|
height: "100%"
|
|
662
684
|
},
|
|
663
|
-
children:
|
|
685
|
+
children: C(e, { children: C($, {
|
|
664
686
|
theme: t.theme,
|
|
665
687
|
options: t.options,
|
|
666
688
|
language: "typescript",
|
|
667
689
|
value: t.value,
|
|
668
690
|
onValidate: t.onValidate,
|
|
669
691
|
beforeMount: t.beforeMount,
|
|
670
|
-
onMount:
|
|
692
|
+
onMount: re
|
|
671
693
|
}) })
|
|
672
694
|
});
|
|
673
|
-
},
|
|
674
|
-
const { className: n, style:
|
|
695
|
+
}, ae = n(t((e, t) => {
|
|
696
|
+
const { className: n, style: p, readOnly: m = !1, darkMode: f, loadingPanel: h, autoFocus: x = !0, frame: E, scripts: M, onStatusChange: O, ...P } = e, _ = S(), $ = i(null), [B, U] = s(!1), H = D(), [K] = w(["insertFunction"]), [te, re] = s({
|
|
675
697
|
message: "Loading",
|
|
676
698
|
cursor: "",
|
|
677
699
|
dirty: !1
|
|
678
|
-
}), [
|
|
700
|
+
}), [ae, ce] = s({
|
|
679
701
|
loading: !1,
|
|
680
702
|
compiling: !1,
|
|
681
703
|
errors: [],
|
|
682
704
|
warnings: []
|
|
683
|
-
}),
|
|
684
|
-
|
|
705
|
+
}), le = b((e) => {
|
|
706
|
+
re((t) => {
|
|
685
707
|
const n = {
|
|
686
708
|
...t,
|
|
687
709
|
...e
|
|
688
710
|
};
|
|
689
|
-
return
|
|
711
|
+
return u.deepEqual(n, t) ? t : (U(n.dirty ?? !1), n);
|
|
690
712
|
});
|
|
691
|
-
}, [
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}, [
|
|
695
|
-
const
|
|
713
|
+
}, [O]);
|
|
714
|
+
r(() => {
|
|
715
|
+
O?.(te);
|
|
716
|
+
}, [O, te]);
|
|
717
|
+
const ue = v(), de = b(async (e) => {
|
|
696
718
|
let t = null, n = null;
|
|
697
719
|
try {
|
|
698
|
-
e && (n = await
|
|
720
|
+
e && (n = await ue.showBusy(_("scriptEditor.saving")), t = await M.createModule({ source: e })), M.addModule(R(M), t, { replace: !0 }), n?.();
|
|
699
721
|
} catch (e) {
|
|
700
|
-
n?.(), console.warn("Unable to compile", e),
|
|
722
|
+
n?.(), console.warn("Unable to compile", e), ue.showError(e);
|
|
701
723
|
}
|
|
702
724
|
return t;
|
|
703
|
-
}, [
|
|
704
|
-
if (
|
|
705
|
-
const e =
|
|
725
|
+
}, [M]), pe = b(async () => {
|
|
726
|
+
if (!$.current || m) return;
|
|
727
|
+
const e = $.current.editor;
|
|
706
728
|
let t;
|
|
707
|
-
if (
|
|
729
|
+
if (te.dirty) {
|
|
708
730
|
const n = e.getValue();
|
|
709
|
-
await
|
|
731
|
+
await de(n), t = I(M);
|
|
710
732
|
const r = t?.getSource(), o = e.getValue(), i = (r?.length ?? 0) !== n.length || r !== o;
|
|
711
|
-
|
|
712
|
-
} else t =
|
|
733
|
+
le({ dirty: i });
|
|
734
|
+
} else t = I(M);
|
|
713
735
|
return t;
|
|
714
|
-
}, [
|
|
715
|
-
|
|
716
|
-
const e =
|
|
736
|
+
}, [te, M]);
|
|
737
|
+
r(() => {
|
|
738
|
+
const e = E?.addListener({ onBeforeHide: async () => (await pe(), !0) });
|
|
717
739
|
return () => {
|
|
718
740
|
e?.();
|
|
719
741
|
};
|
|
720
|
-
}, [
|
|
721
|
-
if (
|
|
722
|
-
}, [
|
|
742
|
+
}, [E]), r(() => {
|
|
743
|
+
if (M) return M.addListeners({ onBeforeSearch: () => pe() });
|
|
744
|
+
}, [M]), L(H, {
|
|
723
745
|
onBeforeSave: async () => {
|
|
724
|
-
await
|
|
746
|
+
await pe();
|
|
725
747
|
},
|
|
726
748
|
onLoad: () => {
|
|
727
|
-
const e =
|
|
728
|
-
e && e.setValue(
|
|
749
|
+
const e = $.current?.editor;
|
|
750
|
+
e && e.setValue(I(M)?.getSource() ?? "");
|
|
729
751
|
}
|
|
730
752
|
});
|
|
731
|
-
const
|
|
732
|
-
if (!
|
|
753
|
+
const ge = b(async (e) => {
|
|
754
|
+
if (!M) return;
|
|
733
755
|
const t = "string" == typeof e ? { functionName: e } : e ?? {};
|
|
734
756
|
let n = null;
|
|
735
757
|
if (t?.declaration || t?.functionName) {
|
|
736
758
|
const e = t.declaration ? t.declaration.getName() : t.functionName;
|
|
737
|
-
(await
|
|
759
|
+
(await M.searchFunctions({ name: e })).length > 0 && (n = e);
|
|
738
760
|
}
|
|
739
761
|
if (n) try {
|
|
740
|
-
await
|
|
762
|
+
await M.executeMacro(n);
|
|
741
763
|
} catch (e) {
|
|
742
|
-
|
|
764
|
+
ue.showError(e);
|
|
743
765
|
}
|
|
744
|
-
}, [
|
|
745
|
-
if (
|
|
746
|
-
const e =
|
|
766
|
+
}, [M, ue]), [me, fe] = s(!1), ye = b(async () => {
|
|
767
|
+
if (!$.current) return null;
|
|
768
|
+
const e = $.current, t = e.editor;
|
|
747
769
|
if (!t) return null;
|
|
748
770
|
const r = await (async (e, t, n = "export") => {
|
|
749
771
|
const r = e.getModel();
|
|
@@ -753,7 +775,7 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
753
775
|
if (!s) return null;
|
|
754
776
|
const a = s.startLineNumber === s.endLineNumber && s.startColumn === s.endColumn ? r.getLineCount() : Math.min(s.endLineNumber, r.getLineCount());
|
|
755
777
|
for (let e = s.startLineNumber; !i && e <= a; e++) {
|
|
756
|
-
const t =
|
|
778
|
+
const t = z(o, r.getOffsetAt({
|
|
757
779
|
lineNumber: e,
|
|
758
780
|
column: 1
|
|
759
781
|
}), "function", n);
|
|
@@ -761,25 +783,25 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
761
783
|
}
|
|
762
784
|
return i;
|
|
763
785
|
})(t, e.monaco);
|
|
764
|
-
return
|
|
786
|
+
return le({ message: (r ?? "").toUpperCase() }), r ? {
|
|
765
787
|
source: t.getValue(),
|
|
766
788
|
name: r
|
|
767
789
|
} : null;
|
|
768
790
|
}, []);
|
|
769
|
-
|
|
770
|
-
const
|
|
771
|
-
|
|
791
|
+
b(d.debounce(pe, 200), []);
|
|
792
|
+
const he = b(async (e, t, n) => {
|
|
793
|
+
ce((e) => ({
|
|
772
794
|
...e,
|
|
773
795
|
compiling: !0
|
|
774
796
|
}));
|
|
775
797
|
let r = null;
|
|
776
798
|
try {
|
|
777
|
-
if (r = await
|
|
799
|
+
if (r = await M.createModule({
|
|
778
800
|
source: n?.getValue(),
|
|
779
801
|
declarationsOnly: !0
|
|
780
802
|
}), !r) return;
|
|
781
803
|
} catch (e) {}
|
|
782
|
-
const o = r ? r.getDiagnostics() :
|
|
804
|
+
const o = r ? r.getDiagnostics() : u.EmptyArray;
|
|
783
805
|
(function(e, t, n) {
|
|
784
806
|
const r = (n ?? []).map((n) => {
|
|
785
807
|
const r = e.getPositionAt(n.start), o = e.getPositionAt(n.start + Math.max(n.length, 1));
|
|
@@ -795,9 +817,9 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
795
817
|
});
|
|
796
818
|
t.editor.setModelMarkers(e, "sheetxl", r);
|
|
797
819
|
})(e, t, o), async function(e, t, n, r) {
|
|
798
|
-
const o =
|
|
820
|
+
const o = q(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
|
|
799
821
|
let n = null, r = null;
|
|
800
|
-
return "formula" === e.type ? (n = "formula.margin-icon", r =
|
|
822
|
+
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")), {
|
|
801
823
|
range: new t.Range(e.lineNumber, 1, e.lineNumber, 1),
|
|
802
824
|
options: {
|
|
803
825
|
isWholeLine: !1,
|
|
@@ -807,33 +829,33 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
807
829
|
}
|
|
808
830
|
};
|
|
809
831
|
});
|
|
810
|
-
|
|
811
|
-
}(e, t, n, r ? r.getFunctions().getItems() :
|
|
832
|
+
Ee.current && Ee.current.clear(), Ee.current = n.createDecorationsCollection(o);
|
|
833
|
+
}(e, t, n, r ? r.getFunctions().getItems() : u.EmptyArray), ce((e) => ({
|
|
812
834
|
...e,
|
|
813
835
|
compiling: !1,
|
|
814
836
|
errors: o.filter((e) => "error" === e.severity).map((e) => `${e.code}: ${e.message}`),
|
|
815
837
|
warnings: o.filter((e) => "warning" === e.severity).map((e) => `${e.code}: ${e.message}`)
|
|
816
838
|
}));
|
|
817
|
-
}, [
|
|
818
|
-
if (
|
|
819
|
-
const t =
|
|
820
|
-
void 0 !== e && (n.message = e),
|
|
839
|
+
}, [M]), be = b(d.debounce(he, 580), []), we = b(async (e) => {
|
|
840
|
+
if (!$.current) return;
|
|
841
|
+
const t = $.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
|
|
842
|
+
void 0 !== e && (n.message = e), le(n);
|
|
821
843
|
}, []);
|
|
822
|
-
|
|
823
|
-
const
|
|
824
|
-
await
|
|
825
|
-
}, [
|
|
826
|
-
const t =
|
|
844
|
+
r(() => {}, [ae]);
|
|
845
|
+
const ke = i(null), xe = b(async () => {
|
|
846
|
+
await pe(), E?.close();
|
|
847
|
+
}, [E]), ve = b((e) => {
|
|
848
|
+
const t = $.current?.editor;
|
|
827
849
|
return !!t && (t.focus(e), !0);
|
|
828
|
-
}, [
|
|
829
|
-
const e =
|
|
850
|
+
}, [te]), Se = b(async () => {
|
|
851
|
+
const e = $.current?.editor, t = e?.getModel(), n = e?.getSelection();
|
|
830
852
|
if (!t || !n) return;
|
|
831
853
|
const r = n.isEmpty() ? t.getLineContent(n.positionLineNumber) + "\n" : t.getValueInRange(n);
|
|
832
854
|
try {
|
|
833
855
|
await navigator.clipboard?.writeText(r);
|
|
834
856
|
} catch {}
|
|
835
|
-
}, []),
|
|
836
|
-
const e =
|
|
857
|
+
}, []), Ce = b(async () => {
|
|
858
|
+
const e = $.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
|
|
837
859
|
if (!n || !r) return;
|
|
838
860
|
const o = r.isEmpty() ? new e.monaco.Range(r.positionLineNumber, 1, r.positionLineNumber + 1, 1) : r, i = n.getValueInRange(o);
|
|
839
861
|
try {
|
|
@@ -846,8 +868,8 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
846
868
|
text: "",
|
|
847
869
|
forceMoveMarkers: !0
|
|
848
870
|
}]), t.pushUndoStop(), t.focus();
|
|
849
|
-
}, []),
|
|
850
|
-
const e =
|
|
871
|
+
}, []), Ne = b(async () => {
|
|
872
|
+
const e = $.current?.editor;
|
|
851
873
|
if (!e) return;
|
|
852
874
|
let t;
|
|
853
875
|
try {
|
|
@@ -862,16 +884,16 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
862
884
|
text: t,
|
|
863
885
|
forceMoveMarkers: !0
|
|
864
886
|
}]), e.pushUndoStop(), e.focus();
|
|
865
|
-
}, []),
|
|
866
|
-
|
|
887
|
+
}, []), Ee = i(null), Le = b((e, t) => {
|
|
888
|
+
$.current = {
|
|
867
889
|
monaco: t,
|
|
868
890
|
editor: e
|
|
869
|
-
},
|
|
891
|
+
}, ne.current = H ?? null;
|
|
870
892
|
const n = e.getModel(), r = [];
|
|
871
|
-
|
|
872
|
-
const o =
|
|
873
|
-
return e.getValue() !== o && e.setValue(o),
|
|
874
|
-
|
|
893
|
+
fe(!0);
|
|
894
|
+
const o = I(M)?.getSource() ?? "";
|
|
895
|
+
return e.getValue() !== o && e.setValue(o), Q ? (we(""), be(n, t, e), j(t)) : (Q = !0, we("Loading Types"), import("monaco-editor-auto-typings/custom-editor.js").then(async (n) => {
|
|
896
|
+
we(""), n.AutoTypings.create(e, {
|
|
875
897
|
shareCache: !0,
|
|
876
898
|
dontAdaptEditorOptions: !0,
|
|
877
899
|
monaco: t,
|
|
@@ -888,8 +910,8 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
888
910
|
"Not implemented yet" === e && (e = "Compile Errors"), console.warn("Error compiling types", e);
|
|
889
911
|
}
|
|
890
912
|
}).then((n) => {
|
|
891
|
-
|
|
892
|
-
if (
|
|
913
|
+
ke.current = n, be(e.getModel(), t, e), (() => {
|
|
914
|
+
if (V) return;
|
|
893
915
|
const e = (e, t) => {
|
|
894
916
|
try {
|
|
895
917
|
if (void 0 === t) try {
|
|
@@ -901,15 +923,17 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
901
923
|
}
|
|
902
924
|
else globalThis[e] = t;
|
|
903
925
|
} catch (e) {}
|
|
904
|
-
}, t =
|
|
926
|
+
}, t = W.length;
|
|
905
927
|
for (let n = 0; n < t; n++) {
|
|
906
|
-
const t =
|
|
907
|
-
e(t,
|
|
928
|
+
const t = W[n];
|
|
929
|
+
e(t, F[t]);
|
|
908
930
|
}
|
|
909
|
-
|
|
910
|
-
})(),
|
|
931
|
+
F = void 0, V = !0;
|
|
932
|
+
})(), j(t);
|
|
911
933
|
});
|
|
912
|
-
})
|
|
934
|
+
}).catch((e) => {
|
|
935
|
+
Q = !1, we(""), console.warn("Auto typings could not be loaded:", e);
|
|
936
|
+
})), ee || (ee = !0, function(e, t) {
|
|
913
937
|
t.languages.registerInlayHintsProvider("typescript", { provideInlayHints(e, n, r) {
|
|
914
938
|
const o = [];
|
|
915
939
|
for (let n = 1; n < e.getLineCount() + 1; n++) {
|
|
@@ -938,109 +962,109 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
938
962
|
label: "Execute",
|
|
939
963
|
keybindings: [t.KeyCode.F8],
|
|
940
964
|
run: async (e) => {
|
|
941
|
-
const t = await
|
|
942
|
-
|
|
965
|
+
const t = await ye();
|
|
966
|
+
ge(t);
|
|
943
967
|
}
|
|
944
968
|
})), r.push(e.addAction({
|
|
945
969
|
id: "saveScript",
|
|
946
970
|
label: "Save Script",
|
|
947
971
|
keybindings: [t.KeyMod.CtrlCmd | t.KeyCode.KeyS],
|
|
948
972
|
run: (e) => {
|
|
949
|
-
|
|
973
|
+
pe();
|
|
950
974
|
}
|
|
951
975
|
})), r.push(e.onMouseDown(async (e) => {
|
|
952
976
|
if (e.target.type === t.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
|
|
953
977
|
e.event.browserEvent.preventDefault();
|
|
954
|
-
const r = e.target.position.lineNumber, o = await (await (await t.languages.typescript.getTypeScriptWorker())(n.uri)).getNavigationTree(n.uri.toString()), i = await
|
|
978
|
+
const r = e.target.position.lineNumber, o = await (await (await t.languages.typescript.getTypeScriptWorker())(n.uri)).getNavigationTree(n.uri.toString()), i = await pe();
|
|
955
979
|
if (!i) return;
|
|
956
|
-
const s = i.getFunctions().getItems(), a =
|
|
980
|
+
const s = i.getFunctions().getItems(), a = q(n, t, s, o).find((e) => e.lineNumber === r);
|
|
957
981
|
if (a) {
|
|
958
982
|
const t = e.event.browserEvent.button;
|
|
959
983
|
if (0 === t) {
|
|
960
|
-
if ("macro" === a.type || "autoRun" === a.type)
|
|
984
|
+
if ("macro" === a.type || "autoRun" === a.type) ge({ functionName: a.name });
|
|
961
985
|
else if ("formula" === a.type) {
|
|
962
986
|
const e = s?.find((e) => e.getName() === a.name);
|
|
963
|
-
e &&
|
|
987
|
+
e && K?.execute(e);
|
|
964
988
|
}
|
|
965
989
|
} else 2 === t && (console.log("Context menu for function:", a.name), e.event.browserEvent.preventDefault());
|
|
966
990
|
}
|
|
967
991
|
}
|
|
968
992
|
})), r.push(e.onDidChangeModelContent(() => {
|
|
969
|
-
|
|
993
|
+
le({ dirty: !0 }), be(n, t, e);
|
|
970
994
|
})), r.push(t.editor.onDidChangeMarkers((e) => {
|
|
971
995
|
e.some((e) => e.toString() === n.uri.toString());
|
|
972
996
|
})), r.push(n.onDidChangeContent((t) => {
|
|
973
|
-
const n =
|
|
974
|
-
|
|
997
|
+
const n = I(M)?.getSource(), r = e.getValue(), o = (n?.length ?? 0) !== r.length || n !== r;
|
|
998
|
+
le({ dirty: o });
|
|
975
999
|
})), r.push(e.onDidChangeCursorPosition((e) => {
|
|
976
|
-
|
|
1000
|
+
we();
|
|
977
1001
|
})), () => {
|
|
978
1002
|
for (const e of r) try {
|
|
979
1003
|
e.dispose();
|
|
980
1004
|
} catch {}
|
|
981
1005
|
};
|
|
982
|
-
}, [
|
|
1006
|
+
}, [M, H]), Me = o(() => me ? null : h || C("div", {
|
|
983
1007
|
style: {
|
|
984
1008
|
position: "absolute",
|
|
985
1009
|
width: "100%",
|
|
986
1010
|
height: "100%"
|
|
987
1011
|
},
|
|
988
|
-
children:
|
|
989
|
-
}), [
|
|
990
|
-
...
|
|
1012
|
+
children: _("scriptEditor.loading")
|
|
1013
|
+
}), [me, h]), De = o(() => ({
|
|
1014
|
+
...T,
|
|
991
1015
|
fixedOverflowWidgets: !1,
|
|
992
1016
|
contextmenu: !1,
|
|
993
1017
|
readOnly: m
|
|
994
|
-
}), [m]),
|
|
995
|
-
|
|
1018
|
+
}), [m]), Oe = i(null);
|
|
1019
|
+
r(() => {
|
|
996
1020
|
const e = {
|
|
997
|
-
theme:
|
|
998
|
-
options:
|
|
999
|
-
value:
|
|
1000
|
-
beforeMount:
|
|
1001
|
-
onValidate:
|
|
1021
|
+
theme: f ? "extended-dark" : "extended",
|
|
1022
|
+
options: De,
|
|
1023
|
+
value: I(M)?.getSource() ?? "",
|
|
1024
|
+
beforeMount: oe,
|
|
1025
|
+
onValidate: ie
|
|
1002
1026
|
}, t = ((e) => {
|
|
1003
|
-
if (
|
|
1004
|
-
if (!
|
|
1005
|
-
|
|
1006
|
-
const e =
|
|
1027
|
+
if (Z) return Z;
|
|
1028
|
+
if (!F) {
|
|
1029
|
+
F = {};
|
|
1030
|
+
const e = W.length;
|
|
1007
1031
|
for (let t = 0; t < e; t++) {
|
|
1008
|
-
const e =
|
|
1009
|
-
|
|
1032
|
+
const e = W[t];
|
|
1033
|
+
F[e] = globalThis[e];
|
|
1010
1034
|
}
|
|
1011
1035
|
}
|
|
1012
1036
|
const t = document.createElement("div");
|
|
1013
1037
|
t.style.display = "none";
|
|
1014
1038
|
const n = document.createElement("div");
|
|
1015
1039
|
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);
|
|
1016
|
-
const r =
|
|
1017
|
-
return
|
|
1040
|
+
const r = a(n);
|
|
1041
|
+
return Z = {
|
|
1018
1042
|
root: r,
|
|
1019
1043
|
hostEl: n,
|
|
1020
1044
|
stashEl: t,
|
|
1021
1045
|
props: e,
|
|
1022
1046
|
setProps: null
|
|
1023
|
-
}, r.render(
|
|
1047
|
+
}, r.render(C(se, {})), Z;
|
|
1024
1048
|
})(e);
|
|
1025
|
-
return t.props = e, t.setProps?.(e),
|
|
1026
|
-
|
|
1049
|
+
return t.props = e, t.setProps?.(e), X = (e, t) => Le(e, t), Oe.current?.appendChild(t.hostEl), J && (Y = Le(J.editor, J.monaco)), () => {
|
|
1050
|
+
Y?.(), Y = null, X = null, $.current = null, Z?.stashEl.appendChild(Z.hostEl);
|
|
1027
1051
|
};
|
|
1028
|
-
}, []),
|
|
1029
|
-
if (!
|
|
1052
|
+
}, []), r(() => {
|
|
1053
|
+
if (!Z) return;
|
|
1030
1054
|
const e = {
|
|
1031
|
-
...
|
|
1032
|
-
theme:
|
|
1033
|
-
options:
|
|
1055
|
+
...Z.props,
|
|
1056
|
+
theme: f ? "extended-dark" : "extended",
|
|
1057
|
+
options: De
|
|
1034
1058
|
};
|
|
1035
|
-
|
|
1036
|
-
}, [
|
|
1037
|
-
const e =
|
|
1059
|
+
Z.props = e, Z.setProps?.(e);
|
|
1060
|
+
}, [f, De]), r(() => {
|
|
1061
|
+
const e = $.current, t = e?.editor;
|
|
1038
1062
|
if (!t) return;
|
|
1039
|
-
|
|
1040
|
-
const n =
|
|
1041
|
-
t.getValue() !== n && (t.setValue(n),
|
|
1042
|
-
}, [
|
|
1043
|
-
const
|
|
1063
|
+
ne.current = H ?? null;
|
|
1064
|
+
const n = I(M)?.getSource() ?? "";
|
|
1065
|
+
t.getValue() !== n && (t.setValue(n), be(t.getModel(), e.monaco, t), le({ dirty: !1 }));
|
|
1066
|
+
}, [M, H]);
|
|
1067
|
+
const Te = N("div", {
|
|
1044
1068
|
style: {
|
|
1045
1069
|
display: "flex",
|
|
1046
1070
|
flex: "1 1 100%",
|
|
@@ -1049,26 +1073,26 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
1049
1073
|
position: "relative",
|
|
1050
1074
|
boxSizing: "border-box"
|
|
1051
1075
|
},
|
|
1052
|
-
children: [
|
|
1053
|
-
ref:
|
|
1076
|
+
children: [C("div", {
|
|
1077
|
+
ref: Oe,
|
|
1054
1078
|
style: {
|
|
1055
1079
|
display: "flex",
|
|
1056
1080
|
flex: "1 1 100%",
|
|
1057
1081
|
width: "100%",
|
|
1058
1082
|
position: "relative"
|
|
1059
1083
|
}
|
|
1060
|
-
}),
|
|
1061
|
-
}),
|
|
1084
|
+
}), Me]
|
|
1085
|
+
}), Ae = k(t, () => ({
|
|
1062
1086
|
isScriptEditorElement: () => !0,
|
|
1063
1087
|
showCommandPalette: () => {
|
|
1064
|
-
|
|
1088
|
+
$.current?.editor && $.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
|
|
1065
1089
|
},
|
|
1066
|
-
getScripts: () =>
|
|
1090
|
+
getScripts: () => M,
|
|
1067
1091
|
focus: (e) => {
|
|
1068
|
-
|
|
1092
|
+
ve(e);
|
|
1069
1093
|
},
|
|
1070
|
-
close: () =>
|
|
1071
|
-
insertSnippet: (e) =>
|
|
1094
|
+
close: () => xe(),
|
|
1095
|
+
insertSnippet: (e) => $.current?.editor ? (async (e, t, n) => {
|
|
1072
1096
|
const r = e.getModel();
|
|
1073
1097
|
if (!r) return;
|
|
1074
1098
|
const o = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), i = e.getPosition();
|
|
@@ -1076,11 +1100,11 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
1076
1100
|
s.lineNumber = 1, s.column = 1;
|
|
1077
1101
|
let a = !1;
|
|
1078
1102
|
for (let e = i.lineNumber; e >= 1; e--) if ("" === r.getLineContent(e).trim()) {
|
|
1079
|
-
const t =
|
|
1103
|
+
const t = z(o, r.getOffsetAt({
|
|
1080
1104
|
lineNumber: e,
|
|
1081
1105
|
column: 1
|
|
1082
1106
|
}), "function");
|
|
1083
|
-
if (!t ||
|
|
1107
|
+
if (!t || G(t)) {
|
|
1084
1108
|
a = !0, s.lineNumber = e + 1;
|
|
1085
1109
|
break;
|
|
1086
1110
|
}
|
|
@@ -1104,71 +1128,78 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
1104
1128
|
endLineNumber: p.startLineNumber,
|
|
1105
1129
|
endColumn: p.startColumn
|
|
1106
1130
|
});
|
|
1107
|
-
})(
|
|
1131
|
+
})($.current.editor, $.current.monaco, e) : Promise.resolve(),
|
|
1108
1132
|
saveSource: async () => {
|
|
1109
|
-
await
|
|
1133
|
+
await pe();
|
|
1110
1134
|
},
|
|
1111
1135
|
runAction: (e) => {
|
|
1112
|
-
const t =
|
|
1136
|
+
const t = $.current?.editor;
|
|
1113
1137
|
t && (t.focus(), t.trigger("source", e, null));
|
|
1114
1138
|
},
|
|
1115
|
-
copy: () =>
|
|
1116
|
-
cut: () =>
|
|
1117
|
-
paste: () =>
|
|
1118
|
-
}), [
|
|
1119
|
-
null !== e &&
|
|
1120
|
-
}, []),
|
|
1121
|
-
return
|
|
1122
|
-
if (!
|
|
1123
|
-
const e =
|
|
1139
|
+
copy: () => Se(),
|
|
1140
|
+
cut: () => Ce(),
|
|
1141
|
+
paste: () => Ne()
|
|
1142
|
+
}), [H]), [Re, Ie] = s(null), Fe = b((e) => {
|
|
1143
|
+
null !== e && Ie(e);
|
|
1144
|
+
}, []), Pe = y.useCommandScope();
|
|
1145
|
+
return r(() => {
|
|
1146
|
+
if (!Pe || !Re) return;
|
|
1147
|
+
const e = Pe.contribution();
|
|
1124
1148
|
return function(e, t) {
|
|
1125
1149
|
const n = t.scriptEditor, r = t;
|
|
1126
1150
|
e.updateCommand("scriptingHelp", { callback: () => {
|
|
1127
1151
|
window?.open("https://www.sheetxl.com/docs/guides/concepts/scripting");
|
|
1128
1152
|
} }), e.updateCommand("showScriptingCommands", { callback: () => {
|
|
1129
1153
|
n.showCommandPalette();
|
|
1130
|
-
} })
|
|
1131
|
-
|
|
1154
|
+
} });
|
|
1155
|
+
const o = r?.readOnly ? [g("reason.scriptsReadOnly")] : [];
|
|
1156
|
+
e.updateCommand("insertScript", {
|
|
1157
|
+
disabledReasons: o,
|
|
1158
|
+
callback: (e) => n.insertSnippet(e ?? "")
|
|
1159
|
+
}), e.updateCommand("saveScripts", {
|
|
1160
|
+
disabledReasons: [...o, ...r?.isDirty ? [] : [g("reason.noChangesToSave")]],
|
|
1132
1161
|
callback: async () => {
|
|
1133
1162
|
await n.saveSource();
|
|
1134
1163
|
}
|
|
1135
1164
|
}), 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") });
|
|
1136
1165
|
}(e, {
|
|
1137
|
-
scriptEditor:
|
|
1138
|
-
isDirty:
|
|
1166
|
+
scriptEditor: Re,
|
|
1167
|
+
isDirty: B,
|
|
1168
|
+
readOnly: m
|
|
1139
1169
|
}), () => {
|
|
1140
1170
|
e.remove();
|
|
1141
1171
|
};
|
|
1142
1172
|
}, [
|
|
1173
|
+
Pe,
|
|
1143
1174
|
Re,
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
]),
|
|
1147
|
-
|
|
1175
|
+
B,
|
|
1176
|
+
m
|
|
1177
|
+
]), r(() => (x && requestAnimationFrame(() => {
|
|
1178
|
+
Ae.current?.focus();
|
|
1148
1179
|
}), () => {
|
|
1149
|
-
|
|
1150
|
-
|
|
1180
|
+
$.current?.editor && requestAnimationFrame(() => {
|
|
1181
|
+
Ae.current?.contains(document.activeElement) && Ae.current?.focus();
|
|
1151
1182
|
});
|
|
1152
|
-
}), []),
|
|
1153
|
-
className:
|
|
1183
|
+
}), []), C("div", {
|
|
1184
|
+
className: c("script-editor", A, n),
|
|
1154
1185
|
style: {
|
|
1155
1186
|
display: "flex",
|
|
1156
1187
|
flexDirection: "row",
|
|
1157
1188
|
flex: "1 1 100%",
|
|
1158
1189
|
position: "relative",
|
|
1159
|
-
...
|
|
1190
|
+
...p
|
|
1160
1191
|
},
|
|
1161
|
-
ref:
|
|
1162
|
-
|
|
1163
|
-
children:
|
|
1192
|
+
ref: l([Ae, Fe]),
|
|
1193
|
+
...P,
|
|
1194
|
+
children: Te
|
|
1164
1195
|
});
|
|
1165
|
-
})),
|
|
1166
|
-
|
|
1167
|
-
},
|
|
1168
|
-
const { scope: t, data: n } = e, { workbook:
|
|
1169
|
-
if (!
|
|
1196
|
+
})), ce = null, le = (e) => {
|
|
1197
|
+
ce = e;
|
|
1198
|
+
}, ue = () => ce, de = n((e) => {
|
|
1199
|
+
const { scope: t, data: n } = e, { workbook: o } = n, i = v(), s = M(), a = s.getOpen(), c = b(async (e) => {
|
|
1200
|
+
if (!o) return;
|
|
1170
1201
|
let t = null;
|
|
1171
|
-
const n =
|
|
1202
|
+
const n = o.getScripts();
|
|
1172
1203
|
if (e?.declaration || e?.functionName) {
|
|
1173
1204
|
const r = e.declaration ? e.declaration.getName() : e.functionName;
|
|
1174
1205
|
(await n.searchFunctions({ name: r })).length > 0 && (t = r);
|
|
@@ -1179,11 +1210,11 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
1179
1210
|
i.showError(e);
|
|
1180
1211
|
return;
|
|
1181
1212
|
}
|
|
1182
|
-
}, [
|
|
1183
|
-
const e =
|
|
1184
|
-
e ?
|
|
1185
|
-
}, [
|
|
1186
|
-
return
|
|
1213
|
+
}, [o, i]), l = b(() => {
|
|
1214
|
+
const e = ue();
|
|
1215
|
+
e ? o && e({ workbook: o }) : s.getOpen().includes("scriptEditor") ? s.close("scriptEditor") : s.activate("scriptEditor", {});
|
|
1216
|
+
}, [o, s]), u = a.includes("scriptEditor");
|
|
1217
|
+
return r(() => {
|
|
1187
1218
|
if (!t) return;
|
|
1188
1219
|
const e = t.contribution();
|
|
1189
1220
|
return e.updateCommand("showScriptEditor", {
|
|
@@ -1197,22 +1228,24 @@ var H = null, j = null, U = null, K = null, q = !1, z = !1, G = !1, Z = { curren
|
|
|
1197
1228
|
}, [
|
|
1198
1229
|
t,
|
|
1199
1230
|
u,
|
|
1200
|
-
|
|
1231
|
+
o,
|
|
1201
1232
|
c,
|
|
1202
1233
|
l
|
|
1203
|
-
]),
|
|
1204
|
-
|
|
1234
|
+
]), L(o, { onLoad: () => {
|
|
1235
|
+
o?.getScripts().start();
|
|
1205
1236
|
} }), null;
|
|
1206
1237
|
});
|
|
1207
|
-
|
|
1208
|
-
var
|
|
1238
|
+
de.displayName = "WorkbookScriptCommands";
|
|
1239
|
+
var pe = {
|
|
1209
1240
|
"reason.noChangesToSave": "No changes to save",
|
|
1241
|
+
"reason.scriptsReadOnly": "Scripts can't be changed while the workbook structure is protected.",
|
|
1210
1242
|
"scriptEditor.glyph.autoRun": "Auto Run",
|
|
1211
1243
|
"scriptEditor.glyph.formula": "Formula",
|
|
1212
1244
|
"scriptEditor.glyph.macro": "Macro",
|
|
1213
1245
|
"scriptEditor.loading": "Loading...",
|
|
1246
|
+
"scriptEditor.retry": "Retry",
|
|
1214
1247
|
"scriptEditor.saving": "Saving Scripts..."
|
|
1215
|
-
},
|
|
1248
|
+
}, ge = [
|
|
1216
1249
|
{
|
|
1217
1250
|
sourceId: "groups",
|
|
1218
1251
|
catalog: {
|
|
@@ -1294,30 +1327,30 @@ var ie = {
|
|
|
1294
1327
|
}
|
|
1295
1328
|
}
|
|
1296
1329
|
}
|
|
1297
|
-
], { DefaultCommandCatalogService:
|
|
1298
|
-
var
|
|
1330
|
+
], { DefaultCommandCatalogService: me } = y, fe = !1;
|
|
1331
|
+
var ye = (e) => {
|
|
1299
1332
|
const { model: t, entryKey: n, frame: r, ref: o, ...i } = e;
|
|
1300
|
-
return
|
|
1333
|
+
return C(ae, {
|
|
1301
1334
|
ref: o,
|
|
1302
1335
|
frame: r,
|
|
1303
1336
|
scripts: t?.getScripts(),
|
|
1304
1337
|
...i
|
|
1305
1338
|
});
|
|
1306
|
-
},
|
|
1307
|
-
|
|
1339
|
+
}, he = () => {
|
|
1340
|
+
E.registerTaskPane({
|
|
1308
1341
|
key: "scriptEditor",
|
|
1309
1342
|
getTitle: () => "Script (Typescript)",
|
|
1310
1343
|
getIcon: () => "ScriptRun",
|
|
1311
|
-
component:
|
|
1344
|
+
component: ye,
|
|
1312
1345
|
keepMounted: !0
|
|
1313
1346
|
}, !0), function() {
|
|
1314
|
-
if (
|
|
1315
|
-
|
|
1316
|
-
const e =
|
|
1347
|
+
if (fe) return;
|
|
1348
|
+
fe = !0;
|
|
1349
|
+
const e = me;
|
|
1317
1350
|
e.registerFromManifest("@sheetxl/scripting-react", import.meta.url, {
|
|
1318
|
-
messages:
|
|
1319
|
-
catalogs:
|
|
1351
|
+
messages: pe,
|
|
1352
|
+
catalogs: ge
|
|
1320
1353
|
}), e.prefetch();
|
|
1321
|
-
}(),
|
|
1354
|
+
}(), y.DefaultCommandRegistry.registerDynamic("workbook", de);
|
|
1322
1355
|
};
|
|
1323
|
-
export {
|
|
1356
|
+
export { ae as ScriptEditor, he as ScriptingReactPlugin, de as WorkbookScriptCommands, ue as getScriptEditorOpener, le as setScriptEditorOpener };
|