@wordpress/block-editor 12.5.0 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +0 -4
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +2 -2
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +14 -18
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.native.js +21 -42
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/index.native.js +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +1 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -2
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build/components/block-toolbar/index.js +4 -3
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +62 -3
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/global-styles/color-panel.js +21 -15
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +4 -8
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +13 -23
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +18 -3
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +12 -18
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +6 -6
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +36 -48
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +3 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +2 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +21 -32
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/link-control/index.js +4 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +1 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +65 -31
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +118 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +49 -8
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-setting/index.js +5 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +1 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +7 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +5 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +0 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +19 -8
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +38 -2
- package/build/utils/object.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +2 -2
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +14 -18
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +24 -43
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +3 -3
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +1 -4
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +3 -3
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +4 -3
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +60 -4
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +21 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +4 -8
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +12 -22
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +18 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +13 -18
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +5 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +37 -49
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +3 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +22 -33
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/link-control/index.js +4 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +1 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +66 -33
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +105 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +50 -8
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-setting/index.js +5 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +2 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +5 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +0 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +16 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +34 -2
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +2 -1
- package/build-style/content.css +2 -1
- package/build-style/style-rtl.css +7 -1
- package/build-style/style.css +7 -1
- package/package.json +32 -32
- package/src/components/block-controls/README.md +89 -0
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-draggable/index.native.js +7 -3
- package/src/components/block-draggable/test/index.native.js +0 -54
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- package/src/components/block-list/block-outline.native.js +26 -25
- package/src/components/block-list/block.native.js +24 -38
- package/src/components/block-list/block.native.scss +18 -40
- package/src/components/block-list/style.native.scss +3 -3
- package/src/components/block-mover/index.native.js +3 -3
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +16 -6
- package/src/components/block-removal-warning-modal/index.js +0 -3
- package/src/components/block-settings/button.native.js +12 -6
- package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
- package/src/components/block-toolbar/index.js +2 -3
- package/src/components/block-toolbar/index.native.js +86 -6
- package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
- package/src/components/block-toolbar/test/index.native.js +42 -0
- package/src/components/button-block-appender/styles.native.scss +2 -2
- package/src/components/caption/README.md +49 -0
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/global-styles/color-panel.js +23 -16
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/global-styles/get-block-css-selector.js +5 -9
- package/src/components/global-styles/hooks.js +20 -26
- package/src/components/global-styles/typography-panel.js +17 -5
- package/src/components/global-styles/use-global-styles-output.js +36 -18
- package/src/components/global-styles/utils.js +15 -6
- package/src/components/iframe/index.js +30 -56
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/README.md +10 -0
- package/src/components/inner-blocks/index.js +4 -0
- package/src/components/inner-blocks/index.native.js +4 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
- package/src/components/inserter/index.js +2 -3
- package/src/components/inserter/index.native.js +17 -36
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/inserter/style.native.scss +10 -15
- package/src/components/link-control/index.js +4 -1
- package/src/components/link-control/search-item.js +1 -1
- package/src/components/link-control/style.scss +8 -1
- package/src/components/link-control/test/index.js +26 -0
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/media-placeholder/index.native.js +108 -59
- package/src/components/media-placeholder/styles.native.scss +59 -24
- package/src/components/preview-options/README.md +18 -17
- package/src/components/preview-options/index.js +2 -2
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/get-rich-text-values.js +105 -0
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/text-transform-control/README.md +44 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/components/use-block-drop-zone/index.native.js +65 -28
- package/src/components/use-setting/index.js +8 -8
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/hooks/utils.js +5 -7
- package/src/private-apis.js +7 -1
- package/src/store/actions.js +1 -2
- package/src/store/private-selectors.js +3 -6
- package/src/store/reducer.js +0 -1
- package/src/store/selectors.js +33 -5
- package/src/store/test/actions.js +3 -0
- package/src/store/test/private-selectors.js +5 -5
- package/src/store/test/reducer.js +14 -7
- package/src/store/test/selectors.js +1 -1
- package/src/utils/object.js +32 -2
- package/src/utils/test/object.js +36 -0
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build/components/block-mobile-toolbar/index.native.js +0 -135
- package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
- package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.native.js +0 -127
- package/src/components/block-mobile-toolbar/style.native.scss +0 -16
- /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
|
@@ -57,6 +57,7 @@ export function kebabCase(str) {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Clones an object.
|
|
60
|
+
* Arrays are also cloned as arrays.
|
|
60
61
|
* Non-object values are returned unchanged.
|
|
61
62
|
*
|
|
62
63
|
* @param {*} object Object to clone.
|
|
@@ -64,6 +65,10 @@ export function kebabCase(str) {
|
|
|
64
65
|
*/
|
|
65
66
|
|
|
66
67
|
function cloneObject(object) {
|
|
68
|
+
if (Array.isArray(object)) {
|
|
69
|
+
return object.map(cloneObject);
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
if (object && typeof object === 'object') {
|
|
68
73
|
return { ...Object.fromEntries(Object.entries(object).map(([key, value]) => [key, cloneObject(value)]))
|
|
69
74
|
};
|
|
@@ -74,7 +79,7 @@ function cloneObject(object) {
|
|
|
74
79
|
/**
|
|
75
80
|
* Immutably sets a value inside an object. Like `lodash#set`, but returning a
|
|
76
81
|
* new object. Treats nullish initial values as empty objects. Clones any
|
|
77
|
-
* nested objects.
|
|
82
|
+
* nested objects. Supports arrays, too.
|
|
78
83
|
*
|
|
79
84
|
* @param {Object} object Object to set a value in.
|
|
80
85
|
* @param {number|string|Array} path Path in the object to modify.
|
|
@@ -88,7 +93,11 @@ export function setImmutably(object, path, value) {
|
|
|
88
93
|
const newObject = object ? cloneObject(object) : {};
|
|
89
94
|
normalizedPath.reduce((acc, key, i) => {
|
|
90
95
|
if (acc[key] === undefined) {
|
|
91
|
-
|
|
96
|
+
if (Number.isInteger(path[i + 1])) {
|
|
97
|
+
acc[key] = [];
|
|
98
|
+
} else {
|
|
99
|
+
acc[key] = {};
|
|
100
|
+
}
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
if (i === normalizedPath.length - 1) {
|
|
@@ -99,4 +108,27 @@ export function setImmutably(object, path, value) {
|
|
|
99
108
|
}, newObject);
|
|
100
109
|
return newObject;
|
|
101
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Helper util to return a value from a certain path of the object.
|
|
113
|
+
* Path is specified as either:
|
|
114
|
+
* - a string of properties, separated by dots, for example: "x.y".
|
|
115
|
+
* - an array of properties, for example `[ 'x', 'y' ]`.
|
|
116
|
+
* You can also specify a default value in case the result is nullish.
|
|
117
|
+
*
|
|
118
|
+
* @param {Object} object Input object.
|
|
119
|
+
* @param {string|Array} path Path to the object property.
|
|
120
|
+
* @param {*} defaultValue Default value if the value at the specified path is nullish.
|
|
121
|
+
* @return {*} Value of the object property at the specified path.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
export const getValueFromObjectPath = (object, path, defaultValue) => {
|
|
125
|
+
var _value;
|
|
126
|
+
|
|
127
|
+
const normalizedPath = Array.isArray(path) ? path : path.split('.');
|
|
128
|
+
let value = object;
|
|
129
|
+
normalizedPath.forEach(fieldName => {
|
|
130
|
+
value = value?.[fieldName];
|
|
131
|
+
});
|
|
132
|
+
return (_value = value) !== null && _value !== void 0 ? _value : defaultValue;
|
|
133
|
+
};
|
|
102
134
|
//# sourceMappingURL=object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/utils/object.js"],"names":["paramCase","normalizePath","path","Array","isArray","toString","kebabCase","str","input","replace","splitRegexp","cloneObject","object","Object","fromEntries","entries","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/utils/object.js"],"names":["paramCase","normalizePath","path","Array","isArray","toString","kebabCase","str","input","replace","splitRegexp","cloneObject","object","map","Object","fromEntries","entries","key","value","setImmutably","normalizedPath","newObject","reduce","acc","i","undefined","Number","isInteger","length","getValueFromObjectPath","defaultValue","split","forEach","fieldName"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase } from 'change-case';\n\n/**\n * Converts a path to an array of its fragments.\n * Supports strings, numbers and arrays:\n *\n * 'foo' => [ 'foo' ]\n * 2 => [ '2' ]\n * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]\n *\n * @param {string|number|Array} path Path\n * @return {Array} Normalized path.\n */\nfunction normalizePath( path ) {\n\tif ( Array.isArray( path ) ) {\n\t\treturn path;\n\t} else if ( typeof path === 'number' ) {\n\t\treturn [ path.toString() ];\n\t}\n\n\treturn [ path ];\n}\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param {string} str String to convert.\n * @return {string} Kebab-cased string\n */\nexport function kebabCase( str ) {\n\tlet input = str;\n\tif ( typeof str !== 'string' ) {\n\t\tinput = str?.toString?.() ?? '';\n\t}\n\n\t// See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970\n\tinput = input.replace( /['\\u2019]/, '' );\n\n\treturn paramCase( input, {\n\t\tsplitRegexp: [\n\t\t\t/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t/(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t],\n\t} );\n}\n\n/**\n * Clones an object.\n * Arrays are also cloned as arrays.\n * Non-object values are returned unchanged.\n *\n * @param {*} object Object to clone.\n * @return {*} Cloned object, or original literal non-object value.\n */\nfunction cloneObject( object ) {\n\tif ( Array.isArray( object ) ) {\n\t\treturn object.map( cloneObject );\n\t}\n\n\tif ( object && typeof object === 'object' ) {\n\t\treturn {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tcloneObject( value ),\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}\n\n\treturn object;\n}\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\tconst normalizedPath = normalizePath( path );\n\tconst newObject = object ? cloneObject( object ) : {};\n\n\tnormalizedPath.reduce( ( acc, key, i ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ i + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( i === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, newObject );\n\n\treturn newObject;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n"]}
|
|
@@ -708,7 +708,8 @@
|
|
|
708
708
|
opacity: 0.62;
|
|
709
709
|
}
|
|
710
710
|
:where(body .is-layout-constrained) .block-editor-default-block-appender > :first-child:first-child {
|
|
711
|
-
margin-
|
|
711
|
+
-webkit-margin-before: 0;
|
|
712
|
+
margin-block-start: 0;
|
|
712
713
|
}
|
|
713
714
|
.block-editor-default-block-appender .components-drop-zone__content-icon {
|
|
714
715
|
display: none;
|
package/build-style/content.css
CHANGED
|
@@ -708,7 +708,8 @@
|
|
|
708
708
|
opacity: 0.62;
|
|
709
709
|
}
|
|
710
710
|
:where(body .is-layout-constrained) .block-editor-default-block-appender > :first-child:first-child {
|
|
711
|
-
margin-
|
|
711
|
+
-webkit-margin-before: 0;
|
|
712
|
+
margin-block-start: 0;
|
|
712
713
|
}
|
|
713
714
|
.block-editor-default-block-appender .components-drop-zone__content-icon {
|
|
714
715
|
display: none;
|
|
@@ -2017,6 +2017,12 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
2017
2017
|
overflow: hidden;
|
|
2018
2018
|
text-overflow: ellipsis;
|
|
2019
2019
|
display: inline-block;
|
|
2020
|
+
width: 100%;
|
|
2021
|
+
}
|
|
2022
|
+
.block-editor-link-control__search-item .components-menu-item__item mark {
|
|
2023
|
+
font-weight: 600;
|
|
2024
|
+
color: inherit;
|
|
2025
|
+
background-color: transparent;
|
|
2020
2026
|
}
|
|
2021
2027
|
.block-editor-link-control__search-item .components-menu-item__shortcut {
|
|
2022
2028
|
color: #757575;
|
|
@@ -2076,7 +2082,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
2076
2082
|
position: relative;
|
|
2077
2083
|
}
|
|
2078
2084
|
.block-editor-link-control__search-item .block-editor-link-control__search-item-title mark {
|
|
2079
|
-
font-weight:
|
|
2085
|
+
font-weight: 600;
|
|
2080
2086
|
color: inherit;
|
|
2081
2087
|
background-color: transparent;
|
|
2082
2088
|
}
|
package/build-style/style.css
CHANGED
|
@@ -2018,6 +2018,12 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
2018
2018
|
overflow: hidden;
|
|
2019
2019
|
text-overflow: ellipsis;
|
|
2020
2020
|
display: inline-block;
|
|
2021
|
+
width: 100%;
|
|
2022
|
+
}
|
|
2023
|
+
.block-editor-link-control__search-item .components-menu-item__item mark {
|
|
2024
|
+
font-weight: 600;
|
|
2025
|
+
color: inherit;
|
|
2026
|
+
background-color: transparent;
|
|
2021
2027
|
}
|
|
2022
2028
|
.block-editor-link-control__search-item .components-menu-item__shortcut {
|
|
2023
2029
|
color: #757575;
|
|
@@ -2077,7 +2083,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
2077
2083
|
position: relative;
|
|
2078
2084
|
}
|
|
2079
2085
|
.block-editor-link-control__search-item .block-editor-link-control__search-item-title mark {
|
|
2080
|
-
font-weight:
|
|
2086
|
+
font-weight: 600;
|
|
2081
2087
|
color: inherit;
|
|
2082
2088
|
background-color: transparent;
|
|
2083
2089
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.6.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -32,37 +32,38 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.16.0",
|
|
35
|
+
"@emotion/react": "^11.7.1",
|
|
35
36
|
"@emotion/styled": "^11.6.0",
|
|
36
37
|
"@react-spring/web": "^9.4.5",
|
|
37
|
-
"@wordpress/a11y": "^3.
|
|
38
|
-
"@wordpress/api-fetch": "^6.
|
|
39
|
-
"@wordpress/blob": "^3.
|
|
40
|
-
"@wordpress/blocks": "^12.
|
|
41
|
-
"@wordpress/components": "^25.
|
|
42
|
-
"@wordpress/compose": "^6.
|
|
43
|
-
"@wordpress/data": "^9.
|
|
44
|
-
"@wordpress/date": "^4.
|
|
45
|
-
"@wordpress/deprecated": "^3.
|
|
46
|
-
"@wordpress/dom": "^3.
|
|
47
|
-
"@wordpress/element": "^5.
|
|
48
|
-
"@wordpress/escape-html": "^2.
|
|
49
|
-
"@wordpress/hooks": "^3.
|
|
50
|
-
"@wordpress/html-entities": "^3.
|
|
51
|
-
"@wordpress/i18n": "^4.
|
|
52
|
-
"@wordpress/icons": "^9.
|
|
53
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
54
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
55
|
-
"@wordpress/keycodes": "^3.
|
|
56
|
-
"@wordpress/notices": "^4.
|
|
57
|
-
"@wordpress/preferences": "^3.
|
|
58
|
-
"@wordpress/private-apis": "^0.
|
|
59
|
-
"@wordpress/rich-text": "^6.
|
|
60
|
-
"@wordpress/shortcode": "^3.
|
|
61
|
-
"@wordpress/style-engine": "^1.
|
|
62
|
-
"@wordpress/token-list": "^2.
|
|
63
|
-
"@wordpress/url": "^3.
|
|
64
|
-
"@wordpress/warning": "^2.
|
|
65
|
-
"@wordpress/wordcount": "^3.
|
|
38
|
+
"@wordpress/a11y": "^3.38.0",
|
|
39
|
+
"@wordpress/api-fetch": "^6.35.0",
|
|
40
|
+
"@wordpress/blob": "^3.38.0",
|
|
41
|
+
"@wordpress/blocks": "^12.15.0",
|
|
42
|
+
"@wordpress/components": "^25.4.0",
|
|
43
|
+
"@wordpress/compose": "^6.15.0",
|
|
44
|
+
"@wordpress/data": "^9.8.0",
|
|
45
|
+
"@wordpress/date": "^4.38.0",
|
|
46
|
+
"@wordpress/deprecated": "^3.38.0",
|
|
47
|
+
"@wordpress/dom": "^3.38.0",
|
|
48
|
+
"@wordpress/element": "^5.15.0",
|
|
49
|
+
"@wordpress/escape-html": "^2.38.0",
|
|
50
|
+
"@wordpress/hooks": "^3.38.0",
|
|
51
|
+
"@wordpress/html-entities": "^3.38.0",
|
|
52
|
+
"@wordpress/i18n": "^4.38.0",
|
|
53
|
+
"@wordpress/icons": "^9.29.0",
|
|
54
|
+
"@wordpress/is-shallow-equal": "^4.38.0",
|
|
55
|
+
"@wordpress/keyboard-shortcuts": "^4.15.0",
|
|
56
|
+
"@wordpress/keycodes": "^3.38.0",
|
|
57
|
+
"@wordpress/notices": "^4.6.0",
|
|
58
|
+
"@wordpress/preferences": "^3.15.0",
|
|
59
|
+
"@wordpress/private-apis": "^0.20.0",
|
|
60
|
+
"@wordpress/rich-text": "^6.15.0",
|
|
61
|
+
"@wordpress/shortcode": "^3.38.0",
|
|
62
|
+
"@wordpress/style-engine": "^1.21.0",
|
|
63
|
+
"@wordpress/token-list": "^2.38.0",
|
|
64
|
+
"@wordpress/url": "^3.39.0",
|
|
65
|
+
"@wordpress/warning": "^2.38.0",
|
|
66
|
+
"@wordpress/wordcount": "^3.38.0",
|
|
66
67
|
"change-case": "^4.1.2",
|
|
67
68
|
"classnames": "^2.3.1",
|
|
68
69
|
"colord": "^2.7.0",
|
|
@@ -71,7 +72,6 @@
|
|
|
71
72
|
"dom-scroll-into-view": "^1.2.1",
|
|
72
73
|
"fast-deep-equal": "^3.1.3",
|
|
73
74
|
"inherits": "^2.0.3",
|
|
74
|
-
"lodash": "^4.17.21",
|
|
75
75
|
"react-autosize-textarea": "^7.1.0",
|
|
76
76
|
"react-easy-crop": "^4.5.1",
|
|
77
77
|
"rememo": "^4.0.2",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "6f14d11ed4cb59df110a28ebaa23ecba95eb673a"
|
|
89
89
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# BlockControls
|
|
2
|
+
|
|
3
|
+
When the user selects a particular block, a toolbar positioned above the selected block displays a set of control buttons. Certain block-level controls are automatically included in the toolbar under specific circumstances. For example, there is a control for converting the block into a different type or when the focused element is a RichText component.
|
|
4
|
+
|
|
5
|
+
With `BlockControls`, you can customize the toolbar to include controls specific to your block type. If the return value of your block type's `edit` function includes a `BlockControls` element, the controls nested inside it will be shown in the selected block's toolbar.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
import {
|
|
16
|
+
BlockControls,
|
|
17
|
+
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
|
|
18
|
+
useBlockProps,
|
|
19
|
+
} from '@wordpress/block-editor';
|
|
20
|
+
import { __ } from '@wordpress/i18n';
|
|
21
|
+
|
|
22
|
+
export default function MyBlockEdit( { attributes, setAttributes } ) {
|
|
23
|
+
const blockProps = useBlockProps( {
|
|
24
|
+
className: 'my-block__custom-class',
|
|
25
|
+
} );
|
|
26
|
+
const { contentPosition } = attributes;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div { ...blockProps }>
|
|
30
|
+
{
|
|
31
|
+
<BlockControls>
|
|
32
|
+
<BlockAlignmentMatrixControl
|
|
33
|
+
label={ __( 'Change content position' ) }
|
|
34
|
+
value={ contentPosition }
|
|
35
|
+
onChange={ ( nextPosition ) =>
|
|
36
|
+
setAttributes( {
|
|
37
|
+
contentPosition: nextPosition,
|
|
38
|
+
} )
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
</BlockControls>
|
|
42
|
+
}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// ...
|
|
48
|
+
|
|
49
|
+
<MyBlockEdit />;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
See [this custom block tutorial page](/docs/how-to-guides/block-tutorial/block-controls-toolbar-and-sidebar.md) for more information and block controls examples.
|
|
53
|
+
|
|
54
|
+
Furthermore, the READMEs of various components inside the block editor package and the components package include examples that also utilize `BlockControls` and can be a good reference.
|
|
55
|
+
|
|
56
|
+
### Props
|
|
57
|
+
|
|
58
|
+
The component accepts the following props:
|
|
59
|
+
|
|
60
|
+
### `group`
|
|
61
|
+
|
|
62
|
+
Group of the block controls. Allows you to create and render multiple groups of block controls.
|
|
63
|
+
|
|
64
|
+
- Type: `string`
|
|
65
|
+
- Default: `default`
|
|
66
|
+
- Required: No
|
|
67
|
+
|
|
68
|
+
### `controls`
|
|
69
|
+
|
|
70
|
+
Allows overriding the default `controls` if the `default` group is used.
|
|
71
|
+
|
|
72
|
+
See [this custom block tutorial page](/docs/how-to-guides/block-tutorial/block-controls-toolbar-and-sidebar.md) for more details and examples with block controls.
|
|
73
|
+
|
|
74
|
+
- Type: `array`
|
|
75
|
+
|
|
76
|
+
### `children`
|
|
77
|
+
|
|
78
|
+
Additional control components to be rendered.
|
|
79
|
+
|
|
80
|
+
- Type: `Element`
|
|
81
|
+
- Required: No.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### `__experimentalShareWithChildBlocks`
|
|
85
|
+
|
|
86
|
+
Whether the additional block controls should be added to the block toolbars of child blocks.
|
|
87
|
+
|
|
88
|
+
- Type: `boolean`
|
|
89
|
+
- Default: `false`
|
|
@@ -22,16 +22,25 @@ const BlockDraggable = ( {
|
|
|
22
22
|
} ) => {
|
|
23
23
|
const { srcRootClientId, isDraggable, icon } = useSelect(
|
|
24
24
|
( select ) => {
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const {
|
|
26
|
+
canMoveBlocks,
|
|
27
|
+
getBlockRootClientId,
|
|
28
|
+
getBlockName,
|
|
29
|
+
getBlockAttributes,
|
|
30
|
+
} = select( blockEditorStore );
|
|
31
|
+
const { getBlockType, getActiveBlockVariation } =
|
|
32
|
+
select( blocksStore );
|
|
28
33
|
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
|
|
29
34
|
const blockName = getBlockName( clientIds[ 0 ] );
|
|
35
|
+
const variation = getActiveBlockVariation(
|
|
36
|
+
blockName,
|
|
37
|
+
getBlockAttributes( clientIds[ 0 ] )
|
|
38
|
+
);
|
|
30
39
|
|
|
31
40
|
return {
|
|
32
41
|
srcRootClientId: rootClientId,
|
|
33
42
|
isDraggable: canMoveBlocks( clientIds, rootClientId ),
|
|
34
|
-
icon: getBlockType( blockName )?.icon,
|
|
43
|
+
icon: variation?.icon || getBlockType( blockName )?.icon,
|
|
35
44
|
};
|
|
36
45
|
},
|
|
37
46
|
[ clientIds ]
|
|
@@ -109,8 +109,12 @@ const BlockDraggableWrapper = ( { children, isRTL } ) => {
|
|
|
109
109
|
draggingScrollHandler( event );
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
const {
|
|
113
|
-
|
|
112
|
+
const {
|
|
113
|
+
onBlockDragOverWorklet,
|
|
114
|
+
onBlockDragEnd,
|
|
115
|
+
onBlockDrop,
|
|
116
|
+
targetBlockIndex,
|
|
117
|
+
} = useBlockDropZone();
|
|
114
118
|
|
|
115
119
|
// Stop dragging blocks if the block draggable is unmounted.
|
|
116
120
|
useEffect( () => {
|
|
@@ -184,7 +188,7 @@ const BlockDraggableWrapper = ( { children, isRTL } ) => {
|
|
|
184
188
|
chip.y.value = dragPosition.y;
|
|
185
189
|
currentYPosition.value = dragPosition.y;
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
onBlockDragOverWorklet( { x, y: y + scroll.offsetY.value } );
|
|
188
192
|
|
|
189
193
|
// Update scrolling velocity
|
|
190
194
|
scrollOnDragOver( dragPosition.y );
|
|
@@ -133,16 +133,6 @@ describe( 'BlockDraggable', () => {
|
|
|
133
133
|
// "firePanGesture" finishes the dragging gesture
|
|
134
134
|
firePanGesture( blockDraggableWrapper );
|
|
135
135
|
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
136
|
-
|
|
137
|
-
// Start dragging from block's mobile toolbar
|
|
138
|
-
fireLongPress(
|
|
139
|
-
paragraphBlock,
|
|
140
|
-
'draggable-trigger-mobile-toolbar'
|
|
141
|
-
);
|
|
142
|
-
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
143
|
-
// "firePanGesture" finishes the dragging gesture
|
|
144
|
-
firePanGesture( blockDraggableWrapper );
|
|
145
|
-
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
146
136
|
} ) );
|
|
147
137
|
|
|
148
138
|
it( 'does not enable drag mode when selected and editing text', async () =>
|
|
@@ -243,16 +233,6 @@ describe( 'BlockDraggable', () => {
|
|
|
243
233
|
// "firePanGesture" finishes the dragging gesture
|
|
244
234
|
firePanGesture( blockDraggableWrapper );
|
|
245
235
|
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
246
|
-
|
|
247
|
-
// Start dragging from block's mobile toolbar
|
|
248
|
-
fireLongPress(
|
|
249
|
-
imageBlock,
|
|
250
|
-
'draggable-trigger-mobile-toolbar'
|
|
251
|
-
);
|
|
252
|
-
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
253
|
-
// "firePanGesture" finishes the dragging gesture
|
|
254
|
-
firePanGesture( blockDraggableWrapper );
|
|
255
|
-
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
256
236
|
} ) );
|
|
257
237
|
} );
|
|
258
238
|
|
|
@@ -301,16 +281,6 @@ describe( 'BlockDraggable', () => {
|
|
|
301
281
|
// "firePanGesture" finishes the dragging gesture
|
|
302
282
|
firePanGesture( blockDraggableWrapper );
|
|
303
283
|
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
304
|
-
|
|
305
|
-
// Start dragging from block's mobile toolbar
|
|
306
|
-
fireLongPress(
|
|
307
|
-
galleryBlock,
|
|
308
|
-
'draggable-trigger-mobile-toolbar'
|
|
309
|
-
);
|
|
310
|
-
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
311
|
-
// "firePanGesture" finishes the dragging gesture
|
|
312
|
-
firePanGesture( blockDraggableWrapper );
|
|
313
|
-
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
314
284
|
} ) );
|
|
315
285
|
|
|
316
286
|
it( 'enables drag mode when nested block is selected', async () =>
|
|
@@ -336,20 +306,6 @@ describe( 'BlockDraggable', () => {
|
|
|
336
306
|
// "firePanGesture" finishes the dragging gesture
|
|
337
307
|
firePanGesture( blockDraggableWrapper );
|
|
338
308
|
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
339
|
-
|
|
340
|
-
// After dropping the block, the gallery item gets automatically selected.
|
|
341
|
-
// Hence, we have to select the gallery item again.
|
|
342
|
-
fireEvent.press( galleryItem );
|
|
343
|
-
|
|
344
|
-
// Start dragging from nested block's mobile toolbar
|
|
345
|
-
fireLongPress(
|
|
346
|
-
galleryItem,
|
|
347
|
-
'draggable-trigger-mobile-toolbar'
|
|
348
|
-
);
|
|
349
|
-
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
350
|
-
// "firePanGesture" finishes the dragging gesture
|
|
351
|
-
firePanGesture( blockDraggableWrapper );
|
|
352
|
-
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
353
309
|
} ) );
|
|
354
310
|
} );
|
|
355
311
|
|
|
@@ -390,16 +346,6 @@ describe( 'BlockDraggable', () => {
|
|
|
390
346
|
// "firePanGesture" finishes the dragging gesture
|
|
391
347
|
firePanGesture( blockDraggableWrapper );
|
|
392
348
|
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
393
|
-
|
|
394
|
-
// Start dragging from block's mobile toolbar
|
|
395
|
-
fireLongPress(
|
|
396
|
-
spacerBlock,
|
|
397
|
-
'draggable-trigger-mobile-toolbar'
|
|
398
|
-
);
|
|
399
|
-
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
400
|
-
// "firePanGesture" finishes the dragging gesture
|
|
401
|
-
firePanGesture( blockDraggableWrapper );
|
|
402
|
-
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
403
349
|
} ) );
|
|
404
350
|
} );
|
|
405
351
|
} );
|
|
@@ -29,7 +29,25 @@ import BlockContext from '../block-context';
|
|
|
29
29
|
*/
|
|
30
30
|
const DEFAULT_BLOCK_CONTEXT = {};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const Edit = ( props ) => {
|
|
33
|
+
const { name } = props;
|
|
34
|
+
const blockType = getBlockType( name );
|
|
35
|
+
|
|
36
|
+
if ( ! blockType ) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// `edit` and `save` are functions or components describing the markup
|
|
41
|
+
// with which a block is displayed. If `blockType` is valid, assign
|
|
42
|
+
// them preferentially as the render value for the block.
|
|
43
|
+
const Component = blockType.edit || blockType.save;
|
|
44
|
+
|
|
45
|
+
return <Component { ...props } />;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const EditWithFilters = withFilters( 'editor.BlockEdit' )( Edit );
|
|
49
|
+
|
|
50
|
+
const EditWithGeneratedProps = ( props ) => {
|
|
33
51
|
const { attributes = {}, name } = props;
|
|
34
52
|
const blockType = getBlockType( name );
|
|
35
53
|
const blockContext = useContext( BlockContext );
|
|
@@ -49,13 +67,8 @@ export const Edit = ( props ) => {
|
|
|
49
67
|
return null;
|
|
50
68
|
}
|
|
51
69
|
|
|
52
|
-
// `edit` and `save` are functions or components describing the markup
|
|
53
|
-
// with which a block is displayed. If `blockType` is valid, assign
|
|
54
|
-
// them preferentially as the render value for the block.
|
|
55
|
-
const Component = blockType.edit || blockType.save;
|
|
56
|
-
|
|
57
70
|
if ( blockType.apiVersion > 1 ) {
|
|
58
|
-
return <
|
|
71
|
+
return <EditWithFilters { ...props } context={ context } />;
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
// Generate a class name for the block's editable form.
|
|
@@ -69,8 +82,12 @@ export const Edit = ( props ) => {
|
|
|
69
82
|
);
|
|
70
83
|
|
|
71
84
|
return (
|
|
72
|
-
<
|
|
85
|
+
<EditWithFilters
|
|
86
|
+
{ ...props }
|
|
87
|
+
context={ context }
|
|
88
|
+
className={ className }
|
|
89
|
+
/>
|
|
73
90
|
);
|
|
74
91
|
};
|
|
75
92
|
|
|
76
|
-
export default
|
|
93
|
+
export default EditWithGeneratedProps;
|
|
@@ -7,51 +7,52 @@ import { View } from 'react-native';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
10
|
-
import { alignmentHelpers } from '@wordpress/components';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
14
|
import styles from './block.scss';
|
|
16
15
|
|
|
16
|
+
const TEXT_BLOCKS_WITH_OUTLINE = [ 'core/missing' ];
|
|
17
|
+
|
|
17
18
|
function BlockOutline( {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
blockCategory,
|
|
20
|
+
hasInnerBlocks,
|
|
21
|
+
isRootList,
|
|
21
22
|
isSelected,
|
|
22
23
|
name,
|
|
23
|
-
screenWidth,
|
|
24
24
|
} ) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes( name );
|
|
26
|
+
const hasBlockTextCategory =
|
|
27
|
+
blockCategory === 'text' && ! textBlockWithOutline;
|
|
28
|
+
const hasBlockMediaCategory =
|
|
29
|
+
blockCategory === 'media' ||
|
|
30
|
+
blockCategory === 'embed' ||
|
|
31
|
+
! blockCategory;
|
|
32
|
+
const shouldShowCompactOutline =
|
|
33
|
+
( hasBlockMediaCategory && ! hasInnerBlocks ) || textBlockWithOutline;
|
|
27
34
|
|
|
28
35
|
const styleSolidBorder = [
|
|
29
36
|
styles.solidBorder,
|
|
30
|
-
isFullWidth( align ) && isScreenWidthWider && styles.borderFullWidth,
|
|
31
|
-
isFullWidth( align ) &&
|
|
32
|
-
isContainerRelated( name ) &&
|
|
33
|
-
isScreenWidthWider &&
|
|
34
|
-
styles.containerBorderFullWidth,
|
|
35
37
|
usePreferredColorSchemeStyle(
|
|
36
38
|
styles.solidBorderColor,
|
|
37
39
|
styles.solidBorderColorDark
|
|
38
40
|
),
|
|
41
|
+
shouldShowCompactOutline && styles.solidBorderCompact,
|
|
42
|
+
hasBlockTextCategory && styles.solidBorderTextContent,
|
|
39
43
|
];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
|
|
45
|
+
const shoudlShowOutline =
|
|
46
|
+
isSelected &&
|
|
47
|
+
( ( hasBlockTextCategory && hasInnerBlocks ) ||
|
|
48
|
+
( ! hasBlockTextCategory && hasInnerBlocks ) ||
|
|
49
|
+
( ! hasBlockTextCategory && isRootList ) ||
|
|
50
|
+
textBlockWithOutline );
|
|
47
51
|
|
|
48
52
|
return (
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
) }
|
|
53
|
-
{ isParentSelected && <View style={ styleDashedBorder } /> }
|
|
54
|
-
</>
|
|
53
|
+
shoudlShowOutline && (
|
|
54
|
+
<View pointerEvents="box-none" style={ styleSolidBorder } />
|
|
55
|
+
)
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
|