@@ -25,6 +25,8 @@ import { decodeEntities } from '@wordpress/html-entities';
25
25
import { __ , sprintf } from '@wordpress/i18n' ;
26
26
import { pin } from '@wordpress/icons' ;
27
27
import { useEntityRecords } from '@wordpress/core-data' ;
28
+ import { useDispatch } from '@wordpress/data' ;
29
+ import { store as noticeStore } from '@wordpress/notices' ;
28
30
29
31
/**
30
32
* Internal dependencies
@@ -44,6 +46,7 @@ export default function CategoriesEdit( {
44
46
} ,
45
47
setAttributes,
46
48
className,
49
+ clientId,
47
50
} ) {
48
51
const selectId = useInstanceId ( CategoriesEdit , 'blocks-category-select' ) ;
49
52
@@ -70,6 +73,15 @@ export default function CategoriesEdit( {
70
73
query
71
74
) ;
72
75
76
+ const { createWarningNotice } = useDispatch ( noticeStore ) ;
77
+ const showRedirectionPreventedNotice = ( event ) => {
78
+ event . preventDefault ( ) ;
79
+ createWarningNotice ( __ ( 'Links are disabled in the editor.' ) , {
80
+ id : `block-library/core/categories/redirection-prevented/${ clientId } ` ,
81
+ type : 'snackbar' ,
82
+ } ) ;
83
+ } ;
84
+
73
85
const getCategoriesList = ( parentId ) => {
74
86
if ( ! categories ?. length ) {
75
87
return [ ] ;
@@ -99,7 +111,7 @@ export default function CategoriesEdit( {
99
111
const { id, link, count, name } = category ;
100
112
return (
101
113
< li key = { id } className = { `cat-item cat-item-${ id } ` } >
102
- < a href = { link } target = "_blank" rel = "noreferrer noopener" >
114
+ < a href = { link } onClick = { showRedirectionPreventedNotice } >
103
115
{ renderCategoryName ( name ) }
104
116
</ a >
105
117
{ showPostCounts && ` (${ count } )` }
0 commit comments