mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 08:57:54 +00:00
Add reset ability to 2D (#874)
This commit is contained in:
1 parent
d551e48a23
commit
1243e755fe
2 files changed
+12
-12
No files matched your search
@@ -369,7 +369,7 @@ const PageDraw = () => {
|
||||
input.click();
|
||||
}}
|
||||
onDelete={(): void => {
|
||||
store.deleteSelectedItems();
|
||||
store.RESET();
|
||||
}}
|
||||
activeToolId={store.activeTool}
|
||||
currentShape={store.currentShape}
|
||||
|
||||
@@ -196,6 +196,7 @@ interface SceneState {
|
||||
|
||||
// Action for deleting selected items
|
||||
deleteSelectedItems: () => void;
|
||||
RESET: () => void;
|
||||
|
||||
// Clipboard actions
|
||||
copySelectedItems: () => void;
|
||||
@@ -234,10 +235,8 @@ interface SceneState {
|
||||
sendBackward: (nodeIds: string[]) => void;
|
||||
|
||||
// Start background removal (enqueues task with Tauri)
|
||||
beginRemoveBackground: (
|
||||
nodeIds: string[],
|
||||
) => Promise<void>;
|
||||
|
||||
beginRemoveBackground: (nodeIds: string[]) => Promise<void>;
|
||||
|
||||
// Finish background removal (handoff back from a Tauri-sent event)
|
||||
finishRemoveBackground: (
|
||||
nodeId: string,
|
||||
@@ -273,7 +272,7 @@ const getNextZIndex = (nodes: Node[], lineNodes: LineNode[]): number => {
|
||||
return allZIndices.length > 0 ? Math.max(...allZIndices) + 1 : 1;
|
||||
};
|
||||
|
||||
export const useSceneStore = create<SceneState>((set, get) => ({
|
||||
export const useSceneStore = create<SceneState>((set, get, store) => ({
|
||||
// Initial state
|
||||
nodes: [],
|
||||
lineNodes: [],
|
||||
@@ -289,7 +288,7 @@ export const useSceneStore = create<SceneState>((set, get) => ({
|
||||
fillColor: "white",
|
||||
currentShape: null,
|
||||
shapeColor: "#4d79b3",
|
||||
|
||||
|
||||
// Cursor initial state
|
||||
cursorPosition: null,
|
||||
cursorVisible: false,
|
||||
@@ -337,7 +336,6 @@ export const useSceneStore = create<SceneState>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
updateNode: (
|
||||
id: string,
|
||||
updates: Partial<Node>,
|
||||
@@ -838,6 +836,10 @@ export const useSceneStore = create<SceneState>((set, get) => ({
|
||||
}
|
||||
},
|
||||
|
||||
RESET: () => {
|
||||
set(store.getInitialState());
|
||||
},
|
||||
|
||||
// Clipboard actions
|
||||
copySelectedItems: () => {
|
||||
set((state) => {
|
||||
@@ -1437,9 +1439,7 @@ export const useSceneStore = create<SceneState>((set, get) => ({
|
||||
});
|
||||
get().saveState();
|
||||
},
|
||||
beginRemoveBackground: async (
|
||||
nodeIds: string[],
|
||||
) => {
|
||||
beginRemoveBackground: async (nodeIds: string[]) => {
|
||||
const hasImageNodes = nodeIds.some((id) => {
|
||||
const node = get().nodes.find((n) => n.id === id);
|
||||
return node ? node.type === "image" : false;
|
||||
@@ -1455,7 +1455,7 @@ export const useSceneStore = create<SceneState>((set, get) => ({
|
||||
}
|
||||
try {
|
||||
const base64Image = await convertFileToBase64(firstNode.imageFile);
|
||||
// NB: This handler is async, so we subscribe (externally) and
|
||||
// NB: This handler is async, so we subscribe (externally) and
|
||||
// wait for the bg removal to complete.
|
||||
const _response = await EnqueueImageBgRemoval({
|
||||
base64_image: base64Image,
|
||||
|
||||
Reference in new issue
Block a user