Skip to content

Commit c26cb16

Browse files
committed
fix old version placeholder
1 parent 50fc5be commit c26cb16

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/core/local-disk/shapes-to-document.mapper.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
createDefaultCanvasSize,
55
DocumentModel,
66
} from '../providers/canvas/canvas.model';
7-
import { QuickMockFileContract } from './local-disk.model';
7+
import { Page, QuickMockFileContract } from './local-disk.model';
88
import { APP_CONSTANTS } from '../providers/canvas/canvas.model';
99

1010
export const mapFromShapesArrayToQuickMockFileDocument = (
@@ -24,14 +24,50 @@ export const mapFromQuickMockFileDocumentToApplicationDocument = (
2424
): DocumentModel => {
2525
return {
2626
activePageIndex: 0,
27-
pages: fileDocument.pages,
27+
pages: AdaptMinor_0_2_Updates(fileDocument.pages),
2828
customColors:
2929
fileDocument.customColors ||
3030
new Array(APP_CONSTANTS.COLOR_SLOTS).fill(null),
3131
size: fileDocument.size ?? createDefaultCanvasSize(),
3232
};
3333
};
3434

35+
const AdaptMinor_0_2_Updates = (pages: Page[]): Page[] => {
36+
return pages.map(page => {
37+
return {
38+
...page,
39+
shapes: page.shapes.map(
40+
AddDefaultValuesForInputPropsPlaceHolderAndPassword
41+
),
42+
};
43+
});
44+
};
45+
46+
const AddDefaultValuesForInputPropsPlaceHolderAndPassword = (
47+
shape: ShapeModel
48+
) => {
49+
switch (shape.type) {
50+
case 'input':
51+
return {
52+
...shape,
53+
otherProps: {
54+
...shape.otherProps,
55+
isPlaceholder:
56+
shape.otherProps?.isPlaceholder !== undefined
57+
? shape.otherProps?.isPlaceholder
58+
: true,
59+
textColor:
60+
shape.otherProps?.isPlaceholder === undefined &&
61+
shape.otherProps?.textColor === '#8c8c8c'
62+
? '#000000'
63+
: shape.otherProps?.textColor,
64+
},
65+
};
66+
default:
67+
return shape;
68+
}
69+
};
70+
3571
const mapTextElementFromV0_1ToV0_2 = (shape: ShapeModel): ShapeModel => {
3672
switch (shape.type) {
3773
case 'heading1':

0 commit comments

Comments
 (0)