@wordpress/block-library 9.33.5 → 9.33.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/heading/index.js +3 -1
- package/build/heading/index.js.map +3 -3
- package/build/heading/variations.js +53 -0
- package/build/heading/variations.js.map +7 -0
- package/build/navigation-link/edit.js +25 -10
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/link-ui/index.js +8 -3
- package/build/navigation-link/link-ui/index.js.map +2 -2
- package/build/navigation-link/shared/controls.js +76 -21
- package/build/navigation-link/shared/controls.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +31 -2
- package/build/navigation-link/shared/use-entity-binding.js.map +3 -3
- package/build/paragraph/index.js +3 -1
- package/build/paragraph/index.js.map +3 -3
- package/build/paragraph/variations.js +55 -0
- package/build/paragraph/variations.js.map +7 -0
- package/build-module/heading/index.js +3 -1
- package/build-module/heading/index.js.map +2 -2
- package/build-module/heading/variations.js +33 -0
- package/build-module/heading/variations.js.map +7 -0
- package/build-module/navigation-link/edit.js +25 -10
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/link-ui/index.js +8 -3
- package/build-module/navigation-link/link-ui/index.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +77 -22
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +35 -3
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/paragraph/index.js +3 -1
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/paragraph/variations.js +35 -0
- package/build-module/paragraph/variations.js.map +7 -0
- package/build-style/accordion-heading/style-rtl.css +19 -3
- package/build-style/accordion-heading/style.css +19 -3
- package/build-style/accordion-panel/style-rtl.css +4 -1
- package/build-style/accordion-panel/style.css +4 -1
- package/build-style/editor-rtl.css +7 -0
- package/build-style/editor.css +7 -0
- package/build-style/navigation-link/editor-rtl.css +7 -0
- package/build-style/navigation-link/editor.css +7 -0
- package/build-style/style-rtl.css +23 -4
- package/build-style/style.css +23 -4
- package/package.json +11 -11
- package/src/accordion-heading/style.scss +40 -7
- package/src/accordion-panel/style.scss +6 -1
- package/src/heading/index.js +2 -0
- package/src/heading/variations.js +37 -0
- package/src/navigation-link/edit.js +44 -13
- package/src/navigation-link/editor.scss +7 -0
- package/src/navigation-link/link-ui/index.js +9 -8
- package/src/navigation-link/shared/controls.js +123 -25
- package/src/navigation-link/shared/test/controls.js +19 -9
- package/src/navigation-link/shared/test/use-entity-binding.js +14 -1
- package/src/navigation-link/shared/use-entity-binding.js +57 -9
- package/src/paragraph/index.js +2 -0
- package/src/paragraph/variations.js +39 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
.wp-block-accordion-panel
|
|
1
|
+
.wp-block-accordion-panel.wp-block-accordion-panel {
|
|
2
|
+
min-width: 100%;
|
|
3
|
+
}
|
|
4
|
+
.wp-block-accordion-panel.wp-block-accordion-panel[inert], .wp-block-accordion-panel.wp-block-accordion-panel[aria-hidden=true] {
|
|
2
5
|
display: none;
|
|
3
6
|
margin-block-start: 0;
|
|
4
7
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
.wp-block-accordion-panel
|
|
1
|
+
.wp-block-accordion-panel.wp-block-accordion-panel {
|
|
2
|
+
min-width: 100%;
|
|
3
|
+
}
|
|
4
|
+
.wp-block-accordion-panel.wp-block-accordion-panel[inert], .wp-block-accordion-panel.wp-block-accordion-panel[aria-hidden=true] {
|
|
2
5
|
display: none;
|
|
3
6
|
margin-block-start: 0;
|
|
4
7
|
}
|
|
@@ -1986,6 +1986,13 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
1986
1986
|
text-transform: uppercase;
|
|
1987
1987
|
}
|
|
1988
1988
|
|
|
1989
|
+
/**
|
|
1990
|
+
* Error text styling for missing entity help text.
|
|
1991
|
+
*/
|
|
1992
|
+
.navigation-link-control__error-text {
|
|
1993
|
+
color: #cc1818;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1989
1996
|
.wp-block-navigation-submenu {
|
|
1990
1997
|
display: block;
|
|
1991
1998
|
}
|
package/build-style/editor.css
CHANGED
|
@@ -1994,6 +1994,13 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
1994
1994
|
text-transform: uppercase;
|
|
1995
1995
|
}
|
|
1996
1996
|
|
|
1997
|
+
/**
|
|
1998
|
+
* Error text styling for missing entity help text.
|
|
1999
|
+
*/
|
|
2000
|
+
.navigation-link-control__error-text {
|
|
2001
|
+
color: #cc1818;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1997
2004
|
.wp-block-navigation-submenu {
|
|
1998
2005
|
display: block;
|
|
1999
2006
|
}
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
.wp-block-accordion-heading.wp-block-accordion-heading {
|
|
25
|
+
min-width: 100%;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
.wp-block-accordion-heading__toggle {
|
|
25
30
|
font-family: inherit;
|
|
26
31
|
font-size: inherit;
|
|
@@ -31,21 +36,32 @@
|
|
|
31
36
|
text-decoration: inherit;
|
|
32
37
|
word-spacing: inherit;
|
|
33
38
|
font-style: inherit;
|
|
34
|
-
background: none;
|
|
35
39
|
border: none;
|
|
36
|
-
color: inherit;
|
|
37
40
|
padding: var(--wp--preset--spacing--20, 1em) 0;
|
|
38
41
|
cursor: pointer;
|
|
39
42
|
overflow: hidden;
|
|
40
43
|
display: flex;
|
|
41
44
|
align-items: center;
|
|
42
45
|
text-align: inherit;
|
|
43
|
-
position: relative;
|
|
44
46
|
width: 100%;
|
|
47
|
+
background-color: inherit !important;
|
|
48
|
+
color: inherit !important;
|
|
45
49
|
}
|
|
46
50
|
.wp-block-accordion-heading__toggle:not(:focus-visible) {
|
|
47
51
|
outline: none;
|
|
48
52
|
}
|
|
53
|
+
.wp-block-accordion-heading__toggle:hover, .wp-block-accordion-heading__toggle:focus {
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
background-color: inherit !important;
|
|
56
|
+
box-shadow: none;
|
|
57
|
+
color: inherit;
|
|
58
|
+
border: none;
|
|
59
|
+
padding: var(--wp--preset--spacing--20, 1em) 0;
|
|
60
|
+
}
|
|
61
|
+
.wp-block-accordion-heading__toggle:focus-visible {
|
|
62
|
+
outline: auto;
|
|
63
|
+
outline-offset: 0;
|
|
64
|
+
}
|
|
49
65
|
.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title {
|
|
50
66
|
text-decoration: underline;
|
|
51
67
|
}
|
|
@@ -62,7 +78,10 @@
|
|
|
62
78
|
justify-content: center;
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
.wp-block-accordion-panel
|
|
81
|
+
.wp-block-accordion-panel.wp-block-accordion-panel {
|
|
82
|
+
min-width: 100%;
|
|
83
|
+
}
|
|
84
|
+
.wp-block-accordion-panel.wp-block-accordion-panel[inert], .wp-block-accordion-panel.wp-block-accordion-panel[aria-hidden=true] {
|
|
66
85
|
display: none;
|
|
67
86
|
margin-block-start: 0;
|
|
68
87
|
}
|
package/build-style/style.css
CHANGED
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
.wp-block-accordion-heading.wp-block-accordion-heading {
|
|
25
|
+
min-width: 100%;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
.wp-block-accordion-heading__toggle {
|
|
25
30
|
font-family: inherit;
|
|
26
31
|
font-size: inherit;
|
|
@@ -31,21 +36,32 @@
|
|
|
31
36
|
text-decoration: inherit;
|
|
32
37
|
word-spacing: inherit;
|
|
33
38
|
font-style: inherit;
|
|
34
|
-
background: none;
|
|
35
39
|
border: none;
|
|
36
|
-
color: inherit;
|
|
37
40
|
padding: var(--wp--preset--spacing--20, 1em) 0;
|
|
38
41
|
cursor: pointer;
|
|
39
42
|
overflow: hidden;
|
|
40
43
|
display: flex;
|
|
41
44
|
align-items: center;
|
|
42
45
|
text-align: inherit;
|
|
43
|
-
position: relative;
|
|
44
46
|
width: 100%;
|
|
47
|
+
background-color: inherit !important;
|
|
48
|
+
color: inherit !important;
|
|
45
49
|
}
|
|
46
50
|
.wp-block-accordion-heading__toggle:not(:focus-visible) {
|
|
47
51
|
outline: none;
|
|
48
52
|
}
|
|
53
|
+
.wp-block-accordion-heading__toggle:hover, .wp-block-accordion-heading__toggle:focus {
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
background-color: inherit !important;
|
|
56
|
+
box-shadow: none;
|
|
57
|
+
color: inherit;
|
|
58
|
+
border: none;
|
|
59
|
+
padding: var(--wp--preset--spacing--20, 1em) 0;
|
|
60
|
+
}
|
|
61
|
+
.wp-block-accordion-heading__toggle:focus-visible {
|
|
62
|
+
outline: auto;
|
|
63
|
+
outline-offset: 0;
|
|
64
|
+
}
|
|
49
65
|
.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title {
|
|
50
66
|
text-decoration: underline;
|
|
51
67
|
}
|
|
@@ -62,7 +78,10 @@
|
|
|
62
78
|
justify-content: center;
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
.wp-block-accordion-panel
|
|
81
|
+
.wp-block-accordion-panel.wp-block-accordion-panel {
|
|
82
|
+
min-width: 100%;
|
|
83
|
+
}
|
|
84
|
+
.wp-block-accordion-panel.wp-block-accordion-panel[inert], .wp-block-accordion-panel.wp-block-accordion-panel[aria-hidden=true] {
|
|
66
85
|
display: none;
|
|
67
86
|
margin-block-start: 0;
|
|
68
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.33.
|
|
3
|
+
"version": "9.33.7",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
"@wordpress/autop": "^4.33.1",
|
|
87
87
|
"@wordpress/base-styles": "^6.9.1",
|
|
88
88
|
"@wordpress/blob": "^4.33.1",
|
|
89
|
-
"@wordpress/block-editor": "^15.6.
|
|
90
|
-
"@wordpress/blocks": "^15.6.
|
|
91
|
-
"@wordpress/components": "^30.6.
|
|
89
|
+
"@wordpress/block-editor": "^15.6.6",
|
|
90
|
+
"@wordpress/blocks": "^15.6.2",
|
|
91
|
+
"@wordpress/components": "^30.6.4",
|
|
92
92
|
"@wordpress/compose": "^7.33.1",
|
|
93
|
-
"@wordpress/core-data": "^7.33.
|
|
93
|
+
"@wordpress/core-data": "^7.33.6",
|
|
94
94
|
"@wordpress/data": "^10.33.1",
|
|
95
95
|
"@wordpress/date": "^5.33.1",
|
|
96
96
|
"@wordpress/deprecated": "^4.33.1",
|
|
@@ -105,14 +105,14 @@
|
|
|
105
105
|
"@wordpress/interactivity-router": "^2.33.1",
|
|
106
106
|
"@wordpress/keyboard-shortcuts": "^5.33.1",
|
|
107
107
|
"@wordpress/keycodes": "^4.33.1",
|
|
108
|
-
"@wordpress/latex-to-mathml": "^1.1.
|
|
108
|
+
"@wordpress/latex-to-mathml": "^1.1.2",
|
|
109
109
|
"@wordpress/notices": "^5.33.1",
|
|
110
|
-
"@wordpress/patterns": "^2.33.
|
|
110
|
+
"@wordpress/patterns": "^2.33.6",
|
|
111
111
|
"@wordpress/primitives": "^4.33.1",
|
|
112
112
|
"@wordpress/private-apis": "^1.33.1",
|
|
113
|
-
"@wordpress/reusable-blocks": "^5.33.
|
|
114
|
-
"@wordpress/rich-text": "^7.33.
|
|
115
|
-
"@wordpress/server-side-render": "^6.9.
|
|
113
|
+
"@wordpress/reusable-blocks": "^5.33.6",
|
|
114
|
+
"@wordpress/rich-text": "^7.33.2",
|
|
115
|
+
"@wordpress/server-side-render": "^6.9.4",
|
|
116
116
|
"@wordpress/url": "^4.33.1",
|
|
117
117
|
"@wordpress/viewport": "^6.33.1",
|
|
118
118
|
"@wordpress/wordcount": "^4.33.1",
|
|
@@ -133,5 +133,5 @@
|
|
|
133
133
|
"publishConfig": {
|
|
134
134
|
"access": "public"
|
|
135
135
|
},
|
|
136
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "e821b2ec0a90d60aa7cafc248ba049f13b4265b7"
|
|
137
137
|
}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
// In many classic themes, selectors like `.entry-content h1` are used,
|
|
2
|
+
// potentially applying relatively high specificity (such as `0-1-1`) to
|
|
3
|
+
// heading elements. To properly override those styles, use a selector
|
|
4
|
+
// with a specificity of `0-2-0`.
|
|
5
|
+
.wp-block-accordion-heading.wp-block-accordion-heading {
|
|
6
|
+
// Some themes may have an explicit width. Since it's unpredictable
|
|
7
|
+
// what CSS specificity should be used to override them, ensure 100%
|
|
8
|
+
// width using min-width instead.
|
|
9
|
+
min-width: 100%;
|
|
10
|
+
// Some classic themes apply default margins to heading elements,
|
|
11
|
+
// so those styles need to be reset.
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
1
15
|
.wp-block-accordion-heading__toggle {
|
|
2
16
|
font-family: inherit;
|
|
3
17
|
font-size: inherit;
|
|
@@ -8,26 +22,45 @@
|
|
|
8
22
|
text-decoration: inherit;
|
|
9
23
|
word-spacing: inherit;
|
|
10
24
|
font-style: inherit;
|
|
11
|
-
background: none;
|
|
12
25
|
border: none;
|
|
13
|
-
color: inherit;
|
|
14
26
|
padding: var(--wp--preset--spacing--20, 1em) 0;
|
|
15
27
|
cursor: pointer;
|
|
16
28
|
overflow: hidden;
|
|
17
29
|
display: flex;
|
|
18
30
|
align-items: center;
|
|
19
31
|
text-align: inherit;
|
|
20
|
-
position: relative;
|
|
21
32
|
width: 100%;
|
|
22
33
|
|
|
34
|
+
// Some themes may apply colors to button elements with a particularly
|
|
35
|
+
// high CSS specificity. Since it's impossible to predict this specificity,
|
|
36
|
+
// we reset the colors using `!important`.
|
|
37
|
+
background-color: inherit !important;
|
|
38
|
+
color: inherit !important;
|
|
39
|
+
|
|
23
40
|
&:not(:focus-visible) {
|
|
24
41
|
outline: none;
|
|
25
42
|
}
|
|
26
43
|
|
|
27
|
-
&:hover
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
&:hover,
|
|
45
|
+
&:focus {
|
|
46
|
+
// Some themes may apply styles when a button element is hovered
|
|
47
|
+
// over or focused. This is not intended for accordion toggle
|
|
48
|
+
// buttons, so we reset it here.
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
background-color: inherit !important;
|
|
51
|
+
box-shadow: none;
|
|
52
|
+
color: inherit;
|
|
53
|
+
border: none;
|
|
54
|
+
padding: var(--wp--preset--spacing--20, 1em) 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus-visible {
|
|
58
|
+
outline: auto;
|
|
59
|
+
outline-offset: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:hover .wp-block-accordion-heading__toggle-title {
|
|
63
|
+
text-decoration: underline;
|
|
31
64
|
}
|
|
32
65
|
}
|
|
33
66
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
.wp-block
|
|
1
|
+
// Some classic themes may use selectors like `.wp-block .wp-block`
|
|
2
|
+
// and apply some kind of width to the blocks. To properly override
|
|
3
|
+
// those styles, use a selector with a specificity of `0-2-0`.
|
|
4
|
+
.wp-block-accordion-panel.wp-block-accordion-panel {
|
|
5
|
+
min-width: 100%;
|
|
6
|
+
|
|
2
7
|
// Prevent blockGap from Accordion Content block from adding extra margin between accordions.
|
|
3
8
|
&[inert],
|
|
4
9
|
&[aria-hidden="true"] {
|
package/src/heading/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import edit from './edit';
|
|
|
13
13
|
import metadata from './block.json';
|
|
14
14
|
import save from './save';
|
|
15
15
|
import transforms from './transforms';
|
|
16
|
+
import variations from './variations';
|
|
16
17
|
|
|
17
18
|
const { name } = metadata;
|
|
18
19
|
|
|
@@ -65,6 +66,7 @@ export const settings = {
|
|
|
65
66
|
},
|
|
66
67
|
edit,
|
|
67
68
|
save,
|
|
69
|
+
variations,
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { Path, SVG } from '@wordpress/primitives';
|
|
6
|
+
import { heading } from '@wordpress/icons';
|
|
7
|
+
|
|
8
|
+
const variations = [
|
|
9
|
+
{
|
|
10
|
+
name: 'heading',
|
|
11
|
+
title: __( 'Heading' ),
|
|
12
|
+
description: __(
|
|
13
|
+
'Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.'
|
|
14
|
+
),
|
|
15
|
+
isDefault: true,
|
|
16
|
+
scope: [ 'inserter', 'transform' ],
|
|
17
|
+
attributes: { fitText: undefined },
|
|
18
|
+
icon: heading,
|
|
19
|
+
},
|
|
20
|
+
// There is a hardcoded workaround in packages/block-editor/src/store/selectors.js
|
|
21
|
+
// to make Stretchy variations appear as the last of their sections in the inserter.
|
|
22
|
+
{
|
|
23
|
+
name: 'stretchy-heading',
|
|
24
|
+
title: __( 'Stretchy Heading' ),
|
|
25
|
+
description: __( 'Heading that resizes to fit its container.' ),
|
|
26
|
+
icon: (
|
|
27
|
+
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
28
|
+
<Path d="m3 18.6 6-4.7 6 4.7V5H3v13.6Zm16.2-9.8v1.5h2.2L17.7 14l1.1 1.1 3.7-3.7v2.2H24V8.8h-4.8Z" />
|
|
29
|
+
</SVG>
|
|
30
|
+
),
|
|
31
|
+
attributes: { fitText: true },
|
|
32
|
+
scope: [ 'inserter', 'transform' ],
|
|
33
|
+
isActive: ( blockAttributes ) => blockAttributes.fitText === true,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export default variations;
|
|
@@ -97,21 +97,35 @@ const useIsInvalidLink = ( kind, type, id, enabled ) => {
|
|
|
97
97
|
const hasId = Number.isInteger( id );
|
|
98
98
|
const blockEditingMode = useBlockEditingMode();
|
|
99
99
|
|
|
100
|
-
const postStatus = useSelect(
|
|
100
|
+
const { postStatus, isDeleted } = useSelect(
|
|
101
101
|
( select ) => {
|
|
102
102
|
if ( ! isPostType ) {
|
|
103
|
-
return null;
|
|
103
|
+
return { postStatus: null, isDeleted: false };
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// Fetching the posts status is an "expensive" operation. Especially for sites with large navigations.
|
|
107
107
|
// When the block is rendered in a template or other disabled contexts we can skip this check in order
|
|
108
108
|
// to avoid all these additional requests that don't really add any value in that mode.
|
|
109
109
|
if ( blockEditingMode === 'disabled' || ! enabled ) {
|
|
110
|
-
return null;
|
|
110
|
+
return { postStatus: null, isDeleted: false };
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
const { getEntityRecord } =
|
|
114
|
-
|
|
113
|
+
const { getEntityRecord, hasFinishedResolution } =
|
|
114
|
+
select( coreStore );
|
|
115
|
+
const entityRecord = getEntityRecord( 'postType', type, id );
|
|
116
|
+
const hasResolved = hasFinishedResolution( 'getEntityRecord', [
|
|
117
|
+
'postType',
|
|
118
|
+
type,
|
|
119
|
+
id,
|
|
120
|
+
] );
|
|
121
|
+
|
|
122
|
+
// If resolution has finished and entityRecord is undefined, the entity was deleted.
|
|
123
|
+
const deleted = hasResolved && entityRecord === undefined;
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
postStatus: entityRecord?.status,
|
|
127
|
+
isDeleted: deleted,
|
|
128
|
+
};
|
|
115
129
|
},
|
|
116
130
|
[ isPostType, blockEditingMode, enabled, type, id ]
|
|
117
131
|
);
|
|
@@ -121,11 +135,13 @@ const useIsInvalidLink = ( kind, type, id, enabled ) => {
|
|
|
121
135
|
// 2. It has an id.
|
|
122
136
|
// 3. It's neither null, nor undefined, as valid items might be either of those while loading.
|
|
123
137
|
// If those conditions are met, check if
|
|
124
|
-
// 1. The post status is
|
|
125
|
-
// 2. The
|
|
138
|
+
// 1. The post status is trash (trashed).
|
|
139
|
+
// 2. The entity doesn't exist (deleted).
|
|
126
140
|
// If either of those is true, invalidate.
|
|
127
141
|
const isInvalid =
|
|
128
|
-
isPostType &&
|
|
142
|
+
isPostType &&
|
|
143
|
+
hasId &&
|
|
144
|
+
( isDeleted || ( postStatus && 'trash' === postStatus ) );
|
|
129
145
|
const isDraft = 'draft' === postStatus;
|
|
130
146
|
|
|
131
147
|
return [ isInvalid, isDraft ];
|
|
@@ -248,7 +264,12 @@ export default function NavigationLinkEdit( {
|
|
|
248
264
|
const { getBlocks } = useSelect( blockEditorStore );
|
|
249
265
|
|
|
250
266
|
// URL binding logic
|
|
251
|
-
const {
|
|
267
|
+
const {
|
|
268
|
+
clearBinding,
|
|
269
|
+
createBinding,
|
|
270
|
+
hasUrlBinding,
|
|
271
|
+
isBoundEntityAvailable,
|
|
272
|
+
} = useEntityBinding( {
|
|
252
273
|
clientId,
|
|
253
274
|
attributes,
|
|
254
275
|
} );
|
|
@@ -405,14 +426,23 @@ export default function NavigationLinkEdit( {
|
|
|
405
426
|
}
|
|
406
427
|
);
|
|
407
428
|
|
|
408
|
-
if (
|
|
429
|
+
if (
|
|
430
|
+
! url ||
|
|
431
|
+
isInvalid ||
|
|
432
|
+
isDraft ||
|
|
433
|
+
( hasUrlBinding && ! isBoundEntityAvailable )
|
|
434
|
+
) {
|
|
409
435
|
blockProps.onClick = () => {
|
|
410
436
|
setIsLinkOpen( true );
|
|
411
437
|
};
|
|
412
438
|
}
|
|
413
439
|
|
|
414
440
|
const classes = clsx( 'wp-block-navigation-item__content', {
|
|
415
|
-
'wp-block-navigation-link__placeholder':
|
|
441
|
+
'wp-block-navigation-link__placeholder':
|
|
442
|
+
! url ||
|
|
443
|
+
isInvalid ||
|
|
444
|
+
isDraft ||
|
|
445
|
+
( hasUrlBinding && ! isBoundEntityAvailable ),
|
|
416
446
|
} );
|
|
417
447
|
|
|
418
448
|
const missingText = getMissingText( type );
|
|
@@ -531,9 +561,10 @@ export default function NavigationLinkEdit( {
|
|
|
531
561
|
link={ attributes }
|
|
532
562
|
onClose={ () => {
|
|
533
563
|
setIsLinkOpen( false );
|
|
534
|
-
// If there is no link
|
|
564
|
+
// If there is no link and no binding, remove the auto-inserted block.
|
|
535
565
|
// This avoids empty blocks which can provided a poor UX.
|
|
536
|
-
if (
|
|
566
|
+
// Don't remove if binding exists (even if entity is unavailable) so user can fix it.
|
|
567
|
+
if ( ! url && ! hasUrlBinding ) {
|
|
537
568
|
onReplace( [] );
|
|
538
569
|
} else if ( isNewLink.current ) {
|
|
539
570
|
// If we just created a new link, select it
|
|
@@ -26,6 +26,7 @@ import { useInstanceId } from '@wordpress/compose';
|
|
|
26
26
|
*/
|
|
27
27
|
import { LinkUIPageCreator } from './page-creator';
|
|
28
28
|
import LinkUIBlockInserter from './block-inserter';
|
|
29
|
+
import { useEntityBinding } from '../shared/use-entity-binding';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Given the Link block's type attribute, return the query params to give to
|
|
@@ -66,7 +67,8 @@ export function getSuggestionsQuery( type, kind ) {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
function UnforwardedLinkUI( props, ref ) {
|
|
69
|
-
const { label, url, opensInNewTab, type, kind, id
|
|
70
|
+
const { label, url, opensInNewTab, type, kind, id } = props.link;
|
|
71
|
+
const { clientId } = props;
|
|
70
72
|
const postType = type || 'page';
|
|
71
73
|
|
|
72
74
|
const [ addingBlock, setAddingBlock ] = useState( false );
|
|
@@ -78,12 +80,11 @@ function UnforwardedLinkUI( props, ref ) {
|
|
|
78
80
|
name: postType,
|
|
79
81
|
} );
|
|
80
82
|
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
!! id;
|
|
83
|
+
// Use the entity binding hook to get binding status
|
|
84
|
+
const { isBoundEntityAvailable } = useEntityBinding( {
|
|
85
|
+
clientId,
|
|
86
|
+
attributes: props.link,
|
|
87
|
+
} );
|
|
87
88
|
|
|
88
89
|
// Memoize link value to avoid overriding the LinkControl's internal state.
|
|
89
90
|
// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.
|
|
@@ -152,7 +153,7 @@ function UnforwardedLinkUI( props, ref ) {
|
|
|
152
153
|
onChange={ props.onChange }
|
|
153
154
|
onRemove={ props.onRemove }
|
|
154
155
|
onCancel={ props.onCancel }
|
|
155
|
-
handleEntities={
|
|
156
|
+
handleEntities={ isBoundEntityAvailable }
|
|
156
157
|
renderControlBottom={ () => {
|
|
157
158
|
// Don't show the tools when there is submitted link (preview state).
|
|
158
159
|
if ( link?.url?.length ) {
|