@wordpress/block-editor 7.0.3 → 7.0.4
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/components/block-actions/index.js +6 -5
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +17 -4
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-html.js +5 -0
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list-appender/index.js +9 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +10 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +1 -1
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +96 -7
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +17 -8
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +17 -13
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/copy-handler/index.js +3 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +2 -2
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +3 -5
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/index.js +0 -18
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +11 -1
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build/components/inserter/preview-panel.js +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +28 -0
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +7 -4
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +16 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/slot.js +5 -2
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/list-view/block-contents.js +1 -20
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +5 -36
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/list-item.js +3 -2
- package/build/components/list-view/list-item.js.map +1 -1
- package/build/components/media-placeholder/index.js +26 -17
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +30 -1
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +65 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build/components/rich-text/index.js +5 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +41 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +28 -9
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +22 -0
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/hooks/align.js +10 -7
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/font-family.js +93 -23
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/style.js +6 -3
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flow.js +4 -1
- package/build/layouts/flow.js.map +1 -1
- package/build/store/reducer.js +11 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/transform-styles/transforms/wrap.js +16 -0
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -5
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +17 -4
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-html.js +5 -0
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +9 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +10 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +96 -8
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +16 -9
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +18 -14
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/copy-handler/index.js +3 -3
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +2 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +3 -5
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/index.js +0 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +11 -1
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -1
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +7 -4
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +16 -2
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +4 -2
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -18
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +7 -37
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/list-item.js +3 -2
- package/build-module/components/list-view/list-item.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +26 -17
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +29 -2
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +53 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build-module/components/rich-text/index.js +4 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +41 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +28 -9
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +20 -0
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/hooks/align.js +10 -7
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/font-family.js +91 -24
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/style.js +6 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flow.js +4 -1
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/reducer.js +11 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +2 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/style-rtl.css +52 -76
- package/build-style/style.css +52 -76
- package/package.json +14 -14
- package/src/components/block-actions/index.js +5 -5
- package/src/components/block-alignment-control/use-available-alignments.js +18 -3
- package/src/components/block-inspector/index.js +1 -1
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list-appender/index.js +8 -0
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-preview/style.scss +0 -17
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu-controls/index.js +9 -6
- package/src/components/block-switcher/block-styles-menu.js +1 -1
- package/src/components/block-tools/index.js +5 -2
- package/src/components/block-tools/insertion-point.js +97 -9
- package/src/components/block-tools/style.scss +4 -35
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/test/utils.js +216 -0
- package/src/components/border-radius-control/utils.js +18 -10
- package/src/components/color-palette/test/__snapshots__/control.js.snap +103 -72
- package/src/components/colors-gradients/control.js +64 -61
- package/src/components/colors-gradients/style.scss +8 -5
- package/src/components/colors-gradients/test/control.js +43 -52
- package/src/components/copy-handler/index.js +1 -1
- package/src/components/default-block-appender/index.js +2 -2
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
- package/src/components/font-appearance-control/index.js +12 -14
- package/src/components/font-appearance-control/style.scss +1 -1
- package/src/components/index.js +0 -2
- package/src/components/inserter/block-patterns-tab.js +11 -4
- package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
- package/src/components/inserter/preview-panel.js +1 -1
- package/src/components/inserter/style.scss +1 -2
- package/src/components/inspector-controls/block-support-slot-container.js +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +4 -2
- package/src/components/inspector-controls/fill.js +23 -2
- package/src/components/inspector-controls/slot.js +6 -1
- package/src/components/link-control/style.scss +9 -5
- package/src/components/list-view/block-contents.js +17 -38
- package/src/components/list-view/block.js +6 -51
- package/src/components/list-view/list-item.js +5 -4
- package/src/components/list-view/style.scss +56 -30
- package/src/components/media-placeholder/index.js +24 -17
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +2 -0
- package/src/components/plain-text/index.native.js +26 -4
- package/src/components/rich-text/embed-handler-picker.native.js +67 -0
- package/src/components/rich-text/index.js +12 -8
- package/src/components/rich-text/index.native.js +35 -1
- package/src/components/rich-text/use-paste-handler.js +30 -12
- package/src/components/rich-text/utils.js +16 -0
- package/src/components/skip-to-selected-block/README.md +39 -0
- package/src/hooks/align.js +11 -7
- package/src/hooks/anchor.js +2 -2
- package/src/hooks/font-family.js +107 -27
- package/src/hooks/style.js +14 -8
- package/src/layouts/flow.js +4 -1
- package/src/store/reducer.js +17 -0
- package/src/store/selectors.js +2 -3
- package/src/store/test/reducer.js +22 -0
- package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
- package/src/utils/transform-styles/transforms/wrap.js +16 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/list-view/block-slot.js +0 -121
- package/build/components/list-view/block-slot.js.map +0 -1
- package/build/components/list-view/editor.js +0 -35
- package/build/components/list-view/editor.js.map +0 -1
- package/build-module/components/list-view/block-slot.js +0 -96
- package/build-module/components/list-view/block-slot.js.map +0 -1
- package/build-module/components/list-view/editor.js +0 -25
- package/build-module/components/list-view/editor.js.map +0 -1
- package/src/components/list-view/block-slot.js +0 -120
- package/src/components/list-view/editor.js +0 -29
|
@@ -4,27 +4,35 @@
|
|
|
4
4
|
import { __experimentalParseUnit as parseUnit } from '@wordpress/components';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Gets the item with the highest occurrence within an array
|
|
8
|
-
* https://stackoverflow.com/a/20762713
|
|
7
|
+
* Gets the (non-undefined) item with the highest occurrence within an array
|
|
8
|
+
* Based in part on: https://stackoverflow.com/a/20762713
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Undefined values are always sorted to the end by `sort`, so this function
|
|
11
|
+
* returns the first element, to always prioritize real values over undefined
|
|
12
|
+
* values.
|
|
13
|
+
*
|
|
14
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description
|
|
15
|
+
*
|
|
16
|
+
* @param {Array<any>} inputArray Array of items to check.
|
|
17
|
+
* @return {any} The item with the most occurrences.
|
|
12
18
|
*/
|
|
13
|
-
function mode(
|
|
19
|
+
export function mode( inputArray ) {
|
|
20
|
+
const arr = [ ...inputArray ];
|
|
14
21
|
return arr
|
|
15
22
|
.sort(
|
|
16
23
|
( a, b ) =>
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
inputArray.filter( ( v ) => v === b ).length -
|
|
25
|
+
inputArray.filter( ( v ) => v === a ).length
|
|
19
26
|
)
|
|
20
|
-
.
|
|
27
|
+
.shift();
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Returns the most common CSS unit in the radius values.
|
|
32
|
+
* Falls back to `px` as a default unit.
|
|
25
33
|
*
|
|
26
34
|
* @param {Object|string} values Radius values.
|
|
27
|
-
* @return {string} Most common CSS unit in values.
|
|
35
|
+
* @return {string} Most common CSS unit in values. Default: `px`.
|
|
28
36
|
*/
|
|
29
37
|
export function getAllUnit( values = {} ) {
|
|
30
38
|
if ( typeof values === 'string' ) {
|
|
@@ -37,7 +45,7 @@ export function getAllUnit( values = {} ) {
|
|
|
37
45
|
return unit;
|
|
38
46
|
} );
|
|
39
47
|
|
|
40
|
-
return mode( allUnits );
|
|
48
|
+
return mode( allUnits ) || 'px';
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
/**
|
|
@@ -14,6 +14,31 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
|
|
|
14
14
|
margin-bottom: inherit;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
.emotion-4 {
|
|
18
|
+
display: -webkit-box;
|
|
19
|
+
display: -webkit-flex;
|
|
20
|
+
display: -ms-flexbox;
|
|
21
|
+
display: flex;
|
|
22
|
+
-webkit-align-items: normal;
|
|
23
|
+
-webkit-box-align: normal;
|
|
24
|
+
-ms-flex-align: normal;
|
|
25
|
+
align-items: normal;
|
|
26
|
+
-webkit-flex-direction: column;
|
|
27
|
+
-ms-flex-direction: column;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
-webkit-box-pack: justify;
|
|
30
|
+
-webkit-justify-content: space-between;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.emotion-4>*+*:not( marquee ) {
|
|
35
|
+
margin-top: calc(4px * 2);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.emotion-4>* {
|
|
39
|
+
min-height: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
17
42
|
<div
|
|
18
43
|
className="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
|
|
19
44
|
>
|
|
@@ -21,97 +46,103 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
|
|
|
21
46
|
className="components-base-control__field emotion-2 emotion-3"
|
|
22
47
|
>
|
|
23
48
|
<fieldset>
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
49
|
+
<div
|
|
50
|
+
className="components-flex components-h-stack components-v-stack emotion-4 emotion-5"
|
|
51
|
+
data-wp-c16t={true}
|
|
52
|
+
data-wp-component="VStack"
|
|
53
|
+
>
|
|
54
|
+
<legend>
|
|
55
|
+
<div
|
|
56
|
+
className="block-editor-color-gradient-control__color-indicator"
|
|
30
57
|
>
|
|
31
|
-
Test Color
|
|
32
58
|
<span
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
className="components-base-control__label"
|
|
60
|
+
>
|
|
61
|
+
Test Color
|
|
62
|
+
<span
|
|
63
|
+
aria-label="(Color: #f00)"
|
|
64
|
+
className="component-color-indicator"
|
|
65
|
+
style={
|
|
66
|
+
Object {
|
|
67
|
+
"background": "#f00",
|
|
68
|
+
}
|
|
38
69
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</
|
|
42
|
-
</
|
|
43
|
-
</legend>
|
|
44
|
-
<div
|
|
45
|
-
className="components-circular-option-picker"
|
|
46
|
-
>
|
|
70
|
+
/>
|
|
71
|
+
</span>
|
|
72
|
+
</div>
|
|
73
|
+
</legend>
|
|
47
74
|
<div
|
|
48
|
-
className="components-circular-option-
|
|
75
|
+
className="components-circular-option-picker"
|
|
49
76
|
>
|
|
50
77
|
<div
|
|
51
|
-
className="components-circular-option-
|
|
78
|
+
className="components-circular-option-picker__swatches"
|
|
52
79
|
>
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
aria-label="Color: red"
|
|
56
|
-
aria-pressed={true}
|
|
57
|
-
className="components-button components-circular-option-picker__option is-pressed"
|
|
58
|
-
onBlur={[Function]}
|
|
59
|
-
onClick={[Function]}
|
|
60
|
-
onFocus={[Function]}
|
|
61
|
-
onMouseDown={[Function]}
|
|
62
|
-
onMouseEnter={[Function]}
|
|
63
|
-
onMouseLeave={[Function]}
|
|
64
|
-
style={
|
|
65
|
-
Object {
|
|
66
|
-
"backgroundColor": "#f00",
|
|
67
|
-
"color": "#f00",
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
type="button"
|
|
71
|
-
/>
|
|
72
|
-
<svg
|
|
73
|
-
aria-hidden={true}
|
|
74
|
-
fill="#000"
|
|
75
|
-
focusable={false}
|
|
76
|
-
height={24}
|
|
77
|
-
role="img"
|
|
78
|
-
viewBox="0 0 24 24"
|
|
79
|
-
width={24}
|
|
80
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
80
|
+
<div
|
|
81
|
+
className="components-circular-option-picker__option-wrapper"
|
|
81
82
|
>
|
|
82
|
-
<
|
|
83
|
-
|
|
83
|
+
<button
|
|
84
|
+
aria-describedby={null}
|
|
85
|
+
aria-label="Color: red"
|
|
86
|
+
aria-pressed={true}
|
|
87
|
+
className="components-button components-circular-option-picker__option is-pressed"
|
|
88
|
+
onBlur={[Function]}
|
|
89
|
+
onClick={[Function]}
|
|
90
|
+
onFocus={[Function]}
|
|
91
|
+
onMouseDown={[Function]}
|
|
92
|
+
onMouseEnter={[Function]}
|
|
93
|
+
onMouseLeave={[Function]}
|
|
94
|
+
style={
|
|
95
|
+
Object {
|
|
96
|
+
"backgroundColor": "#f00",
|
|
97
|
+
"color": "#f00",
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
type="button"
|
|
84
101
|
/>
|
|
85
|
-
|
|
102
|
+
<svg
|
|
103
|
+
aria-hidden={true}
|
|
104
|
+
fill="#000"
|
|
105
|
+
focusable={false}
|
|
106
|
+
height={24}
|
|
107
|
+
role="img"
|
|
108
|
+
viewBox="0 0 24 24"
|
|
109
|
+
width={24}
|
|
110
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
111
|
+
>
|
|
112
|
+
<path
|
|
113
|
+
d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
|
|
114
|
+
/>
|
|
115
|
+
</svg>
|
|
116
|
+
</div>
|
|
86
117
|
</div>
|
|
87
|
-
</div>
|
|
88
|
-
<div
|
|
89
|
-
className="components-circular-option-picker__custom-clear-wrapper"
|
|
90
|
-
>
|
|
91
118
|
<div
|
|
92
|
-
className="components-
|
|
93
|
-
tabIndex="-1"
|
|
119
|
+
className="components-circular-option-picker__custom-clear-wrapper"
|
|
94
120
|
>
|
|
121
|
+
<div
|
|
122
|
+
className="components-dropdown components-circular-option-picker__dropdown-link-action"
|
|
123
|
+
tabIndex="-1"
|
|
124
|
+
>
|
|
125
|
+
<button
|
|
126
|
+
aria-describedby={null}
|
|
127
|
+
aria-expanded={false}
|
|
128
|
+
aria-haspopup="true"
|
|
129
|
+
aria-label="Custom color picker"
|
|
130
|
+
className="components-button is-link"
|
|
131
|
+
onClick={[Function]}
|
|
132
|
+
type="button"
|
|
133
|
+
>
|
|
134
|
+
Custom color
|
|
135
|
+
</button>
|
|
136
|
+
</div>
|
|
95
137
|
<button
|
|
96
138
|
aria-describedby={null}
|
|
97
|
-
|
|
98
|
-
aria-haspopup="true"
|
|
99
|
-
aria-label="Custom color picker"
|
|
100
|
-
className="components-button is-link"
|
|
139
|
+
className="components-button components-circular-option-picker__clear is-secondary is-small"
|
|
101
140
|
onClick={[Function]}
|
|
102
141
|
type="button"
|
|
103
142
|
>
|
|
104
|
-
|
|
143
|
+
Clear
|
|
105
144
|
</button>
|
|
106
145
|
</div>
|
|
107
|
-
<button
|
|
108
|
-
aria-describedby={null}
|
|
109
|
-
className="components-button components-circular-option-picker__clear is-secondary is-small"
|
|
110
|
-
onClick={[Function]}
|
|
111
|
-
type="button"
|
|
112
|
-
>
|
|
113
|
-
Clear
|
|
114
|
-
</button>
|
|
115
146
|
</div>
|
|
116
147
|
</div>
|
|
117
148
|
</fieldset>
|
|
@@ -10,8 +10,9 @@ import { every, isEmpty } from 'lodash';
|
|
|
10
10
|
import { useState } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
12
|
BaseControl,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
__experimentalVStack as VStack,
|
|
14
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
15
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
15
16
|
ColorIndicator,
|
|
16
17
|
ColorPalette,
|
|
17
18
|
GradientPicker,
|
|
@@ -110,66 +111,68 @@ function ColorGradientControlInner( {
|
|
|
110
111
|
) }
|
|
111
112
|
>
|
|
112
113
|
<fieldset>
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
<VisualLabel
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
</Button>
|
|
134
|
-
<Button
|
|
135
|
-
isSmall
|
|
136
|
-
isPressed={ currentTab === 'gradient' }
|
|
137
|
-
onClick={ () => setCurrentTab( 'gradient' ) }
|
|
114
|
+
<VStack space={ 3 }>
|
|
115
|
+
<legend>
|
|
116
|
+
<div className="block-editor-color-gradient-control__color-indicator">
|
|
117
|
+
<BaseControl.VisualLabel>
|
|
118
|
+
<VisualLabel
|
|
119
|
+
currentTab={ currentTab }
|
|
120
|
+
label={ label }
|
|
121
|
+
colorValue={ colorValue }
|
|
122
|
+
gradientValue={ gradientValue }
|
|
123
|
+
/>
|
|
124
|
+
</BaseControl.VisualLabel>
|
|
125
|
+
</div>
|
|
126
|
+
</legend>
|
|
127
|
+
{ canChooseAColor && canChooseAGradient && (
|
|
128
|
+
<ToggleGroupControl
|
|
129
|
+
value={ currentTab }
|
|
130
|
+
onChange={ setCurrentTab }
|
|
131
|
+
label={ __( 'Select color type' ) }
|
|
132
|
+
hideLabelFromVision
|
|
133
|
+
isBlock
|
|
138
134
|
>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
135
|
+
<ToggleGroupControlOption
|
|
136
|
+
value="color"
|
|
137
|
+
label={ __( 'Solid' ) }
|
|
138
|
+
/>
|
|
139
|
+
<ToggleGroupControlOption
|
|
140
|
+
value="gradient"
|
|
141
|
+
label={ __( 'Gradient' ) }
|
|
142
|
+
/>
|
|
143
|
+
</ToggleGroupControl>
|
|
144
|
+
) }
|
|
145
|
+
{ ( currentTab === 'color' || ! canChooseAGradient ) && (
|
|
146
|
+
<ColorPalette
|
|
147
|
+
value={ colorValue }
|
|
148
|
+
onChange={
|
|
149
|
+
canChooseAGradient
|
|
150
|
+
? ( newColor ) => {
|
|
151
|
+
onColorChange( newColor );
|
|
152
|
+
onGradientChange();
|
|
153
|
+
}
|
|
154
|
+
: onColorChange
|
|
155
|
+
}
|
|
156
|
+
{ ...{ colors, disableCustomColors } }
|
|
157
|
+
clearable={ clearable }
|
|
158
|
+
/>
|
|
159
|
+
) }
|
|
160
|
+
{ ( currentTab === 'gradient' || ! canChooseAColor ) && (
|
|
161
|
+
<GradientPicker
|
|
162
|
+
value={ gradientValue }
|
|
163
|
+
onChange={
|
|
164
|
+
canChooseAColor
|
|
165
|
+
? ( newGradient ) => {
|
|
166
|
+
onGradientChange( newGradient );
|
|
167
|
+
onColorChange();
|
|
168
|
+
}
|
|
169
|
+
: onGradientChange
|
|
170
|
+
}
|
|
171
|
+
{ ...{ gradients, disableCustomGradients } }
|
|
172
|
+
clearable={ clearable }
|
|
173
|
+
/>
|
|
174
|
+
) }
|
|
175
|
+
</VStack>
|
|
173
176
|
</fieldset>
|
|
174
177
|
</BaseControl>
|
|
175
178
|
);
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
.block-editor-color-gradient-control__color-indicator {
|
|
3
3
|
margin-bottom: $grid-unit-15;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
.block-editor-color-gradient-control__button-tabs {
|
|
7
|
-
display: block;
|
|
8
|
-
margin-bottom: $grid-unit-15;
|
|
9
|
-
}
|
|
10
5
|
}
|
|
11
6
|
|
|
12
7
|
.block-editor-panel-color-gradient-settings {
|
|
@@ -45,4 +40,12 @@
|
|
|
45
40
|
margin-right: 0;
|
|
46
41
|
}
|
|
47
42
|
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// This shouldn't be needed but there's a rule in the inspector controls
|
|
46
|
+
// overriding this causing too much spacing.
|
|
47
|
+
// That generic rule should ideally be removed.
|
|
48
|
+
.block-editor-block-inspector & .components-base-control {
|
|
49
|
+
margin-bottom: inherit;
|
|
50
|
+
}
|
|
48
51
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
4
5
|
import { create, act } from 'react-test-renderer';
|
|
5
6
|
import { noop } from 'lodash';
|
|
6
7
|
|
|
@@ -27,67 +28,57 @@ const getButtonWithAriaLabelStartPredicate = ( ariaLabelStart ) => (
|
|
|
27
28
|
);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const
|
|
31
|
-
|
|
31
|
+
const getTabWithTestPredicate = ( text ) => ( element ) => {
|
|
32
|
+
return (
|
|
33
|
+
element.type === 'button' &&
|
|
34
|
+
element.props[ 'aria-label' ] &&
|
|
35
|
+
element.props[ 'aria-label' ] === text
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const colorTabButtonPredicate = getTabWithTestPredicate( 'Solid' );
|
|
40
|
+
const gradientTabButtonPredicate = getTabWithTestPredicate( 'Gradient' );
|
|
32
41
|
|
|
33
42
|
describe( 'ColorPaletteControl', () => {
|
|
34
43
|
it( 'renders tabs if it is possible to select a color and a gradient rendering a color picker at the start', async () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
onGradientChange={ noop }
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
66
|
-
} );
|
|
44
|
+
render(
|
|
45
|
+
<ColorGradientControl
|
|
46
|
+
label="Test Color Gradient"
|
|
47
|
+
colorValue="#f00"
|
|
48
|
+
colors={ [
|
|
49
|
+
{ color: '#f00', name: 'red' },
|
|
50
|
+
{ color: '#0f0', name: 'green' },
|
|
51
|
+
] }
|
|
52
|
+
gradients={ [
|
|
53
|
+
{
|
|
54
|
+
gradient:
|
|
55
|
+
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%',
|
|
56
|
+
name: 'Vivid cyan blue to vivid purple',
|
|
57
|
+
slug: 'vivid-cyan-blue-to-vivid-purple',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
gradient:
|
|
61
|
+
'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
|
|
62
|
+
name: 'Light green cyan to vivid green cyan',
|
|
63
|
+
slug: 'light-green-cyan-to-vivid-green-cyan',
|
|
64
|
+
},
|
|
65
|
+
] }
|
|
66
|
+
disableCustomColors={ false }
|
|
67
|
+
disableCustomGradients={ false }
|
|
68
|
+
onColorChange={ noop }
|
|
69
|
+
onGradientChange={ noop }
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
67
72
|
|
|
68
73
|
// Is showing the two tab buttons.
|
|
69
|
-
expect(
|
|
70
|
-
|
|
71
|
-
);
|
|
72
|
-
expect(
|
|
73
|
-
wrapper.root.findAll( gradientTabButtonPredicate )
|
|
74
|
-
).toHaveLength( 1 );
|
|
74
|
+
expect( screen.queryByLabelText( 'Solid' ) ).toBeInTheDocument();
|
|
75
|
+
expect( screen.queryByLabelText( 'Gradient' ) ).toBeInTheDocument();
|
|
75
76
|
|
|
76
77
|
// Is showing the two predefined Colors.
|
|
77
|
-
expect(
|
|
78
|
-
wrapper.root.findAll(
|
|
79
|
-
( element ) =>
|
|
80
|
-
element.type === 'button' &&
|
|
81
|
-
element.props &&
|
|
82
|
-
element.props[ 'aria-label' ] &&
|
|
83
|
-
element.props[ 'aria-label' ].startsWith( 'Color:' )
|
|
84
|
-
)
|
|
85
|
-
).toHaveLength( 2 );
|
|
78
|
+
expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
|
|
86
79
|
|
|
87
80
|
// Is showing the custom color picker.
|
|
88
|
-
expect(
|
|
89
|
-
wrapper.root.findAll( getButtonWithTestPredicate( 'Custom color' ) )
|
|
90
|
-
).toHaveLength( 1 );
|
|
81
|
+
expect( screen.queryByText( 'Custom color' ) ).toBeInTheDocument();
|
|
91
82
|
} );
|
|
92
83
|
|
|
93
84
|
it( 'renders the color picker and does not render tabs if it is only possible to select a color', async () => {
|
|
@@ -31,7 +31,7 @@ export function useNotifyCopy() {
|
|
|
31
31
|
let notice = '';
|
|
32
32
|
if ( selectedBlockClientIds.length === 1 ) {
|
|
33
33
|
const clientId = selectedBlockClientIds[ 0 ];
|
|
34
|
-
const
|
|
34
|
+
const title = getBlockType( getBlockName( clientId ) )?.title;
|
|
35
35
|
notice =
|
|
36
36
|
eventType === 'copy'
|
|
37
37
|
? sprintf(
|
|
@@ -59,8 +59,8 @@ export function DefaultBlockAppender( {
|
|
|
59
59
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
60
60
|
role="button"
|
|
61
61
|
aria-label={ __( 'Add block' ) }
|
|
62
|
-
//
|
|
63
|
-
className="
|
|
62
|
+
// A wrapping container for this one already has the wp-block className.
|
|
63
|
+
className="block-editor-default-block-appender__content"
|
|
64
64
|
onFocus={ onAppend }
|
|
65
65
|
>
|
|
66
66
|
{ showPrompt ? value : ZWNBSP }
|
|
@@ -7,7 +7,7 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
|
|
|
7
7
|
>
|
|
8
8
|
<p
|
|
9
9
|
aria-label="Add block"
|
|
10
|
-
className="
|
|
10
|
+
className="block-editor-default-block-appender__content"
|
|
11
11
|
contentEditable={true}
|
|
12
12
|
onFocus={
|
|
13
13
|
[MockFunction] {
|
|
@@ -43,7 +43,7 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
|
|
|
43
43
|
>
|
|
44
44
|
<p
|
|
45
45
|
aria-label="Add block"
|
|
46
|
-
className="
|
|
46
|
+
className="block-editor-default-block-appender__content"
|
|
47
47
|
contentEditable={true}
|
|
48
48
|
onFocus={[MockFunction]}
|
|
49
49
|
role="button"
|
|
@@ -67,7 +67,7 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = `
|
|
|
67
67
|
>
|
|
68
68
|
<p
|
|
69
69
|
aria-label="Add block"
|
|
70
|
-
className="
|
|
70
|
+
className="block-editor-default-block-appender__content"
|
|
71
71
|
contentEditable={true}
|
|
72
72
|
onFocus={[MockFunction]}
|
|
73
73
|
role="button"
|
|
@@ -195,19 +195,17 @@ export default function FontAppearanceControl( props ) {
|
|
|
195
195
|
};
|
|
196
196
|
|
|
197
197
|
return (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
onChange
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
) }
|
|
211
|
-
</fieldset>
|
|
198
|
+
hasStylesOrWeights && (
|
|
199
|
+
<CustomSelectControl
|
|
200
|
+
className="components-font-appearance-control"
|
|
201
|
+
label={ getLabel() }
|
|
202
|
+
describedBy={ getDescribedBy() }
|
|
203
|
+
options={ selectOptions }
|
|
204
|
+
value={ currentSelection }
|
|
205
|
+
onChange={ ( { selectedItem } ) =>
|
|
206
|
+
onChange( selectedItem.style )
|
|
207
|
+
}
|
|
208
|
+
/>
|
|
209
|
+
)
|
|
212
210
|
);
|
|
213
211
|
}
|
package/src/components/index.js
CHANGED
|
@@ -70,8 +70,6 @@ export { default as __experimentalLinkControlSearchResults } from './link-contro
|
|
|
70
70
|
export { default as __experimentalLinkControlSearchItem } from './link-control/search-item';
|
|
71
71
|
export { default as LineHeightControl } from './line-height-control';
|
|
72
72
|
export { default as __experimentalListView } from './list-view';
|
|
73
|
-
export { ListViewBlockFill as __experimentalListViewBlockFill } from './list-view/block-slot';
|
|
74
|
-
export { default as __experimentalListViewEditor } from './list-view/editor';
|
|
75
73
|
export { default as MediaReplaceFlow } from './media-replace-flow';
|
|
76
74
|
export { default as MediaPlaceholder } from './media-placeholder';
|
|
77
75
|
export { default as MediaUpload } from './media-upload';
|
|
@@ -31,11 +31,18 @@ function BlockPatternsCategory( {
|
|
|
31
31
|
// Remove any empty categories
|
|
32
32
|
const populatedCategories = useMemo(
|
|
33
33
|
() =>
|
|
34
|
-
allCategories
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
allCategories
|
|
35
|
+
.filter( ( category ) =>
|
|
36
|
+
allPatterns.some( ( pattern ) =>
|
|
37
|
+
pattern.categories?.includes( category.name )
|
|
38
|
+
)
|
|
37
39
|
)
|
|
38
|
-
|
|
40
|
+
.sort( ( { name: currentName }, { name: nextName } ) => {
|
|
41
|
+
if ( ! [ currentName, nextName ].includes( 'featured' ) ) {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
return currentName === 'featured' ? -1 : 1;
|
|
45
|
+
} ),
|
|
39
46
|
[ allPatterns, allCategories ]
|
|
40
47
|
);
|
|
41
48
|
|