From 76036a5a5e9c99ce3bbc513e24a09a6528d1ec0b Mon Sep 17 00:00:00 2001 From: Braulio Date: Mon, 18 Nov 2024 09:17:12 +0100 Subject: [PATCH 1/3] fix in progress --- .../local-disk/shapes-to-document.mapper.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/core/local-disk/shapes-to-document.mapper.ts b/src/core/local-disk/shapes-to-document.mapper.ts index e32bbe69..6186b360 100644 --- a/src/core/local-disk/shapes-to-document.mapper.ts +++ b/src/core/local-disk/shapes-to-document.mapper.ts @@ -1,3 +1,4 @@ +import { FONT_SIZE_VALUES } from '@/common/components/mock-components/front-components/shape.const'; import { ShapeModel } from '../model'; import { DocumentModel } from '../providers/canvas/canvas.model'; import { QuickMockFileContract } from './local-disk.model'; @@ -21,18 +22,41 @@ export const mapFromQuickMockFileDocumentToApplicationDocument = ( }; }; +const mapTextElementFromV0_1ToV0_2 = (shape: ShapeModel): ShapeModel => { + switch (shape.type) { + case 'heading1': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.HEADING1, + }, + }; + default: + return shape; + } +}; + +const setTextElementsDefaultFontSizeV0_1 = ( + shapes: ShapeModel[] +): ShapeModel[] => { + return shapes.map(mapTextElementFromV0_1ToV0_2); +}; + // Example function to handle version 0.1 parsing export const mapFromQuickMockFileDocumentToApplicationDocumentV0_1 = ( fileDocument: QuickMockFileContract ): DocumentModel => { // Combine all shapes into a single page - const combinedShapes: ShapeModel[] = fileDocument.pages.reduce( + let combinedShapes: ShapeModel[] = fileDocument.pages.reduce( (acc: ShapeModel[], page) => { return acc.concat(page.shapes); }, [] ); + combinedShapes = setTextElementsDefaultFontSizeV0_1(combinedShapes); + return { activePageIndex: 0, pages: [ From 2b5128ac3c4a951c8fc1bc2e8b36757d237a547f Mon Sep 17 00:00:00 2001 From: Antonio Contreras Date: Mon, 18 Nov 2024 10:22:08 +0100 Subject: [PATCH 2/3] fix fontSize to the other text components --- .../local-disk/shapes-to-document.mapper.ts | 48 +++++++++++++++++++ src/core/local-disk/use-local-disk.hook.ts | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/core/local-disk/shapes-to-document.mapper.ts b/src/core/local-disk/shapes-to-document.mapper.ts index 6186b360..d34a23c0 100644 --- a/src/core/local-disk/shapes-to-document.mapper.ts +++ b/src/core/local-disk/shapes-to-document.mapper.ts @@ -32,6 +32,54 @@ const mapTextElementFromV0_1ToV0_2 = (shape: ShapeModel): ShapeModel => { fontSize: FONT_SIZE_VALUES.HEADING1, }, }; + case 'heading2': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.HEADING2, + }, + }; + case 'heading3': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.HEADING3, + }, + }; + case 'link': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.LINK, + }, + }; + case 'normaltext': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.NORMALTEXT, + }, + }; + case 'smalltext': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.SMALLTEXT, + }, + }; + case 'paragraph': + return { + ...shape, + otherProps: { + ...shape, + fontSize: FONT_SIZE_VALUES.PARAGRAPH, + }, + }; default: return shape; } diff --git a/src/core/local-disk/use-local-disk.hook.ts b/src/core/local-disk/use-local-disk.hook.ts index 1d5bd4ea..9aa43522 100644 --- a/src/core/local-disk/use-local-disk.hook.ts +++ b/src/core/local-disk/use-local-disk.hook.ts @@ -58,7 +58,7 @@ export const useLocalDisk = () => { reader.onload = () => { const content = reader.result as string; const parseData: QuickMockFileContract = JSON.parse(content); - + console.log(parseData.version); if (parseData.version === '0.1') { // Handle version 0.1 parsing const appDocument = From caa8732d2d5236bd89e2cff99fc9073d311582e2 Mon Sep 17 00:00:00 2001 From: Antonio Contreras Date: Mon, 18 Nov 2024 10:25:03 +0100 Subject: [PATCH 3/3] remove console log --- src/core/local-disk/use-local-disk.hook.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/local-disk/use-local-disk.hook.ts b/src/core/local-disk/use-local-disk.hook.ts index 9aa43522..fbcb3f18 100644 --- a/src/core/local-disk/use-local-disk.hook.ts +++ b/src/core/local-disk/use-local-disk.hook.ts @@ -58,7 +58,6 @@ export const useLocalDisk = () => { reader.onload = () => { const content = reader.result as string; const parseData: QuickMockFileContract = JSON.parse(content); - console.log(parseData.version); if (parseData.version === '0.1') { // Handle version 0.1 parsing const appDocument =