From 3a65b2b1c9a7866b64a15652dea9a92fdeb48663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Manuel=20Pi=C3=B1eiro=20Cid?= Date: Tue, 11 Mar 2025 10:05:31 +0100 Subject: [PATCH 1/2] chore: initial commit From 4915657fbc795de2bdc7660ab271729ba32a0c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Manuel=20Pi=C3=B1eiro=20Cid?= Date: Tue, 11 Mar 2025 10:14:39 +0100 Subject: [PATCH 2/2] chore: fix linting issues --- .../overlay/operations-overlay.tsx | 94 +++++++++---------- .../overlay/room-information-overlay.tsx | 6 +- .../room-components/overlay/tools-overlay.tsx | 48 +++++++++- 3 files changed, 91 insertions(+), 57 deletions(-) diff --git a/code/components/room-components/overlay/operations-overlay.tsx b/code/components/room-components/overlay/operations-overlay.tsx index 3177b56..d56b929 100644 --- a/code/components/room-components/overlay/operations-overlay.tsx +++ b/code/components/room-components/overlay/operations-overlay.tsx @@ -1,9 +1,21 @@ "use client"; import React from "react"; -import { Clipboard, Copy, Trash2, Redo2, Undo2, Group, Ungroup, MonitorDown, ImageDown } from "lucide-react"; +import { + Clipboard, + Copy, + Trash2, + Group, + Ungroup, + MonitorDown, + ImageDown, +} from "lucide-react"; import { useWeave } from "@inditextech/weavejs-react"; -import { WeaveCopyPasteNodesPlugin, WeaveExportNodeActionParams, WeaveExportStageActionParams } from "@inditextech/weavejs-sdk"; +import { + WeaveCopyPasteNodesPlugin, + WeaveExportNodeActionParams, + WeaveExportStageActionParams, +} from "@inditextech/weavejs-sdk"; import { ToolbarButton } from "../toolbar/toolbar-button"; export function OperationsOverlay() { @@ -16,9 +28,6 @@ export function OperationsOverlay() { const canCopy = useWeave((state) => state.copyPaste.canCopy); const canPaste = useWeave((state) => state.copyPaste.canPaste); - const canUndo = useWeave((state) => state.undoRedo.canUndo); - const canRedo = useWeave((state) => state.undoRedo.canRedo); - return (
@@ -46,14 +55,17 @@ export function OperationsOverlay() { tooltipSide="top" />
-
+
} disabled={isActionActive || !canCopy} onClick={() => { if (instance) { - const weaveCopyPasteNodesPlugin = instance.getPlugin("copyPasteNodes"); + const weaveCopyPasteNodesPlugin = + instance.getPlugin( + "copyPasteNodes" + ); if (weaveCopyPasteNodesPlugin) { return weaveCopyPasteNodesPlugin.copy(); } @@ -67,7 +79,10 @@ export function OperationsOverlay() { disabled={isActionActive || !canPaste} onClick={() => { if (instance) { - const weaveCopyPasteNodesPlugin = instance.getPlugin("copyPasteNodes"); + const weaveCopyPasteNodesPlugin = + instance.getPlugin( + "copyPasteNodes" + ); if (weaveCopyPasteNodesPlugin) { return weaveCopyPasteNodesPlugin.paste(); } @@ -77,47 +92,23 @@ export function OperationsOverlay() { tooltipSide="top" />
-
-
- } - disabled={isActionActive || !canUndo} - onClick={() => { - if (instance) { - const actualStore = instance.getStore(); - actualStore.undoStateStep(); - } - }} - label="Undo" - tooltipSide="top" - /> - } - disabled={isActionActive || !canRedo} - onClick={() => { - if (instance) { - const actualStore = instance.getStore(); - actualStore.redoStateStep(); - } - }} - label="Redo" - tooltipSide="top" - /> -
-
+
} disabled={selectedNodes.length !== 1} onClick={() => { if (instance && selectedNodes.length === 1) { - instance.triggerAction("exportNodeTool", { - node: selectedNodes[0].instance, - options: { - padding: 20, - pixelRatio: 2, - }, - }); + instance.triggerAction( + "exportNodeTool", + { + node: selectedNodes[0].instance, + options: { + padding: 20, + pixelRatio: 2, + }, + } + ); } }} tooltipSide="top" @@ -127,19 +118,22 @@ export function OperationsOverlay() { icon={} onClick={() => { if (instance) { - instance.triggerAction("exportStageTool", { - options: { - padding: 20, - pixelRatio: 2, - }, - }); + instance.triggerAction( + "exportStageTool", + { + options: { + padding: 20, + pixelRatio: 2, + }, + } + ); } }} tooltipSide="top" label="Export canvas as image" />
-
+
} diff --git a/code/components/room-components/overlay/room-information-overlay.tsx b/code/components/room-components/overlay/room-information-overlay.tsx index 4bd969f..f84b9d8 100644 --- a/code/components/room-components/overlay/room-information-overlay.tsx +++ b/code/components/room-components/overlay/room-information-overlay.tsx @@ -11,8 +11,10 @@ export function RoomInformationOverlay() {
-
-
{room}
+
+
+ {room} +
); diff --git a/code/components/room-components/overlay/tools-overlay.tsx b/code/components/room-components/overlay/tools-overlay.tsx index e014618..5406932 100644 --- a/code/components/room-components/overlay/tools-overlay.tsx +++ b/code/components/room-components/overlay/tools-overlay.tsx @@ -2,7 +2,17 @@ import React from "react"; import { ToolbarButton } from "../toolbar/toolbar-button"; -import { Brush, ImagePlus, PenTool, Presentation, Square, SwatchBook, Type } from "lucide-react"; +import { + Brush, + ImagePlus, + PenTool, + Presentation, + Square, + SwatchBook, + Type, + Redo2, + Undo2, +} from "lucide-react"; import { useWeave } from "@inditextech/weavejs-react"; import { Toolbar } from "../toolbar/toolbar"; @@ -12,6 +22,9 @@ export function ToolsOverlay() { const isActionActive = useWeave((state) => state.actions.active); const actualAction = useWeave((state) => state.actions.actual); + const canUndo = useWeave((state) => state.undoRedo.canUndo); + const canRedo = useWeave((state) => state.undoRedo.canRedo); + const triggerRectangleTool = React.useCallback(() => { if (instance && actualAction !== "rectangleTool") { instance.triggerAction("rectangleTool"); @@ -76,7 +89,7 @@ export function ToolsOverlay() { }, [instance, actualAction]); return ( -
+
} @@ -113,9 +126,8 @@ export function ToolsOverlay() { onClick={triggerImageTool} label="Add an image" /> -
-
-
+
+ } active={actualAction === "pantoneTool"} @@ -131,6 +143,32 @@ export function ToolsOverlay() { label="Create a workspace" /> + + } + disabled={isActionActive || !canUndo} + onClick={() => { + if (instance) { + const actualStore = instance.getStore(); + actualStore.undoStateStep(); + } + }} + label="Undo" + tooltipSide="top" + /> + } + disabled={isActionActive || !canRedo} + onClick={() => { + if (instance) { + const actualStore = instance.getStore(); + actualStore.redoStateStep(); + } + }} + label="Redo" + tooltipSide="top" + /> +
); }