check fix data
This commit is contained in:
@@ -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 ?? {};
|
||||
|
||||
Reference in New Issue
Block a user