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' ;
88import { APP_CONSTANTS } from '../providers/canvas/canvas.model' ;
99
1010export const mapFromShapesArrayToQuickMockFileDocument = (
@@ -24,14 +24,56 @@ 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+ // Small update no need to go for 0_3, but input placeHolder needs to have default value
57+ // if undefined
58+ shape . otherProps ?. isPlaceholder !== undefined
59+ ? shape . otherProps ?. isPlaceholder
60+ : true ,
61+ textColor :
62+ // Small update, no need to go for 0_3,
63+ // but input textColor needs to have default value
64+ // if undefined, and textColor was placeholder gray color
65+ // in this case change it to black
66+ shape . otherProps ?. isPlaceholder === undefined &&
67+ shape . otherProps ?. textColor === '#8c8c8c'
68+ ? '#000000'
69+ : shape . otherProps ?. textColor ,
70+ } ,
71+ } ;
72+ default :
73+ return shape ;
74+ }
75+ } ;
76+
3577const mapTextElementFromV0_1ToV0_2 = ( shape : ShapeModel ) : ShapeModel => {
3678 switch ( shape . type ) {
3779 case 'heading1' :
0 commit comments