@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
|
@@ -1,140 +1,38 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* WordPress dependencies
|
|
5
3
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
-
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
9
|
-
import { getCSSRules } from '@wordpress/style-engine';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
10
5
|
/**
|
|
11
6
|
* Internal dependencies
|
|
12
7
|
*/
|
|
13
8
|
|
|
14
|
-
import
|
|
15
|
-
import { appendSelectors, getBlockGapCSS } from './utils';
|
|
9
|
+
import { getBlockGapCSS, getAlignmentsInfo } from './utils';
|
|
16
10
|
import { getGapBoxControlValueFromStyle } from '../hooks/gap';
|
|
17
11
|
import { shouldSkipSerialization } from '../hooks/utils';
|
|
18
12
|
export default {
|
|
19
13
|
name: 'default',
|
|
20
14
|
label: __('Flow'),
|
|
21
|
-
inspectorControls: function DefaultLayoutInspectorControls(
|
|
22
|
-
|
|
23
|
-
layout,
|
|
24
|
-
onChange
|
|
25
|
-
} = _ref;
|
|
26
|
-
const {
|
|
27
|
-
wideSize,
|
|
28
|
-
contentSize
|
|
29
|
-
} = layout;
|
|
30
|
-
const units = useCustomUnits({
|
|
31
|
-
availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
|
|
32
|
-
});
|
|
33
|
-
return createElement(Fragment, null, createElement("div", {
|
|
34
|
-
className: "block-editor-hooks__layout-controls"
|
|
35
|
-
}, createElement("div", {
|
|
36
|
-
className: "block-editor-hooks__layout-controls-unit"
|
|
37
|
-
}, createElement(UnitControl, {
|
|
38
|
-
label: __('Content'),
|
|
39
|
-
labelPosition: "top",
|
|
40
|
-
__unstableInputWidth: "80px",
|
|
41
|
-
value: contentSize || wideSize || '',
|
|
42
|
-
onChange: nextWidth => {
|
|
43
|
-
nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
|
|
44
|
-
onChange({ ...layout,
|
|
45
|
-
contentSize: nextWidth
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
units: units
|
|
49
|
-
}), createElement(Icon, {
|
|
50
|
-
icon: positionCenter
|
|
51
|
-
})), createElement("div", {
|
|
52
|
-
className: "block-editor-hooks__layout-controls-unit"
|
|
53
|
-
}, createElement(UnitControl, {
|
|
54
|
-
label: __('Wide'),
|
|
55
|
-
labelPosition: "top",
|
|
56
|
-
__unstableInputWidth: "80px",
|
|
57
|
-
value: wideSize || contentSize || '',
|
|
58
|
-
onChange: nextWidth => {
|
|
59
|
-
nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
|
|
60
|
-
onChange({ ...layout,
|
|
61
|
-
wideSize: nextWidth
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
units: units
|
|
65
|
-
}), createElement(Icon, {
|
|
66
|
-
icon: stretchWide
|
|
67
|
-
}))), createElement("div", {
|
|
68
|
-
className: "block-editor-hooks__layout-controls-reset"
|
|
69
|
-
}, createElement(Button, {
|
|
70
|
-
variant: "secondary",
|
|
71
|
-
isSmall: true,
|
|
72
|
-
disabled: !contentSize && !wideSize,
|
|
73
|
-
onClick: () => onChange({
|
|
74
|
-
contentSize: undefined,
|
|
75
|
-
wideSize: undefined,
|
|
76
|
-
inherit: false
|
|
77
|
-
})
|
|
78
|
-
}, __('Reset'))), createElement("p", {
|
|
79
|
-
className: "block-editor-hooks__layout-controls-helptext"
|
|
80
|
-
}, __('Customize the width for all elements that are assigned to the center or wide columns.')));
|
|
15
|
+
inspectorControls: function DefaultLayoutInspectorControls() {
|
|
16
|
+
return null;
|
|
81
17
|
},
|
|
82
18
|
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
83
19
|
return null;
|
|
84
20
|
},
|
|
85
|
-
getLayoutStyle: function getLayoutStyle(
|
|
86
|
-
var _style$spacing
|
|
21
|
+
getLayoutStyle: function getLayoutStyle(_ref) {
|
|
22
|
+
var _style$spacing;
|
|
87
23
|
|
|
88
24
|
let {
|
|
89
25
|
selector,
|
|
90
|
-
layout = {},
|
|
91
26
|
style,
|
|
92
27
|
blockName,
|
|
93
28
|
hasBlockGapSupport,
|
|
94
29
|
layoutDefinitions
|
|
95
|
-
} =
|
|
96
|
-
const {
|
|
97
|
-
contentSize,
|
|
98
|
-
wideSize
|
|
99
|
-
} = layout;
|
|
30
|
+
} = _ref;
|
|
100
31
|
const blockGapStyleValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // If a block's block.json skips serialization for spacing or
|
|
101
32
|
// spacing.blockGap, don't apply the user-defined value to the styles.
|
|
102
33
|
|
|
103
34
|
const blockGapValue = blockGapStyleValue !== null && blockGapStyleValue !== void 0 && blockGapStyleValue.top && !shouldSkipSerialization(blockName, 'spacing', 'blockGap') ? blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top : '';
|
|
104
|
-
let output =
|
|
105
|
-
${appendSelectors(selector, '> :where(:not(.alignleft):not(.alignright):not(.alignfull))')} {
|
|
106
|
-
max-width: ${contentSize !== null && contentSize !== void 0 ? contentSize : wideSize};
|
|
107
|
-
margin-left: auto !important;
|
|
108
|
-
margin-right: auto !important;
|
|
109
|
-
}
|
|
110
|
-
${appendSelectors(selector, '> .alignwide')} {
|
|
111
|
-
max-width: ${wideSize !== null && wideSize !== void 0 ? wideSize : contentSize};
|
|
112
|
-
}
|
|
113
|
-
${appendSelectors(selector, '> .alignfull')} {
|
|
114
|
-
max-width: none;
|
|
115
|
-
}
|
|
116
|
-
` : ''; // If there is custom padding, add negative margins for alignfull blocks.
|
|
117
|
-
|
|
118
|
-
if (style !== null && style !== void 0 && (_style$spacing2 = style.spacing) !== null && _style$spacing2 !== void 0 && _style$spacing2.padding) {
|
|
119
|
-
// The style object might be storing a preset so we need to make sure we get a usable value.
|
|
120
|
-
const paddingValues = getCSSRules(style);
|
|
121
|
-
paddingValues.forEach(rule => {
|
|
122
|
-
if (rule.key === 'paddingRight') {
|
|
123
|
-
output += `
|
|
124
|
-
${appendSelectors(selector, '> .alignfull')} {
|
|
125
|
-
margin-right: calc(${rule.value} * -1);
|
|
126
|
-
}
|
|
127
|
-
`;
|
|
128
|
-
} else if (rule.key === 'paddingLeft') {
|
|
129
|
-
output += `
|
|
130
|
-
${appendSelectors(selector, '> .alignfull')} {
|
|
131
|
-
margin-left: calc(${rule.value} * -1);
|
|
132
|
-
}
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
} // Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
137
|
-
|
|
35
|
+
let output = ''; // Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
138
36
|
|
|
139
37
|
if (hasBlockGapSupport && blockGapValue) {
|
|
140
38
|
output += getBlockGapCSS(selector, layoutDefinitions, 'default', blockGapValue);
|
|
@@ -161,10 +59,6 @@ export default {
|
|
|
161
59
|
}));
|
|
162
60
|
}
|
|
163
61
|
|
|
164
|
-
const {
|
|
165
|
-
contentSize,
|
|
166
|
-
wideSize
|
|
167
|
-
} = layout;
|
|
168
62
|
const alignments = [{
|
|
169
63
|
name: 'left'
|
|
170
64
|
}, {
|
|
@@ -172,20 +66,6 @@ export default {
|
|
|
172
66
|
}, {
|
|
173
67
|
name: 'right'
|
|
174
68
|
}];
|
|
175
|
-
|
|
176
|
-
if (contentSize) {
|
|
177
|
-
alignments.unshift({
|
|
178
|
-
name: 'full'
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (wideSize) {
|
|
183
|
-
alignments.unshift({
|
|
184
|
-
name: 'wide',
|
|
185
|
-
info: alignmentInfo.wide
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
69
|
alignments.unshift({
|
|
190
70
|
name: 'none',
|
|
191
71
|
info: alignmentInfo.none
|
|
@@ -194,39 +74,4 @@ export default {
|
|
|
194
74
|
}
|
|
195
75
|
|
|
196
76
|
};
|
|
197
|
-
/**
|
|
198
|
-
* Helper method to assign contextual info to clarify
|
|
199
|
-
* alignment settings.
|
|
200
|
-
*
|
|
201
|
-
* Besides checking if `contentSize` and `wideSize` have a
|
|
202
|
-
* value, we now show this information only if their values
|
|
203
|
-
* are not a `css var`. This needs to change when parsing
|
|
204
|
-
* css variables land.
|
|
205
|
-
*
|
|
206
|
-
* @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
|
|
207
|
-
*
|
|
208
|
-
* @param {Object} layout The layout object.
|
|
209
|
-
* @return {Object} An object with contextual info per alignment.
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
function getAlignmentsInfo(layout) {
|
|
213
|
-
const {
|
|
214
|
-
contentSize,
|
|
215
|
-
wideSize
|
|
216
|
-
} = layout;
|
|
217
|
-
const alignmentInfo = {};
|
|
218
|
-
const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
|
|
219
|
-
|
|
220
|
-
if (sizeRegex.test(contentSize)) {
|
|
221
|
-
// translators: %s: container size (i.e. 600px etc)
|
|
222
|
-
alignmentInfo.none = sprintf(__('Max %s wide'), contentSize);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (sizeRegex.test(wideSize)) {
|
|
226
|
-
// translators: %s: container size (i.e. 600px etc)
|
|
227
|
-
alignmentInfo.wide = sprintf(__('Max %s wide'), wideSize);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return alignmentInfo;
|
|
231
|
-
}
|
|
232
77
|
//# sourceMappingURL=flow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/layouts/flow.js"],"names":["Button","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__","sprintf","Icon","positionCenter","stretchWide","getCSSRules","useSetting","appendSelectors","getBlockGapCSS","getGapBoxControlValueFromStyle","shouldSkipSerialization","name","label","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","wideSize","contentSize","units","availableUnits","nextWidth","parseFloat","undefined","inherit","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","output","padding","paddingValues","forEach","rule","key","value","getOrientation","getAlignments","alignmentInfo","getAlignmentsInfo","align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A;;AACD,MAAKuC,SAAS,CAACC,IAAV,CAAgBzC,QAAhB,CAAL,EAAkC;AACjC;AACA8B,IAAAA,aAAa,CAACQ,IAAd,GAAqBtD,OAAO,CAAED,EAAE,CAAE,aAAF,CAAJ,EAAuBiB,QAAvB,CAA5B;AACA;;AACD,SAAO8B,aAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, positionCenter, stretchWide } from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport { appendSelectors, getBlockGapCSS } from './utils';\nimport { getGapBoxControlValueFromStyle } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nexport default {\n\tname: 'default',\n\tlabel: __( 'Flow' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t} ) {\n\t\tconst { wideSize, contentSize } = layout;\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t\t'%',\n\t\t\t\t'px',\n\t\t\t\t'em',\n\t\t\t\t'rem',\n\t\t\t\t'vw',\n\t\t\t],\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"block-editor-hooks__layout-controls-reset\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tisSmall\n\t\t\t\t\t\tdisabled={ ! contentSize && ! wideSize }\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\tcontentSize: undefined,\n\t\t\t\t\t\t\t\twideSize: undefined,\n\t\t\t\t\t\t\t\tinherit: false,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\n\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst { contentSize, wideSize } = layout;\n\t\tconst blockGapStyleValue = getGapBoxControlValueFromStyle(\n\t\t\tstyle?.spacing?.blockGap\n\t\t);\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tblockGapStyleValue?.top &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? blockGapStyleValue?.top\n\t\t\t\t: '';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: auto !important;\n\t\t\t\t\t\tmargin-right: auto !important;\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'default',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n\n/**\n * Helper method to assign contextual info to clarify\n * alignment settings.\n *\n * Besides checking if `contentSize` and `wideSize` have a\n * value, we now show this information only if their values\n * are not a `css var`. This needs to change when parsing\n * css variables land.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752\n *\n * @param {Object} layout The layout object.\n * @return {Object} An object with contextual info per alignment.\n */\nfunction getAlignmentsInfo( layout ) {\n\tconst { contentSize, wideSize } = layout;\n\tconst alignmentInfo = {};\n\tconst sizeRegex = /^(?!0)\\d+(px|em|rem|vw|vh|%)?$/i;\n\tif ( sizeRegex.test( contentSize ) ) {\n\t\t// translators: %s: container size (i.e. 600px etc)\n\t\talignmentInfo.none = sprintf( __( 'Max %s wide' ), contentSize );\n\t}\n\tif ( sizeRegex.test( wideSize ) ) {\n\t\t// translators: %s: container size (i.e. 600px etc)\n\t\talignmentInfo.wide = sprintf( __( 'Max %s wide' ), wideSize );\n\t}\n\treturn alignmentInfo;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/layouts/flow.js"],"names":["__","getBlockGapCSS","getAlignmentsInfo","getGapBoxControlValueFromStyle","shouldSkipSerialization","name","label","inspectorControls","DefaultLayoutInspectorControls","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","output","getOrientation","getAlignments","layout","alignmentInfo","alignments","undefined","includes","unshift","map","alignment","info","none"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AAC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,CAAEC,MAAF,EAAW;AACvB,UAAMC,aAAa,GAAGxB,iBAAiB,CAAEuB,MAAF,CAAvC;;AACA,QAAKA,MAAM,CAACE,UAAP,KAAsBC,SAA3B,EAAuC;AACtC,UAAK,CAAEH,MAAM,CAACE,UAAP,CAAkBE,QAAlB,CAA4B,MAA5B,CAAP,EAA8C;AAC7CJ,QAAAA,MAAM,CAACE,UAAP,CAAkBG,OAAlB,CAA2B,MAA3B;AACA;;AACD,aAAOL,MAAM,CAACE,UAAP,CAAkBI,GAAlB,CAAyBC,SAAF,KAAmB;AAChD3B,QAAAA,IAAI,EAAE2B,SAD0C;AAEhDC,QAAAA,IAAI,EAAEP,aAAa,CAAEM,SAAF;AAF6B,OAAnB,CAAvB,CAAP;AAIA;;AAED,UAAML,UAAU,GAAG,CAClB;AAAEtB,MAAAA,IAAI,EAAE;AAAR,KADkB,EAElB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAFkB,EAGlB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAHkB,CAAnB;AAMAsB,IAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,MAAAA,IAAI,EAAE,MAAR;AAAgB4B,MAAAA,IAAI,EAAEP,aAAa,CAACQ;AAApC,KAApB;AAEA,WAAOP,UAAP;AACA;;AAhEa,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapBoxControlValueFromStyle } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nexport default {\n\tname: 'default',\n\tlabel: __( 'Flow' ),\n\tinspectorControls: function DefaultLayoutInspectorControls() {\n\t\treturn null;\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst blockGapStyleValue = getGapBoxControlValueFromStyle(\n\t\t\tstyle?.spacing?.blockGap\n\t\t);\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tblockGapStyleValue?.top &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? blockGapStyleValue?.top\n\t\t\t\t: '';\n\n\t\tlet output = '';\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'default',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/layouts/index.js"],"names":["flex","flow","layoutTypes","getLayoutType","name","find","layoutType","getLayoutTypes"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAMC,WAAW,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/layouts/index.js"],"names":["flex","flow","constrained","layoutTypes","getLayoutType","name","find","layoutType","getLayoutTypes"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAEA,MAAMC,WAAW,GAAG,CAAEF,IAAF,EAAQD,IAAR,EAAcE,WAAd,CAApB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,aAAT,GAA2C;AAAA,MAAnBC,IAAmB,uEAAZ,SAAY;AACjD,SAAOF,WAAW,CAACG,IAAZ,CAAoBC,UAAF,IAAkBA,UAAU,CAACF,IAAX,KAAoBA,IAAxD,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,cAAT,GAA0B;AAChC,SAAOL,WAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport flex from './flex';\nimport flow from './flow';\nimport constrained from './constrained';\n\nconst layoutTypes = [ flow, flex, constrained ];\n\n/**\n * Retrieves a layout type by name.\n *\n * @param {string} name - The name of the layout type.\n * @return {Object} Layout type.\n */\nexport function getLayoutType( name = 'default' ) {\n\treturn layoutTypes.find( ( layoutType ) => layoutType.name === name );\n}\n\n/**\n * Retrieves the available layout types.\n *\n * @return {Array} Layout types.\n */\nexport function getLayoutTypes() {\n\treturn layoutTypes;\n}\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
1
5
|
/**
|
|
2
6
|
* Utility to generate the proper CSS selector for layout styles.
|
|
3
7
|
*
|
|
@@ -6,6 +10,7 @@
|
|
|
6
10
|
*
|
|
7
11
|
* @return {string} - CSS selector.
|
|
8
12
|
*/
|
|
13
|
+
|
|
9
14
|
export function appendSelectors(selectors) {
|
|
10
15
|
let append = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
11
16
|
// Ideally we shouldn't need the `.editor-styles-wrapper` increased specificity here
|
|
@@ -45,4 +50,39 @@ export function getBlockGapCSS(selector, layoutDefinitions, layoutType, blockGap
|
|
|
45
50
|
|
|
46
51
|
return output;
|
|
47
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Helper method to assign contextual info to clarify
|
|
55
|
+
* alignment settings.
|
|
56
|
+
*
|
|
57
|
+
* Besides checking if `contentSize` and `wideSize` have a
|
|
58
|
+
* value, we now show this information only if their values
|
|
59
|
+
* are not a `css var`. This needs to change when parsing
|
|
60
|
+
* css variables land.
|
|
61
|
+
*
|
|
62
|
+
* @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} layout The layout object.
|
|
65
|
+
* @return {Object} An object with contextual info per alignment.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
export function getAlignmentsInfo(layout) {
|
|
69
|
+
const {
|
|
70
|
+
contentSize,
|
|
71
|
+
wideSize
|
|
72
|
+
} = layout;
|
|
73
|
+
const alignmentInfo = {};
|
|
74
|
+
const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%)?$/i;
|
|
75
|
+
|
|
76
|
+
if (sizeRegex.test(contentSize)) {
|
|
77
|
+
// translators: %s: container size (i.e. 600px etc)
|
|
78
|
+
alignmentInfo.none = sprintf(__('Max %s wide'), contentSize);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (sizeRegex.test(wideSize)) {
|
|
82
|
+
// translators: %s: container size (i.e. 600px etc)
|
|
83
|
+
alignmentInfo.wide = sprintf(__('Max %s wide'), wideSize);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return alignmentInfo;
|
|
87
|
+
}
|
|
48
88
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/layouts/utils.js"],"names":["appendSelectors","selectors","append","split","map","subselector","join","getBlockGapCSS","selector","layoutDefinitions","layoutType","blockGapValue","output","spacingStyles","length","forEach","gapStyle","trim","Object","entries","rules","cssProperty","value"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/layouts/utils.js"],"names":["__","sprintf","appendSelectors","selectors","append","split","map","subselector","join","getBlockGapCSS","selector","layoutDefinitions","layoutType","blockGapValue","output","spacingStyles","length","forEach","gapStyle","trim","Object","entries","rules","cssProperty","value","getAlignmentsInfo","layout","contentSize","wideSize","alignmentInfo","sizeRegex","test","none","wide"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,SAA1B,EAAmD;AAAA,MAAdC,MAAc,uEAAL,EAAK;AACzD;AACA;AACA;AACA;AACA;AAEA,SAAOD,SAAS,CACdE,KADK,CACE,GADF,EAELC,GAFK,CAGHC,WAAF,IACE,0BAA0BA,WAAa,GACvCH,MAAM,GAAI,IAAIA,MAAQ,EAAhB,GAAoB,EAC1B,EANG,EAQLI,IARK,CAQC,GARD,CAAP;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CACNC,QADM,EAENC,iBAFM,EAGNC,UAHM,EAINC,aAJM,EAKL;AAAA;;AACD,MAAIC,MAAM,GAAG,EAAb;;AACA,MACCH,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,6BAAAA,iBAAiB,CAAIC,UAAJ,CAAjB,kGAAmCG,aAAnC,0EAAkDC,MAAlD,IACAH,aAFD,EAGE;AACDF,IAAAA,iBAAiB,CAAEC,UAAF,CAAjB,CAAgCG,aAAhC,CAA8CE,OAA9C,CAAyDC,QAAF,IAAgB;AACtEJ,MAAAA,MAAM,IAAK,GAAGZ,eAAe,CAC5BQ,QAD4B,EAE5BQ,QAAQ,CAACR,QAAT,CAAkBS,IAAlB,EAF4B,CAG1B,KAHH;AAIAL,MAAAA,MAAM,IAAIM,MAAM,CAACC,OAAP,CAAgBH,QAAQ,CAACI,KAAzB,EACRhB,GADQ,CAER;AAAA,YAAE,CAAEiB,WAAF,EAAeC,KAAf,CAAF;AAAA,eACE,GAAGD,WAAa,KAAKC,KAAK,GAAGA,KAAH,GAAWX,aAAe,EADtD;AAAA,OAFQ,EAKRL,IALQ,CAKF,IALE,CAAV;AAMAM,MAAAA,MAAM,IAAI,KAAV;AACA,KAZD;AAaA;;AACD,SAAOA,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,iBAAT,CAA4BC,MAA5B,EAAqC;AAC3C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAA4BF,MAAlC;AACA,QAAMG,aAAa,GAAG,EAAtB;AACA,QAAMC,SAAS,GAAG,iCAAlB;;AACA,MAAKA,SAAS,CAACC,IAAV,CAAgBJ,WAAhB,CAAL,EAAqC;AACpC;AACAE,IAAAA,aAAa,CAACG,IAAd,GAAqB/B,OAAO,CAAED,EAAE,CAAE,aAAF,CAAJ,EAAuB2B,WAAvB,CAA5B;AACA;;AACD,MAAKG,SAAS,CAACC,IAAV,CAAgBH,QAAhB,CAAL,EAAkC;AACjC;AACAC,IAAAA,aAAa,CAACI,IAAd,GAAqBhC,OAAO,CAAED,EAAE,CAAE,aAAF,CAAJ,EAAuB4B,QAAvB,CAA5B;AACA;;AACD,SAAOC,aAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Utility to generate the proper CSS selector for layout styles.\n *\n * @param {string} selectors CSS selector, also supports multiple comma-separated selectors.\n * @param {string} append The string to append.\n *\n * @return {string} - CSS selector.\n */\nexport function appendSelectors( selectors, append = '' ) {\n\t// Ideally we shouldn't need the `.editor-styles-wrapper` increased specificity here\n\t// The problem though is that we have a `.editor-styles-wrapper p { margin: reset; }` style\n\t// it's used to reset the default margin added by wp-admin to paragraphs\n\t// so we need this to be higher speficity otherwise, it won't be applied to paragraphs inside containers\n\t// When the post editor is fully iframed, this extra classname could be removed.\n\n\treturn selectors\n\t\t.split( ',' )\n\t\t.map(\n\t\t\t( subselector ) =>\n\t\t\t\t`.editor-styles-wrapper ${ subselector }${\n\t\t\t\t\tappend ? ` ${ append }` : ''\n\t\t\t\t}`\n\t\t)\n\t\t.join( ',' );\n}\n\n/**\n * Get generated blockGap CSS rules based on layout definitions provided in theme.json\n * Falsy values in the layout definition's spacingStyles rules will be swapped out\n * with the provided `blockGapValue`.\n *\n * @param {string} selector The CSS selector to target for the generated rules.\n * @param {Object} layoutDefinitions Layout definitions object from theme.json.\n * @param {string} layoutType The layout type (e.g. `default` or `flex`).\n * @param {string} blockGapValue The current blockGap value to be applied.\n * @return {string} The generated CSS rules.\n */\nexport function getBlockGapCSS(\n\tselector,\n\tlayoutDefinitions,\n\tlayoutType,\n\tblockGapValue\n) {\n\tlet output = '';\n\tif (\n\t\tlayoutDefinitions?.[ layoutType ]?.spacingStyles?.length &&\n\t\tblockGapValue\n\t) {\n\t\tlayoutDefinitions[ layoutType ].spacingStyles.forEach( ( gapStyle ) => {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\tgapStyle.selector.trim()\n\t\t\t) } { `;\n\t\t\toutput += Object.entries( gapStyle.rules )\n\t\t\t\t.map(\n\t\t\t\t\t( [ cssProperty, value ] ) =>\n\t\t\t\t\t\t`${ cssProperty }: ${ value ? value : blockGapValue }`\n\t\t\t\t)\n\t\t\t\t.join( '; ' );\n\t\t\toutput += '; }';\n\t\t} );\n\t}\n\treturn output;\n}\n\n/**\n * Helper method to assign contextual info to clarify\n * alignment settings.\n *\n * Besides checking if `contentSize` and `wideSize` have a\n * value, we now show this information only if their values\n * are not a `css var`. This needs to change when parsing\n * css variables land.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34710#issuecomment-918000752\n *\n * @param {Object} layout The layout object.\n * @return {Object} An object with contextual info per alignment.\n */\nexport function getAlignmentsInfo( layout ) {\n\tconst { contentSize, wideSize } = layout;\n\tconst alignmentInfo = {};\n\tconst sizeRegex = /^(?!0)\\d+(px|em|rem|vw|vh|%)?$/i;\n\tif ( sizeRegex.test( contentSize ) ) {\n\t\t// translators: %s: container size (i.e. 600px etc)\n\t\talignmentInfo.none = sprintf( __( 'Max %s wide' ), contentSize );\n\t}\n\tif ( sizeRegex.test( wideSize ) ) {\n\t\t// translators: %s: container size (i.e. 600px etc)\n\t\talignmentInfo.wide = sprintf( __( 'Max %s wide' ), wideSize );\n\t}\n\treturn alignmentInfo;\n}\n"]}
|
|
@@ -899,6 +899,7 @@ export const __unstableExpandSelection = () => _ref14 => {
|
|
|
899
899
|
|
|
900
900
|
export const mergeBlocks = (firstBlockClientId, secondBlockClientId) => _ref15 => {
|
|
901
901
|
let {
|
|
902
|
+
registry,
|
|
902
903
|
select,
|
|
903
904
|
dispatch
|
|
904
905
|
} = _ref15;
|
|
@@ -909,14 +910,35 @@ export const mergeBlocks = (firstBlockClientId, secondBlockClientId) => _ref15 =
|
|
|
909
910
|
});
|
|
910
911
|
const [clientIdA, clientIdB] = blocks;
|
|
911
912
|
const blockA = select.getBlock(clientIdA);
|
|
912
|
-
const blockAType = getBlockType(blockA.name);
|
|
913
|
+
const blockAType = getBlockType(blockA.name);
|
|
914
|
+
if (!blockAType) return;
|
|
915
|
+
const blockB = select.getBlock(clientIdB);
|
|
913
916
|
|
|
914
917
|
if (blockAType && !blockAType.merge) {
|
|
915
|
-
|
|
918
|
+
// If there's no merge function defined, attempt merging inner
|
|
919
|
+
// blocks.
|
|
920
|
+
const blocksWithTheSameType = switchToBlockType(blockB, blockAType.name); // Only focus the previous block if it's not mergeable.
|
|
921
|
+
|
|
922
|
+
if ((blocksWithTheSameType === null || blocksWithTheSameType === void 0 ? void 0 : blocksWithTheSameType.length) !== 1) {
|
|
923
|
+
dispatch.selectBlock(blockA.clientId);
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
const [blockWithSameType] = blocksWithTheSameType;
|
|
928
|
+
|
|
929
|
+
if (blockWithSameType.innerBlocks.length < 1) {
|
|
930
|
+
dispatch.selectBlock(blockA.clientId);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
registry.batch(() => {
|
|
935
|
+
dispatch.insertBlocks(blockWithSameType.innerBlocks, undefined, clientIdA);
|
|
936
|
+
dispatch.removeBlock(clientIdB);
|
|
937
|
+
dispatch.selectBlock(blockWithSameType.innerBlocks[0].clientId);
|
|
938
|
+
});
|
|
916
939
|
return;
|
|
917
940
|
}
|
|
918
941
|
|
|
919
|
-
const blockB = select.getBlock(clientIdB);
|
|
920
942
|
const blockBType = getBlockType(blockB.name);
|
|
921
943
|
const {
|
|
922
944
|
clientId,
|