@wordpress/block-editor 10.4.0 → 10.5.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/CHANGELOG.md +7 -0
- package/README.md +0 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -3
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +44 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +5 -3
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +39 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +13 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +39 -26
- package/build-style/style.css +39 -26
- package/package.json +28 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-list/style.scss +10 -5
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +7 -4
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +76 -16
- package/src/hooks/layout.js +2 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +16 -9
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +19 -0
|
@@ -33,7 +33,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
33
33
|
fontSize: '30px',
|
|
34
34
|
} );
|
|
35
35
|
expect( fluidTypographyValues ).toBe(
|
|
36
|
-
'clamp(22.5px, 1.406rem + ((1vw - 7.68px) *
|
|
36
|
+
'clamp(22.5px, 1.406rem + ((1vw - 7.68px) * 0.901), 30px)'
|
|
37
37
|
);
|
|
38
38
|
} );
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
42
42
|
fontSize: '30px',
|
|
43
43
|
} );
|
|
44
44
|
expect( fluidTypographyValues ).toBe(
|
|
45
|
-
'clamp(22.5px, 1.406rem + ((1vw - 7.68px) *
|
|
45
|
+
'clamp(22.5px, 1.406rem + ((1vw - 7.68px) * 0.901), 30px)'
|
|
46
46
|
);
|
|
47
47
|
} );
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
53
53
|
maximumViewPortWidth: '1000px',
|
|
54
54
|
} );
|
|
55
55
|
expect( fluidTypographyValues ).toBe(
|
|
56
|
-
'clamp(22.5px, 1.406rem + ((1vw - 5px) *
|
|
56
|
+
'clamp(22.5px, 1.406rem + ((1vw - 5px) * 1.5), 30px)'
|
|
57
57
|
);
|
|
58
58
|
} );
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
63
63
|
scaleFactor: '2',
|
|
64
64
|
} );
|
|
65
65
|
expect( fluidTypographyValues ).toBe(
|
|
66
|
-
'clamp(22.5px, 1.406rem + ((1vw - 7.68px) *
|
|
66
|
+
'clamp(22.5px, 1.406rem + ((1vw - 7.68px) * 1.803), 30px)'
|
|
67
67
|
);
|
|
68
68
|
} );
|
|
69
69
|
|
|
@@ -74,7 +74,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
74
74
|
maximumFontSizeFactor: '2',
|
|
75
75
|
} );
|
|
76
76
|
expect( fluidTypographyValues ).toBe(
|
|
77
|
-
'clamp(15px, 0.938rem + ((1vw - 7.68px) *
|
|
77
|
+
'clamp(15px, 0.938rem + ((1vw - 7.68px) * 1.803), 30px)'
|
|
78
78
|
);
|
|
79
79
|
} );
|
|
80
80
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find, pickBy
|
|
4
|
+
import { find, pickBy } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -43,8 +43,7 @@ export default ( ...fontSizeNames ) => {
|
|
|
43
43
|
* and the value is the custom font size attribute name.
|
|
44
44
|
* Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
|
|
45
45
|
*/
|
|
46
|
-
const fontSizeAttributeNames = reduce(
|
|
47
|
-
fontSizeNames,
|
|
46
|
+
const fontSizeAttributeNames = fontSizeNames.reduce(
|
|
48
47
|
( fontSizeAttributeNamesAccumulator, fontSizeAttributeName ) => {
|
|
49
48
|
fontSizeAttributeNamesAccumulator[
|
|
50
49
|
fontSizeAttributeName
|
|
@@ -81,12 +80,13 @@ export default ( ...fontSizeNames ) => {
|
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
createSetters() {
|
|
84
|
-
return reduce(
|
|
85
|
-
fontSizeAttributeNames,
|
|
83
|
+
return Object.entries( fontSizeAttributeNames ).reduce(
|
|
86
84
|
(
|
|
87
85
|
settersAccumulator,
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
[
|
|
87
|
+
fontSizeAttributeName,
|
|
88
|
+
customFontSizeAttributeName,
|
|
89
|
+
]
|
|
90
90
|
) => {
|
|
91
91
|
const upperFirstFontSizeAttributeName =
|
|
92
92
|
upperFirst( fontSizeAttributeName );
|
|
@@ -159,15 +159,18 @@ export default ( ...fontSizeNames ) => {
|
|
|
159
159
|
return null;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const newState =
|
|
162
|
+
const newState = Object.entries(
|
|
163
163
|
pickBy(
|
|
164
164
|
fontSizeAttributeNames,
|
|
165
165
|
didAttributesChange
|
|
166
|
-
)
|
|
166
|
+
)
|
|
167
|
+
).reduce(
|
|
167
168
|
(
|
|
168
169
|
newStateAccumulator,
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
[
|
|
171
|
+
fontSizeAttributeName,
|
|
172
|
+
customFontSizeAttributeName,
|
|
173
|
+
]
|
|
171
174
|
) => {
|
|
172
175
|
const fontSizeAttributeValue =
|
|
173
176
|
attributes[ fontSizeAttributeName ];
|
package/src/components/index.js
CHANGED
|
@@ -73,6 +73,7 @@ export { default as __experimentalLinkControlSearchResults } from './link-contro
|
|
|
73
73
|
export { default as __experimentalLinkControlSearchItem } from './link-control/search-item';
|
|
74
74
|
export { default as LineHeightControl } from './line-height-control';
|
|
75
75
|
export { default as __experimentalListView } from './list-view';
|
|
76
|
+
export { default as __experimentalOffCanvasEditor } from './off-canvas-editor';
|
|
76
77
|
export { default as MediaReplaceFlow } from './media-replace-flow';
|
|
77
78
|
export { default as MediaPlaceholder } from './media-placeholder';
|
|
78
79
|
export { default as MediaUpload } from './media-upload';
|
|
@@ -150,7 +150,8 @@ const ForwardedInnerBlocks = forwardRef( ( props, ref ) => {
|
|
|
150
150
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
|
|
151
151
|
*/
|
|
152
152
|
export function useInnerBlocksProps( props = {}, options = {} ) {
|
|
153
|
-
const { __unstableDisableLayoutClassNames } =
|
|
153
|
+
const { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =
|
|
154
|
+
options;
|
|
154
155
|
const { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =
|
|
155
156
|
useBlockEditContext();
|
|
156
157
|
const isSmallScreen = useViewportMatch( 'medium', '<' );
|
|
@@ -187,11 +188,13 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
|
|
|
187
188
|
[ clientId, isSmallScreen ]
|
|
188
189
|
);
|
|
189
190
|
|
|
191
|
+
const blockDropZoneRef = useBlockDropZone( {
|
|
192
|
+
rootClientId: clientId,
|
|
193
|
+
} );
|
|
194
|
+
|
|
190
195
|
const ref = useMergeRefs( [
|
|
191
196
|
props.ref,
|
|
192
|
-
|
|
193
|
-
rootClientId: clientId,
|
|
194
|
-
} ),
|
|
197
|
+
__unstableDisableDropZone ? null : blockDropZoneRef,
|
|
195
198
|
] );
|
|
196
199
|
|
|
197
200
|
const innerBlocksProps = {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useMemo } from '@wordpress/element';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { addQueryArgs } from '@wordpress/url';
|
|
7
|
+
import { Button } from '@wordpress/components';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -59,14 +60,15 @@ export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
|
|
|
59
60
|
rootClientId={ rootClientId }
|
|
60
61
|
/>
|
|
61
62
|
<div className="block-editor-inserter__manage-reusable-blocks-container">
|
|
62
|
-
<
|
|
63
|
+
<Button
|
|
63
64
|
className="block-editor-inserter__manage-reusable-blocks"
|
|
65
|
+
variant="secondary"
|
|
64
66
|
href={ addQueryArgs( 'edit.php', {
|
|
65
67
|
post_type: 'wp_block',
|
|
66
68
|
} ) }
|
|
67
69
|
>
|
|
68
70
|
{ __( 'Manage Reusable blocks' ) }
|
|
69
|
-
</
|
|
71
|
+
</Button>
|
|
70
72
|
</div>
|
|
71
73
|
</>
|
|
72
74
|
);
|
|
@@ -174,9 +174,13 @@ $block-inserter-tabs-height: 44px;
|
|
|
174
174
|
text-align: right;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
.block-editor-inserter__manage-reusable-blocks-container {
|
|
178
|
+
margin: auto $grid-unit-20 $grid-unit-20;
|
|
179
|
+
}
|
|
180
|
+
|
|
177
181
|
.block-editor-inserter__manage-reusable-blocks {
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
justify-content: center;
|
|
183
|
+
width: 100%;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
.block-editor-inserter__no-results {
|
|
@@ -341,10 +345,6 @@ $block-inserter-tabs-height: 44px;
|
|
|
341
345
|
position: relative; // prevents overscroll when block library is open
|
|
342
346
|
}
|
|
343
347
|
|
|
344
|
-
.block-editor-inserter__manage-reusable-blocks-container {
|
|
345
|
-
padding: $grid-unit-20;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
348
|
.block-editor-inserter__quick-inserter {
|
|
349
349
|
width: 100%;
|
|
350
350
|
|
|
@@ -442,7 +442,8 @@ $block-inserter-tabs-height: 44px;
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
&__list {
|
|
445
|
-
margin-left: $sidebar-width
|
|
445
|
+
margin-left: $sidebar-width;
|
|
446
|
+
padding: $grid-unit-30 0 $grid-unit-40;
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
.block-editor-block-patterns-list {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render,
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
-
import { useSelect } from '@wordpress/data';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
@@ -22,35 +21,6 @@ jest.mock( '../hooks/use-block-types-state', () => {
|
|
|
22
21
|
return mock;
|
|
23
22
|
} );
|
|
24
23
|
|
|
25
|
-
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
26
|
-
// This allows us to tweak the returned value on each test.
|
|
27
|
-
const mock = jest.fn();
|
|
28
|
-
return mock;
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
|
-
jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
|
|
32
|
-
return {
|
|
33
|
-
useDispatch: () => ( {} ),
|
|
34
|
-
};
|
|
35
|
-
} );
|
|
36
|
-
|
|
37
|
-
const debouncedSpeak = jest.fn();
|
|
38
|
-
|
|
39
|
-
function InserterBlockList( props ) {
|
|
40
|
-
return <ReusableBlocksTab debouncedSpeak={ debouncedSpeak } { ...props } />;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const initializeAllClosedMenuState = ( propOverrides ) => {
|
|
44
|
-
const { container } = render( <InserterBlockList { ...propOverrides } /> );
|
|
45
|
-
const activeTabs = container.querySelectorAll(
|
|
46
|
-
'.components-panel__body.is-opened button.components-panel__body-toggle'
|
|
47
|
-
);
|
|
48
|
-
activeTabs.forEach( ( tab ) => {
|
|
49
|
-
fireEvent.click( tab );
|
|
50
|
-
} );
|
|
51
|
-
return container;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
24
|
describe( 'InserterMenu', () => {
|
|
55
25
|
beforeAll( () => {
|
|
56
26
|
registerBlockType( 'core/block', {
|
|
@@ -59,19 +29,17 @@ describe( 'InserterMenu', () => {
|
|
|
59
29
|
edit: () => {},
|
|
60
30
|
} );
|
|
61
31
|
} );
|
|
32
|
+
|
|
62
33
|
afterAll( () => {
|
|
63
34
|
unregisterBlockType( 'core/block' );
|
|
64
35
|
} );
|
|
65
|
-
beforeEach( () => {
|
|
66
|
-
debouncedSpeak.mockClear();
|
|
67
36
|
|
|
37
|
+
beforeEach( () => {
|
|
68
38
|
useBlockTypesState.mockImplementation( () => [
|
|
69
39
|
items,
|
|
70
40
|
categories,
|
|
71
41
|
collections,
|
|
72
42
|
] );
|
|
73
|
-
|
|
74
|
-
useSelect.mockImplementation( () => false );
|
|
75
43
|
} );
|
|
76
44
|
|
|
77
45
|
it( 'should show nothing if there are no items', () => {
|
|
@@ -81,36 +49,25 @@ describe( 'InserterMenu', () => {
|
|
|
81
49
|
categories,
|
|
82
50
|
collections,
|
|
83
51
|
] );
|
|
84
|
-
const { container } = render(
|
|
85
|
-
<InserterBlockList filterValue="random" />
|
|
86
|
-
);
|
|
87
|
-
const visibleBlocks = container.querySelector(
|
|
88
|
-
'.block-editor-block-types-list__item'
|
|
89
|
-
);
|
|
90
52
|
|
|
91
|
-
|
|
53
|
+
render( <ReusableBlocksTab filterValue="random" /> );
|
|
54
|
+
|
|
55
|
+
expect( screen.queryByRole( 'option' ) ).not.toBeInTheDocument();
|
|
92
56
|
} );
|
|
93
57
|
|
|
94
58
|
it( 'should list reusable blocks', () => {
|
|
95
|
-
|
|
96
|
-
const blocks = container.querySelectorAll(
|
|
97
|
-
'.block-editor-block-types-list__item-title'
|
|
98
|
-
);
|
|
59
|
+
render( <ReusableBlocksTab /> );
|
|
99
60
|
|
|
100
|
-
expect(
|
|
101
|
-
|
|
61
|
+
expect(
|
|
62
|
+
screen.getByRole( 'option', { name: 'My reusable block' } )
|
|
63
|
+
).toBeVisible();
|
|
102
64
|
} );
|
|
103
65
|
|
|
104
66
|
it( 'should trim whitespace of search terms', () => {
|
|
105
|
-
|
|
106
|
-
<InserterBlockList filterValue=" my reusable" />
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const blocks = container.querySelectorAll(
|
|
110
|
-
'.block-editor-block-types-list__item-title'
|
|
111
|
-
);
|
|
67
|
+
render( <ReusableBlocksTab filterValue=" my reusable" /> );
|
|
112
68
|
|
|
113
|
-
expect(
|
|
114
|
-
|
|
69
|
+
expect(
|
|
70
|
+
screen.getByRole( 'option', { name: 'My reusable block' } )
|
|
71
|
+
).toBeVisible();
|
|
115
72
|
} );
|
|
116
73
|
} );
|
|
@@ -20,6 +20,7 @@ import LinkControlSettingsDrawer from './settings-drawer';
|
|
|
20
20
|
import LinkControlSearchInput from './search-input';
|
|
21
21
|
import LinkPreview from './link-preview';
|
|
22
22
|
import useCreatePage from './use-create-page';
|
|
23
|
+
import useInternalInputValue from './use-internal-input-value';
|
|
23
24
|
import { ViewerFill } from './viewer-slot';
|
|
24
25
|
import { DEFAULT_LINK_SETTINGS } from './constants';
|
|
25
26
|
|
|
@@ -132,22 +133,19 @@ function LinkControl( {
|
|
|
132
133
|
const isMounting = useRef( true );
|
|
133
134
|
const wrapperNode = useRef();
|
|
134
135
|
const textInputRef = useRef();
|
|
136
|
+
const isEndingEditWithFocus = useRef( false );
|
|
137
|
+
|
|
138
|
+
const [ internalUrlInputValue, setInternalUrlInputValue ] =
|
|
139
|
+
useInternalInputValue( value?.url || '' );
|
|
140
|
+
|
|
141
|
+
const [ internalTextInputValue, setInternalTextInputValue ] =
|
|
142
|
+
useInternalInputValue( value?.title || '' );
|
|
135
143
|
|
|
136
|
-
const [ internalInputValue, setInternalInputValue ] = useState(
|
|
137
|
-
value?.url || ''
|
|
138
|
-
);
|
|
139
|
-
const [ internalTextValue, setInternalTextValue ] = useState(
|
|
140
|
-
value?.title || ''
|
|
141
|
-
);
|
|
142
|
-
const currentInputValue = propInputValue || internalInputValue;
|
|
143
144
|
const [ isEditingLink, setIsEditingLink ] = useState(
|
|
144
145
|
forceIsEditingLink !== undefined
|
|
145
146
|
? forceIsEditingLink
|
|
146
147
|
: ! value || ! value.url
|
|
147
148
|
);
|
|
148
|
-
const isEndingEditWithFocus = useRef( false );
|
|
149
|
-
|
|
150
|
-
const currentInputIsEmpty = ! currentInputValue?.trim()?.length;
|
|
151
149
|
|
|
152
150
|
const { createPage, isCreatingPage, errorMessage } =
|
|
153
151
|
useCreatePage( createSuggestion );
|
|
@@ -191,53 +189,35 @@ function LinkControl( {
|
|
|
191
189
|
isEndingEditWithFocus.current = false;
|
|
192
190
|
}, [ isEditingLink, isCreatingPage ] );
|
|
193
191
|
|
|
194
|
-
useEffect( () => {
|
|
195
|
-
/**
|
|
196
|
-
* If the value's `text` property changes then sync this
|
|
197
|
-
* back up with state.
|
|
198
|
-
*/
|
|
199
|
-
if ( value?.title && value.title !== internalTextValue ) {
|
|
200
|
-
setInternalTextValue( value.title );
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Update the state value internalInputValue if the url value changes
|
|
205
|
-
* for example when clicking on another anchor
|
|
206
|
-
*/
|
|
207
|
-
if ( value?.url ) {
|
|
208
|
-
setInternalInputValue( value.url );
|
|
209
|
-
}
|
|
210
|
-
}, [ value ] );
|
|
211
|
-
|
|
212
192
|
/**
|
|
213
193
|
* Cancels editing state and marks that focus may need to be restored after
|
|
214
194
|
* the next render, if focus was within the wrapper when editing finished.
|
|
215
195
|
*/
|
|
216
|
-
|
|
196
|
+
const stopEditing = () => {
|
|
217
197
|
isEndingEditWithFocus.current = !! wrapperNode.current?.contains(
|
|
218
198
|
wrapperNode.current.ownerDocument.activeElement
|
|
219
199
|
);
|
|
220
200
|
|
|
221
201
|
setIsEditingLink( false );
|
|
222
|
-
}
|
|
202
|
+
};
|
|
223
203
|
|
|
224
204
|
const handleSelectSuggestion = ( updatedValue ) => {
|
|
225
205
|
onChange( {
|
|
226
206
|
...updatedValue,
|
|
227
|
-
title:
|
|
207
|
+
title: internalTextInputValue || updatedValue?.title,
|
|
228
208
|
} );
|
|
229
209
|
stopEditing();
|
|
230
210
|
};
|
|
231
211
|
|
|
232
212
|
const handleSubmit = () => {
|
|
233
213
|
if (
|
|
234
|
-
|
|
235
|
-
|
|
214
|
+
currentUrlInputValue !== value?.url ||
|
|
215
|
+
internalTextInputValue !== value?.title
|
|
236
216
|
) {
|
|
237
217
|
onChange( {
|
|
238
218
|
...value,
|
|
239
|
-
url:
|
|
240
|
-
title:
|
|
219
|
+
url: currentUrlInputValue,
|
|
220
|
+
title: internalTextInputValue,
|
|
241
221
|
} );
|
|
242
222
|
}
|
|
243
223
|
stopEditing();
|
|
@@ -254,6 +234,10 @@ function LinkControl( {
|
|
|
254
234
|
}
|
|
255
235
|
};
|
|
256
236
|
|
|
237
|
+
const currentUrlInputValue = propInputValue || internalUrlInputValue;
|
|
238
|
+
|
|
239
|
+
const currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;
|
|
240
|
+
|
|
257
241
|
const shownUnlinkControl =
|
|
258
242
|
onRemove && value && ! isEditingLink && ! isCreatingPage;
|
|
259
243
|
|
|
@@ -289,8 +273,8 @@ function LinkControl( {
|
|
|
289
273
|
ref={ textInputRef }
|
|
290
274
|
className="block-editor-link-control__field block-editor-link-control__text-content"
|
|
291
275
|
label="Text"
|
|
292
|
-
value={
|
|
293
|
-
onChange={
|
|
276
|
+
value={ internalTextInputValue }
|
|
277
|
+
onChange={ setInternalTextInputValue }
|
|
294
278
|
onKeyDown={ handleSubmitWithEnter }
|
|
295
279
|
/>
|
|
296
280
|
) }
|
|
@@ -299,10 +283,10 @@ function LinkControl( {
|
|
|
299
283
|
currentLink={ value }
|
|
300
284
|
className="block-editor-link-control__field block-editor-link-control__search-input"
|
|
301
285
|
placeholder={ searchInputPlaceholder }
|
|
302
|
-
value={
|
|
286
|
+
value={ currentUrlInputValue }
|
|
303
287
|
withCreateSuggestion={ withCreateSuggestion }
|
|
304
288
|
onCreateSuggestion={ createPage }
|
|
305
|
-
onChange={
|
|
289
|
+
onChange={ setInternalUrlInputValue }
|
|
306
290
|
onSelect={ handleSelectSuggestion }
|
|
307
291
|
showInitialSuggestions={ showInitialSuggestions }
|
|
308
292
|
allowDirectEntry={ ! noDirectEntry }
|
|
@@ -111,7 +111,7 @@ const LinkControlSearchInput = forwardRef(
|
|
|
111
111
|
allowDirectEntry ||
|
|
112
112
|
( suggestion && Object.keys( suggestion ).length >= 1 )
|
|
113
113
|
) {
|
|
114
|
-
const { id, url, ...restLinkProps } = currentLink;
|
|
114
|
+
const { id, url, ...restLinkProps } = currentLink ?? {};
|
|
115
115
|
onSelect(
|
|
116
116
|
// Some direct entries don't have types or IDs, and we still need to clear the previous ones.
|
|
117
117
|
{ ...restLinkProps, ...suggestion },
|