@pixerate/editor 0.26.1 → 0.28.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.
- package/README.md +32 -3
- package/dist/agent/index.cjs +56 -6
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +6 -4
- package/dist/agent/index.d.ts +6 -4
- package/dist/agent/index.js +51 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/animation/index.cjs +62 -0
- package/dist/animation/index.cjs.map +1 -0
- package/dist/animation/index.d.cts +296 -0
- package/dist/animation/index.d.ts +296 -0
- package/dist/animation/index.js +62 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/{builtins-Chj6zv_O.d.ts → builtins-haN82vjT.d.ts} +33 -3
- package/dist/{builtins-CdPcLwwF.d.cts → builtins-nMXh9sT3.d.cts} +33 -3
- package/dist/canvas/index.cjs +535 -737
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +74 -291
- package/dist/canvas/index.d.ts +74 -291
- package/dist/canvas/index.js +417 -619
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-X7HXL2SB.js → chunk-3RPOW4CS.js} +342 -16
- package/dist/chunk-3RPOW4CS.js.map +1 -0
- package/dist/{chunk-UBCFIABU.js → chunk-5H2OPMXZ.js} +183 -6
- package/dist/chunk-5H2OPMXZ.js.map +1 -0
- package/dist/chunk-A6PHCAGX.cjs +87 -0
- package/dist/chunk-A6PHCAGX.cjs.map +1 -0
- package/dist/{chunk-HRMEDT2L.js → chunk-D6AVOTSD.js} +6 -85
- package/dist/chunk-D6AVOTSD.js.map +1 -0
- package/dist/chunk-HXDMZQTD.cjs +497 -0
- package/dist/chunk-HXDMZQTD.cjs.map +1 -0
- package/dist/chunk-IB3ZHQAX.js +497 -0
- package/dist/chunk-IB3ZHQAX.js.map +1 -0
- package/dist/{chunk-4BVP64JJ.cjs → chunk-K2UYKJ6M.cjs} +24 -103
- package/dist/chunk-K2UYKJ6M.cjs.map +1 -0
- package/dist/{chunk-HDYMLS3X.cjs → chunk-MC2LQN5S.cjs} +196 -19
- package/dist/chunk-MC2LQN5S.cjs.map +1 -0
- package/dist/{chunk-XQFHLT53.js → chunk-MXZJ4PKN.js} +24 -10
- package/dist/chunk-MXZJ4PKN.js.map +1 -0
- package/dist/{chunk-LN2POBHT.cjs → chunk-OYEFRO3D.cjs} +28 -14
- package/dist/chunk-OYEFRO3D.cjs.map +1 -0
- package/dist/chunk-PWJARCI4.js +637 -0
- package/dist/chunk-PWJARCI4.js.map +1 -0
- package/dist/chunk-TGD52FEZ.js +87 -0
- package/dist/chunk-TGD52FEZ.js.map +1 -0
- package/dist/chunk-TTYCN6ZH.cjs +637 -0
- package/dist/chunk-TTYCN6ZH.cjs.map +1 -0
- package/dist/{chunk-NQF32I6Z.cjs → chunk-U7VGDSNY.cjs} +463 -137
- package/dist/chunk-U7VGDSNY.cjs.map +1 -0
- package/dist/commands/index.cjs +30 -410
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +17 -397
- package/dist/commands/index.js.map +1 -1
- package/dist/{controller-CxXGOEmy.d.ts → controller-w6eRTjF8.d.cts} +67 -2
- package/dist/{controller-CxXGOEmy.d.cts → controller-w6eRTjF8.d.ts} +67 -2
- package/dist/extensions/index.cjs +25 -7
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +32 -14
- package/dist/generation/index.cjs +3 -3
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.js +3 -3
- package/dist/{index-jcJwmBYt.d.cts → index-C6gaQRH0.d.cts} +53 -4
- package/dist/{index-B273Zllk.d.ts → index-DXAv_R08.d.ts} +53 -4
- package/dist/index.cjs +57 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +132 -94
- package/dist/index.js.map +1 -1
- package/dist/spreadsheet/index.cjs +23 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +76 -3
- package/dist/spreadsheet/index.d.ts +76 -3
- package/dist/spreadsheet/index.js +28 -8
- package/dist/tokens/index.cjs +4 -2
- package/dist/tokens/index.cjs.map +1 -1
- package/dist/tokens/index.js +6 -4
- package/package.json +6 -1
- package/dist/chunk-4BVP64JJ.cjs.map +0 -1
- package/dist/chunk-HDYMLS3X.cjs.map +0 -1
- package/dist/chunk-HRMEDT2L.js.map +0 -1
- package/dist/chunk-LN2POBHT.cjs.map +0 -1
- package/dist/chunk-NQF32I6Z.cjs.map +0 -1
- package/dist/chunk-UBCFIABU.js.map +0 -1
- package/dist/chunk-X7HXL2SB.js.map +0 -1
- package/dist/chunk-XQFHLT53.js.map +0 -1
package/dist/commands/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
DEFAULT_HISTORY_SHORTCUTS,
|
|
3
|
+
createArrangeCommands,
|
|
4
|
+
createComponentCommands,
|
|
5
|
+
createHistoryCommands,
|
|
6
|
+
createShapeCommands,
|
|
7
|
+
createSpreadsheetCommands,
|
|
8
|
+
hasVariantCommands,
|
|
9
|
+
matchHistoryShortcut
|
|
10
|
+
} from "../chunk-IB3ZHQAX.js";
|
|
11
|
+
import {
|
|
12
|
+
validateJsonSchema
|
|
13
|
+
} from "../chunk-ARRTP33I.js";
|
|
14
|
+
import {
|
|
3
15
|
PLATFORMS,
|
|
4
16
|
ShortcutMap,
|
|
5
17
|
chordToString,
|
|
@@ -17,9 +29,6 @@ import {
|
|
|
17
29
|
shortcutCode,
|
|
18
30
|
toShortcutBindings
|
|
19
31
|
} from "../chunk-7DWMJCAT.js";
|
|
20
|
-
import {
|
|
21
|
-
validateJsonSchema
|
|
22
|
-
} from "../chunk-ARRTP33I.js";
|
|
23
32
|
|
|
24
33
|
// src/commands/registry.ts
|
|
25
34
|
var CommandRegistryError = class extends Error {
|
|
@@ -239,10 +248,10 @@ var CommandRegistry = class {
|
|
|
239
248
|
}
|
|
240
249
|
/** Like `execute`, but awaits async commands (rejections become `failed` results). */
|
|
241
250
|
async executeAsync(id, params, context = this.context) {
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
251
|
+
const outcome = this.execute(id, params, context);
|
|
252
|
+
if (!outcome.ok || !isThenable(outcome.result)) return outcome;
|
|
244
253
|
try {
|
|
245
|
-
const result = await
|
|
254
|
+
const result = await outcome.result;
|
|
246
255
|
this.notify();
|
|
247
256
|
return { ok: true, id, result };
|
|
248
257
|
} catch (error) {
|
|
@@ -680,396 +689,6 @@ function createCommandToolProvider(registry, options = {}) {
|
|
|
680
689
|
};
|
|
681
690
|
}
|
|
682
691
|
|
|
683
|
-
// src/commands/builtins.ts
|
|
684
|
-
var DEFAULT_HISTORY_SHORTCUTS = [
|
|
685
|
-
{ command: "undo", chord: "Mod+Z" },
|
|
686
|
-
{ command: "redo", chord: "Mod+Shift+Z" },
|
|
687
|
-
{ command: "redo", chord: "Mod+Y", platforms: ["windows", "linux"] }
|
|
688
|
-
];
|
|
689
|
-
function createHistoryCommands(history, options = {}) {
|
|
690
|
-
const prefix = options.prefix ?? "history.";
|
|
691
|
-
const group = options.group ?? "Edit";
|
|
692
|
-
const shortcutsOf = (command) => DEFAULT_HISTORY_SHORTCUTS.filter((b) => b.command === command).map(({ command: _c, ...rest }) => rest);
|
|
693
|
-
return [
|
|
694
|
-
{
|
|
695
|
-
id: `${prefix}undo`,
|
|
696
|
-
label: "Undo",
|
|
697
|
-
group,
|
|
698
|
-
keywords: ["revert", "back"],
|
|
699
|
-
description: "Reverts the last change.",
|
|
700
|
-
shortcut: shortcutsOf("undo"),
|
|
701
|
-
...options.scope ? { scope: options.scope } : {},
|
|
702
|
-
enabled: () => history.getState().canUndo ? true : "Nothing to undo.",
|
|
703
|
-
run: () => {
|
|
704
|
-
history.undo();
|
|
705
|
-
return { undone: true, state: history.getState() };
|
|
706
|
-
}
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
id: `${prefix}redo`,
|
|
710
|
-
label: "Redo",
|
|
711
|
-
group,
|
|
712
|
-
keywords: ["repeat", "forward"],
|
|
713
|
-
description: "Re-applies the last undone change.",
|
|
714
|
-
shortcut: shortcutsOf("redo"),
|
|
715
|
-
...options.scope ? { scope: options.scope } : {},
|
|
716
|
-
enabled: () => history.getState().canRedo ? true : "Nothing to redo.",
|
|
717
|
-
run: () => {
|
|
718
|
-
history.redo();
|
|
719
|
-
return { redone: true, state: history.getState() };
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
];
|
|
723
|
-
}
|
|
724
|
-
var historyShortcutMap = null;
|
|
725
|
-
function matchHistoryShortcut(event, options = {}) {
|
|
726
|
-
historyShortcutMap ??= new ShortcutMap(DEFAULT_HISTORY_SHORTCUTS);
|
|
727
|
-
return historyShortcutMap.resolve(event, options)?.command ?? null;
|
|
728
|
-
}
|
|
729
|
-
var ARRANGE_LABELS = {
|
|
730
|
-
alignLeft: "Align Left",
|
|
731
|
-
alignCenter: "Align Horizontal Centers",
|
|
732
|
-
alignRight: "Align Right",
|
|
733
|
-
alignTop: "Align Top",
|
|
734
|
-
alignMiddle: "Align Vertical Centers",
|
|
735
|
-
alignBottom: "Align Bottom",
|
|
736
|
-
distributeHorizontal: "Distribute Horizontally",
|
|
737
|
-
distributeVertical: "Distribute Vertically",
|
|
738
|
-
lock: "Lock",
|
|
739
|
-
unlock: "Unlock",
|
|
740
|
-
bringForward: "Bring Forward",
|
|
741
|
-
sendBackward: "Send Backward",
|
|
742
|
-
bringToFront: "Bring to Front",
|
|
743
|
-
sendToBack: "Send to Back",
|
|
744
|
-
nextScene: "Next Scene",
|
|
745
|
-
previousScene: "Previous Scene"
|
|
746
|
-
};
|
|
747
|
-
var IDS_PARAMS = {
|
|
748
|
-
type: "object",
|
|
749
|
-
properties: {
|
|
750
|
-
ids: {
|
|
751
|
-
type: "array",
|
|
752
|
-
items: { type: "string" },
|
|
753
|
-
description: "Node ids to act on (default: the selection)."
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
function createArrangeCommands(controller, options = {}) {
|
|
758
|
-
const prefix = options.prefix ?? "canvas.";
|
|
759
|
-
const group = options.group ?? "Arrange";
|
|
760
|
-
const scope = options.scope === null ? void 0 : options.scope ?? "canvas";
|
|
761
|
-
const bindings = options.bindings ?? DEFAULT_ARRANGE_SHORTCUTS;
|
|
762
|
-
const count = (params) => params?.ids?.length ?? options.getSelectedIds?.().length;
|
|
763
|
-
const needs = (min, what) => (_, params) => {
|
|
764
|
-
const n = count(params);
|
|
765
|
-
if (n === void 0 || n >= min) return true;
|
|
766
|
-
return min === 1 ? `Select a ${what} first.` : `Select at least ${min} ${what}s.`;
|
|
767
|
-
};
|
|
768
|
-
const run = {
|
|
769
|
-
alignLeft: (ids) => controller.align("left", ids),
|
|
770
|
-
alignCenter: (ids) => controller.align("center", ids),
|
|
771
|
-
alignRight: (ids) => controller.align("right", ids),
|
|
772
|
-
alignTop: (ids) => controller.align("top", ids),
|
|
773
|
-
alignMiddle: (ids) => controller.align("middle", ids),
|
|
774
|
-
alignBottom: (ids) => controller.align("bottom", ids),
|
|
775
|
-
distributeHorizontal: (ids) => controller.distribute("horizontal", "gaps", ids),
|
|
776
|
-
distributeVertical: (ids) => controller.distribute("vertical", "gaps", ids),
|
|
777
|
-
lock: (ids) => controller.lock(ids),
|
|
778
|
-
unlock: (ids) => controller.unlock(ids),
|
|
779
|
-
bringForward: (ids) => controller.reorder("bringForward", ids),
|
|
780
|
-
sendBackward: (ids) => controller.reorder("sendBackward", ids),
|
|
781
|
-
bringToFront: (ids) => controller.reorder("bringToFront", ids),
|
|
782
|
-
sendToBack: (ids) => controller.reorder("sendToBack", ids),
|
|
783
|
-
nextScene: () => options.scenes?.next(),
|
|
784
|
-
previousScene: () => options.scenes?.previous()
|
|
785
|
-
};
|
|
786
|
-
const actions = Object.keys(ARRANGE_LABELS);
|
|
787
|
-
return actions.filter((action) => options.scenes || action !== "nextScene" && action !== "previousScene").map((action) => {
|
|
788
|
-
const isScene = action === "nextScene" || action === "previousScene";
|
|
789
|
-
const enabled = isScene ? void 0 : action.startsWith("align") ? needs(2, "node") : action.startsWith("distribute") ? needs(3, "node") : needs(1, "node");
|
|
790
|
-
return {
|
|
791
|
-
id: `${prefix}${action}`,
|
|
792
|
-
label: ARRANGE_LABELS[action],
|
|
793
|
-
group: isScene ? "Scenes" : group,
|
|
794
|
-
keywords: isScene ? ["scene", "slide", "page"] : action.startsWith("align") ? ["align"] : ["arrange", "layer", "order"],
|
|
795
|
-
...scope ? { scope } : {},
|
|
796
|
-
shortcut: bindings.filter((b) => b.action === action).map((b) => b.label),
|
|
797
|
-
...isScene ? {} : { params: IDS_PARAMS },
|
|
798
|
-
...enabled ? { enabled } : {},
|
|
799
|
-
run: (_ctx, params) => run[action](params?.ids)
|
|
800
|
-
};
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
var SHAPE_COMMANDS = [
|
|
804
|
-
{ op: "unite", label: "Unite Shapes", keywords: ["union", "merge", "boolean", "combine"] },
|
|
805
|
-
{ op: "intersect", label: "Intersect Shapes", keywords: ["intersection", "boolean", "combine"] },
|
|
806
|
-
{ op: "subtract", label: "Subtract Shapes", keywords: ["difference", "minus front", "boolean", "combine"] },
|
|
807
|
-
{ op: "exclude", label: "Exclude Shapes", keywords: ["xor", "boolean", "combine"] },
|
|
808
|
-
{ op: "divide", label: "Divide Shapes", keywords: ["split", "pathfinder", "boolean"] }
|
|
809
|
-
];
|
|
810
|
-
var JOIN_PARAM = { type: "string", enum: ["miter", "round", "bevel"], description: "Corner style (default miter)." };
|
|
811
|
-
function createShapeCommands(controller, options = {}) {
|
|
812
|
-
const prefix = options.prefix ?? "canvas.";
|
|
813
|
-
const group = options.group ?? "Shape";
|
|
814
|
-
const scope = options.scope === null ? void 0 : options.scope ?? "canvas";
|
|
815
|
-
const base = { group, ...scope ? { scope } : {} };
|
|
816
|
-
const combine = SHAPE_COMMANDS.map(
|
|
817
|
-
({ op, label, keywords }) => ({
|
|
818
|
-
...base,
|
|
819
|
-
id: `${prefix}${op}`,
|
|
820
|
-
label,
|
|
821
|
-
keywords: [...keywords],
|
|
822
|
-
description: `${label.split(" ")[0]}s the selected shapes into a new path (curves are kept).`,
|
|
823
|
-
params: IDS_PARAMS,
|
|
824
|
-
enabled: (_ctx, params) => controller.canCombineShapes(params?.ids) ? true : "Select at least two unlocked shapes.",
|
|
825
|
-
run: (_ctx, params) => controller.combineShapes(op, params?.ids)
|
|
826
|
-
})
|
|
827
|
-
);
|
|
828
|
-
return [
|
|
829
|
-
...combine,
|
|
830
|
-
{
|
|
831
|
-
...base,
|
|
832
|
-
id: `${prefix}offsetPath`,
|
|
833
|
-
label: "Offset Path\u2026",
|
|
834
|
-
keywords: ["inset", "outset", "grow", "shrink", "expand", "contract"],
|
|
835
|
-
description: "Grows (positive distance) or shrinks (negative) the selected shapes.",
|
|
836
|
-
params: {
|
|
837
|
-
type: "object",
|
|
838
|
-
properties: {
|
|
839
|
-
distance: { type: "number", description: `Offset in canvas units (default ${options.defaultOffset ?? 10}).` },
|
|
840
|
-
join: JOIN_PARAM,
|
|
841
|
-
miterLimit: { type: "number", description: "Miter limit (default 4)." },
|
|
842
|
-
ids: IDS_PARAMS.properties.ids
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
enabled: (_ctx, params) => controller.canOffsetShapes(params?.ids) ? true : "Select an unlocked shape.",
|
|
846
|
-
run: (_ctx, params) => controller.offsetShapes(params?.distance ?? options.defaultOffset ?? 10, params?.ids, {
|
|
847
|
-
...params?.join ? { join: params.join } : {},
|
|
848
|
-
...params?.miterLimit !== void 0 ? { miterLimit: params.miterLimit } : {}
|
|
849
|
-
})
|
|
850
|
-
},
|
|
851
|
-
{
|
|
852
|
-
...base,
|
|
853
|
-
id: `${prefix}outlineStroke`,
|
|
854
|
-
label: "Outline Stroke",
|
|
855
|
-
keywords: ["expand stroke", "stroke to path", "convert stroke"],
|
|
856
|
-
description: "Converts the strokes of the selected shapes to filled shapes.",
|
|
857
|
-
params: {
|
|
858
|
-
type: "object",
|
|
859
|
-
properties: {
|
|
860
|
-
join: JOIN_PARAM,
|
|
861
|
-
cap: { type: "string", enum: ["butt", "round", "square"], description: "Line cap (default butt)." },
|
|
862
|
-
miterLimit: { type: "number", description: "Miter limit (default 4)." },
|
|
863
|
-
ids: IDS_PARAMS.properties.ids
|
|
864
|
-
}
|
|
865
|
-
},
|
|
866
|
-
enabled: (_ctx, params) => controller.canOutlineStroke(params?.ids) ? true : "Select an unlocked shape with a stroke.",
|
|
867
|
-
run: (_ctx, params) => controller.outlineStroke(params?.ids, {
|
|
868
|
-
...params?.join ? { join: params.join } : {},
|
|
869
|
-
...params?.cap ? { cap: params.cap } : {},
|
|
870
|
-
...params?.miterLimit !== void 0 ? { miterLimit: params.miterLimit } : {}
|
|
871
|
-
})
|
|
872
|
-
}
|
|
873
|
-
];
|
|
874
|
-
}
|
|
875
|
-
var outcome = (result) => {
|
|
876
|
-
if (!result.ok) throw new Error(result.reason);
|
|
877
|
-
return { ids: result.ids };
|
|
878
|
-
};
|
|
879
|
-
var ID_PARAM = { type: "string", description: "Instance (or layer inside one) to act on (default: the first selected node)." };
|
|
880
|
-
function createComponentCommands(controller, options = {}) {
|
|
881
|
-
const prefix = options.prefix ?? "canvas.";
|
|
882
|
-
const group = options.group ?? "Components";
|
|
883
|
-
const scope = options.scope === null ? void 0 : options.scope ?? "canvas";
|
|
884
|
-
const base = { group, ...scope ? { scope } : {} };
|
|
885
|
-
const idParams = { type: "object", properties: { id: ID_PARAM } };
|
|
886
|
-
return [
|
|
887
|
-
{
|
|
888
|
-
...base,
|
|
889
|
-
id: `${prefix}createComponent`,
|
|
890
|
-
label: "Create Component",
|
|
891
|
-
keywords: ["component", "symbol", "main component", "reusable"],
|
|
892
|
-
description: "Turns the selected frame into a main component, or wraps the selection in one.",
|
|
893
|
-
params: IDS_PARAMS,
|
|
894
|
-
shortcut: "Mod+Alt+K",
|
|
895
|
-
enabled: (_ctx, params) => controller.canCreateComponent(params?.ids),
|
|
896
|
-
run: (_ctx, params) => outcome(controller.createComponent(params?.ids))
|
|
897
|
-
},
|
|
898
|
-
{
|
|
899
|
-
...base,
|
|
900
|
-
id: `${prefix}combineAsVariants`,
|
|
901
|
-
label: "Combine as Variants",
|
|
902
|
-
keywords: ["component set", "variant", "variants"],
|
|
903
|
-
description: "Wraps the selected components in a component set.",
|
|
904
|
-
params: IDS_PARAMS,
|
|
905
|
-
enabled: (_ctx, params) => controller.canCombineAsVariants(params?.ids),
|
|
906
|
-
run: (_ctx, params) => outcome(controller.combineAsVariants(params?.ids))
|
|
907
|
-
},
|
|
908
|
-
{
|
|
909
|
-
...base,
|
|
910
|
-
id: `${prefix}createInstance`,
|
|
911
|
-
label: "Create Instance",
|
|
912
|
-
keywords: ["instance", "insert component", "use component"],
|
|
913
|
-
description: "Places an instance of a component (or a component set\u2019s default variant).",
|
|
914
|
-
params: {
|
|
915
|
-
type: "object",
|
|
916
|
-
properties: {
|
|
917
|
-
componentId: { type: "string", description: "Component or component set id." },
|
|
918
|
-
parentId: { type: "string", description: "Frame to place it in (default: the canvas)." },
|
|
919
|
-
x: { type: "number", description: "X in the parent\u2019s space (default: next to the main)." },
|
|
920
|
-
y: { type: "number", description: "Y in the parent\u2019s space." },
|
|
921
|
-
properties: { type: "object", description: "Variant and component property values.", additionalProperties: true }
|
|
922
|
-
},
|
|
923
|
-
required: ["componentId"]
|
|
924
|
-
},
|
|
925
|
-
enabled: (_ctx, params) => params?.componentId === void 0 ? true : controller.canCreateInstance(params.componentId, params.parentId),
|
|
926
|
-
run: (_ctx, params) => outcome(
|
|
927
|
-
controller.createInstance(params.componentId, {
|
|
928
|
-
...params.parentId !== void 0 ? { parentId: params.parentId } : {},
|
|
929
|
-
...params.x !== void 0 || params.y !== void 0 ? { position: { x: params.x ?? 0, y: params.y ?? 0 } } : {},
|
|
930
|
-
...params.properties ? { properties: params.properties } : {}
|
|
931
|
-
})
|
|
932
|
-
)
|
|
933
|
-
},
|
|
934
|
-
{
|
|
935
|
-
...base,
|
|
936
|
-
id: `${prefix}detachInstance`,
|
|
937
|
-
label: "Detach Instance",
|
|
938
|
-
keywords: ["unlink", "break instance"],
|
|
939
|
-
description: "Turns the selected instances into plain frames that keep their look.",
|
|
940
|
-
params: IDS_PARAMS,
|
|
941
|
-
shortcut: "Mod+Alt+B",
|
|
942
|
-
enabled: (_ctx, params) => controller.canDetachInstance(params?.ids),
|
|
943
|
-
run: (_ctx, params) => outcome(controller.detachInstance(params?.ids))
|
|
944
|
-
},
|
|
945
|
-
{
|
|
946
|
-
...base,
|
|
947
|
-
id: `${prefix}resetOverrides`,
|
|
948
|
-
label: "Reset All Changes",
|
|
949
|
-
keywords: ["reset instance", "reset overrides", "revert"],
|
|
950
|
-
description: "Resets the overrides of an instance (or of a layer, or one override group) to its main.",
|
|
951
|
-
params: {
|
|
952
|
-
type: "object",
|
|
953
|
-
properties: {
|
|
954
|
-
id: ID_PARAM,
|
|
955
|
-
group: { type: "string", description: 'One override group to reset, e.g. "data.label" or "shape.fill" (default: all).' }
|
|
956
|
-
}
|
|
957
|
-
},
|
|
958
|
-
enabled: (_ctx, params) => controller.canResetOverrides(params?.id),
|
|
959
|
-
run: (_ctx, params) => outcome(controller.resetOverrides(params?.id, params?.group))
|
|
960
|
-
},
|
|
961
|
-
{
|
|
962
|
-
...base,
|
|
963
|
-
id: `${prefix}pushOverrides`,
|
|
964
|
-
label: "Push Changes to Main Component",
|
|
965
|
-
keywords: ["push overrides", "update main component"],
|
|
966
|
-
description: "Copies the instance\u2019s overrides to its main component and every other instance.",
|
|
967
|
-
params: idParams,
|
|
968
|
-
enabled: (_ctx, params) => controller.canPushOverrides(params?.id),
|
|
969
|
-
run: (_ctx, params) => outcome(controller.pushOverrides(params?.id))
|
|
970
|
-
},
|
|
971
|
-
{
|
|
972
|
-
...base,
|
|
973
|
-
id: `${prefix}goToMainComponent`,
|
|
974
|
-
label: "Go to Main Component",
|
|
975
|
-
keywords: ["main component", "find main", "reveal"],
|
|
976
|
-
description: "Selects the main component of the selected instance.",
|
|
977
|
-
params: idParams,
|
|
978
|
-
enabled: (_ctx, params) => controller.canGoToMainComponent(params?.id),
|
|
979
|
-
run: (_ctx, params) => {
|
|
980
|
-
const main = controller.goToMainComponent(params?.id);
|
|
981
|
-
if (!main) throw new Error("The main component was not found.");
|
|
982
|
-
return { id: main };
|
|
983
|
-
}
|
|
984
|
-
},
|
|
985
|
-
{
|
|
986
|
-
...base,
|
|
987
|
-
id: `${prefix}swapInstance`,
|
|
988
|
-
label: "Swap Instance\u2026",
|
|
989
|
-
keywords: ["replace instance", "swap component"],
|
|
990
|
-
description: "Makes the selected instances show another component, keeping matching overrides.",
|
|
991
|
-
params: {
|
|
992
|
-
type: "object",
|
|
993
|
-
properties: {
|
|
994
|
-
componentId: { type: "string", description: "Component or component set to swap to." },
|
|
995
|
-
ids: IDS_PARAMS.properties.ids
|
|
996
|
-
},
|
|
997
|
-
required: ["componentId"]
|
|
998
|
-
},
|
|
999
|
-
enabled: (_ctx, params) => controller.canSwapInstance(params?.componentId, params?.ids),
|
|
1000
|
-
run: (_ctx, params) => outcome(controller.swapInstance(params.componentId, params?.ids))
|
|
1001
|
-
},
|
|
1002
|
-
{
|
|
1003
|
-
...base,
|
|
1004
|
-
id: `${prefix}setInstanceProperties`,
|
|
1005
|
-
label: "Set Instance Properties\u2026",
|
|
1006
|
-
keywords: ["variant", "switch variant", "component property", "toggle"],
|
|
1007
|
-
description: "Sets variant properties (switching variants) and component property values of the selected instances.",
|
|
1008
|
-
params: {
|
|
1009
|
-
type: "object",
|
|
1010
|
-
properties: {
|
|
1011
|
-
properties: { type: "object", description: "Property name \u2192 value (variant value, boolean, text or component id).", additionalProperties: true },
|
|
1012
|
-
ids: IDS_PARAMS.properties.ids
|
|
1013
|
-
},
|
|
1014
|
-
required: ["properties"]
|
|
1015
|
-
},
|
|
1016
|
-
enabled: (_ctx, params) => controller.canSetInstanceProperties(params?.ids),
|
|
1017
|
-
run: (_ctx, params) => outcome(controller.setInstanceProperties(params.properties, params?.ids))
|
|
1018
|
-
},
|
|
1019
|
-
{
|
|
1020
|
-
...base,
|
|
1021
|
-
id: `${prefix}restoreMainComponent`,
|
|
1022
|
-
label: "Restore Main Component",
|
|
1023
|
-
keywords: ["missing main", "recover component"],
|
|
1024
|
-
description: "Turns an instance whose main was deleted back into the main component.",
|
|
1025
|
-
params: idParams,
|
|
1026
|
-
enabled: (_ctx, params) => controller.canRestoreMainComponent(params?.id),
|
|
1027
|
-
run: (_ctx, params) => outcome(controller.restoreMainComponent(params?.id))
|
|
1028
|
-
},
|
|
1029
|
-
{
|
|
1030
|
-
...base,
|
|
1031
|
-
id: `${prefix}listComponents`,
|
|
1032
|
-
label: "List Components",
|
|
1033
|
-
keywords: ["components", "variants", "assets"],
|
|
1034
|
-
description: "Lists the components and component sets (with their variant options).",
|
|
1035
|
-
readOnly: true,
|
|
1036
|
-
run: () => controller.list()
|
|
1037
|
-
},
|
|
1038
|
-
{
|
|
1039
|
-
...base,
|
|
1040
|
-
id: `${prefix}inspectInstance`,
|
|
1041
|
-
label: "Inspect Instance",
|
|
1042
|
-
keywords: ["instance", "overrides", "properties"],
|
|
1043
|
-
description: "Describes an instance: its main, variant, property values and overrides.",
|
|
1044
|
-
params: idParams,
|
|
1045
|
-
readOnly: true,
|
|
1046
|
-
enabled: (_ctx, params) => controller.inspect(params?.id) ? true : "Select an instance.",
|
|
1047
|
-
run: (_ctx, params) => controller.inspect(params?.id) ?? null
|
|
1048
|
-
}
|
|
1049
|
-
];
|
|
1050
|
-
}
|
|
1051
|
-
function createSpreadsheetCommands(controller, options = {}) {
|
|
1052
|
-
const prefix = options.prefix ?? "spreadsheet.";
|
|
1053
|
-
const scope = options.scope === null ? void 0 : options.scope ?? "spreadsheet";
|
|
1054
|
-
const hasRange = () => controller.selectedRange ? true : "Select a range first.";
|
|
1055
|
-
const base = { group: "Table", ...scope ? { scope } : {} };
|
|
1056
|
-
return [
|
|
1057
|
-
{ ...base, id: `${prefix}toggleFilters`, label: "Toggle Filters", keywords: ["filter"], run: () => controller.toggleFilters() },
|
|
1058
|
-
{
|
|
1059
|
-
...base,
|
|
1060
|
-
id: `${prefix}clearFilters`,
|
|
1061
|
-
label: "Clear Filters",
|
|
1062
|
-
keywords: ["filter", "reset"],
|
|
1063
|
-
enabled: () => controller.getFilterState().rules.length > 0 ? true : "No filters to clear.",
|
|
1064
|
-
run: () => controller.clearFilters()
|
|
1065
|
-
},
|
|
1066
|
-
{ ...base, id: `${prefix}unhideAll`, label: "Unhide All Rows and Columns", keywords: ["show", "hidden"], run: () => controller.unhideAll() },
|
|
1067
|
-
{ ...base, id: `${prefix}mergeCells`, label: "Merge Cells", keywords: ["combine"], enabled: hasRange, run: () => controller.mergeCells() },
|
|
1068
|
-
{ ...base, id: `${prefix}unmergeCells`, label: "Unmerge Cells", keywords: ["split"], enabled: hasRange, run: () => controller.unmergeCells() },
|
|
1069
|
-
{ ...base, id: `${prefix}transposeRange`, label: "Transpose Range", keywords: ["rotate", "swap rows columns"], enabled: hasRange, run: () => controller.transposeRange() }
|
|
1070
|
-
];
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
692
|
// src/commands/animation.ts
|
|
1074
693
|
var EASING_DESCRIPTION = "Easing preset (linear, ease, ease-in, ease-out, ease-in-out, ease-in-back, ease-out-back, spring, hold) or a CSS cubic-bezier(x1, y1, x2, y2).";
|
|
1075
694
|
var VALUES = {
|
|
@@ -1267,6 +886,7 @@ export {
|
|
|
1267
886
|
formatShortcut,
|
|
1268
887
|
fuzzyMatch,
|
|
1269
888
|
fuzzyScore,
|
|
889
|
+
hasVariantCommands,
|
|
1270
890
|
isEditableEventTarget,
|
|
1271
891
|
keyToCode,
|
|
1272
892
|
matchHistoryShortcut,
|