fix build
This commit is contained in:
@@ -307,34 +307,36 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
},
|
||||
selectedObjectId: null,
|
||||
setSelectedObjectId: (id) => {
|
||||
set({
|
||||
set({
|
||||
selectedObjectId: id,
|
||||
selectedObjectIds: id ? [id] : []
|
||||
selectedObjectIds: id ? [id] : [],
|
||||
});
|
||||
},
|
||||
selectedObjectIds: [],
|
||||
setSelectedObjectIds: (ids) => {
|
||||
set({
|
||||
set({
|
||||
selectedObjectIds: ids,
|
||||
selectedObjectId: ids.length > 0 ? ids[0] : null
|
||||
selectedObjectId: ids.length > 0 ? ids[0] : null,
|
||||
});
|
||||
},
|
||||
addToSelection: (id) => {
|
||||
const state = get();
|
||||
if (!state.selectedObjectIds.includes(id)) {
|
||||
const newIds = [...state.selectedObjectIds, id];
|
||||
set({
|
||||
set({
|
||||
selectedObjectIds: newIds,
|
||||
selectedObjectId: newIds[0]
|
||||
selectedObjectId: newIds[0],
|
||||
});
|
||||
}
|
||||
},
|
||||
removeFromSelection: (id) => {
|
||||
const state = get();
|
||||
const newIds = state.selectedObjectIds.filter(selectedId => selectedId !== id);
|
||||
set({
|
||||
const newIds = state.selectedObjectIds.filter(
|
||||
(selectedId) => selectedId !== id
|
||||
);
|
||||
set({
|
||||
selectedObjectIds: newIds,
|
||||
selectedObjectId: newIds.length > 0 ? newIds[0] : null
|
||||
selectedObjectId: newIds.length > 0 ? newIds[0] : null,
|
||||
});
|
||||
},
|
||||
selectedTableId: null,
|
||||
@@ -650,7 +652,9 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
if (!obj) return;
|
||||
|
||||
const newVisible = !(obj.visible ?? true);
|
||||
const shouldDeselect = !newVisible && (state.selectedObjectId === id || state.selectedTableId === id);
|
||||
const shouldDeselect =
|
||||
!newVisible &&
|
||||
(state.selectedObjectId === id || state.selectedTableId === id);
|
||||
|
||||
if (state.currentPageId) {
|
||||
set((state) => ({
|
||||
@@ -704,7 +708,9 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
oldGroupIdsToRemove.add(id);
|
||||
} else if (obj?.groupId) {
|
||||
// اگر این آبجکت در یک گروه است، همه آبجکتهای آن گروه را اضافه کن
|
||||
const oldGroupMembers = state.objects.filter((o) => o.groupId === obj.groupId);
|
||||
const oldGroupMembers = state.objects.filter(
|
||||
(o) => o.groupId === obj.groupId
|
||||
);
|
||||
oldGroupMembers.forEach((member) => {
|
||||
if (member.type !== "group") {
|
||||
allObjectIdsToGroup.add(member.id);
|
||||
@@ -721,10 +727,10 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
if (allObjectIdsToGroup.size < 2) return;
|
||||
|
||||
const groupId = `group-${crypto.randomUUID()}`;
|
||||
const objectsToGroup = state.objects.filter((obj) =>
|
||||
allObjectIdsToGroup.has(obj.id) && obj.type !== "group"
|
||||
const objectsToGroup = state.objects.filter(
|
||||
(obj) => allObjectIdsToGroup.has(obj.id) && obj.type !== "group"
|
||||
);
|
||||
|
||||
|
||||
if (objectsToGroup.length === 0) return;
|
||||
|
||||
// محاسبه bounds گروه با در نظر گرفتن rotation
|
||||
@@ -737,7 +743,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
// برای متنهایی که width و height ندارند، از مقادیر پیشفرض استفاده کن
|
||||
let w = obj.width || 0;
|
||||
let h = obj.height || 0;
|
||||
|
||||
|
||||
if (obj.type === "text") {
|
||||
// اگر متن width نداره، از fontSize و طول متن برای تخمین استفاده کن
|
||||
if (!w) {
|
||||
@@ -750,7 +756,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
h = obj.fontSize || 24;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const cx = (obj.x || 0) + w / 2;
|
||||
const cy = (obj.y || 0) + h / 2;
|
||||
const rot = ((obj.rotation || 0) * Math.PI) / 180;
|
||||
@@ -853,7 +859,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
selectedObjectIds: [],
|
||||
}));
|
||||
},
|
||||
getGroupObjects: (groupId) => {
|
||||
getGroupObjects: (groupId: string) => {
|
||||
const state = get();
|
||||
return state.objects.filter((obj) => obj.groupId === groupId);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user