@wordpress/block-library 9.30.0 → 9.30.1-next.836ecdcae.0
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/accordion-content/edit.js +8 -8
- package/build/accordion-content/edit.js.map +1 -1
- package/build/accordion-content/index.js +2 -1
- package/build/accordion-content/index.js.map +1 -1
- package/build/accordion-panel/index.js +2 -1
- package/build/accordion-panel/index.js.map +1 -1
- package/build/navigation/constants.js +5 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +45 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/leaf-more-menu.js +0 -1
- package/build/navigation/edit/leaf-more-menu.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +40 -5
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation-link/link-ui.js +64 -56
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-link/page-creator.js +143 -0
- package/build/navigation-link/page-creator.js.map +1 -0
- package/build/search/edit.js +22 -14
- package/build/search/edit.js.map +1 -1
- package/build-module/accordion-content/edit.js +8 -8
- package/build-module/accordion-content/edit.js.map +1 -1
- package/build-module/accordion-content/index.js +2 -1
- package/build-module/accordion-content/index.js.map +1 -1
- package/build-module/accordion-panel/index.js +2 -1
- package/build-module/accordion-panel/index.js.map +1 -1
- package/build-module/navigation/constants.js +5 -1
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +50 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/leaf-more-menu.js +0 -1
- package/build-module/navigation/edit/leaf-more-menu.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +40 -5
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +68 -60
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-link/page-creator.js +137 -0
- package/build-module/navigation-link/page-creator.js.map +1 -0
- package/build-module/search/edit.js +22 -14
- package/build-module/search/edit.js.map +1 -1
- package/build-style/accordion/style-rtl.css +5 -6
- package/build-style/accordion/style.css +5 -6
- package/build-style/editor-rtl.css +14 -0
- package/build-style/editor.css +14 -0
- package/build-style/form-input/style-rtl.css +4 -3
- package/build-style/form-input/style.css +4 -3
- package/build-style/navigation-link/editor-rtl.css +14 -0
- package/build-style/navigation-link/editor.css +14 -0
- package/build-style/navigation-link/style-rtl.css +1 -1
- package/build-style/navigation-link/style.css +1 -1
- package/build-style/post-comments-form/style-rtl.css +8 -5
- package/build-style/post-comments-form/style.css +8 -5
- package/build-style/search/style-rtl.css +11 -12
- package/build-style/search/style.css +11 -12
- package/build-style/style-rtl.css +29 -27
- package/build-style/style.css +29 -27
- package/package.json +35 -35
- package/src/accordion/style.scss +6 -6
- package/src/accordion-content/block.json +2 -1
- package/src/accordion-content/edit.js +21 -27
- package/src/accordion-panel/block.json +2 -1
- package/src/cover/test/edit.js +1 -5
- package/src/form-input/style.scss +3 -2
- package/src/navigation/constants.js +4 -0
- package/src/navigation/edit/index.js +50 -1
- package/src/navigation/edit/leaf-more-menu.js +0 -1
- package/src/navigation/edit/menu-inspector-controls.js +40 -5
- package/src/navigation-link/editor.scss +17 -0
- package/src/navigation-link/link-ui.js +88 -81
- package/src/navigation-link/page-creator.js +164 -0
- package/src/navigation-link/style.scss +1 -1
- package/src/post-comments-form/style.scss +11 -11
- package/src/search/edit.js +44 -13
- package/src/search/index.php +16 -2
- package/src/search/style.scss +15 -16
package/build-style/style.css
CHANGED
|
@@ -147,11 +147,6 @@
|
|
|
147
147
|
transform: rotate(45deg);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.accordion-content__heading {
|
|
151
|
-
margin-block-start: 0;
|
|
152
|
-
margin-block-end: 0;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
150
|
.accordion-content__toggle {
|
|
156
151
|
font-family: inherit;
|
|
157
152
|
font-size: inherit;
|
|
@@ -182,7 +177,11 @@
|
|
|
182
177
|
.is-layout-flow > .wp-block-accordion-panel,
|
|
183
178
|
.wp-block-accordion-panel {
|
|
184
179
|
overflow: hidden;
|
|
185
|
-
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.wp-block-accordion-panel[inert],
|
|
183
|
+
.wp-block-accordion-panel[aria-hidden=true] {
|
|
184
|
+
margin-block-start: 0;
|
|
186
185
|
}
|
|
187
186
|
|
|
188
187
|
.accordion-panel__wrapper {
|
|
@@ -1304,15 +1303,16 @@ body:not(.editor-styles-wrapper) .wp-block-cover:not(.wp-block-cover:has(.wp-blo
|
|
|
1304
1303
|
width: fit-content;
|
|
1305
1304
|
}
|
|
1306
1305
|
|
|
1307
|
-
.wp-block-form-input__input {
|
|
1306
|
+
:where(.wp-block-form-input__input) {
|
|
1308
1307
|
padding: 0 0.5em;
|
|
1309
1308
|
font-size: 1em;
|
|
1310
1309
|
margin-bottom: 0.5em;
|
|
1311
1310
|
}
|
|
1312
|
-
.wp-block-form-input__input[type=text], .wp-block-form-input__input[type=password], .wp-block-form-input__input[type=date], .wp-block-form-input__input[type=datetime], .wp-block-form-input__input[type=datetime-local], .wp-block-form-input__input[type=email], .wp-block-form-input__input[type=month], .wp-block-form-input__input[type=number], .wp-block-form-input__input[type=search], .wp-block-form-input__input[type=tel], .wp-block-form-input__input[type=time], .wp-block-form-input__input[type=url], .wp-block-form-input__input[type=week] {
|
|
1311
|
+
:where(.wp-block-form-input__input)[type=text], :where(.wp-block-form-input__input)[type=password], :where(.wp-block-form-input__input)[type=date], :where(.wp-block-form-input__input)[type=datetime], :where(.wp-block-form-input__input)[type=datetime-local], :where(.wp-block-form-input__input)[type=email], :where(.wp-block-form-input__input)[type=month], :where(.wp-block-form-input__input)[type=number], :where(.wp-block-form-input__input)[type=search], :where(.wp-block-form-input__input)[type=tel], :where(.wp-block-form-input__input)[type=time], :where(.wp-block-form-input__input)[type=url], :where(.wp-block-form-input__input)[type=week] {
|
|
1313
1312
|
min-height: 2em;
|
|
1314
1313
|
line-height: 2;
|
|
1315
|
-
border: 1px
|
|
1314
|
+
border-width: 1px;
|
|
1315
|
+
border-style: solid;
|
|
1316
1316
|
}
|
|
1317
1317
|
|
|
1318
1318
|
textarea.wp-block-form-input__input {
|
|
@@ -2900,7 +2900,7 @@ html.has-modal-open {
|
|
|
2900
2900
|
}
|
|
2901
2901
|
|
|
2902
2902
|
.link-ui-tools {
|
|
2903
|
-
|
|
2903
|
+
outline: 1px solid #f0f0f0;
|
|
2904
2904
|
padding: 8px;
|
|
2905
2905
|
}
|
|
2906
2906
|
|
|
@@ -3007,14 +3007,17 @@ p.has-text-align-left[style*="writing-mode:vertical-lr"] {
|
|
|
3007
3007
|
box-sizing: border-box;
|
|
3008
3008
|
}
|
|
3009
3009
|
|
|
3010
|
-
:where(.wp-block-post-comments-form
|
|
3011
|
-
:where(.wp-block-post-comments-form
|
|
3012
|
-
border: 1px
|
|
3010
|
+
:where(.wp-block-post-comments-form textarea),
|
|
3011
|
+
:where(.wp-block-post-comments-form input:not([type=submit])) {
|
|
3012
|
+
border-width: 1px;
|
|
3013
|
+
border-style: solid;
|
|
3014
|
+
border-color: #949494;
|
|
3013
3015
|
font-size: 1em;
|
|
3014
3016
|
font-family: inherit;
|
|
3015
3017
|
}
|
|
3016
|
-
|
|
3017
|
-
:where(.wp-block-post-comments-form
|
|
3018
|
+
|
|
3019
|
+
:where(.wp-block-post-comments-form textarea),
|
|
3020
|
+
:where(.wp-block-post-comments-form input:where(:not([type=submit]):not([type=checkbox]))) {
|
|
3018
3021
|
padding: calc(0.667em + 2px);
|
|
3019
3022
|
}
|
|
3020
3023
|
|
|
@@ -3505,17 +3508,6 @@ ul.wp-block-rss.is-grid li {
|
|
|
3505
3508
|
width: 100%;
|
|
3506
3509
|
}
|
|
3507
3510
|
|
|
3508
|
-
.wp-block-search__input {
|
|
3509
|
-
padding: 8px;
|
|
3510
|
-
flex-grow: 1;
|
|
3511
|
-
margin-left: 0;
|
|
3512
|
-
margin-right: 0;
|
|
3513
|
-
min-width: 3rem;
|
|
3514
|
-
border: 1px solid #949494;
|
|
3515
|
-
text-decoration: unset !important;
|
|
3516
|
-
appearance: initial;
|
|
3517
|
-
}
|
|
3518
|
-
|
|
3519
3511
|
.wp-block-search.wp-block-search__button-only .wp-block-search__button {
|
|
3520
3512
|
margin-left: 0;
|
|
3521
3513
|
flex-shrink: 0;
|
|
@@ -3558,11 +3550,21 @@ ul.wp-block-rss.is-grid li {
|
|
|
3558
3550
|
letter-spacing: inherit;
|
|
3559
3551
|
text-transform: inherit;
|
|
3560
3552
|
font-style: inherit;
|
|
3553
|
+
padding: 8px;
|
|
3554
|
+
flex-grow: 1;
|
|
3555
|
+
margin-left: 0;
|
|
3556
|
+
margin-right: 0;
|
|
3557
|
+
min-width: 3rem;
|
|
3558
|
+
border: 1px solid #949494;
|
|
3559
|
+
text-decoration: unset !important;
|
|
3560
|
+
appearance: initial;
|
|
3561
3561
|
}
|
|
3562
3562
|
|
|
3563
3563
|
:where(.wp-block-search__button-inside .wp-block-search__inside-wrapper) {
|
|
3564
3564
|
padding: 4px;
|
|
3565
|
-
border: 1px
|
|
3565
|
+
border-width: 1px;
|
|
3566
|
+
border-style: solid;
|
|
3567
|
+
border-color: #949494;
|
|
3566
3568
|
background-color: #fff;
|
|
3567
3569
|
box-sizing: border-box;
|
|
3568
3570
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.30.0",
|
|
3
|
+
"version": "9.30.1-next.836ecdcae.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -42,39 +42,39 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "7.25.7",
|
|
45
|
-
"@wordpress/a11y": "^4.30.0",
|
|
46
|
-
"@wordpress/api-fetch": "^7.30.0",
|
|
47
|
-
"@wordpress/autop": "^4.30.0",
|
|
48
|
-
"@wordpress/blob": "^4.30.0",
|
|
49
|
-
"@wordpress/block-editor": "^15.3.0",
|
|
50
|
-
"@wordpress/blocks": "^15.3.0",
|
|
51
|
-
"@wordpress/components": "^30.3.0",
|
|
52
|
-
"@wordpress/compose": "^7.30.0",
|
|
53
|
-
"@wordpress/core-data": "^7.30.0",
|
|
54
|
-
"@wordpress/data": "^10.30.0",
|
|
55
|
-
"@wordpress/date": "^5.30.0",
|
|
56
|
-
"@wordpress/deprecated": "^4.30.0",
|
|
57
|
-
"@wordpress/dom": "^4.30.0",
|
|
58
|
-
"@wordpress/element": "^6.30.0",
|
|
59
|
-
"@wordpress/escape-html": "^3.30.0",
|
|
60
|
-
"@wordpress/hooks": "^4.30.0",
|
|
61
|
-
"@wordpress/html-entities": "^4.30.0",
|
|
62
|
-
"@wordpress/i18n": "^6.3.0",
|
|
63
|
-
"@wordpress/icons": "^10.30.0",
|
|
64
|
-
"@wordpress/interactivity": "^6.30.0",
|
|
65
|
-
"@wordpress/interactivity-router": "^2.30.0",
|
|
66
|
-
"@wordpress/keyboard-shortcuts": "^5.30.0",
|
|
67
|
-
"@wordpress/keycodes": "^4.30.0",
|
|
68
|
-
"@wordpress/notices": "^5.30.0",
|
|
69
|
-
"@wordpress/patterns": "^2.30.0",
|
|
70
|
-
"@wordpress/primitives": "^4.30.0",
|
|
71
|
-
"@wordpress/private-apis": "^1.30.0",
|
|
72
|
-
"@wordpress/reusable-blocks": "^5.30.0",
|
|
73
|
-
"@wordpress/rich-text": "^7.30.0",
|
|
74
|
-
"@wordpress/server-side-render": "^6.6.0",
|
|
75
|
-
"@wordpress/url": "^4.30.0",
|
|
76
|
-
"@wordpress/viewport": "^6.30.0",
|
|
77
|
-
"@wordpress/wordcount": "^4.30.0",
|
|
45
|
+
"@wordpress/a11y": "^4.30.1-next.836ecdcae.0",
|
|
46
|
+
"@wordpress/api-fetch": "^7.30.1-next.836ecdcae.0",
|
|
47
|
+
"@wordpress/autop": "^4.30.1-next.836ecdcae.0",
|
|
48
|
+
"@wordpress/blob": "^4.30.1-next.836ecdcae.0",
|
|
49
|
+
"@wordpress/block-editor": "^15.3.1-next.836ecdcae.0",
|
|
50
|
+
"@wordpress/blocks": "^15.3.1-next.836ecdcae.0",
|
|
51
|
+
"@wordpress/components": "^30.3.2-next.836ecdcae.0",
|
|
52
|
+
"@wordpress/compose": "^7.30.1-next.836ecdcae.0",
|
|
53
|
+
"@wordpress/core-data": "^7.30.1-next.836ecdcae.0",
|
|
54
|
+
"@wordpress/data": "^10.30.1-next.836ecdcae.0",
|
|
55
|
+
"@wordpress/date": "^5.30.1-next.836ecdcae.0",
|
|
56
|
+
"@wordpress/deprecated": "^4.30.1-next.836ecdcae.0",
|
|
57
|
+
"@wordpress/dom": "^4.30.1-next.836ecdcae.0",
|
|
58
|
+
"@wordpress/element": "^6.30.1-next.836ecdcae.0",
|
|
59
|
+
"@wordpress/escape-html": "^3.30.1-next.836ecdcae.0",
|
|
60
|
+
"@wordpress/hooks": "^4.30.1-next.836ecdcae.0",
|
|
61
|
+
"@wordpress/html-entities": "^4.30.1-next.836ecdcae.0",
|
|
62
|
+
"@wordpress/i18n": "^6.3.1-next.836ecdcae.0",
|
|
63
|
+
"@wordpress/icons": "^10.30.1-next.836ecdcae.0",
|
|
64
|
+
"@wordpress/interactivity": "^6.30.1-next.836ecdcae.0",
|
|
65
|
+
"@wordpress/interactivity-router": "^2.30.1-next.836ecdcae.0",
|
|
66
|
+
"@wordpress/keyboard-shortcuts": "^5.30.1-next.836ecdcae.0",
|
|
67
|
+
"@wordpress/keycodes": "^4.30.1-next.836ecdcae.0",
|
|
68
|
+
"@wordpress/notices": "^5.30.1-next.836ecdcae.0",
|
|
69
|
+
"@wordpress/patterns": "^2.30.1-next.836ecdcae.0",
|
|
70
|
+
"@wordpress/primitives": "^4.30.1-next.836ecdcae.0",
|
|
71
|
+
"@wordpress/private-apis": "^1.30.1-next.836ecdcae.0",
|
|
72
|
+
"@wordpress/reusable-blocks": "^5.30.1-next.836ecdcae.0",
|
|
73
|
+
"@wordpress/rich-text": "^7.30.1-next.836ecdcae.0",
|
|
74
|
+
"@wordpress/server-side-render": "^6.6.1-next.836ecdcae.0",
|
|
75
|
+
"@wordpress/url": "^4.30.1-next.836ecdcae.0",
|
|
76
|
+
"@wordpress/viewport": "^6.30.1-next.836ecdcae.0",
|
|
77
|
+
"@wordpress/wordcount": "^4.30.1-next.836ecdcae.0",
|
|
78
78
|
"change-case": "^4.1.2",
|
|
79
79
|
"clsx": "^2.1.1",
|
|
80
80
|
"colord": "^2.7.0",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "3e60b4c1e78d7b27acbf1d7dd172bbd64358a0f2"
|
|
96
96
|
}
|
package/src/accordion/style.scss
CHANGED
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.accordion-content__heading {
|
|
17
|
-
margin-block-start: 0;
|
|
18
|
-
margin-block-end: 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
.accordion-content__toggle {
|
|
22
17
|
font-family: inherit;
|
|
23
18
|
font-size: inherit;
|
|
@@ -48,7 +43,12 @@
|
|
|
48
43
|
.is-layout-flow > .wp-block-accordion-panel,
|
|
49
44
|
.wp-block-accordion-panel {
|
|
50
45
|
overflow: hidden;
|
|
51
|
-
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Prevent blockGap from Accordion Content block from adding extra margin between accordions.
|
|
49
|
+
.wp-block-accordion-panel[inert],
|
|
50
|
+
.wp-block-accordion-panel[aria-hidden="true"] {
|
|
51
|
+
margin-block-start: 0;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
.accordion-panel__wrapper {
|
|
@@ -25,11 +25,8 @@ import clsx from 'clsx';
|
|
|
25
25
|
*/
|
|
26
26
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
27
27
|
|
|
28
|
-
export default function Edit( {
|
|
29
|
-
|
|
30
|
-
clientId,
|
|
31
|
-
setAttributes,
|
|
32
|
-
} ) {
|
|
28
|
+
export default function Edit( { attributes, clientId, setAttributes } ) {
|
|
29
|
+
const { openByDefault } = attributes;
|
|
33
30
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
34
31
|
|
|
35
32
|
const { isSelected, getBlockOrder } = useSelect(
|
|
@@ -67,29 +64,26 @@ export default function Edit( {
|
|
|
67
64
|
updateBlockAttributes,
|
|
68
65
|
] );
|
|
69
66
|
|
|
70
|
-
const blockProps = useBlockProps(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
openByDefault,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
67
|
+
const blockProps = useBlockProps( {
|
|
68
|
+
className: clsx( {
|
|
69
|
+
'is-open': openByDefault || isSelected,
|
|
70
|
+
} ),
|
|
71
|
+
} );
|
|
72
|
+
|
|
73
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
74
|
+
template: [
|
|
75
|
+
[ 'core/accordion-header', {} ],
|
|
76
|
+
[
|
|
77
|
+
'core/accordion-panel',
|
|
78
|
+
{
|
|
79
|
+
openByDefault,
|
|
80
|
+
},
|
|
87
81
|
],
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
82
|
+
],
|
|
83
|
+
templateLock: 'all',
|
|
84
|
+
directInsert: true,
|
|
85
|
+
templateInsertUpdatesSelection: true,
|
|
86
|
+
} );
|
|
93
87
|
|
|
94
88
|
return (
|
|
95
89
|
<>
|
package/src/cover/test/edit.js
CHANGED
|
@@ -51,11 +51,7 @@ async function createAndSelectBlock() {
|
|
|
51
51
|
name: 'Black',
|
|
52
52
|
} )
|
|
53
53
|
);
|
|
54
|
-
await
|
|
55
|
-
screen.getByRole( 'button', {
|
|
56
|
-
name: 'Select parent block: Cover',
|
|
57
|
-
} )
|
|
58
|
-
);
|
|
54
|
+
await selectBlock( 'Block: Cover' );
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
describe( 'Cover block', () => {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
width: fit-content;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
.wp-block-form-input__input {
|
|
37
|
+
:where(.wp-block-form-input__input) {
|
|
38
38
|
padding: 0 0.5em;
|
|
39
39
|
font-size: 1em;
|
|
40
40
|
margin-bottom: 0.5em;
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
&[type="week"] {
|
|
55
55
|
min-height: 2em;
|
|
56
56
|
line-height: 2;
|
|
57
|
-
border: 1px
|
|
57
|
+
border-width: 1px;
|
|
58
|
+
border-style: solid;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
|
|
27
27
|
__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
|
|
28
28
|
useBlockEditingMode,
|
|
29
|
+
BlockControls,
|
|
29
30
|
} from '@wordpress/block-editor';
|
|
30
31
|
import { EntityProvider, store as coreStore } from '@wordpress/core-data';
|
|
31
32
|
|
|
@@ -40,10 +41,13 @@ import {
|
|
|
40
41
|
Button,
|
|
41
42
|
Spinner,
|
|
42
43
|
Notice,
|
|
44
|
+
ToolbarButton,
|
|
45
|
+
ToolbarGroup,
|
|
43
46
|
} from '@wordpress/components';
|
|
44
47
|
import { __ } from '@wordpress/i18n';
|
|
45
48
|
import { speak } from '@wordpress/a11y';
|
|
46
|
-
import { close, Icon } from '@wordpress/icons';
|
|
49
|
+
import { close, Icon, page } from '@wordpress/icons';
|
|
50
|
+
import { createBlock } from '@wordpress/blocks';
|
|
47
51
|
import { useInstanceId } from '@wordpress/compose';
|
|
48
52
|
|
|
49
53
|
/**
|
|
@@ -75,6 +79,48 @@ import AccessibleDescription from './accessible-description';
|
|
|
75
79
|
import AccessibleMenuDescription from './accessible-menu-description';
|
|
76
80
|
import { unlock } from '../../lock-unlock';
|
|
77
81
|
import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
|
|
82
|
+
import { DEFAULT_BLOCK } from '../constants';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Component that renders the Add page button for the Navigation block.
|
|
86
|
+
*
|
|
87
|
+
* @param {Object} props Component props.
|
|
88
|
+
* @param {string} props.clientId Block client ID.
|
|
89
|
+
* @return {JSX.Element|null} The Add page button component or null if not applicable.
|
|
90
|
+
*/
|
|
91
|
+
function NavigationAddPageButton( { clientId } ) {
|
|
92
|
+
const { insertBlock } = useDispatch( blockEditorStore );
|
|
93
|
+
const { getBlockCount } = useSelect( blockEditorStore );
|
|
94
|
+
|
|
95
|
+
const onAddPage = useCallback( () => {
|
|
96
|
+
// Get the current number of blocks to insert at the end
|
|
97
|
+
const blockCount = getBlockCount( clientId );
|
|
98
|
+
|
|
99
|
+
// Create a new navigation link block (default block)
|
|
100
|
+
const newBlock = createBlock( DEFAULT_BLOCK.name, {
|
|
101
|
+
kind: DEFAULT_BLOCK.attributes.kind,
|
|
102
|
+
type: DEFAULT_BLOCK.attributes.type,
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
// Insert the block at the end of the navigation
|
|
106
|
+
insertBlock( newBlock, blockCount, clientId );
|
|
107
|
+
}, [ clientId, insertBlock, getBlockCount ] );
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<BlockControls>
|
|
111
|
+
<ToolbarGroup>
|
|
112
|
+
<ToolbarButton
|
|
113
|
+
name="add-page"
|
|
114
|
+
icon={ page }
|
|
115
|
+
title={ __( 'Add page' ) }
|
|
116
|
+
onClick={ onAddPage }
|
|
117
|
+
>
|
|
118
|
+
{ __( 'Add page' ) }
|
|
119
|
+
</ToolbarButton>
|
|
120
|
+
</ToolbarGroup>
|
|
121
|
+
</BlockControls>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
78
124
|
|
|
79
125
|
function ColorTools( {
|
|
80
126
|
textColor,
|
|
@@ -937,6 +983,9 @@ function Navigation( {
|
|
|
937
983
|
blockEditingMode={ blockEditingMode }
|
|
938
984
|
/>
|
|
939
985
|
{ blockEditingMode === 'default' && stylingInspectorControls }
|
|
986
|
+
{ blockEditingMode === 'contentOnly' && isEntityAvailable && (
|
|
987
|
+
<NavigationAddPageButton clientId={ clientId } />
|
|
988
|
+
) }
|
|
940
989
|
{ blockEditingMode === 'default' && isEntityAvailable && (
|
|
941
990
|
<InspectorControls group="advanced">
|
|
942
991
|
{ hasResolvedCanUserUpdateNavigationMenu &&
|
|
@@ -35,7 +35,8 @@ const BLOCKS_WITH_LINK_UI_SUPPORT = [
|
|
|
35
35
|
const { PrivateListView } = unlock( blockEditorPrivateApis );
|
|
36
36
|
|
|
37
37
|
function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
|
|
38
|
-
const { updateBlockAttributes } =
|
|
38
|
+
const { updateBlockAttributes, removeBlock } =
|
|
39
|
+
useDispatch( blockEditorStore );
|
|
39
40
|
|
|
40
41
|
const supportsLinkControls = BLOCKS_WITH_LINK_UI_SUPPORT?.includes(
|
|
41
42
|
insertedBlock?.name
|
|
@@ -47,6 +48,27 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
|
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Cleanup function for auto-inserted Navigation Link blocks.
|
|
53
|
+
*
|
|
54
|
+
* Removes the block if it has no URL and clears the inserted block state.
|
|
55
|
+
* This ensures consistent cleanup behavior across different contexts.
|
|
56
|
+
*/
|
|
57
|
+
const cleanupInsertedBlock = () => {
|
|
58
|
+
// Prevent automatic block selection when removing blocks in list view context
|
|
59
|
+
// This avoids focus stealing that would close the list view and switch to canvas
|
|
60
|
+
const shouldAutoSelectBlock = false;
|
|
61
|
+
|
|
62
|
+
// Follows the exact same pattern as Navigation Link block's onClose handler
|
|
63
|
+
// If there is no URL then remove the auto-inserted block to avoid empty blocks
|
|
64
|
+
if ( ! insertedBlock?.attributes?.url && insertedBlock?.clientId ) {
|
|
65
|
+
// Remove the block entirely to avoid poor UX
|
|
66
|
+
// This matches the Navigation Link block's behavior
|
|
67
|
+
removeBlock( insertedBlock.clientId, shouldAutoSelectBlock );
|
|
68
|
+
}
|
|
69
|
+
setInsertedBlock( null );
|
|
70
|
+
};
|
|
71
|
+
|
|
50
72
|
const setInsertedBlockAttributes =
|
|
51
73
|
( _insertedBlockClientId ) => ( _updatedAttributes ) => {
|
|
52
74
|
if ( ! _insertedBlockClientId ) {
|
|
@@ -55,12 +77,28 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
|
|
|
55
77
|
updateBlockAttributes( _insertedBlockClientId, _updatedAttributes );
|
|
56
78
|
};
|
|
57
79
|
|
|
80
|
+
// Wrapper function to clean up original block when a new block is selected
|
|
81
|
+
const handleSetInsertedBlock = ( newBlock ) => {
|
|
82
|
+
// Prevent automatic block selection when removing blocks in list view context
|
|
83
|
+
// This avoids focus stealing that would close the list view and switch to canvas
|
|
84
|
+
const shouldAutoSelectBlock = false;
|
|
85
|
+
|
|
86
|
+
// If we have an existing inserted block and a new block is being set,
|
|
87
|
+
// remove the original block to avoid duplicates
|
|
88
|
+
if ( insertedBlock?.clientId && newBlock ) {
|
|
89
|
+
removeBlock( insertedBlock.clientId, shouldAutoSelectBlock );
|
|
90
|
+
}
|
|
91
|
+
setInsertedBlock( newBlock );
|
|
92
|
+
};
|
|
93
|
+
|
|
58
94
|
return (
|
|
59
95
|
<LinkUI
|
|
60
96
|
clientId={ insertedBlock?.clientId }
|
|
61
97
|
link={ insertedBlock?.attributes }
|
|
98
|
+
onBlockInsert={ handleSetInsertedBlock }
|
|
62
99
|
onClose={ () => {
|
|
63
|
-
|
|
100
|
+
// Use cleanup function
|
|
101
|
+
cleanupInsertedBlock();
|
|
64
102
|
} }
|
|
65
103
|
onChange={ ( updatedValue ) => {
|
|
66
104
|
updateAttributes(
|
|
@@ -70,9 +108,6 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
|
|
|
70
108
|
);
|
|
71
109
|
setInsertedBlock( null );
|
|
72
110
|
} }
|
|
73
|
-
onCancel={ () => {
|
|
74
|
-
setInsertedBlock( null );
|
|
75
|
-
} }
|
|
76
111
|
/>
|
|
77
112
|
);
|
|
78
113
|
}
|
|
@@ -122,3 +122,20 @@
|
|
|
122
122
|
gap: $grid-unit-10;
|
|
123
123
|
height: auto;
|
|
124
124
|
}
|
|
125
|
+
|
|
126
|
+
.link-ui-page-creator {
|
|
127
|
+
// Match LinkControl width constraints for consistent UI sizing
|
|
128
|
+
max-width: 350px;
|
|
129
|
+
min-width: auto;
|
|
130
|
+
width: 90vw;
|
|
131
|
+
padding-top: $grid-unit-10;
|
|
132
|
+
|
|
133
|
+
&__inner {
|
|
134
|
+
padding: $grid-unit-20;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&__back {
|
|
138
|
+
margin-left: $grid-unit-10;
|
|
139
|
+
text-transform: uppercase;
|
|
140
|
+
}
|
|
141
|
+
}
|