@wordpress/block-editor 8.5.4 → 9.0.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 +9 -0
- package/README.md +4 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +97 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +7 -3
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +83 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +7 -3
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +5 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +128 -276
- package/build-style/style.css +128 -276
- package/package.json +28 -28
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +90 -0
- package/src/components/block-popover/style.scss +27 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +0 -1
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/index.js +11 -41
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/url-input/index.js +6 -3
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -6,60 +6,23 @@ import classNames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { __
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import {
|
|
11
11
|
ToolbarDropdownMenu,
|
|
12
12
|
ToolbarGroup,
|
|
13
13
|
MenuGroup,
|
|
14
14
|
MenuItem,
|
|
15
15
|
} from '@wordpress/components';
|
|
16
|
-
import {
|
|
17
|
-
alignNone,
|
|
18
|
-
positionCenter,
|
|
19
|
-
positionLeft,
|
|
20
|
-
positionRight,
|
|
21
|
-
stretchFullWidth,
|
|
22
|
-
stretchWide,
|
|
23
|
-
} from '@wordpress/icons';
|
|
24
|
-
import { Platform } from '@wordpress/element';
|
|
25
16
|
|
|
26
17
|
/**
|
|
27
18
|
* Internal dependencies
|
|
28
19
|
*/
|
|
29
20
|
import useAvailableAlignments from './use-available-alignments';
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
left: {
|
|
37
|
-
icon: positionLeft,
|
|
38
|
-
title: __( 'Align left' ),
|
|
39
|
-
},
|
|
40
|
-
center: {
|
|
41
|
-
icon: positionCenter,
|
|
42
|
-
title: __( 'Align center' ),
|
|
43
|
-
},
|
|
44
|
-
right: {
|
|
45
|
-
icon: positionRight,
|
|
46
|
-
title: __( 'Align right' ),
|
|
47
|
-
},
|
|
48
|
-
wide: {
|
|
49
|
-
icon: stretchWide,
|
|
50
|
-
title: __( 'Wide width' ),
|
|
51
|
-
},
|
|
52
|
-
full: {
|
|
53
|
-
icon: stretchFullWidth,
|
|
54
|
-
title: __( 'Full width' ),
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const DEFAULT_CONTROL = 'none';
|
|
59
|
-
|
|
60
|
-
const POPOVER_PROPS = {
|
|
61
|
-
isAlternate: true,
|
|
62
|
-
};
|
|
21
|
+
import {
|
|
22
|
+
BLOCK_ALIGNMENTS_CONTROLS,
|
|
23
|
+
DEFAULT_CONTROL,
|
|
24
|
+
POPOVER_PROPS,
|
|
25
|
+
} from './constants';
|
|
63
26
|
|
|
64
27
|
function BlockAlignmentUI( {
|
|
65
28
|
value,
|
|
@@ -92,72 +55,69 @@ function BlockAlignmentUI( {
|
|
|
92
55
|
label: __( 'Align' ),
|
|
93
56
|
toggleProps: { describedBy: __( 'Change alignment' ) },
|
|
94
57
|
};
|
|
95
|
-
const extraProps =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
);
|
|
159
|
-
},
|
|
160
|
-
};
|
|
58
|
+
const extraProps = isToolbar
|
|
59
|
+
? {
|
|
60
|
+
isCollapsed,
|
|
61
|
+
controls: enabledControls.map( ( { name: controlName } ) => {
|
|
62
|
+
return {
|
|
63
|
+
...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
|
|
64
|
+
isActive:
|
|
65
|
+
value === controlName ||
|
|
66
|
+
( ! value && controlName === 'none' ),
|
|
67
|
+
role: isCollapsed ? 'menuitemradio' : undefined,
|
|
68
|
+
onClick: () => onChangeAlignment( controlName ),
|
|
69
|
+
};
|
|
70
|
+
} ),
|
|
71
|
+
}
|
|
72
|
+
: {
|
|
73
|
+
children: ( { onClose } ) => {
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<MenuGroup className="block-editor-block-alignment-control__menu-group">
|
|
77
|
+
{ enabledControls.map(
|
|
78
|
+
( { name: controlName, info } ) => {
|
|
79
|
+
const {
|
|
80
|
+
icon,
|
|
81
|
+
title,
|
|
82
|
+
} = BLOCK_ALIGNMENTS_CONTROLS[
|
|
83
|
+
controlName
|
|
84
|
+
];
|
|
85
|
+
// If no value is provided, mark as selected the `none` option.
|
|
86
|
+
const isSelected =
|
|
87
|
+
controlName === value ||
|
|
88
|
+
( ! value &&
|
|
89
|
+
controlName === 'none' );
|
|
90
|
+
return (
|
|
91
|
+
<MenuItem
|
|
92
|
+
key={ controlName }
|
|
93
|
+
icon={ icon }
|
|
94
|
+
iconPosition="left"
|
|
95
|
+
className={ classNames(
|
|
96
|
+
'components-dropdown-menu__menu-item',
|
|
97
|
+
{
|
|
98
|
+
'is-active': isSelected,
|
|
99
|
+
}
|
|
100
|
+
) }
|
|
101
|
+
isSelected={ isSelected }
|
|
102
|
+
onClick={ () => {
|
|
103
|
+
onChangeAlignment(
|
|
104
|
+
controlName
|
|
105
|
+
);
|
|
106
|
+
onClose();
|
|
107
|
+
} }
|
|
108
|
+
role="menuitemradio"
|
|
109
|
+
info={ info }
|
|
110
|
+
>
|
|
111
|
+
{ title }
|
|
112
|
+
</MenuItem>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
) }
|
|
116
|
+
</MenuGroup>
|
|
117
|
+
</>
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
161
121
|
|
|
162
122
|
return <UIComponent { ...commonProps } { ...extraProps } />;
|
|
163
123
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
ToolbarDropdownMenu,
|
|
7
|
+
ToolbarGroup,
|
|
8
|
+
BottomSheetSelectControl,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import useAvailableAlignments from './use-available-alignments';
|
|
15
|
+
import {
|
|
16
|
+
BLOCK_ALIGNMENTS_CONTROLS,
|
|
17
|
+
DEFAULT_CONTROL,
|
|
18
|
+
POPOVER_PROPS,
|
|
19
|
+
} from './constants';
|
|
20
|
+
|
|
21
|
+
function BlockAlignmentUI( {
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
controls,
|
|
25
|
+
isToolbar,
|
|
26
|
+
isCollapsed = true,
|
|
27
|
+
isBottomSheetControl = false,
|
|
28
|
+
} ) {
|
|
29
|
+
const enabledControls = useAvailableAlignments( controls );
|
|
30
|
+
const hasEnabledControls = !! enabledControls.length;
|
|
31
|
+
|
|
32
|
+
if ( ! hasEnabledControls ) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onChangeAlignment( align ) {
|
|
37
|
+
onChange( [ value, 'none' ].includes( align ) ? undefined : align );
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const activeAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[ value ];
|
|
41
|
+
const defaultAlignmentControl =
|
|
42
|
+
BLOCK_ALIGNMENTS_CONTROLS[ DEFAULT_CONTROL ];
|
|
43
|
+
|
|
44
|
+
const toolbarUIComponent = isToolbar ? ToolbarGroup : ToolbarDropdownMenu;
|
|
45
|
+
const UIComponent = isBottomSheetControl
|
|
46
|
+
? BottomSheetSelectControl
|
|
47
|
+
: toolbarUIComponent;
|
|
48
|
+
|
|
49
|
+
const commonProps = {
|
|
50
|
+
label: __( 'Align' ),
|
|
51
|
+
};
|
|
52
|
+
const extraProps = isBottomSheetControl
|
|
53
|
+
? {
|
|
54
|
+
options: enabledControls.map( ( { name: controlName } ) => {
|
|
55
|
+
const control = BLOCK_ALIGNMENTS_CONTROLS[ controlName ];
|
|
56
|
+
return {
|
|
57
|
+
value: controlName,
|
|
58
|
+
label: control.title,
|
|
59
|
+
icon: control.icon,
|
|
60
|
+
};
|
|
61
|
+
} ),
|
|
62
|
+
value: activeAlignmentControl ? value : 'none',
|
|
63
|
+
onChange: ( align ) => onChangeAlignment( align ),
|
|
64
|
+
}
|
|
65
|
+
: {
|
|
66
|
+
icon: activeAlignmentControl
|
|
67
|
+
? activeAlignmentControl.icon
|
|
68
|
+
: defaultAlignmentControl.icon,
|
|
69
|
+
isCollapsed: isToolbar ? isCollapsed : undefined,
|
|
70
|
+
controls: enabledControls.map( ( { name: controlName } ) => {
|
|
71
|
+
return {
|
|
72
|
+
...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
|
|
73
|
+
isActive:
|
|
74
|
+
value === controlName ||
|
|
75
|
+
( ! value && controlName === 'none' ),
|
|
76
|
+
onClick: () => onChangeAlignment( controlName ),
|
|
77
|
+
};
|
|
78
|
+
} ),
|
|
79
|
+
popoverProps: POPOVER_PROPS,
|
|
80
|
+
toggleProps: { describedBy: __( 'Change alignment' ) },
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return <UIComponent { ...commonProps } { ...extraProps } />;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default BlockAlignmentUI;
|
|
@@ -25,6 +25,7 @@ export default function BlockContentOverlay( {
|
|
|
25
25
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
|
+
canEdit,
|
|
28
29
|
isParentSelected,
|
|
29
30
|
hasChildSelected,
|
|
30
31
|
isDraggingBlocks,
|
|
@@ -36,8 +37,10 @@ export default function BlockContentOverlay( {
|
|
|
36
37
|
hasSelectedInnerBlock,
|
|
37
38
|
isDraggingBlocks: _isDraggingBlocks,
|
|
38
39
|
isBlockHighlighted,
|
|
40
|
+
canEditBlock,
|
|
39
41
|
} = select( blockEditorStore );
|
|
40
42
|
return {
|
|
43
|
+
canEdit: canEditBlock( clientId ),
|
|
41
44
|
isParentSelected: isBlockSelected( clientId ),
|
|
42
45
|
hasChildSelected: hasSelectedInnerBlock( clientId, true ),
|
|
43
46
|
isDraggingBlocks: _isDraggingBlocks(),
|
|
@@ -59,6 +62,12 @@ export default function BlockContentOverlay( {
|
|
|
59
62
|
);
|
|
60
63
|
|
|
61
64
|
useEffect( () => {
|
|
65
|
+
// The overlay is always active when editing is locked.
|
|
66
|
+
if ( ! canEdit ) {
|
|
67
|
+
setIsOverlayActive( true );
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
// Reenable when blocks are not in use.
|
|
63
72
|
if ( ! isParentSelected && ! hasChildSelected && ! isOverlayActive ) {
|
|
64
73
|
setIsOverlayActive( true );
|
|
@@ -75,7 +84,13 @@ export default function BlockContentOverlay( {
|
|
|
75
84
|
if ( hasChildSelected && isOverlayActive ) {
|
|
76
85
|
setIsOverlayActive( false );
|
|
77
86
|
}
|
|
78
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
isParentSelected,
|
|
89
|
+
hasChildSelected,
|
|
90
|
+
isOverlayActive,
|
|
91
|
+
isHovered,
|
|
92
|
+
canEdit,
|
|
93
|
+
] );
|
|
79
94
|
|
|
80
95
|
// Disabled because the overlay div doesn't actually have a role or functionality
|
|
81
96
|
// as far as the a11y is concerned. We're just catching the first click so that
|
|
@@ -88,7 +103,9 @@ export default function BlockContentOverlay( {
|
|
|
88
103
|
onMouseEnter={ () => setIsHovered( true ) }
|
|
89
104
|
onMouseLeave={ () => setIsHovered( false ) }
|
|
90
105
|
onMouseUp={
|
|
91
|
-
isOverlayActive
|
|
106
|
+
isOverlayActive && canEdit
|
|
107
|
+
? () => setIsOverlayActive( false )
|
|
108
|
+
: undefined
|
|
92
109
|
}
|
|
93
110
|
>
|
|
94
111
|
{ wrapperProps?.children }
|
|
@@ -47,6 +47,7 @@ function BlockForType( {
|
|
|
47
47
|
onDeleteBlock,
|
|
48
48
|
onReplace,
|
|
49
49
|
parentWidth,
|
|
50
|
+
parentBlockAlignment,
|
|
50
51
|
wrapperProps,
|
|
51
52
|
blockWidth,
|
|
52
53
|
baseGlobalStyles,
|
|
@@ -95,6 +96,7 @@ function BlockForType( {
|
|
|
95
96
|
contentStyle={ contentStyle }
|
|
96
97
|
onDeleteBlock={ onDeleteBlock }
|
|
97
98
|
blockWidth={ blockWidth }
|
|
99
|
+
parentBlockAlignment={ parentBlockAlignment }
|
|
98
100
|
/>
|
|
99
101
|
<View onLayout={ getBlockWidth } />
|
|
100
102
|
</GlobalStylesContext.Provider>
|
|
@@ -262,12 +262,17 @@
|
|
|
262
262
|
right: $border-width;
|
|
263
263
|
bottom: $border-width;
|
|
264
264
|
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
|
|
265
|
-
|
|
265
|
+
// Border is outset, so subtract the width to achieve correct radius.
|
|
266
|
+
border-radius: $radius-block-ui - $border-width;
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
&.is-selected {
|
|
270
|
-
cursor:
|
|
271
|
+
cursor: default;
|
|
272
|
+
|
|
273
|
+
&.rich-text {
|
|
274
|
+
cursor: unset;
|
|
275
|
+
}
|
|
271
276
|
|
|
272
277
|
&::after {
|
|
273
278
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); // Selected not focussed.
|
|
@@ -303,22 +308,6 @@
|
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
// Active entity spotlight.
|
|
307
|
-
// Disable if focus mode is active.
|
|
308
|
-
.is-root-container:not(.is-focus-mode) .block-editor-block-list__block.has-active-entity {
|
|
309
|
-
opacity: 0.5;
|
|
310
|
-
transition: opacity 0.1s linear;
|
|
311
|
-
@include reduce-motion("transition");
|
|
312
|
-
|
|
313
|
-
&.is-active-entity,
|
|
314
|
-
&.has-child-selected,
|
|
315
|
-
&:not(.has-child-selected) .block-editor-block-list__block,
|
|
316
|
-
&.is-active-entity .block-editor-block-list__block,
|
|
317
|
-
.is-active-entity .block-editor-block-list__block {
|
|
318
|
-
opacity: 1;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
311
|
.wp-block[data-align="left"] > *,
|
|
323
312
|
.wp-block[data-align="right"] > *,
|
|
324
313
|
.wp-block.alignleft,
|
|
@@ -33,12 +33,8 @@ export function useBlockClassNames( clientId ) {
|
|
|
33
33
|
getSettings,
|
|
34
34
|
hasSelectedInnerBlock,
|
|
35
35
|
isTyping,
|
|
36
|
-
__experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames,
|
|
37
36
|
} = select( blockEditorStore );
|
|
38
|
-
const {
|
|
39
|
-
__experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
|
|
40
|
-
outlineMode,
|
|
41
|
-
} = getSettings();
|
|
37
|
+
const { outlineMode } = getSettings();
|
|
42
38
|
const isDragging = isBlockBeingDragged( clientId );
|
|
43
39
|
const isSelected = isBlockSelected( clientId );
|
|
44
40
|
const name = getBlockName( clientId );
|
|
@@ -48,9 +44,6 @@ export function useBlockClassNames( clientId ) {
|
|
|
48
44
|
clientId,
|
|
49
45
|
checkDeep
|
|
50
46
|
);
|
|
51
|
-
const activeEntityBlockId = getActiveBlockIdByBlockNames(
|
|
52
|
-
spotlightEntityBlocks
|
|
53
|
-
);
|
|
54
47
|
return classnames( {
|
|
55
48
|
'is-selected': isSelected,
|
|
56
49
|
'is-highlighted': isBlockHighlighted( clientId ),
|
|
@@ -58,9 +51,6 @@ export function useBlockClassNames( clientId ) {
|
|
|
58
51
|
'is-reusable': isReusableBlock( getBlockType( name ) ),
|
|
59
52
|
'is-dragging': isDragging,
|
|
60
53
|
'has-child-selected': isAncestorOfSelectedBlock,
|
|
61
|
-
'has-active-entity': activeEntityBlockId,
|
|
62
|
-
// Determine if there is an active entity area to spotlight.
|
|
63
|
-
'is-active-entity': activeEntityBlockId === clientId,
|
|
64
54
|
'remove-outline': isSelected && outlineMode && isTyping(),
|
|
65
55
|
} );
|
|
66
56
|
},
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';
|
|
15
15
|
import { useInstanceId } from '@wordpress/compose';
|
|
16
|
-
import { useDispatch } from '@wordpress/data';
|
|
16
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
17
|
+
import { isReusableBlock, getBlockType } from '@wordpress/blocks';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -24,7 +25,18 @@ import { store as blockEditorStore } from '../../store';
|
|
|
24
25
|
|
|
25
26
|
export default function BlockLockModal( { clientId, onClose } ) {
|
|
26
27
|
const [ lock, setLock ] = useState( { move: false, remove: false } );
|
|
27
|
-
const { canMove, canRemove } = useBlockLock( clientId );
|
|
28
|
+
const { canEdit, canMove, canRemove } = useBlockLock( clientId );
|
|
29
|
+
const { isReusable } = useSelect(
|
|
30
|
+
( select ) => {
|
|
31
|
+
const { getBlockName } = select( blockEditorStore );
|
|
32
|
+
const blockName = getBlockName( clientId );
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
isReusable: isReusableBlock( getBlockType( blockName ) ),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[ clientId ]
|
|
39
|
+
);
|
|
28
40
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
29
41
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
30
42
|
const instanceId = useInstanceId(
|
|
@@ -36,8 +48,9 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
36
48
|
setLock( {
|
|
37
49
|
move: ! canMove,
|
|
38
50
|
remove: ! canRemove,
|
|
51
|
+
...( isReusable ? { edit: ! canEdit } : {} ),
|
|
39
52
|
} );
|
|
40
|
-
}, [ canMove, canRemove ] );
|
|
53
|
+
}, [ canEdit, canMove, canRemove, isReusable ] );
|
|
41
54
|
|
|
42
55
|
const isAllChecked = Object.values( lock ).every( Boolean );
|
|
43
56
|
const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;
|
|
@@ -81,10 +94,36 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
81
94
|
setLock( {
|
|
82
95
|
move: newValue,
|
|
83
96
|
remove: newValue,
|
|
97
|
+
...( isReusable ? { edit: newValue } : {} ),
|
|
84
98
|
} )
|
|
85
99
|
}
|
|
86
100
|
/>
|
|
87
101
|
<ul className="block-editor-block-lock-modal__checklist">
|
|
102
|
+
{ isReusable && (
|
|
103
|
+
<li className="block-editor-block-lock-modal__checklist-item">
|
|
104
|
+
<CheckboxControl
|
|
105
|
+
label={
|
|
106
|
+
<>
|
|
107
|
+
{ __( 'Restrict editing' ) }
|
|
108
|
+
<Icon
|
|
109
|
+
icon={
|
|
110
|
+
lock.edit
|
|
111
|
+
? lockIcon
|
|
112
|
+
: unlockIcon
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
</>
|
|
116
|
+
}
|
|
117
|
+
checked={ !! lock.edit }
|
|
118
|
+
onChange={ ( edit ) =>
|
|
119
|
+
setLock( ( prevLock ) => ( {
|
|
120
|
+
...prevLock,
|
|
121
|
+
edit,
|
|
122
|
+
} ) )
|
|
123
|
+
}
|
|
124
|
+
/>
|
|
125
|
+
</li>
|
|
126
|
+
) }
|
|
88
127
|
<li className="block-editor-block-lock-modal__checklist-item">
|
|
89
128
|
<CheckboxControl
|
|
90
129
|
label={
|
|
@@ -15,7 +15,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
15
15
|
|
|
16
16
|
export default function BlockLockToolbar( { clientId } ) {
|
|
17
17
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
18
|
-
const { canMove, canRemove, canLock } = useBlockLock( clientId );
|
|
18
|
+
const { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );
|
|
19
19
|
|
|
20
20
|
const [ isModalOpen, toggleModal ] = useReducer(
|
|
21
21
|
( isActive ) => ! isActive,
|
|
@@ -26,7 +26,7 @@ export default function BlockLockToolbar( { clientId } ) {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if ( canMove && canRemove ) {
|
|
29
|
+
if ( canEdit && canMove && canRemove ) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -19,6 +19,7 @@ export default function useBlockLock( clientId ) {
|
|
|
19
19
|
return useSelect(
|
|
20
20
|
( select ) => {
|
|
21
21
|
const {
|
|
22
|
+
canEditBlock,
|
|
22
23
|
canMoveBlock,
|
|
23
24
|
canRemoveBlock,
|
|
24
25
|
canLockBlockType,
|
|
@@ -27,14 +28,16 @@ export default function useBlockLock( clientId ) {
|
|
|
27
28
|
} = select( blockEditorStore );
|
|
28
29
|
const rootClientId = getBlockRootClientId( clientId );
|
|
29
30
|
|
|
31
|
+
const canEdit = canEditBlock( clientId );
|
|
30
32
|
const canMove = canMoveBlock( clientId, rootClientId );
|
|
31
33
|
const canRemove = canRemoveBlock( clientId, rootClientId );
|
|
32
34
|
|
|
33
35
|
return {
|
|
36
|
+
canEdit,
|
|
34
37
|
canMove,
|
|
35
38
|
canRemove,
|
|
36
39
|
canLock: canLockBlockType( getBlockName( clientId ) ),
|
|
37
|
-
isLocked: ! canMove || ! canRemove,
|
|
40
|
+
isLocked: ! canEdit || ! canMove || ! canRemove,
|
|
38
41
|
};
|
|
39
42
|
},
|
|
40
43
|
[ clientId ]
|
|
@@ -8,7 +8,7 @@ import { castArray, first, last } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { getBlockType } from '@wordpress/blocks';
|
|
11
|
-
import { Button } from '@wordpress/components';
|
|
11
|
+
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
12
12
|
import { useInstanceId } from '@wordpress/compose';
|
|
13
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
14
|
import { forwardRef } from '@wordpress/element';
|
|
@@ -139,12 +139,10 @@ const BlockMoverButton = forwardRef(
|
|
|
139
139
|
aria-describedby={ descriptionId }
|
|
140
140
|
{ ...props }
|
|
141
141
|
onClick={ isDisabled ? null : onClick }
|
|
142
|
-
|
|
142
|
+
disabled={ isDisabled }
|
|
143
|
+
__experimentalIsFocusable
|
|
143
144
|
/>
|
|
144
|
-
<
|
|
145
|
-
id={ descriptionId }
|
|
146
|
-
className="block-editor-block-mover-button__description"
|
|
147
|
-
>
|
|
145
|
+
<VisuallyHidden id={ descriptionId }>
|
|
148
146
|
{ getBlockMoverDescription(
|
|
149
147
|
blocksCount,
|
|
150
148
|
blockType && blockType.title,
|
|
@@ -154,7 +152,7 @@ const BlockMoverButton = forwardRef(
|
|
|
154
152
|
direction === 'up' ? -1 : 1,
|
|
155
153
|
orientation
|
|
156
154
|
) }
|
|
157
|
-
</
|
|
155
|
+
</VisuallyHidden>
|
|
158
156
|
</>
|
|
159
157
|
);
|
|
160
158
|
}
|