@@ -17,7 +17,17 @@ import { verticalAlign } from "./verticalAlign";
1717export const parseComponent =
1818 ( defaultHeight : number , defaultWidth : number , props ?: VBMLProps ) =>
1919 ( component : IVBMLComponent ) => {
20- if ( "rawCharacters" in component ) return component . rawCharacters ;
20+ if ( "rawCharacters" in component ) {
21+ const raw = component . rawCharacters ;
22+ if ( typeof raw === "string" ) {
23+ try {
24+ return JSON . parse ( parseProps ( props || { } ) ( raw ) ) as number [ ] [ ] ;
25+ } catch ( e ) {
26+ return [ [ ] ] ; // Return an empty board if parsing fails
27+ }
28+ }
29+ return raw ;
30+ }
2131
2232 const width = component ?. style ?. width || defaultWidth ;
2333 const height = component ?. style ?. height || defaultHeight ;
@@ -27,7 +37,7 @@ export const parseComponent =
2737 return randomColors (
2838 component ?. style ?. height || height ,
2939 component ?. style ?. width || width ,
30- colors
40+ colors ,
3141 ) ;
3242 }
3343
@@ -44,7 +54,7 @@ export const parseComponent =
4454 map ( convertCharactersToCharacterCodes ) ,
4555 verticalAlign ( height , component ?. style ?. align || Align . top ) ,
4656 horizontalAlign ( width , component ?. style ?. justify || Justify . left ) ,
47- renderComponent ( emptyComponent )
57+ renderComponent ( emptyComponent ) ,
4858 ) ( template ) as number [ ] [ ] ;
4959 } ;
5060
@@ -55,7 +65,7 @@ export const parseAbsoluteComponent =
5565 characters : parseComponent (
5666 defaultHeight ,
5767 defaultWidth ,
58- props
68+ props ,
5969 ) ( component ) as number [ ] [ ] ,
6070 x : component . style ?. absolutePosition ?. x || 0 ,
6171 y : component . style ?. absolutePosition ?. y || 0 ,
0 commit comments