fix text shape place

This commit is contained in:
hamid zarghami
2026-01-07 10:11:10 +03:30
parent 9479a3425b
commit 9237bf0ba4
3 changed files with 86 additions and 45 deletions
+10 -6
View File
@@ -44,7 +44,10 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
type: obj.type as EditorObject['type'],
x: obj.x,
y: obj.y,
opacity: obj.opacity ?? 1,
// در JSON، opacity به صورت 0-100 است (درصد)
// در editor هم opacity به صورت 0-100 است
// پس opacity را مستقیماً استفاده می‌کنیم
opacity: obj.opacity !== undefined ? obj.opacity : 100,
visible: true,
};
@@ -66,11 +69,12 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
// برای circle در viewer-data.json، x, y به عنوان گوشه بالا-چپ bounding box است
// اما در editor، circle با مرکز در x, y ذخیره می‌شود
// پس باید تبدیل کنیم
if (obj.type === 'rectangle' && obj.shapeType === 'circle') {
// تبدیل از گوشه بالا-چپ به مرکز
baseObject.x = obj.x + (obj.width || 100) / 2;
baseObject.y = obj.y + (obj.height || 100) / 2;
}
// اما بر اساس بررسی، در JSON موقعیت به عنوان مرکز ذخیره شده است
// پس نباید تبدیل کنیم - مستقیماً استفاده می‌کنیم
// اگر در آینده JSON به صورت گوشه بالا-چپ export شود، باید تبدیل کنیم:
// baseObject.x = obj.x + (obj.width || 100) / 2;
// baseObject.y = obj.y + (obj.height || 100) / 2;
// اما فعلاً 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;