@@ -19,6 +19,7 @@ import {
1919} from '@wordpress/components' ;
2020import { __ , sprintf } from '@wordpress/i18n' ;
2121import { getBlockDefaultClassName } from '@wordpress/blocks' ;
22+ import { useEffect } from '@wordpress/element' ;
2223
2324/**
2425 * Internal dependencies
@@ -55,7 +56,29 @@ function OpenTableEdit( {
5556 setAttributes ( validatedAttributes ) ;
5657 }
5758
58- const { align, rid, style, iframe, domain, lang, newtab } = attributes ;
59+ const { align, rid, style, iframe, domain, lang, newtab, __isBlockPreview } = attributes ;
60+ const isPlaceholder = isEmpty ( rid ) ;
61+
62+ useEffect ( ( ) => {
63+ noticeOperations . removeAllNotices ( ) ;
64+ if (
65+ ! isPlaceholder &&
66+ ! __isBlockPreview &&
67+ 'wide' === style &&
68+ 'wide' !== align &&
69+ 'full' !== align
70+ ) {
71+ const content = (
72+ < >
73+ { __ (
74+ 'With the OpenTable block you may encounter display issues if you use its "wide" style with anything other than "wide" or "full" alignment. The wide display style may also not work well on smaller screens.' ,
75+ 'jetpack'
76+ ) }
77+ </ >
78+ ) ;
79+ noticeOperations . createNotice ( { status : 'warning' , content } ) ;
80+ }
81+ } , [ __isBlockPreview , align , isPlaceholder , noticeOperations , rid , style ] ) ;
5982
6083 const parseEmbedCode = embedCode => {
6184 const newAttributes = getAttributesFromEmbedCode ( embedCode ) ;
@@ -197,17 +220,20 @@ function OpenTableEdit( {
197220 ) ;
198221
199222 const editClasses = classnames ( className , {
200- [ `${ defaultClassName } -theme-${ style } ` ] : ! isEmpty ( rid ) && styleValues . includes ( style ) ,
201- 'is-placeholder' : isEmpty ( rid ) ,
223+ [ `${ defaultClassName } -theme-${ style } ` ] : ! isPlaceholder && styleValues . includes ( style ) ,
224+ 'is-placeholder' : isPlaceholder ,
202225 'is-multi' : 'multi' === getTypeAndTheme ( style ) [ 0 ] ,
203226 [ `align${ align } ` ] : align ,
204227 } ) ;
205228
206229 return (
207- < div className = { editClasses } >
208- { ! isEmpty ( rid ) && inspectorControls }
209- { ! isEmpty ( rid ) ? blockPreview ( ) : blockPlaceholder }
210- </ div >
230+ < >
231+ { noticeUI }
232+ < div className = { editClasses } >
233+ { ! isPlaceholder && inspectorControls }
234+ { ! isPlaceholder ? blockPreview ( ) : blockPlaceholder }
235+ </ div >
236+ </ >
211237 ) ;
212238}
213239
0 commit comments