@@ -313,6 +313,44 @@ export const escapeHtml = (text: string, whitelist?: EscapeHtmlWhitelist[]): str
313313
314314} ;
315315
316+ export const replaceBrTags = ( text : string ) : string => {
317+ return text . replace ( / < b r \s * \/ ? > / g, '<br />' ) ;
318+ } ;
319+
320+ export const replaceClassWithClassName = ( text : string ) : string => {
321+ return text . replace ( / c l a s s = " ( [ ^ " ] + ) " / g, ( match , p1 ) => {
322+ return `className="${ p1 } "` ;
323+ } ) ;
324+ } ;
325+
326+ export const convertStyleToStyleObject = ( style : string ) : Record < string , string > => {
327+ if ( ! style ) return { } ;
328+
329+ // Split the style string by semicolons and filter out empty strings
330+ const stylePairs = style . split ( ';' ) . filter ( Boolean ) ;
331+
332+ return stylePairs . reduce ( ( acc , pair ) => {
333+ // Split each pair by colon and trim whitespace
334+ const [ property , value ] = pair . split ( ':' ) . map ( str => str . trim ( ) ) ;
335+
336+ if ( property && value ) {
337+ // Convert CSS property to camelCase (e.g., text-align -> textAlign)
338+ const camelCaseProperty = property . replace ( / - ( [ a - z ] ) / g, ( _ , letter ) => letter . toUpperCase ( ) ) ;
339+ acc [ camelCaseProperty ] = value ;
340+ }
341+
342+ return acc ;
343+ } , { } as Record < string , string > ) ;
344+ } ;
345+
346+ export const replaceStyleStringWithObject = ( style : string ) : string => {
347+ return style . replace ( / s t y l e = " ( [ ^ " ] + ) " / g, ( match , p1 ) => {
348+ return `style={${ JSON . stringify ( convertStyleToStyleObject ( p1 ) ) } }` ;
349+ } ) ;
350+
351+ }
352+
353+
316354export const getGridRows = (
317355 items : FormComponentModel [ ] ,
318356 viewport : Viewports
0 commit comments