@@ -14,28 +14,32 @@ export const debounce = <T extends (...args: unknown[]) => void>(
1414
1515export const handleValidationErrors = ( ) => {
1616 const debouncedUnsub = debounce ( ( ) => unsub ( ) , 5000 ) ;
17+
1718 const unsub = subscribe ( ( ) => {
1819 const editor = document . querySelector (
1920 '#editor, iframe[name="editor-canvas"]' ,
2021 ) ;
21- const blockError = editor ?. querySelector (
22+ const blockErrors = editor ?. querySelectorAll (
2223 '.wp-block-kevinbatdorf-code-block-pro .block-editor-warning' ,
2324 ) ;
24- if ( blockError ) unsub ( ) ;
25- const message = blockError ?. querySelector (
26- '.block-editor-warning__message' ,
27- ) ;
28- if ( ! message ) return ;
29- message . textContent = __ (
30- 'This block has been updated. Press update to refresh.' ,
31- 'code-block-pro' ,
32- ) ;
33- const button = blockError ?. querySelector (
34- '.block-editor-warning__action button' ,
35- ) ;
36- if ( ! button ) return ;
37- button . textContent = __ ( 'Update' , 'code-block-pro' ) ;
38-
25+ if ( ! blockErrors ?. length ) return ;
26+ blockErrors . forEach ( ( blockError ) => {
27+ const message = blockError . querySelector (
28+ '.block-editor-warning__message' ,
29+ ) ;
30+ if ( message ) {
31+ message . textContent = __ (
32+ 'This block has been updated. Press update to refresh.' ,
33+ 'code-block-pro' ,
34+ ) ;
35+ }
36+ const button = blockError . querySelector (
37+ '.block-editor-warning__action button' ,
38+ ) ;
39+ if ( button ) {
40+ button . textContent = __ ( 'Update' , 'code-block-pro' ) ;
41+ }
42+ } ) ;
3943 debouncedUnsub ( ) ;
4044 } ) ;
4145} ;
0 commit comments