mask
This commit is contained in:
@@ -62,6 +62,9 @@ export type EditorObject = {
|
||||
visible?: boolean;
|
||||
isMask?: boolean;
|
||||
showMaskGuide?: boolean;
|
||||
maskId?: string; // Reference to mask shape (DATA only, NO rendering logic)
|
||||
maskInvert?: boolean; // اگر true: overlap مخفی میشود، اگر false: overlap نمایش داده میشود
|
||||
groupId?: string;
|
||||
};
|
||||
|
||||
export type Page = {
|
||||
@@ -136,6 +139,8 @@ type EditorStoreType = {
|
||||
setCurrentPage: (pageId: string) => void;
|
||||
updatePageName: (pageId: string, name: string) => void;
|
||||
toggleObjectVisibility: (id: string) => void;
|
||||
groupObjects: (objectIds: string[]) => void;
|
||||
ungroupObjects: (groupId: string) => void;
|
||||
};
|
||||
|
||||
const createTableCellId = (row: number, col: number) => `cell-${row}-${col}`;
|
||||
@@ -640,5 +645,52 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
selectedTableId: shouldDeselect ? null : state.selectedTableId,
|
||||
}));
|
||||
},
|
||||
groupObjects: (objectIds) => {
|
||||
const state = get();
|
||||
if (objectIds.length < 2) return;
|
||||
|
||||
const groupId = `group-${crypto.randomUUID()}`;
|
||||
const updateObjects = (objects: EditorObject[]) =>
|
||||
objects.map((obj) =>
|
||||
objectIds.includes(obj.id) ? { ...obj, groupId } : obj
|
||||
);
|
||||
|
||||
if (state.currentPageId) {
|
||||
set((state) => ({
|
||||
objects: updateObjects(state.objects),
|
||||
pages: state.pages.map((p) =>
|
||||
p.id === state.currentPageId
|
||||
? { ...p, objects: updateObjects(p.objects) }
|
||||
: p
|
||||
),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
set((state) => ({
|
||||
objects: updateObjects(state.objects),
|
||||
}));
|
||||
},
|
||||
ungroupObjects: (groupId) => {
|
||||
const state = get();
|
||||
const updateObjects = (objects: EditorObject[]) =>
|
||||
objects.map((obj) =>
|
||||
obj.groupId === groupId ? { ...obj, groupId: undefined } : obj
|
||||
);
|
||||
|
||||
if (state.currentPageId) {
|
||||
set((state) => ({
|
||||
objects: updateObjects(state.objects),
|
||||
pages: state.pages.map((p) =>
|
||||
p.id === state.currentPageId
|
||||
? { ...p, objects: updateObjects(p.objects) }
|
||||
: p
|
||||
),
|
||||
}));
|
||||
return;
|
||||
}
|
||||
set((state) => ({
|
||||
objects: updateObjects(state.objects),
|
||||
}));
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user