check fix data

This commit is contained in:
Hamid
2026-05-17 00:50:23 -07:00
parent 7589a26706
commit 5bbd677f41
3 changed files with 78 additions and 23 deletions
+32 -15
View File
@@ -150,6 +150,7 @@ type EditorStoreType = {
pages: Page[],
documentSettings?: Partial<DocumentSettings>,
) => void;
resetEditor: () => void;
clipboardObjects: EditorObject[];
objectHistoryPast: EditorObject[][];
objectHistoryFuture: EditorObject[][];
@@ -167,6 +168,22 @@ type EditorStoreType = {
) => void;
};
const DEFAULT_DOCUMENT_SETTINGS: DocumentSettings = {
displayStyle: "double",
autoPlay: false,
pageFlipSound: true,
leftToRightFlip: false,
smartGuide: true,
backgroundType: "color",
backgroundColor: "#ffffff",
backgroundGradient: {
from: "#ffffff",
to: "#e2e8f0",
angle: 135,
},
backgroundImageUrl: "",
};
export const useEditorStore = create<EditorStoreType>((set, get) => {
const initialPage = createInitialPage("جلد");
const cloneObjectsForPaste = (
@@ -209,21 +226,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
};
return {
documentSettings: {
displayStyle: "double",
autoPlay: false,
pageFlipSound: true,
leftToRightFlip: false,
smartGuide: true,
backgroundType: "color",
backgroundColor: "#ffffff",
backgroundGradient: {
from: "#ffffff",
to: "#e2e8f0",
angle: 135,
},
backgroundImageUrl: "",
},
documentSettings: { ...DEFAULT_DOCUMENT_SETTINGS },
updateDocumentSettings: (updates) =>
set((state) => ({
documentSettings: { ...state.documentSettings, ...updates },
@@ -984,6 +987,20 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
const state = get();
return state.objects.filter((obj) => obj.groupId === groupId);
},
resetEditor: () => {
const page = createInitialPage("جلد");
set({
pages: [page],
currentPageId: page.id,
objects: page.objects,
guides: [],
selectedObjectId: null,
selectedObjectIds: [],
objectHistoryPast: [],
objectHistoryFuture: [],
documentSettings: { ...DEFAULT_DOCUMENT_SETTINGS },
});
},
loadPages: (pages, documentSettings) => {
if (pages.length === 0) return;
const fallbackSettings = documentSettings ?? {};