33 * Internal dependencies.
44 */
55import DEFAULT from './default.json'
6+ import mapsGraphic from './images/maps.png'
67import {
78 addBackgroundScheme , addContainerScheme ,
89 addPlaceholderForPostsBlock , cleanParse ,
@@ -13,7 +14,9 @@ import {
1314/**
1415 * External dependencies.
1516 */
16- import { isPro , devMode } from 'stackable'
17+ import {
18+ isPro , devMode , srcUrl ,
19+ } from 'stackable'
1720import { fetchDesign } from '~stackable/design-library'
1821import { cloneDeep } from 'lodash'
1922
@@ -138,6 +141,22 @@ export const usePreviewRenderer = (
138141 preview = addPlaceholderForPostsBlock ( preview , defaultValues . posts_placeholder , defaultValues )
139142 }
140143
144+ // For designs with maps block, replace the iframe with an img of the maps
145+ if ( preview . includes ( 'stk-block-map' ) ) {
146+ // Regex to match <div ... class="...stk-block-map...">...</div>
147+ preview = preview . replace (
148+ / ( < d i v [ ^ > ] * c l a s s = " [ ^ " ] * s t k - b l o c k - m a p [ ^ " ] * " [ ^ > ] * > ) ( [ \s \S ] * ?) ( < \/ d i v > ) / g,
149+ ( match , divStart , divContent , divEnd ) => {
150+ // Replace <iframe ...></iframe> or <iframe .../> with <img ... />
151+ const replacedContent = divContent . replace (
152+ / < i f r a m e [ \s \S ] * ?< \/ i f r a m e > | < i f r a m e [ \s \S ] * ?\/ > / g,
153+ '<img src="' + srcUrl + '/' + mapsGraphic + '" />'
154+ )
155+ return divStart + replacedContent + divEnd
156+ }
157+ )
158+ }
159+
141160 const cleanedBlock = preview . replace ( / < ! - - [ \s \S ] * ?- - > / g, '' ) // removes comment
142161
143162 setBlocks ( {
0 commit comments