Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions src/core/local-disk/shapes-to-document.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
createDefaultCanvasSize,
DocumentModel,
} from '../providers/canvas/canvas.model';
import { QuickMockFileContract } from './local-disk.model';
import { Page, QuickMockFileContract } from './local-disk.model';
import { APP_CONSTANTS } from '../providers/canvas/canvas.model';

export const mapFromShapesArrayToQuickMockFileDocument = (
Expand All @@ -24,14 +24,56 @@ export const mapFromQuickMockFileDocumentToApplicationDocument = (
): DocumentModel => {
return {
activePageIndex: 0,
pages: fileDocument.pages,
pages: AdaptMinor_0_2_Updates(fileDocument.pages),
customColors:
fileDocument.customColors ||
new Array(APP_CONSTANTS.COLOR_SLOTS).fill(null),
size: fileDocument.size ?? createDefaultCanvasSize(),
};
};

const AdaptMinor_0_2_Updates = (pages: Page[]): Page[] => {
return pages.map(page => {
return {
...page,
shapes: page.shapes.map(
AddDefaultValuesForInputPropsPlaceHolderAndPassword
),
};
});
};

const AddDefaultValuesForInputPropsPlaceHolderAndPassword = (
shape: ShapeModel
) => {
switch (shape.type) {
case 'input':
return {
...shape,
otherProps: {
...shape.otherProps,
isPlaceholder:
// Small update no need to go for 0_3, but input placeHolder needs to have default value
// if undefined
shape.otherProps?.isPlaceholder !== undefined
? shape.otherProps?.isPlaceholder
: true,
textColor:
// Small update, no need to go for 0_3,
// but input textColor needs to have default value
// if undefined, and textColor was placeholder gray color
// in this case change it to black
shape.otherProps?.isPlaceholder === undefined &&
shape.otherProps?.textColor === '#8c8c8c'
? '#000000'
: shape.otherProps?.textColor,
},
};
default:
return shape;
}
};

const mapTextElementFromV0_1ToV0_2 = (shape: ShapeModel): ShapeModel => {
switch (shape.type) {
case 'heading1':
Expand Down