@@ -14,28 +14,32 @@ export const debounce = <T extends (...args: unknown[]) => void>(
14
14
15
15
export const handleValidationErrors = ( ) => {
16
16
const debouncedUnsub = debounce ( ( ) => unsub ( ) , 5000 ) ;
17
+
17
18
const unsub = subscribe ( ( ) => {
18
19
const editor = document . querySelector (
19
20
'#editor, iframe[name="editor-canvas"]' ,
20
21
) ;
21
- const blockError = editor ?. querySelector (
22
+ const blockErrors = editor ?. querySelectorAll (
22
23
'.wp-block-kevinbatdorf-code-block-pro .block-editor-warning' ,
23
24
) ;
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
+ } ) ;
39
43
debouncedUnsub ( ) ;
40
44
} ) ;
41
45
} ;
0 commit comments