@wordpress/block-editor 15.10.1-next.v.0 → 15.11.1-next.v.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/build/components/block-controls/index.cjs +1 -1
- package/build/components/block-controls/index.cjs.map +2 -2
- package/build/components/block-edit/context.cjs +5 -0
- package/build/components/block-edit/context.cjs.map +2 -2
- package/build/components/block-edit/index.cjs +3 -0
- package/build/components/block-edit/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +7 -27
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-list/block.cjs +3 -0
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +37 -13
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +1 -1
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +1 -1
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +2 -26
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-visibility/index.cjs +7 -9
- package/build/components/block-visibility/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs +13 -11
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +1 -1
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/block-visibility/utils.cjs +5 -1
- package/build/components/block-visibility/utils.cjs.map +2 -2
- package/build/components/block-visibility/viewport-menu-item.cjs +11 -4
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +4 -6
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +121 -0
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +7 -0
- package/build/components/button-block-appender/index.cjs +23 -19
- package/build/components/button-block-appender/index.cjs.map +2 -2
- package/build/components/color-palette/with-color-context.cjs +1 -1
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/color-style-selector/index.cjs +1 -1
- package/build/components/color-style-selector/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +5 -3
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +1 -1
- package/build/components/colors-gradients/dropdown.cjs.map +2 -2
- package/build/components/editable-text/index.cjs +5 -1
- package/build/components/editable-text/index.cjs.map +2 -2
- package/build/components/font-sizes/font-size-picker.cjs +2 -1
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs +5 -3
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +26 -13
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +1 -1
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/gradients/with-gradient.cjs +1 -1
- package/build/components/gradients/with-gradient.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -25
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/index.cjs +1 -1
- package/build/components/inspector-controls/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +1 -1
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +7 -7
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +8 -16
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +29 -34
- package/build/components/list-view/block.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +3 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/provider/index.cjs +7 -8
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/with-registry-provider.cjs +1 -1
- package/build/components/provider/with-registry-provider.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +2 -34
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +52 -86
- package/build/hooks/block-fields/index.cjs.map +3 -3
- package/build/hooks/block-fields/link/index.cjs +2 -11
- package/build/hooks/block-fields/link/index.cjs.map +2 -2
- package/build/hooks/block-fields/media/index.cjs +9 -14
- package/build/hooks/block-fields/media/index.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +1 -1
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +141 -0
- package/build/hooks/custom-css.cjs.map +7 -0
- package/build/hooks/fit-text.cjs +14 -7
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +1 -1
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/index.cjs +6 -1
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout.cjs +10 -4
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +32 -11
- package/build/hooks/list-view.cjs.map +3 -3
- package/build/hooks/utils.cjs +5 -4
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs +12 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/store/defaults.cjs +3 -0
- package/build/store/defaults.cjs.map +2 -2
- package/build/store/private-selectors.cjs +45 -37
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +7 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +5 -1
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-controls/index.mjs +1 -1
- package/build-module/components/block-controls/index.mjs.map +2 -2
- package/build-module/components/block-edit/context.mjs +4 -0
- package/build-module/components/block-edit/context.mjs.map +2 -2
- package/build-module/components/block-edit/index.mjs +4 -0
- package/build-module/components/block-edit/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +7 -27
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +3 -0
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +37 -13
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +2 -2
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +2 -26
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-visibility/index.mjs +6 -9
- package/build-module/components/block-visibility/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +13 -11
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +1 -1
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +5 -1
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +11 -4
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +4 -6
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +95 -0
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +7 -0
- package/build-module/components/button-block-appender/index.mjs +23 -19
- package/build-module/components/button-block-appender/index.mjs.map +2 -2
- package/build-module/components/color-palette/with-color-context.mjs +1 -1
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/color-style-selector/index.mjs +1 -1
- package/build-module/components/color-style-selector/index.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs +5 -3
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +1 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/editable-text/index.mjs +5 -1
- package/build-module/components/editable-text/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +2 -1
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs +5 -3
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +22 -13
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +1 -1
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +1 -1
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/gradients/with-gradient.mjs +1 -1
- package/build-module/components/gradients/with-gradient.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +16 -22
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/index.mjs +1 -1
- package/build-module/components/inspector-controls/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +7 -7
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +8 -16
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +31 -36
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs +3 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +7 -8
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/with-registry-provider.mjs +1 -1
- package/build-module/components/provider/with-registry-provider.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +3 -37
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +45 -87
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +2 -11
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +9 -14
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +1 -1
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +112 -0
- package/build-module/hooks/custom-css.mjs.map +7 -0
- package/build-module/hooks/fit-text.mjs +14 -7
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +1 -1
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/index.mjs +6 -1
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +10 -4
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +33 -12
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +7 -5
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +12 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/store/defaults.mjs +3 -0
- package/build-module/store/defaults.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +42 -40
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +7 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +5 -1
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +39 -39
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-controls/test/index.js +1 -0
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +6 -0
- package/src/components/block-edit/test/edit.js +10 -0
- package/src/components/block-inspector/index.js +16 -38
- package/src/components/block-list/block.js +3 -0
- package/src/components/block-list/block.native.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +49 -29
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-preview/test/index.js +11 -7
- package/src/components/block-settings-menu-controls/index.js +2 -2
- package/src/components/block-switcher/test/index.js +2 -0
- package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
- package/src/components/block-switcher/test/utils.js +2 -0
- package/src/components/block-toolbar/index.js +2 -2
- package/src/components/block-tools/index.js +2 -29
- package/src/components/block-visibility/index.js +3 -19
- package/src/components/block-visibility/modal.js +16 -14
- package/src/components/block-visibility/test/use-block-visibility.js +27 -25
- package/src/components/block-visibility/test/utils.js +24 -8
- package/src/components/block-visibility/use-block-visibility.js +1 -4
- package/src/components/block-visibility/utils.js +9 -1
- package/src/components/block-visibility/viewport-menu-item.js +11 -5
- package/src/components/block-visibility/viewport-toolbar.js +5 -6
- package/src/components/block-visibility/viewport-visibility-info.js +131 -0
- package/src/components/button-block-appender/index.js +2 -2
- package/src/components/color-palette/with-color-context.js +1 -1
- package/src/components/color-style-selector/index.js +2 -3
- package/src/components/colors/with-colors.js +23 -20
- package/src/components/colors-gradients/dropdown.js +2 -3
- package/src/components/editable-text/index.js +5 -1
- package/src/components/font-sizes/font-size-picker.js +1 -0
- package/src/components/font-sizes/with-font-sizes.js +13 -10
- package/src/components/global-styles/advanced-panel.js +35 -16
- package/src/components/global-styles/filters-panel.js +2 -3
- package/src/components/global-styles/shadow-panel-components.js +1 -1
- package/src/components/global-styles/style.scss +9 -5
- package/src/components/gradients/with-gradient.js +7 -4
- package/src/components/inner-blocks/test/index.js +2 -0
- package/src/components/inspector-controls/fill.js +30 -20
- package/src/components/inspector-controls/index.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +5 -1
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -11
- package/src/components/link-control/test/index.js +6 -1
- package/src/components/list-view/block-select-button.js +16 -25
- package/src/components/list-view/block.js +38 -43
- package/src/components/list-view/utils.js +4 -2
- package/src/components/media-replace-flow/test/index.js +13 -11
- package/src/components/provider/index.js +11 -10
- package/src/components/provider/test/use-block-sync.js +1 -0
- package/src/components/provider/with-registry-provider.js +1 -1
- package/src/components/use-block-commands/index.js +0 -41
- package/src/hooks/block-fields/index.js +66 -111
- package/src/hooks/block-fields/link/index.js +2 -14
- package/src/hooks/block-fields/media/index.js +9 -21
- package/src/hooks/cross-origin-isolation.js +19 -18
- package/src/hooks/custom-css.js +176 -0
- package/src/hooks/fit-text.js +20 -5
- package/src/hooks/grid-visualizer.js +15 -14
- package/src/hooks/index.js +6 -1
- package/src/hooks/layout.js +55 -43
- package/src/hooks/list-view.js +46 -12
- package/src/hooks/test/align.js +1 -0
- package/src/hooks/test/allowed-blocks.js +8 -0
- package/src/hooks/test/auto-inspector-controls.js +4 -0
- package/src/hooks/test/font-size.js +1 -0
- package/src/hooks/test/metadata.js +4 -0
- package/src/hooks/test/text-align.js +1 -0
- package/src/hooks/utils.js +124 -116
- package/src/layouts/grid.js +19 -3
- package/src/layouts/test/grid.js +1 -1
- package/src/store/defaults.js +4 -0
- package/src/store/private-selectors.js +94 -63
- package/src/store/selectors.js +14 -6
- package/src/store/test/actions.js +7 -0
- package/src/store/test/private-selectors.js +116 -119
- package/src/store/test/reducer.js +4 -0
- package/src/store/test/registry-selectors.js +2 -0
- package/src/store/test/selectors.js +19 -0
- package/src/utils/fit-text-utils.js +12 -2
- package/build/components/block-visibility/block-visibility-info.cjs +0 -63
- package/build/components/block-visibility/block-visibility-info.cjs.map +0 -7
- package/build/components/block-visibility/menu-item.cjs +0 -109
- package/build/components/block-visibility/menu-item.cjs.map +0 -7
- package/build/components/block-visibility/toolbar.cjs +0 -92
- package/build/components/block-visibility/toolbar.cjs.map +0 -7
- package/build-module/components/block-visibility/block-visibility-info.mjs +0 -47
- package/build-module/components/block-visibility/block-visibility-info.mjs.map +0 -7
- package/build-module/components/block-visibility/menu-item.mjs +0 -88
- package/build-module/components/block-visibility/menu-item.mjs.map +0 -7
- package/build-module/components/block-visibility/toolbar.mjs +0 -71
- package/build-module/components/block-visibility/toolbar.mjs.map +0 -7
- package/src/components/block-visibility/block-visibility-info.js +0 -62
- package/src/components/block-visibility/menu-item.js +0 -96
- package/src/components/block-visibility/toolbar.js +0 -88
- /package/src/components/block-icon/stories/{index.story.js → index.story.ts} +0 -0
- /package/src/components/contrast-checker/stories/{index.story.js → index.story.ts} +0 -0
|
@@ -39,9 +39,10 @@ const upperFirst = ( [ firstLetter, ...rest ] ) =>
|
|
|
39
39
|
*/
|
|
40
40
|
const withCustomColorPalette = ( colorsArray ) =>
|
|
41
41
|
createHigherOrderComponent(
|
|
42
|
-
( WrappedComponent ) =>
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
( WrappedComponent ) =>
|
|
43
|
+
function WithCustomColorPalette( props ) {
|
|
44
|
+
return <WrappedComponent { ...props } colors={ colorsArray } />;
|
|
45
|
+
},
|
|
45
46
|
'withCustomColorPalette'
|
|
46
47
|
);
|
|
47
48
|
|
|
@@ -53,22 +54,24 @@ const withCustomColorPalette = ( colorsArray ) =>
|
|
|
53
54
|
*/
|
|
54
55
|
const withEditorColorPalette = () =>
|
|
55
56
|
createHigherOrderComponent(
|
|
56
|
-
( WrappedComponent ) =>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
( WrappedComponent ) =>
|
|
58
|
+
function WithEditorColorPalette( props ) {
|
|
59
|
+
const [ userPalette, themePalette, defaultPalette ] =
|
|
60
|
+
useSettings(
|
|
61
|
+
'color.palette.custom',
|
|
62
|
+
'color.palette.theme',
|
|
63
|
+
'color.palette.default'
|
|
64
|
+
);
|
|
65
|
+
const allColors = useMemo(
|
|
66
|
+
() => [
|
|
67
|
+
...( userPalette || [] ),
|
|
68
|
+
...( themePalette || [] ),
|
|
69
|
+
...( defaultPalette || [] ),
|
|
70
|
+
],
|
|
71
|
+
[ userPalette, themePalette, defaultPalette ]
|
|
72
|
+
);
|
|
73
|
+
return <WrappedComponent { ...props } colors={ allColors } />;
|
|
74
|
+
},
|
|
72
75
|
'withEditorColorPalette'
|
|
73
76
|
);
|
|
74
77
|
|
|
@@ -94,7 +97,7 @@ function createColorHOC( colorTypes, withColorPalette ) {
|
|
|
94
97
|
return compose( [
|
|
95
98
|
withColorPalette,
|
|
96
99
|
( WrappedComponent ) => {
|
|
97
|
-
return class extends Component {
|
|
100
|
+
return class WithColors extends Component {
|
|
98
101
|
constructor( props ) {
|
|
99
102
|
super( props );
|
|
100
103
|
|
|
@@ -80,9 +80,8 @@ const LabeledColorIndicator = ( { colorValue, label } ) => (
|
|
|
80
80
|
// Renders a color dropdown's toggle as an `Item` if it is within an `ItemGroup`
|
|
81
81
|
// or as a `Button` if it isn't e.g. the controls are being rendered in
|
|
82
82
|
// a `ToolsPanel`.
|
|
83
|
-
const renderToggle =
|
|
84
|
-
(
|
|
85
|
-
( { onToggle, isOpen } ) => {
|
|
83
|
+
const renderToggle = ( settings ) =>
|
|
84
|
+
function Toggle( { onToggle, isOpen } ) {
|
|
86
85
|
const {
|
|
87
86
|
clearable,
|
|
88
87
|
colorValue,
|
|
@@ -12,7 +12,11 @@ const EditableText = forwardRef( ( props, ref ) => {
|
|
|
12
12
|
return <RichText ref={ ref } { ...props } __unstableDisableFormats />;
|
|
13
13
|
} );
|
|
14
14
|
|
|
15
|
-
EditableText.Content = ( {
|
|
15
|
+
EditableText.Content = function Content( {
|
|
16
|
+
value = '',
|
|
17
|
+
tagName: Tag = 'div',
|
|
18
|
+
...props
|
|
19
|
+
} ) {
|
|
16
20
|
return <Tag { ...props }>{ value }</Tag>;
|
|
17
21
|
};
|
|
18
22
|
|
|
@@ -51,19 +51,22 @@ export default ( ...fontSizeNames ) => {
|
|
|
51
51
|
return createHigherOrderComponent(
|
|
52
52
|
compose( [
|
|
53
53
|
createHigherOrderComponent(
|
|
54
|
-
( WrappedComponent ) =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
( WrappedComponent ) =>
|
|
55
|
+
function WithFontSizesInner( props ) {
|
|
56
|
+
const [ fontSizes ] = useSettings(
|
|
57
|
+
'typography.fontSizes'
|
|
58
|
+
);
|
|
59
|
+
return (
|
|
60
|
+
<WrappedComponent
|
|
61
|
+
{ ...props }
|
|
62
|
+
fontSizes={ fontSizes || DEFAULT_FONT_SIZES }
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
63
66
|
'withFontSizes'
|
|
64
67
|
),
|
|
65
68
|
( WrappedComponent ) => {
|
|
66
|
-
return class extends Component {
|
|
69
|
+
return class WithFontSizes extends Component {
|
|
67
70
|
constructor( props ) {
|
|
68
71
|
super( props );
|
|
69
72
|
|
|
@@ -14,10 +14,26 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
*/
|
|
15
15
|
import { default as transformStyles } from '../../utils/transform-styles';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Validates that a CSS string doesn't contain HTML markup.
|
|
19
|
+
* Uses the same validation as the PHP/global styles REST API.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} css The CSS string to validate.
|
|
22
|
+
* @return {boolean} True if the CSS is valid, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
export function validateCSS( css ) {
|
|
25
|
+
// Check for HTML markup.
|
|
26
|
+
if ( typeof css === 'string' && /<\/?\w/.test( css ) ) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
export default function AdvancedPanel( {
|
|
18
33
|
value,
|
|
19
34
|
onChange,
|
|
20
35
|
inheritedValue = value,
|
|
36
|
+
help,
|
|
21
37
|
} ) {
|
|
22
38
|
// Custom CSS
|
|
23
39
|
const [ cssError, setCSSError ] = useState( null );
|
|
@@ -27,30 +43,32 @@ export default function AdvancedPanel( {
|
|
|
27
43
|
...value,
|
|
28
44
|
css: newValue,
|
|
29
45
|
} );
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[ { css: newValue } ],
|
|
36
|
-
'.for-validation-only'
|
|
46
|
+
|
|
47
|
+
// Validate immediately on change for quick feedback.
|
|
48
|
+
if ( ! validateCSS( newValue ) ) {
|
|
49
|
+
setCSSError(
|
|
50
|
+
__( 'The custom CSS is invalid. Do not use <> markup.' )
|
|
37
51
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Clear HTML markup error if CSS is now valid.
|
|
56
|
+
if ( cssError ) {
|
|
57
|
+
setCSSError( null );
|
|
41
58
|
}
|
|
42
59
|
}
|
|
43
60
|
function handleOnBlur( event ) {
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
const cssValue = event?.target?.value;
|
|
62
|
+
|
|
63
|
+
if ( ! cssValue || ! validateCSS( cssValue ) ) {
|
|
46
64
|
return;
|
|
47
65
|
}
|
|
48
66
|
|
|
49
|
-
// Check if the
|
|
50
|
-
// to ensure that `transformStyles` validates the CSS.
|
|
51
|
-
// wrapping selector here is not used in the actual output of any styles.
|
|
67
|
+
// Check if the value is valid CSS structure on blur (more expensive check).
|
|
68
|
+
// Pass a wrapping selector to ensure that `transformStyles` validates the CSS.
|
|
69
|
+
// Note that the wrapping selector here is not used in the actual output of any styles.
|
|
52
70
|
const [ transformed ] = transformStyles(
|
|
53
|
-
[ { css:
|
|
71
|
+
[ { css: cssValue } ],
|
|
54
72
|
'.for-validation-only'
|
|
55
73
|
);
|
|
56
74
|
|
|
@@ -75,6 +93,7 @@ export default function AdvancedPanel( {
|
|
|
75
93
|
onBlur={ handleOnBlur }
|
|
76
94
|
className="block-editor-global-styles-advanced-panel__custom-css-input"
|
|
77
95
|
spellCheck={ false }
|
|
96
|
+
help={ help }
|
|
78
97
|
/>
|
|
79
98
|
</VStack>
|
|
80
99
|
);
|
|
@@ -118,9 +118,8 @@ const LabeledColorIndicator = ( { indicator, label } ) => (
|
|
|
118
118
|
</HStack>
|
|
119
119
|
);
|
|
120
120
|
|
|
121
|
-
const renderToggle =
|
|
122
|
-
(
|
|
123
|
-
( { onToggle, isOpen } ) => {
|
|
121
|
+
const renderToggle = ( duotone, resetDuotone ) =>
|
|
122
|
+
function Toggle( { onToggle, isOpen } ) {
|
|
124
123
|
const duotoneButtonRef = useRef( undefined );
|
|
125
124
|
|
|
126
125
|
const toggleProps = {
|
|
@@ -136,7 +136,7 @@ export function ShadowPopover( { shadow, onShadowChange, settings } ) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function renderShadowToggle( shadow, onShadowChange ) {
|
|
139
|
-
return ( { onToggle, isOpen } )
|
|
139
|
+
return function ShadowToggle( { onToggle, isOpen } ) {
|
|
140
140
|
const shadowButtonRef = useRef( undefined );
|
|
141
141
|
|
|
142
142
|
const toggleProps = {
|
|
@@ -100,11 +100,15 @@
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
.block-editor-global-styles-advanced-panel__custom-css-input
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
.block-editor-global-styles-advanced-panel__custom-css-input {
|
|
104
|
+
margin-bottom: $grid-unit-20;
|
|
105
|
+
|
|
106
|
+
textarea {
|
|
107
|
+
font-family: $editor_html_font;
|
|
108
|
+
// CSS input is always LTR regardless of language.
|
|
109
|
+
/*rtl:ignore*/
|
|
110
|
+
direction: ltr;
|
|
111
|
+
}
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
.block-editor-panel-duotone-settings__reset {
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalUseGradient } from './use-gradient';
|
|
5
5
|
|
|
6
|
-
export const withGradient = ( WrappedComponent ) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export const withGradient = ( WrappedComponent ) =>
|
|
7
|
+
function WithGradient( props ) {
|
|
8
|
+
const { gradientValue } = __experimentalUseGradient();
|
|
9
|
+
return (
|
|
10
|
+
<WrappedComponent { ...props } gradientValue={ gradientValue } />
|
|
11
|
+
);
|
|
12
|
+
};
|
|
@@ -27,6 +27,7 @@ describe( 'InnerBlocks', () => {
|
|
|
27
27
|
|
|
28
28
|
it( 'should return element as string, with inner blocks', () => {
|
|
29
29
|
registerBlockType( 'core/fruit', {
|
|
30
|
+
apiVersion: 3,
|
|
30
31
|
category: 'text',
|
|
31
32
|
|
|
32
33
|
title: 'fruit',
|
|
@@ -62,6 +63,7 @@ describe( 'InnerBlocks', () => {
|
|
|
62
63
|
|
|
63
64
|
it( 'should force serialize for invalid block with inner blocks', () => {
|
|
64
65
|
const blockType = {
|
|
66
|
+
apiVersion: 3,
|
|
65
67
|
attributes: {
|
|
66
68
|
throw: {
|
|
67
69
|
type: 'boolean',
|
|
@@ -15,15 +15,18 @@ import { useEffect, useContext } from '@wordpress/element';
|
|
|
15
15
|
import {
|
|
16
16
|
useBlockEditContext,
|
|
17
17
|
mayDisplayControlsKey,
|
|
18
|
+
mayDisplayPatternEditingControlsKey,
|
|
18
19
|
} from '../block-edit/context';
|
|
19
20
|
import groups from './groups';
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const PATTERN_EDITING_GROUPS = [ 'content', 'list' ];
|
|
23
|
+
const TEMPLATE_PART_GROUPS = [ 'default', 'settings', 'advanced' ];
|
|
24
|
+
|
|
25
|
+
export default function InspectorControlsFill( {
|
|
22
26
|
children,
|
|
23
27
|
group = 'default',
|
|
24
28
|
__experimentalGroup,
|
|
25
29
|
resetAllFilter,
|
|
26
|
-
forceDisplayControls,
|
|
27
30
|
} ) {
|
|
28
31
|
if ( __experimentalGroup ) {
|
|
29
32
|
deprecated(
|
|
@@ -43,7 +46,31 @@ export function PrivateInspectorControlsFill( {
|
|
|
43
46
|
warning( `Unknown InspectorControls group "${ group }" provided.` );
|
|
44
47
|
return null;
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
// During pattern editing:
|
|
51
|
+
// - All blocks can show pattern editing groups (content, list).
|
|
52
|
+
// - Template parts can show a settings tab (default, settings, advanced groups).
|
|
53
|
+
// - Other blocks cannot show a settings tab.
|
|
54
|
+
if ( context[ mayDisplayPatternEditingControlsKey ] ) {
|
|
55
|
+
// Template parts are allowed to show a settings tab to allow access to the
|
|
56
|
+
// 'Design' and 'Advanced' panels.
|
|
57
|
+
const isTemplatePart = context.name === 'core/template-part';
|
|
58
|
+
const isTemplatePartGroup = TEMPLATE_PART_GROUPS.includes( group );
|
|
59
|
+
const isPatternEditingGroup = PATTERN_EDITING_GROUPS.includes( group );
|
|
60
|
+
|
|
61
|
+
const canShowGroup =
|
|
62
|
+
( isTemplatePart && isTemplatePartGroup ) || isPatternEditingGroup;
|
|
63
|
+
|
|
64
|
+
if ( ! canShowGroup ) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Outside pattern editing, use the standard rules for displaying controls.
|
|
70
|
+
if (
|
|
71
|
+
! context[ mayDisplayPatternEditingControlsKey ] &&
|
|
72
|
+
! context[ mayDisplayControlsKey ]
|
|
73
|
+
) {
|
|
47
74
|
return null;
|
|
48
75
|
}
|
|
49
76
|
|
|
@@ -64,23 +91,6 @@ export function PrivateInspectorControlsFill( {
|
|
|
64
91
|
);
|
|
65
92
|
}
|
|
66
93
|
|
|
67
|
-
export default function InspectorControlsFill( {
|
|
68
|
-
children,
|
|
69
|
-
group = 'default',
|
|
70
|
-
__experimentalGroup,
|
|
71
|
-
resetAllFilter,
|
|
72
|
-
} ) {
|
|
73
|
-
return (
|
|
74
|
-
<PrivateInspectorControlsFill
|
|
75
|
-
group={ group }
|
|
76
|
-
__experimentalGroup={ __experimentalGroup }
|
|
77
|
-
resetAllFilter={ resetAllFilter }
|
|
78
|
-
>
|
|
79
|
-
{ children }
|
|
80
|
-
</PrivateInspectorControlsFill>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
94
|
function RegisterResetAll( { resetAllFilter, children } ) {
|
|
85
95
|
const { registerResetAllFilter, deregisterResetAllFilter } =
|
|
86
96
|
useContext( ToolsPanelContext );
|
|
@@ -12,7 +12,7 @@ InspectorControls.Slot = InspectorControlsSlot;
|
|
|
12
12
|
export const InspectorAdvancedControls = ( props ) => {
|
|
13
13
|
return <InspectorControlsFill { ...props } group="advanced" />;
|
|
14
14
|
};
|
|
15
|
-
InspectorAdvancedControls.Slot = ( props )
|
|
15
|
+
InspectorAdvancedControls.Slot = function Slot( props ) {
|
|
16
16
|
return <InspectorControlsSlot { ...props } group="advanced" />;
|
|
17
17
|
};
|
|
18
18
|
InspectorAdvancedControls.slotName = 'InspectorAdvancedControls';
|
|
@@ -44,7 +44,11 @@ export default function InspectorControlsTabs( {
|
|
|
44
44
|
|
|
45
45
|
// Auto-select first available tab unless user has made a selection
|
|
46
46
|
useEffect( () => {
|
|
47
|
-
if (
|
|
47
|
+
if (
|
|
48
|
+
! tabs?.length ||
|
|
49
|
+
( hasUserSelectionRef.current &&
|
|
50
|
+
tabs.some( ( tab ) => tab.name === selectedTabId ) )
|
|
51
|
+
) {
|
|
48
52
|
return;
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -84,27 +84,29 @@ export default function useInspectorControlsTabs(
|
|
|
84
84
|
...( hasListFills && hasStyleFills > 1 ? advancedFills : [] ),
|
|
85
85
|
];
|
|
86
86
|
|
|
87
|
+
// When the block fields experiment is active, only rely on `hasContentFills`
|
|
88
|
+
// to determine whether the content tab to be shown. The tab purely uses slot
|
|
89
|
+
// fills in this situation.
|
|
90
|
+
const shouldShowBlockFields =
|
|
91
|
+
window?.__experimentalContentOnlyInspectorFields;
|
|
87
92
|
const hasContentTab =
|
|
88
93
|
hasContentFills ||
|
|
89
|
-
|
|
94
|
+
( ! shouldShowBlockFields && contentClientIds?.length );
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
if ( hasContentTab ) {
|
|
97
|
+
tabs.push( TAB_CONTENT );
|
|
98
|
+
}
|
|
92
99
|
|
|
93
100
|
// Add the tabs in the order that they will default to if available.
|
|
94
101
|
// List View > Content > Settings > Styles.
|
|
95
|
-
if (
|
|
102
|
+
if ( hasListFills ) {
|
|
96
103
|
tabs.push( TAB_LIST_VIEW );
|
|
97
104
|
}
|
|
98
105
|
|
|
99
|
-
if ( hasContentTab ) {
|
|
100
|
-
tabs.push( TAB_CONTENT );
|
|
101
|
-
}
|
|
102
|
-
|
|
103
106
|
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
! isSectionBlock
|
|
107
|
+
settingsFills.length ||
|
|
108
|
+
// Advanced fills show up in settings tab if available or they blend into the default tab, if there's only one tab.
|
|
109
|
+
( advancedFills.length && ( hasContentTab || hasListFills ) )
|
|
108
110
|
) {
|
|
109
111
|
tabs.push( TAB_SETTINGS );
|
|
110
112
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
fireEvent,
|
|
6
|
-
render,
|
|
6
|
+
render as baseRender,
|
|
7
7
|
screen,
|
|
8
8
|
waitFor,
|
|
9
9
|
within,
|
|
@@ -13,6 +13,7 @@ import userEvent from '@testing-library/user-event';
|
|
|
13
13
|
/**
|
|
14
14
|
* WordPress dependencies
|
|
15
15
|
*/
|
|
16
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
16
17
|
import { useState, createElement } from '@wordpress/element';
|
|
17
18
|
import { useSelect } from '@wordpress/data';
|
|
18
19
|
|
|
@@ -79,6 +80,10 @@ afterEach( () => {
|
|
|
79
80
|
mockFetchRichUrlData?.mockReset(); // Conditionally reset as it may NOT be a mock.
|
|
80
81
|
} );
|
|
81
82
|
|
|
83
|
+
function render( ui ) {
|
|
84
|
+
return baseRender( ui, { wrapper: SlotFillProvider } );
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
/**
|
|
83
88
|
* Workaround to trigger an arrow up keypress event.
|
|
84
89
|
*
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
} from '@wordpress/icons';
|
|
22
22
|
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
23
23
|
import { useSelect } from '@wordpress/data';
|
|
24
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Internal dependencies
|
|
@@ -61,30 +60,22 @@ function ListViewBlockSelectButton(
|
|
|
61
60
|
context: 'list-view',
|
|
62
61
|
} );
|
|
63
62
|
const { isLocked } = useBlockLock( clientId );
|
|
64
|
-
const {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
isBlockHidden: areBlocksHiddenAnywhere( [ clientId ] ),
|
|
80
|
-
hasPatternName: !! blockAttributes?.metadata?.patternName,
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
[ clientId ]
|
|
84
|
-
);
|
|
63
|
+
const { isBlockHidden, hasPatternName } = useSelect(
|
|
64
|
+
( select ) => {
|
|
65
|
+
const {
|
|
66
|
+
isBlockHiddenAnywhere: _isBlockHidden,
|
|
67
|
+
getBlockAttributes,
|
|
68
|
+
} = unlock( select( blockEditorStore ) );
|
|
69
|
+
return {
|
|
70
|
+
isBlockHidden: _isBlockHidden( clientId ),
|
|
71
|
+
hasPatternName:
|
|
72
|
+
!! getBlockAttributes( clientId )?.metadata?.patternName,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
[ clientId ]
|
|
76
|
+
);
|
|
77
|
+
|
|
85
78
|
const shouldShowLockIcon = isLocked;
|
|
86
|
-
const shouldShowBlockVisibilityIcon =
|
|
87
|
-
canToggleBlockVisibility && isBlockHidden;
|
|
88
79
|
const isSticky = blockInformation?.positionType === 'sticky';
|
|
89
80
|
const images = useListViewImages( { clientId, isExpanded } );
|
|
90
81
|
|
|
@@ -170,7 +161,7 @@ function ListViewBlockSelectButton(
|
|
|
170
161
|
) ) }
|
|
171
162
|
</span>
|
|
172
163
|
) : null }
|
|
173
|
-
{
|
|
164
|
+
{ isBlockHidden && (
|
|
174
165
|
<span className="block-editor-list-view-block-select-button__block-visibility">
|
|
175
166
|
<Icon icon={ unseen } />
|
|
176
167
|
</span>
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
memo,
|
|
26
26
|
} from '@wordpress/element';
|
|
27
27
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
28
|
-
import { __ } from '@wordpress/i18n';
|
|
28
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
29
29
|
import { BACKSPACE, DELETE } from '@wordpress/keycodes';
|
|
30
30
|
import { isShallowEqual } from '@wordpress/is-shallow-equal';
|
|
31
31
|
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
|
|
@@ -53,8 +53,9 @@ import { useBlockLock } from '../block-lock';
|
|
|
53
53
|
import AriaReferencedText from './aria-referenced-text';
|
|
54
54
|
import { unlock } from '../../lock-unlock';
|
|
55
55
|
import usePasteStyles from '../use-paste-styles';
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
56
|
+
import { useBlockVisibility, BlockVisibilityModal } from '../block-visibility';
|
|
57
|
+
import { deviceTypeKey } from '../../store/private-keys';
|
|
58
|
+
import { BLOCK_VISIBILITY_VIEWPORTS } from '../block-visibility/constants';
|
|
58
59
|
|
|
59
60
|
function ListViewBlock( {
|
|
60
61
|
block: { clientId },
|
|
@@ -98,7 +99,6 @@ function ListViewBlock( {
|
|
|
98
99
|
removeBlocks,
|
|
99
100
|
insertAfterBlock,
|
|
100
101
|
insertBeforeBlock,
|
|
101
|
-
updateBlockAttributes,
|
|
102
102
|
} = unlock( useDispatch( blockEditorStore ) );
|
|
103
103
|
|
|
104
104
|
const debouncedToggleBlockHighlight = useDebounce(
|
|
@@ -125,29 +125,52 @@ function ListViewBlock( {
|
|
|
125
125
|
|
|
126
126
|
const pasteStyles = usePasteStyles();
|
|
127
127
|
|
|
128
|
-
const { block, blockName, allowRightClickOverrides,
|
|
128
|
+
const { block, blockName, allowRightClickOverrides, selectedDeviceType } =
|
|
129
129
|
useSelect(
|
|
130
130
|
( select ) => {
|
|
131
|
-
const {
|
|
132
|
-
getBlock,
|
|
133
|
-
getBlockName: _getBlockName,
|
|
134
|
-
getSettings,
|
|
135
|
-
} = select( blockEditorStore );
|
|
136
|
-
const { isBlockHidden: _isBlockHidden } = unlock(
|
|
131
|
+
const { getBlock, getBlockName, getSettings } = unlock(
|
|
137
132
|
select( blockEditorStore )
|
|
138
133
|
);
|
|
139
134
|
|
|
140
135
|
return {
|
|
141
136
|
block: getBlock( clientId ),
|
|
142
|
-
blockName:
|
|
137
|
+
blockName: getBlockName( clientId ),
|
|
143
138
|
allowRightClickOverrides:
|
|
144
139
|
getSettings().allowRightClickOverrides,
|
|
145
|
-
|
|
140
|
+
selectedDeviceType:
|
|
141
|
+
getSettings()?.[ deviceTypeKey ]?.toLowerCase() ||
|
|
142
|
+
BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
|
|
146
143
|
};
|
|
147
144
|
},
|
|
148
145
|
[ clientId ]
|
|
149
146
|
);
|
|
150
147
|
|
|
148
|
+
// Use hook to get current viewport and if block is currently hidden (accurate viewport detection)
|
|
149
|
+
const { isBlockCurrentlyHidden, currentViewport } = useBlockVisibility( {
|
|
150
|
+
blockVisibility: block?.attributes?.metadata?.blockVisibility,
|
|
151
|
+
deviceType: selectedDeviceType,
|
|
152
|
+
} );
|
|
153
|
+
|
|
154
|
+
// Determine label based on whether block or parent is hidden
|
|
155
|
+
const blockVisibilityDescription = useMemo( () => {
|
|
156
|
+
if ( isBlockCurrentlyHidden ) {
|
|
157
|
+
if ( block?.attributes?.metadata?.blockVisibility === false ) {
|
|
158
|
+
return __( 'Block is hidden' );
|
|
159
|
+
}
|
|
160
|
+
return sprintf(
|
|
161
|
+
/* translators: %s: viewport name (Desktop, Tablet, Mobile) */
|
|
162
|
+
__( 'Block is hidden on %s' ),
|
|
163
|
+
BLOCK_VISIBILITY_VIEWPORTS[ currentViewport ]?.label ||
|
|
164
|
+
currentViewport
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}, [
|
|
169
|
+
isBlockCurrentlyHidden,
|
|
170
|
+
block?.attributes?.metadata?.blockVisibility,
|
|
171
|
+
currentViewport,
|
|
172
|
+
] );
|
|
173
|
+
|
|
151
174
|
const showBlockActions =
|
|
152
175
|
// When a block hides its toolbar it also hides the block settings menu,
|
|
153
176
|
// since that menu is part of the toolbar in the editor canvas.
|
|
@@ -387,32 +410,8 @@ function ListViewBlock( {
|
|
|
387
410
|
return;
|
|
388
411
|
}
|
|
389
412
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
setVisibilityModalClientIds( blocksToUpdate );
|
|
393
|
-
} else {
|
|
394
|
-
const hasHiddenBlock = blocks.some(
|
|
395
|
-
( blockToUpdate ) =>
|
|
396
|
-
blockToUpdate.attributes.metadata?.blockVisibility ===
|
|
397
|
-
false
|
|
398
|
-
);
|
|
399
|
-
const attributesByClientId = Object.fromEntries(
|
|
400
|
-
blocks.map( ( { clientId: mapClientId, attributes } ) => [
|
|
401
|
-
mapClientId,
|
|
402
|
-
{
|
|
403
|
-
metadata: cleanEmptyObject( {
|
|
404
|
-
...attributes?.metadata,
|
|
405
|
-
blockVisibility: hasHiddenBlock
|
|
406
|
-
? undefined
|
|
407
|
-
: false,
|
|
408
|
-
} ),
|
|
409
|
-
},
|
|
410
|
-
] )
|
|
411
|
-
);
|
|
412
|
-
updateBlockAttributes( blocksToUpdate, attributesByClientId, {
|
|
413
|
-
uniqueByBlock: true,
|
|
414
|
-
} );
|
|
415
|
-
}
|
|
413
|
+
// Open the visibility breakpoints modal.
|
|
414
|
+
setVisibilityModalClientIds( blocksToUpdate );
|
|
416
415
|
}
|
|
417
416
|
}
|
|
418
417
|
|
|
@@ -540,10 +539,6 @@ function ListViewBlock( {
|
|
|
540
539
|
isLocked
|
|
541
540
|
);
|
|
542
541
|
|
|
543
|
-
const blockVisibilityDescription = isBlockHidden
|
|
544
|
-
? __( 'Block is hidden.' )
|
|
545
|
-
: null;
|
|
546
|
-
|
|
547
542
|
const hasSiblings = siblingBlockCount > 0;
|
|
548
543
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
549
544
|
const moverCellClassName = clsx(
|