@wordpress/block-editor 9.7.0 → 9.7.1-next.d6164808d3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-edit-visually-button/index.js +46 -0
- package/build/components/block-edit-visually-button/index.js.map +1 -0
- package/build/components/block-popover/inbetween.js +4 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/index.js +2 -6
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -16
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +31 -3
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +20 -6
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +21 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/utils.js +13 -16
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/copy-handler/index.js +6 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -7
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +5 -5
- package/build/components/duotone/components.js.map +1 -1
- package/build/components/font-family/index.js +1 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +17 -4
- 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/inserter/search-items.js +22 -4
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/rich-text/use-enter.js +0 -4
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -11
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +53 -0
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/index.js +100 -0
- package/build/components/spacing-sizes-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls.js +52 -0
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/linked-button.js +38 -0
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js +208 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +202 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +4 -2
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +10 -2
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/border-radius.js +2 -7
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border.js +2 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +15 -0
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +6 -4
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -7
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/layout.js +20 -12
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +28 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -8
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +4 -50
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/constrained.js +215 -0
- package/build/layouts/constrained.js.map +1 -0
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +7 -169
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +43 -0
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +25 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -6
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-edit-visually-button/index.js +35 -0
- package/build-module/components/block-edit-visually-button/index.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +4 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +3 -6
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -16
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +32 -4
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +20 -6
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +22 -7
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +13 -16
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/copy-handler/index.js +7 -1
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -6
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +5 -5
- package/build-module/components/duotone/components.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +16 -3
- 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/inserter/search-items.js +19 -5
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +5 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +0 -4
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -10
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/index.js +83 -0
- package/build-module/components/spacing-sizes-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +192 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +174 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -2
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +10 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/border-radius.js +2 -7
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border.js +2 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +13 -0
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +3 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +1 -6
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/layout.js +20 -12
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +26 -12
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +17 -8
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -53
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/constrained.js +197 -0
- package/build-module/layouts/constrained.js.map +1 -0
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +8 -163
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +40 -0
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +25 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +115 -20
- package/build-style/style.css +115 -20
- package/package.json +30 -28
- package/src/components/block-alignment-control/use-available-alignments.js +1 -1
- package/src/components/block-edit-visually-button/index.js +39 -0
- package/src/components/block-popover/inbetween.js +4 -1
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +1 -0
- package/src/components/block-toolbar/index.js +2 -0
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +25 -5
- package/src/components/border-radius-control/input-controls.js +40 -13
- package/src/components/border-radius-control/test/utils.js +22 -60
- package/src/components/border-radius-control/utils.js +12 -16
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/copy-handler/index.js +18 -0
- package/src/components/date-format-picker/index.js +12 -14
- package/src/components/date-format-picker/style.scss +0 -4
- package/src/components/duotone/components.js +5 -5
- package/src/components/duotone-control/style.scss +0 -4
- package/src/components/font-appearance-control/style.scss +0 -2
- package/src/components/font-family/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +11 -1
- package/src/components/index.js +1 -0
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/style.scss +11 -4
- package/src/components/list-view/use-block-selection.js +2 -8
- package/src/components/media-replace-flow/style.scss +1 -0
- package/src/components/rich-text/use-enter.js +0 -3
- package/src/components/rich-text/use-format-types.js +6 -6
- package/src/components/spacing-sizes-control/all-input-control.js +40 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
- package/src/components/spacing-sizes-control/index.js +91 -0
- package/src/components/spacing-sizes-control/input-controls.js +46 -0
- package/src/components/spacing-sizes-control/linked-button.js +25 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +280 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +156 -0
- package/src/components/spacing-sizes-control/utils.js +195 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/border-radius.js +2 -6
- package/src/hooks/border.js +2 -2
- package/src/hooks/color.js +13 -3
- package/src/hooks/dimensions.js +15 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/gap.js +7 -2
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +45 -14
- package/src/hooks/margin.js +49 -17
- package/src/hooks/padding.js +41 -14
- package/src/hooks/style.js +5 -56
- package/src/hooks/test/gap.js +22 -0
- package/src/hooks/typography.scss +0 -1
- package/src/layouts/constrained.js +217 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +6 -173
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/constrained.js +21 -0
- package/src/layouts/utils.js +34 -0
- package/src/store/actions.js +32 -4
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
package/src/layouts/flow.js
CHANGED
|
@@ -1,122 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
__experimentalUseCustomUnits as useCustomUnits,
|
|
7
|
-
__experimentalUnitControl as UnitControl,
|
|
8
|
-
} from '@wordpress/components';
|
|
9
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
11
|
-
import { getCSSRules } from '@wordpress/style-engine';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
12
5
|
|
|
13
6
|
/**
|
|
14
7
|
* Internal dependencies
|
|
15
8
|
*/
|
|
16
|
-
|
|
17
|
-
import {
|
|
9
|
+
|
|
10
|
+
import { getBlockGapCSS, getAlignmentsInfo } from './utils';
|
|
18
11
|
import { getGapBoxControlValueFromStyle } from '../hooks/gap';
|
|
19
12
|
import { shouldSkipSerialization } from '../hooks/utils';
|
|
20
13
|
|
|
21
14
|
export default {
|
|
22
15
|
name: 'default',
|
|
23
16
|
label: __( 'Flow' ),
|
|
24
|
-
inspectorControls: function DefaultLayoutInspectorControls( {
|
|
25
|
-
|
|
26
|
-
onChange,
|
|
27
|
-
} ) {
|
|
28
|
-
const { wideSize, contentSize } = layout;
|
|
29
|
-
const units = useCustomUnits( {
|
|
30
|
-
availableUnits: useSetting( 'spacing.units' ) || [
|
|
31
|
-
'%',
|
|
32
|
-
'px',
|
|
33
|
-
'em',
|
|
34
|
-
'rem',
|
|
35
|
-
'vw',
|
|
36
|
-
],
|
|
37
|
-
} );
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<div className="block-editor-hooks__layout-controls">
|
|
42
|
-
<div className="block-editor-hooks__layout-controls-unit">
|
|
43
|
-
<UnitControl
|
|
44
|
-
label={ __( 'Content' ) }
|
|
45
|
-
labelPosition="top"
|
|
46
|
-
__unstableInputWidth="80px"
|
|
47
|
-
value={ contentSize || wideSize || '' }
|
|
48
|
-
onChange={ ( nextWidth ) => {
|
|
49
|
-
nextWidth =
|
|
50
|
-
0 > parseFloat( nextWidth )
|
|
51
|
-
? '0'
|
|
52
|
-
: nextWidth;
|
|
53
|
-
onChange( {
|
|
54
|
-
...layout,
|
|
55
|
-
contentSize: nextWidth,
|
|
56
|
-
} );
|
|
57
|
-
} }
|
|
58
|
-
units={ units }
|
|
59
|
-
/>
|
|
60
|
-
<Icon icon={ positionCenter } />
|
|
61
|
-
</div>
|
|
62
|
-
<div className="block-editor-hooks__layout-controls-unit">
|
|
63
|
-
<UnitControl
|
|
64
|
-
label={ __( 'Wide' ) }
|
|
65
|
-
labelPosition="top"
|
|
66
|
-
__unstableInputWidth="80px"
|
|
67
|
-
value={ wideSize || contentSize || '' }
|
|
68
|
-
onChange={ ( nextWidth ) => {
|
|
69
|
-
nextWidth =
|
|
70
|
-
0 > parseFloat( nextWidth )
|
|
71
|
-
? '0'
|
|
72
|
-
: nextWidth;
|
|
73
|
-
onChange( {
|
|
74
|
-
...layout,
|
|
75
|
-
wideSize: nextWidth,
|
|
76
|
-
} );
|
|
77
|
-
} }
|
|
78
|
-
units={ units }
|
|
79
|
-
/>
|
|
80
|
-
<Icon icon={ stretchWide } />
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
<div className="block-editor-hooks__layout-controls-reset">
|
|
84
|
-
<Button
|
|
85
|
-
variant="secondary"
|
|
86
|
-
isSmall
|
|
87
|
-
disabled={ ! contentSize && ! wideSize }
|
|
88
|
-
onClick={ () =>
|
|
89
|
-
onChange( {
|
|
90
|
-
contentSize: undefined,
|
|
91
|
-
wideSize: undefined,
|
|
92
|
-
inherit: false,
|
|
93
|
-
} )
|
|
94
|
-
}
|
|
95
|
-
>
|
|
96
|
-
{ __( 'Reset' ) }
|
|
97
|
-
</Button>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
<p className="block-editor-hooks__layout-controls-helptext">
|
|
101
|
-
{ __(
|
|
102
|
-
'Customize the width for all elements that are assigned to the center or wide columns.'
|
|
103
|
-
) }
|
|
104
|
-
</p>
|
|
105
|
-
</>
|
|
106
|
-
);
|
|
17
|
+
inspectorControls: function DefaultLayoutInspectorControls() {
|
|
18
|
+
return null;
|
|
107
19
|
},
|
|
108
20
|
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
109
21
|
return null;
|
|
110
22
|
},
|
|
111
23
|
getLayoutStyle: function getLayoutStyle( {
|
|
112
24
|
selector,
|
|
113
|
-
layout = {},
|
|
114
25
|
style,
|
|
115
26
|
blockName,
|
|
116
27
|
hasBlockGapSupport,
|
|
117
28
|
layoutDefinitions,
|
|
118
29
|
} ) {
|
|
119
|
-
const { contentSize, wideSize } = layout;
|
|
120
30
|
const blockGapStyleValue = getGapBoxControlValueFromStyle(
|
|
121
31
|
style?.spacing?.blockGap
|
|
122
32
|
);
|
|
@@ -128,46 +38,7 @@ export default {
|
|
|
128
38
|
? blockGapStyleValue?.top
|
|
129
39
|
: '';
|
|
130
40
|
|
|
131
|
-
let output =
|
|
132
|
-
!! contentSize || !! wideSize
|
|
133
|
-
? `
|
|
134
|
-
${ appendSelectors(
|
|
135
|
-
selector,
|
|
136
|
-
'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
|
|
137
|
-
) } {
|
|
138
|
-
max-width: ${ contentSize ?? wideSize };
|
|
139
|
-
margin-left: auto !important;
|
|
140
|
-
margin-right: auto !important;
|
|
141
|
-
}
|
|
142
|
-
${ appendSelectors( selector, '> .alignwide' ) } {
|
|
143
|
-
max-width: ${ wideSize ?? contentSize };
|
|
144
|
-
}
|
|
145
|
-
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
146
|
-
max-width: none;
|
|
147
|
-
}
|
|
148
|
-
`
|
|
149
|
-
: '';
|
|
150
|
-
|
|
151
|
-
// If there is custom padding, add negative margins for alignfull blocks.
|
|
152
|
-
if ( style?.spacing?.padding ) {
|
|
153
|
-
// The style object might be storing a preset so we need to make sure we get a usable value.
|
|
154
|
-
const paddingValues = getCSSRules( style );
|
|
155
|
-
paddingValues.forEach( ( rule ) => {
|
|
156
|
-
if ( rule.key === 'paddingRight' ) {
|
|
157
|
-
output += `
|
|
158
|
-
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
159
|
-
margin-right: calc(${ rule.value } * -1);
|
|
160
|
-
}
|
|
161
|
-
`;
|
|
162
|
-
} else if ( rule.key === 'paddingLeft' ) {
|
|
163
|
-
output += `
|
|
164
|
-
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
165
|
-
margin-left: calc(${ rule.value } * -1);
|
|
166
|
-
}
|
|
167
|
-
`;
|
|
168
|
-
}
|
|
169
|
-
} );
|
|
170
|
-
}
|
|
41
|
+
let output = '';
|
|
171
42
|
|
|
172
43
|
// Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
173
44
|
if ( hasBlockGapSupport && blockGapValue ) {
|
|
@@ -194,7 +65,6 @@ export default {
|
|
|
194
65
|
info: alignmentInfo[ alignment ],
|
|
195
66
|
} ) );
|
|
196
67
|
}
|
|
197
|
-
const { contentSize, wideSize } = layout;
|
|
198
68
|
|
|
199
69
|
const alignments = [
|
|
200
70
|
{ name: 'left' },
|
|
@@ -202,45 +72,8 @@ export default {
|
|
|
202
72
|
{ name: 'right' },
|
|
203
73
|
];
|
|
204
74
|
|
|
205
|
-
if ( contentSize ) {
|
|
206
|
-
alignments.unshift( { name: 'full' } );
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if ( wideSize ) {
|
|
210
|
-
alignments.unshift( { name: 'wide', info: alignmentInfo.wide } );
|
|
211
|
-
}
|
|
212
|
-
|
|
213
75
|
alignments.unshift( { name: 'none', info: alignmentInfo.none } );
|
|
214
76
|
|
|
215
77
|
return alignments;
|
|
216
78
|
},
|
|
217
79
|
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Helper method to assign contextual info to clarify
|
|
221
|
-
* alignment settings.
|
|
222
|
-
*
|
|
223
|
-
* Besides checking if `contentSize` and `wideSize` have a
|
|
224
|
-
* value, we now show this information only if their values
|
|
225
|
-
* are not a `css var`. This needs to change when parsing
|
|
226
|
-
* css variables land.
|
|
227
|
-
*
|
|
228
|
-
* @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
|
|
229
|
-
*
|
|
230
|
-
* @param {Object} layout The layout object.
|
|
231
|
-
* @return {Object} An object with contextual info per alignment.
|
|
232
|
-
*/
|
|
233
|
-
function getAlignmentsInfo( layout ) {
|
|
234
|
-
const { contentSize, wideSize } = layout;
|
|
235
|
-
const alignmentInfo = {};
|
|
236
|
-
const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
|
|
237
|
-
if ( sizeRegex.test( contentSize ) ) {
|
|
238
|
-
// translators: %s: container size (i.e. 600px etc)
|
|
239
|
-
alignmentInfo.none = sprintf( __( 'Max %s wide' ), contentSize );
|
|
240
|
-
}
|
|
241
|
-
if ( sizeRegex.test( wideSize ) ) {
|
|
242
|
-
// translators: %s: container size (i.e. 600px etc)
|
|
243
|
-
alignmentInfo.wide = sprintf( __( 'Max %s wide' ), wideSize );
|
|
244
|
-
}
|
|
245
|
-
return alignmentInfo;
|
|
246
|
-
}
|
package/src/layouts/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import constrained from '../constrained';
|
|
5
|
+
|
|
6
|
+
describe( 'getLayoutStyle', () => {
|
|
7
|
+
it( 'should return an empty string if no non-default params are provided', () => {
|
|
8
|
+
const expected = '';
|
|
9
|
+
|
|
10
|
+
const result = constrained.getLayoutStyle( {
|
|
11
|
+
selector: '.my-container',
|
|
12
|
+
layout: {},
|
|
13
|
+
style: {},
|
|
14
|
+
blockName: 'test-block',
|
|
15
|
+
hasBlockGapSupport: false,
|
|
16
|
+
layoutDefinitions: undefined,
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
expect( result ).toBe( expected );
|
|
20
|
+
} );
|
|
21
|
+
} );
|
package/src/layouts/utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Utility to generate the proper CSS selector for layout styles.
|
|
3
8
|
*
|
|
@@ -62,3 +67,32 @@ export function getBlockGapCSS(
|
|
|
62
67
|
}
|
|
63
68
|
return output;
|
|
64
69
|
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Helper method to assign contextual info to clarify
|
|
73
|
+
* alignment settings.
|
|
74
|
+
*
|
|
75
|
+
* Besides checking if `contentSize` and `wideSize` have a
|
|
76
|
+
* value, we now show this information only if their values
|
|
77
|
+
* are not a `css var`. This needs to change when parsing
|
|
78
|
+
* css variables land.
|
|
79
|
+
*
|
|
80
|
+
* @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
|
|
81
|
+
*
|
|
82
|
+
* @param {Object} layout The layout object.
|
|
83
|
+
* @return {Object} An object with contextual info per alignment.
|
|
84
|
+
*/
|
|
85
|
+
export function getAlignmentsInfo( layout ) {
|
|
86
|
+
const { contentSize, wideSize } = layout;
|
|
87
|
+
const alignmentInfo = {};
|
|
88
|
+
const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
|
|
89
|
+
if ( sizeRegex.test( contentSize ) ) {
|
|
90
|
+
// translators: %s: container size (i.e. 600px etc)
|
|
91
|
+
alignmentInfo.none = sprintf( __( 'Max %s wide' ), contentSize );
|
|
92
|
+
}
|
|
93
|
+
if ( sizeRegex.test( wideSize ) ) {
|
|
94
|
+
// translators: %s: container size (i.e. 600px etc)
|
|
95
|
+
alignmentInfo.wide = sprintf( __( 'Max %s wide' ), wideSize );
|
|
96
|
+
}
|
|
97
|
+
return alignmentInfo;
|
|
98
|
+
}
|
package/src/store/actions.js
CHANGED
|
@@ -1002,7 +1002,7 @@ export const __unstableExpandSelection =
|
|
|
1002
1002
|
*/
|
|
1003
1003
|
export const mergeBlocks =
|
|
1004
1004
|
( firstBlockClientId, secondBlockClientId ) =>
|
|
1005
|
-
( { select, dispatch } ) => {
|
|
1005
|
+
( { registry, select, dispatch } ) => {
|
|
1006
1006
|
const blocks = [ firstBlockClientId, secondBlockClientId ];
|
|
1007
1007
|
dispatch( { type: 'MERGE_BLOCKS', blocks } );
|
|
1008
1008
|
|
|
@@ -1010,13 +1010,41 @@ export const mergeBlocks =
|
|
|
1010
1010
|
const blockA = select.getBlock( clientIdA );
|
|
1011
1011
|
const blockAType = getBlockType( blockA.name );
|
|
1012
1012
|
|
|
1013
|
-
|
|
1013
|
+
if ( ! blockAType ) return;
|
|
1014
|
+
|
|
1015
|
+
const blockB = select.getBlock( clientIdB );
|
|
1016
|
+
|
|
1014
1017
|
if ( blockAType && ! blockAType.merge ) {
|
|
1015
|
-
|
|
1018
|
+
// If there's no merge function defined, attempt merging inner
|
|
1019
|
+
// blocks.
|
|
1020
|
+
const blocksWithTheSameType = switchToBlockType(
|
|
1021
|
+
blockB,
|
|
1022
|
+
blockAType.name
|
|
1023
|
+
);
|
|
1024
|
+
// Only focus the previous block if it's not mergeable.
|
|
1025
|
+
if ( blocksWithTheSameType?.length !== 1 ) {
|
|
1026
|
+
dispatch.selectBlock( blockA.clientId );
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
const [ blockWithSameType ] = blocksWithTheSameType;
|
|
1030
|
+
if ( blockWithSameType.innerBlocks.length < 1 ) {
|
|
1031
|
+
dispatch.selectBlock( blockA.clientId );
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
registry.batch( () => {
|
|
1035
|
+
dispatch.insertBlocks(
|
|
1036
|
+
blockWithSameType.innerBlocks,
|
|
1037
|
+
undefined,
|
|
1038
|
+
clientIdA
|
|
1039
|
+
);
|
|
1040
|
+
dispatch.removeBlock( clientIdB );
|
|
1041
|
+
dispatch.selectBlock(
|
|
1042
|
+
blockWithSameType.innerBlocks[ 0 ].clientId
|
|
1043
|
+
);
|
|
1044
|
+
} );
|
|
1016
1045
|
return;
|
|
1017
1046
|
}
|
|
1018
1047
|
|
|
1019
|
-
const blockB = select.getBlock( clientIdB );
|
|
1020
1048
|
const blockBType = getBlockType( blockB.name );
|
|
1021
1049
|
const { clientId, attributeKey, offset } = select.getSelectionStart();
|
|
1022
1050
|
const selectedBlockType =
|
package/src/store/selectors.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
some,
|
|
11
11
|
find,
|
|
12
12
|
filter,
|
|
13
|
-
mapKeys,
|
|
14
13
|
orderBy,
|
|
15
14
|
} from 'lodash';
|
|
16
15
|
import createSelector from 'rememo';
|
|
@@ -2078,9 +2077,11 @@ export const getBlockTransformItems = createSelector(
|
|
|
2078
2077
|
)
|
|
2079
2078
|
.map( buildBlockTypeTransformItem );
|
|
2080
2079
|
|
|
2081
|
-
const itemsByName =
|
|
2082
|
-
blockTypeTransformItems,
|
|
2083
|
-
|
|
2080
|
+
const itemsByName = Object.fromEntries(
|
|
2081
|
+
Object.entries( blockTypeTransformItems ).map( ( [ , value ] ) => [
|
|
2082
|
+
value.name,
|
|
2083
|
+
value,
|
|
2084
|
+
] )
|
|
2084
2085
|
);
|
|
2085
2086
|
|
|
2086
2087
|
// Consider unwraping the highest priority.
|
package/src/style.scss
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = BlockEditVisuallyButton;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _blocks = require("@wordpress/blocks");
|
|
15
|
-
|
|
16
|
-
var _components = require("@wordpress/components");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _data = require("@wordpress/data");
|
|
21
|
-
|
|
22
|
-
var _store = require("../../store");
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
function BlockEditVisuallyButton(_ref) {
|
|
32
|
-
let {
|
|
33
|
-
clientIds,
|
|
34
|
-
...props
|
|
35
|
-
} = _ref;
|
|
36
|
-
const {
|
|
37
|
-
block,
|
|
38
|
-
shouldRender
|
|
39
|
-
} = (0, _data.useSelect)(select => {
|
|
40
|
-
const firstBlockClientId = clientIds[0];
|
|
41
|
-
const {
|
|
42
|
-
isBlockMultiSelected,
|
|
43
|
-
getBlockMode,
|
|
44
|
-
getBlock
|
|
45
|
-
} = select(_store.store);
|
|
46
|
-
const isSingleSelected = !isBlockMultiSelected(firstBlockClientId);
|
|
47
|
-
const isHtmlMode = getBlockMode(firstBlockClientId) === 'html';
|
|
48
|
-
return {
|
|
49
|
-
block: getBlock(firstBlockClientId),
|
|
50
|
-
shouldRender: isSingleSelected && isHtmlMode
|
|
51
|
-
};
|
|
52
|
-
}, [clientIds[0]]);
|
|
53
|
-
const {
|
|
54
|
-
replaceBlocks
|
|
55
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
56
|
-
const onClick = (0, _element.useCallback)(() => {
|
|
57
|
-
replaceBlocks(block.clientId, (0, _blocks.rawHandler)({
|
|
58
|
-
HTML: (0, _blocks.getBlockContent)(block)
|
|
59
|
-
}));
|
|
60
|
-
}, [block]);
|
|
61
|
-
|
|
62
|
-
if (!shouldRender) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, (0, _extends2.default)({
|
|
67
|
-
onClick: onClick
|
|
68
|
-
}, props), (0, _i18n.__)('Edit visually')));
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=block-edit-visually-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-settings-menu/block-edit-visually-button.js"],"names":["BlockEditVisuallyButton","clientIds","props","block","shouldRender","select","firstBlockClientId","isBlockMultiSelected","getBlockMode","getBlock","blockEditorStore","isSingleSelected","isHtmlMode","replaceBlocks","onClick","clientId","HTML"],"mappings":";;;;;;;;;AAOA;;;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,uBAAT,OAA4D;AAAA,MAA1B;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,GAA0B;AAC1E,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAA0B,qBAC7BC,MAAF,IAAc;AACb,UAAMC,kBAAkB,GAAGL,SAAS,CAAE,CAAF,CAApC;AACA,UAAM;AAAEM,MAAAA,oBAAF;AAAwBC,MAAAA,YAAxB;AAAsCC,MAAAA;AAAtC,QACLJ,MAAM,CAAEK,YAAF,CADP;AAEA,UAAMC,gBAAgB,GACrB,CAAEJ,oBAAoB,CAAED,kBAAF,CADvB;AAEA,UAAMM,UAAU,GAAGJ,YAAY,CAAEF,kBAAF,CAAZ,KAAuC,MAA1D;AAEA,WAAO;AACNH,MAAAA,KAAK,EAAEM,QAAQ,CAAEH,kBAAF,CADT;AAENF,MAAAA,YAAY,EAAEO,gBAAgB,IAAIC;AAF5B,KAAP;AAIA,GAb8B,EAc/B,CAAEX,SAAS,CAAE,CAAF,CAAX,CAd+B,CAAhC;AAiBA,QAAM;AAAEY,IAAAA;AAAF,MAAoB,uBAAaH,YAAb,CAA1B;AACA,QAAMI,OAAO,GAAG,0BAAa,MAAM;AAClCD,IAAAA,aAAa,CACZV,KAAK,CAACY,QADM,EAEZ,wBAAY;AAAEC,MAAAA,IAAI,EAAE,6BAAiBb,KAAjB;AAAR,KAAZ,CAFY,CAAb;AAIA,GALe,EAKb,CAAEA,KAAF,CALa,CAAhB;;AAOA,MAAK,CAAEC,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,wBAAD,QACC,4BAAC,yBAAD;AAAe,IAAA,OAAO,EAAGU;AAAzB,KAAwCZ,KAAxC,GACG,cAAI,eAAJ,CADH,CADD,CADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { rawHandler, getBlockContent } from '@wordpress/blocks';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockEditVisuallyButton( { clientIds, ...props } ) {\n\tconst { block, shouldRender } = useSelect(\n\t\t( select ) => {\n\t\t\tconst firstBlockClientId = clientIds[ 0 ];\n\t\t\tconst { isBlockMultiSelected, getBlockMode, getBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst isSingleSelected =\n\t\t\t\t! isBlockMultiSelected( firstBlockClientId );\n\t\t\tconst isHtmlMode = getBlockMode( firstBlockClientId ) === 'html';\n\n\t\t\treturn {\n\t\t\t\tblock: getBlock( firstBlockClientId ),\n\t\t\t\tshouldRender: isSingleSelected && isHtmlMode,\n\t\t\t};\n\t\t},\n\t\t[ clientIds[ 0 ] ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst onClick = useCallback( () => {\n\t\treplaceBlocks(\n\t\t\tblock.clientId,\n\t\t\trawHandler( { HTML: getBlockContent( block ) } )\n\t\t);\n\t}, [ block ] );\n\n\tif ( ! shouldRender ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton onClick={ onClick } { ...props }>\n\t\t\t\t{ __( 'Edit visually' ) }\n\t\t\t</ToolbarButton>\n\t\t</ToolbarGroup>\n\t);\n}\n"]}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { createElement } from "@wordpress/element";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* WordPress dependencies
|
|
6
|
-
*/
|
|
7
|
-
import { rawHandler, getBlockContent } from '@wordpress/blocks';
|
|
8
|
-
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
|
-
import { useCallback } from '@wordpress/element';
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { store as blockEditorStore } from '../../store';
|
|
17
|
-
export default function BlockEditVisuallyButton(_ref) {
|
|
18
|
-
let {
|
|
19
|
-
clientIds,
|
|
20
|
-
...props
|
|
21
|
-
} = _ref;
|
|
22
|
-
const {
|
|
23
|
-
block,
|
|
24
|
-
shouldRender
|
|
25
|
-
} = useSelect(select => {
|
|
26
|
-
const firstBlockClientId = clientIds[0];
|
|
27
|
-
const {
|
|
28
|
-
isBlockMultiSelected,
|
|
29
|
-
getBlockMode,
|
|
30
|
-
getBlock
|
|
31
|
-
} = select(blockEditorStore);
|
|
32
|
-
const isSingleSelected = !isBlockMultiSelected(firstBlockClientId);
|
|
33
|
-
const isHtmlMode = getBlockMode(firstBlockClientId) === 'html';
|
|
34
|
-
return {
|
|
35
|
-
block: getBlock(firstBlockClientId),
|
|
36
|
-
shouldRender: isSingleSelected && isHtmlMode
|
|
37
|
-
};
|
|
38
|
-
}, [clientIds[0]]);
|
|
39
|
-
const {
|
|
40
|
-
replaceBlocks
|
|
41
|
-
} = useDispatch(blockEditorStore);
|
|
42
|
-
const onClick = useCallback(() => {
|
|
43
|
-
replaceBlocks(block.clientId, rawHandler({
|
|
44
|
-
HTML: getBlockContent(block)
|
|
45
|
-
}));
|
|
46
|
-
}, [block]);
|
|
47
|
-
|
|
48
|
-
if (!shouldRender) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return createElement(ToolbarGroup, null, createElement(ToolbarButton, _extends({
|
|
53
|
-
onClick: onClick
|
|
54
|
-
}, props), __('Edit visually')));
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=block-edit-visually-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-settings-menu/block-edit-visually-button.js"],"names":["rawHandler","getBlockContent","ToolbarButton","ToolbarGroup","__","useSelect","useDispatch","useCallback","store","blockEditorStore","BlockEditVisuallyButton","clientIds","props","block","shouldRender","select","firstBlockClientId","isBlockMultiSelected","getBlockMode","getBlock","isSingleSelected","isHtmlMode","replaceBlocks","onClick","clientId","HTML"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,eAArB,QAA4C,mBAA5C;AACA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,uBAA5C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,uBAAT,OAA4D;AAAA,MAA1B;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,GAA0B;AAC1E,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAA0BT,SAAS,CACtCU,MAAF,IAAc;AACb,UAAMC,kBAAkB,GAAGL,SAAS,CAAE,CAAF,CAApC;AACA,UAAM;AAAEM,MAAAA,oBAAF;AAAwBC,MAAAA,YAAxB;AAAsCC,MAAAA;AAAtC,QACLJ,MAAM,CAAEN,gBAAF,CADP;AAEA,UAAMW,gBAAgB,GACrB,CAAEH,oBAAoB,CAAED,kBAAF,CADvB;AAEA,UAAMK,UAAU,GAAGH,YAAY,CAAEF,kBAAF,CAAZ,KAAuC,MAA1D;AAEA,WAAO;AACNH,MAAAA,KAAK,EAAEM,QAAQ,CAAEH,kBAAF,CADT;AAENF,MAAAA,YAAY,EAAEM,gBAAgB,IAAIC;AAF5B,KAAP;AAIA,GAbuC,EAcxC,CAAEV,SAAS,CAAE,CAAF,CAAX,CAdwC,CAAzC;AAiBA,QAAM;AAAEW,IAAAA;AAAF,MAAoBhB,WAAW,CAAEG,gBAAF,CAArC;AACA,QAAMc,OAAO,GAAGhB,WAAW,CAAE,MAAM;AAClCe,IAAAA,aAAa,CACZT,KAAK,CAACW,QADM,EAEZxB,UAAU,CAAE;AAAEyB,MAAAA,IAAI,EAAExB,eAAe,CAAEY,KAAF;AAAvB,KAAF,CAFE,CAAb;AAIA,GAL0B,EAKxB,CAAEA,KAAF,CALwB,CAA3B;;AAOA,MAAK,CAAEC,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,YAAD,QACC,cAAC,aAAD;AAAe,IAAA,OAAO,EAAGS;AAAzB,KAAwCX,KAAxC,GACGR,EAAE,CAAE,eAAF,CADL,CADD,CADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { rawHandler, getBlockContent } from '@wordpress/blocks';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockEditVisuallyButton( { clientIds, ...props } ) {\n\tconst { block, shouldRender } = useSelect(\n\t\t( select ) => {\n\t\t\tconst firstBlockClientId = clientIds[ 0 ];\n\t\t\tconst { isBlockMultiSelected, getBlockMode, getBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst isSingleSelected =\n\t\t\t\t! isBlockMultiSelected( firstBlockClientId );\n\t\t\tconst isHtmlMode = getBlockMode( firstBlockClientId ) === 'html';\n\n\t\t\treturn {\n\t\t\t\tblock: getBlock( firstBlockClientId ),\n\t\t\t\tshouldRender: isSingleSelected && isHtmlMode,\n\t\t\t};\n\t\t},\n\t\t[ clientIds[ 0 ] ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst onClick = useCallback( () => {\n\t\treplaceBlocks(\n\t\t\tblock.clientId,\n\t\t\trawHandler( { HTML: getBlockContent( block ) } )\n\t\t);\n\t}, [ block ] );\n\n\tif ( ! shouldRender ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton onClick={ onClick } { ...props }>\n\t\t\t\t{ __( 'Edit visually' ) }\n\t\t\t</ToolbarButton>\n\t\t</ToolbarGroup>\n\t);\n}\n"]}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { rawHandler, getBlockContent } from '@wordpress/blocks';
|
|
5
|
-
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import { useCallback } from '@wordpress/element';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { store as blockEditorStore } from '../../store';
|
|
14
|
-
|
|
15
|
-
export default function BlockEditVisuallyButton( { clientIds, ...props } ) {
|
|
16
|
-
const { block, shouldRender } = useSelect(
|
|
17
|
-
( select ) => {
|
|
18
|
-
const firstBlockClientId = clientIds[ 0 ];
|
|
19
|
-
const { isBlockMultiSelected, getBlockMode, getBlock } =
|
|
20
|
-
select( blockEditorStore );
|
|
21
|
-
const isSingleSelected =
|
|
22
|
-
! isBlockMultiSelected( firstBlockClientId );
|
|
23
|
-
const isHtmlMode = getBlockMode( firstBlockClientId ) === 'html';
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
block: getBlock( firstBlockClientId ),
|
|
27
|
-
shouldRender: isSingleSelected && isHtmlMode,
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
[ clientIds[ 0 ] ]
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
34
|
-
const onClick = useCallback( () => {
|
|
35
|
-
replaceBlocks(
|
|
36
|
-
block.clientId,
|
|
37
|
-
rawHandler( { HTML: getBlockContent( block ) } )
|
|
38
|
-
);
|
|
39
|
-
}, [ block ] );
|
|
40
|
-
|
|
41
|
-
if ( ! shouldRender ) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<ToolbarGroup>
|
|
47
|
-
<ToolbarButton onClick={ onClick } { ...props }>
|
|
48
|
-
{ __( 'Edit visually' ) }
|
|
49
|
-
</ToolbarButton>
|
|
50
|
-
</ToolbarGroup>
|
|
51
|
-
);
|
|
52
|
-
}
|