cover
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { EditorObject } from '@/pages/editor/store/editorStore';
|
||||
import type { PageData } from '../types';
|
||||
import type { EditorObject, TableData } from "@/pages/editor/store/editorStore";
|
||||
import type { PageData } from "../types";
|
||||
|
||||
type ViewerDataPage = {
|
||||
id: string;
|
||||
@@ -25,7 +25,7 @@ type ViewerDataPage = {
|
||||
rotation?: number;
|
||||
opacity?: number;
|
||||
letterSpacing?: number;
|
||||
tableData?: any;
|
||||
tableData?: TableData;
|
||||
}>;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
const objects: EditorObject[] = page.objects.map((obj) => {
|
||||
const baseObject: EditorObject = {
|
||||
id: obj.id,
|
||||
type: obj.type as EditorObject['type'],
|
||||
type: obj.type as EditorObject["type"],
|
||||
x: obj.x,
|
||||
y: obj.y,
|
||||
// در JSON، opacity به صورت 0-100 است (درصد)
|
||||
@@ -53,7 +53,7 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
|
||||
// برای line و arrow، width و height در viewer-data.json به عنوان مختصات انتهایی هستند
|
||||
// در EditorObject هم به عنوان مختصات انتهایی ذخیره میشوند
|
||||
if (obj.type === 'line' || obj.type === 'arrow') {
|
||||
if (obj.type === "line" || obj.type === "arrow") {
|
||||
// width و height مستقیماً مختصات نقطه پایان هستند
|
||||
if (obj.width !== undefined) {
|
||||
baseObject.width = obj.width;
|
||||
@@ -77,7 +77,8 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
// اما فعلاً JSON به صورت مرکز است، پس تبدیل نمیکنیم
|
||||
if (obj.fill !== undefined) baseObject.fill = obj.fill;
|
||||
if (obj.stroke !== undefined) baseObject.stroke = obj.stroke;
|
||||
if (obj.strokeWidth !== undefined) baseObject.strokeWidth = obj.strokeWidth;
|
||||
if (obj.strokeWidth !== undefined)
|
||||
baseObject.strokeWidth = obj.strokeWidth;
|
||||
if (obj.rotation !== undefined) baseObject.rotation = obj.rotation;
|
||||
|
||||
// ویژگیهای متنی
|
||||
@@ -85,26 +86,27 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
if (obj.fontSize !== undefined) baseObject.fontSize = obj.fontSize;
|
||||
if (obj.fontFamily !== undefined) baseObject.fontFamily = obj.fontFamily;
|
||||
if (obj.fontWeight !== undefined) baseObject.fontWeight = obj.fontWeight;
|
||||
if (obj.letterSpacing !== undefined) baseObject.letterSpacing = obj.letterSpacing;
|
||||
if (obj.letterSpacing !== undefined)
|
||||
baseObject.letterSpacing = obj.letterSpacing;
|
||||
|
||||
// انواع خاص objectها
|
||||
if (obj.type === 'rectangle' && obj.shapeType) {
|
||||
baseObject.shapeType = obj.shapeType as EditorObject['shapeType'];
|
||||
if (obj.type === "rectangle" && obj.shapeType) {
|
||||
baseObject.shapeType = obj.shapeType as EditorObject["shapeType"];
|
||||
}
|
||||
|
||||
if (obj.type === 'image' && obj.imageUrl) {
|
||||
if (obj.type === "image" && obj.imageUrl) {
|
||||
baseObject.imageUrl = obj.imageUrl;
|
||||
}
|
||||
|
||||
if (obj.type === 'video' && obj.videoUrl) {
|
||||
if (obj.type === "video" && obj.videoUrl) {
|
||||
baseObject.videoUrl = obj.videoUrl;
|
||||
}
|
||||
|
||||
if (obj.type === 'link' && obj.linkUrl) {
|
||||
if (obj.type === "link" && obj.linkUrl) {
|
||||
baseObject.linkUrl = obj.linkUrl;
|
||||
}
|
||||
|
||||
if (obj.type === 'grid' && obj.tableData) {
|
||||
if (obj.type === "grid" && obj.tableData) {
|
||||
baseObject.tableData = obj.tableData;
|
||||
}
|
||||
|
||||
@@ -119,4 +121,3 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user