@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
|
@@ -33,6 +33,7 @@ describe( 'BlockSwitcher', () => {
|
|
|
33
33
|
clientId: 'a1303fd6-3e60-4fff-a770-0e0ea656c5b9',
|
|
34
34
|
};
|
|
35
35
|
const headingBlockType = {
|
|
36
|
+
apiVersion: 3,
|
|
36
37
|
category: 'text',
|
|
37
38
|
title: 'Heading',
|
|
38
39
|
edit: () => {},
|
|
@@ -54,6 +55,7 @@ describe( 'BlockSwitcher', () => {
|
|
|
54
55
|
},
|
|
55
56
|
};
|
|
56
57
|
const paragraphBlockType = {
|
|
58
|
+
apiVersion: 3,
|
|
57
59
|
category: 'text',
|
|
58
60
|
title: 'Paragraph',
|
|
59
61
|
edit: () => {},
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
describe( 'use-transformed-patterns', () => {
|
|
15
15
|
beforeAll( () => {
|
|
16
16
|
registerBlockType( 'core/test-block-1', {
|
|
17
|
+
apiVersion: 3,
|
|
17
18
|
attributes: {
|
|
18
19
|
align: {
|
|
19
20
|
type: 'string',
|
|
@@ -36,6 +37,7 @@ describe( 'use-transformed-patterns', () => {
|
|
|
36
37
|
title: 'test block 1',
|
|
37
38
|
} );
|
|
38
39
|
registerBlockType( 'core/test-block-2', {
|
|
40
|
+
apiVersion: 3,
|
|
39
41
|
attributes: {
|
|
40
42
|
align: { type: 'string' },
|
|
41
43
|
content: { type: 'boolean' },
|
|
@@ -12,6 +12,7 @@ describe( 'BlockSwitcher - utils', () => {
|
|
|
12
12
|
describe( 'getRetainedBlockAttributes', () => {
|
|
13
13
|
beforeAll( () => {
|
|
14
14
|
registerBlockType( 'core/test-block-1', {
|
|
15
|
+
apiVersion: 3,
|
|
15
16
|
attributes: {
|
|
16
17
|
align: {
|
|
17
18
|
type: 'string',
|
|
@@ -34,6 +35,7 @@ describe( 'BlockSwitcher - utils', () => {
|
|
|
34
35
|
title: 'test block 1',
|
|
35
36
|
} );
|
|
36
37
|
registerBlockType( 'core/test-block-2', {
|
|
38
|
+
apiVersion: 3,
|
|
37
39
|
attributes: {
|
|
38
40
|
align: { type: 'string' },
|
|
39
41
|
content: { type: 'boolean' },
|
|
@@ -27,7 +27,7 @@ import BlockControls from '../block-controls';
|
|
|
27
27
|
import __unstableBlockToolbarLastItem from './block-toolbar-last-item';
|
|
28
28
|
import BlockSettingsMenu from '../block-settings-menu';
|
|
29
29
|
import { BlockLockToolbar } from '../block-lock';
|
|
30
|
-
import {
|
|
30
|
+
import { ViewportVisibilityToolbar } from '../block-visibility';
|
|
31
31
|
import { BlockGroupToolbar } from '../convert-to-group-buttons';
|
|
32
32
|
import BlockEditVisuallyButton from '../block-edit-visually-button';
|
|
33
33
|
import { useShowHoveredOrFocusedGestures } from './utils';
|
|
@@ -213,7 +213,7 @@ export function PrivateBlockToolbar( {
|
|
|
213
213
|
/>
|
|
214
214
|
{ isDefaultEditingMode &&
|
|
215
215
|
showBlockVisibilityButton && (
|
|
216
|
-
<
|
|
216
|
+
<ViewportVisibilityToolbar
|
|
217
217
|
clientIds={ blockClientIds }
|
|
218
218
|
/>
|
|
219
219
|
) }
|
|
@@ -35,7 +35,6 @@ import { useShowBlockTools } from './use-show-block-tools';
|
|
|
35
35
|
import { unlock } from '../../lock-unlock';
|
|
36
36
|
import usePasteStyles from '../use-paste-styles';
|
|
37
37
|
import { BlockVisibilityModal } from '../block-visibility';
|
|
38
|
-
import { cleanEmptyObject } from '../../hooks/utils';
|
|
39
38
|
|
|
40
39
|
function selector( select ) {
|
|
41
40
|
const {
|
|
@@ -101,7 +100,6 @@ export default function BlockTools( {
|
|
|
101
100
|
moveBlocksDown,
|
|
102
101
|
expandBlock,
|
|
103
102
|
stopEditingContentOnlySection,
|
|
104
|
-
updateBlockAttributes,
|
|
105
103
|
} = unlock( useDispatch( blockEditorStore ) );
|
|
106
104
|
|
|
107
105
|
function onKeyDown( event ) {
|
|
@@ -230,33 +228,8 @@ export default function BlockTools( {
|
|
|
230
228
|
return;
|
|
231
229
|
}
|
|
232
230
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
setVisibilityModalClientIds( clientIds );
|
|
236
|
-
} else {
|
|
237
|
-
const hasHiddenBlock = blocks.some(
|
|
238
|
-
( block ) =>
|
|
239
|
-
block.attributes.metadata?.blockVisibility === false
|
|
240
|
-
);
|
|
241
|
-
const attributesByClientId = Object.fromEntries(
|
|
242
|
-
blocks.map(
|
|
243
|
-
( { clientId: mapClientId, attributes } ) => [
|
|
244
|
-
mapClientId,
|
|
245
|
-
{
|
|
246
|
-
metadata: cleanEmptyObject( {
|
|
247
|
-
...attributes?.metadata,
|
|
248
|
-
blockVisibility: hasHiddenBlock
|
|
249
|
-
? undefined
|
|
250
|
-
: false,
|
|
251
|
-
} ),
|
|
252
|
-
},
|
|
253
|
-
]
|
|
254
|
-
)
|
|
255
|
-
);
|
|
256
|
-
updateBlockAttributes( clientIds, attributesByClientId, {
|
|
257
|
-
uniqueByBlock: true,
|
|
258
|
-
} );
|
|
259
|
-
}
|
|
231
|
+
// Open the visibility breakpoints modal.
|
|
232
|
+
setVisibilityModalClientIds( clientIds );
|
|
260
233
|
}
|
|
261
234
|
}
|
|
262
235
|
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
export { default as BlockVisibilityModal } from './modal';
|
|
2
2
|
export { default as useBlockVisibility } from './use-block-visibility';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import BlockVisibilityMenuItemDefault from './menu-item';
|
|
8
|
-
import BlockVisibilityViewportMenuItem from './viewport-menu-item';
|
|
9
|
-
|
|
10
|
-
const hasViewportVisibilityExperiment =
|
|
11
|
-
typeof window !== 'undefined' &&
|
|
12
|
-
window.__experimentalHideBlocksBasedOnScreenSize;
|
|
13
|
-
|
|
14
|
-
// Conditionally export the viewport versions when the experimental flag is enabled.
|
|
15
|
-
export const BlockVisibilityMenuItem = hasViewportVisibilityExperiment
|
|
16
|
-
? BlockVisibilityViewportMenuItem
|
|
17
|
-
: BlockVisibilityMenuItemDefault;
|
|
18
|
-
|
|
19
|
-
export const BlockVisibilityToolbar = hasViewportVisibilityExperiment
|
|
20
|
-
? BlockVisibilityViewportToolbar
|
|
21
|
-
: BlockVisibilityToolbarDefault;
|
|
3
|
+
export { default as ViewportVisibilityToolbar } from './viewport-toolbar';
|
|
4
|
+
export { default as BlockVisibilityViewportMenuItem } from './viewport-menu-item';
|
|
5
|
+
export { default as ViewportVisibilityInfo } from './viewport-visibility-info';
|
|
@@ -118,7 +118,7 @@ export default function BlockVisibilityModal( { clientIds, onClose } ) {
|
|
|
118
118
|
return sprintf(
|
|
119
119
|
// translators: %s: The shortcut key to access the List View.
|
|
120
120
|
__(
|
|
121
|
-
'Block visibility settings
|
|
121
|
+
'Block visibility settings updated. You can access them via the List View (%s).'
|
|
122
122
|
),
|
|
123
123
|
listViewShortcut
|
|
124
124
|
);
|
|
@@ -160,18 +160,20 @@ export default function BlockVisibilityModal( { clientIds, onClose } ) {
|
|
|
160
160
|
event.preventDefault();
|
|
161
161
|
const newVisibility = hideEverywhere
|
|
162
162
|
? false
|
|
163
|
-
:
|
|
164
|
-
(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
: {
|
|
164
|
+
viewport: BLOCK_VISIBILITY_VIEWPORT_ENTRIES.reduce(
|
|
165
|
+
( acc, [ , { key } ] ) => {
|
|
166
|
+
if ( viewportChecked[ key ] ) {
|
|
167
|
+
// Values are inverted to hide the block on the selected viewport.
|
|
168
|
+
// In the UI, the checkbox is checked (true) when the block is hidden on the selected viewport,
|
|
169
|
+
// so 'false' means hide the block on the selected viewport.
|
|
170
|
+
acc[ key ] = false;
|
|
171
|
+
}
|
|
172
|
+
return acc;
|
|
173
|
+
},
|
|
174
|
+
{}
|
|
175
|
+
),
|
|
176
|
+
};
|
|
175
177
|
const attributesByClientId = Object.fromEntries(
|
|
176
178
|
blocks.map( ( { clientId, attributes } ) => [
|
|
177
179
|
clientId,
|
|
@@ -190,7 +192,7 @@ export default function BlockVisibilityModal( { clientIds, onClose } ) {
|
|
|
190
192
|
createSuccessNotice( noticeMessage, {
|
|
191
193
|
id: hideEverywhere
|
|
192
194
|
? 'block-visibility-hidden'
|
|
193
|
-
: 'block-visibility-viewports-
|
|
195
|
+
: 'block-visibility-viewports-updated',
|
|
194
196
|
type: 'snackbar',
|
|
195
197
|
} );
|
|
196
198
|
onClose();
|
|
@@ -38,12 +38,6 @@ describe( 'useBlockVisibility', () => {
|
|
|
38
38
|
beforeEach( () => {
|
|
39
39
|
// Reset all mocks before each test
|
|
40
40
|
jest.clearAllMocks();
|
|
41
|
-
// Enable experimental flag
|
|
42
|
-
window.__experimentalHideBlocksBasedOnScreenSize = true;
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
afterEach( () => {
|
|
46
|
-
delete window.__experimentalHideBlocksBasedOnScreenSize;
|
|
47
41
|
} );
|
|
48
42
|
|
|
49
43
|
describe( 'Device type overrides', () => {
|
|
@@ -52,7 +46,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
52
46
|
|
|
53
47
|
const { result } = renderHook( () =>
|
|
54
48
|
useBlockVisibility( {
|
|
55
|
-
blockVisibility: { mobile: false },
|
|
49
|
+
blockVisibility: { viewport: { mobile: false } },
|
|
56
50
|
deviceType: 'mobile',
|
|
57
51
|
} )
|
|
58
52
|
);
|
|
@@ -66,9 +60,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
66
60
|
const { result } = renderHook( () =>
|
|
67
61
|
useBlockVisibility( {
|
|
68
62
|
blockVisibility: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
viewport: {
|
|
64
|
+
mobile: true,
|
|
65
|
+
tablet: false,
|
|
66
|
+
desktop: false,
|
|
67
|
+
},
|
|
72
68
|
},
|
|
73
69
|
deviceType: 'mobile',
|
|
74
70
|
} )
|
|
@@ -82,7 +78,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
82
78
|
|
|
83
79
|
const { result } = renderHook( () =>
|
|
84
80
|
useBlockVisibility( {
|
|
85
|
-
blockVisibility: { tablet: false },
|
|
81
|
+
blockVisibility: { viewport: { tablet: false } },
|
|
86
82
|
deviceType: 'tablet',
|
|
87
83
|
} )
|
|
88
84
|
);
|
|
@@ -98,7 +94,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
98
94
|
|
|
99
95
|
const { result } = renderHook( () =>
|
|
100
96
|
useBlockVisibility( {
|
|
101
|
-
blockVisibility: { desktop: false },
|
|
97
|
+
blockVisibility: { viewport: { desktop: false } },
|
|
102
98
|
deviceType: 'desktop',
|
|
103
99
|
} )
|
|
104
100
|
);
|
|
@@ -116,7 +112,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
116
112
|
|
|
117
113
|
const { result } = renderHook( () =>
|
|
118
114
|
useBlockVisibility( {
|
|
119
|
-
blockVisibility: { mobile: false },
|
|
115
|
+
blockVisibility: { viewport: { mobile: false } },
|
|
120
116
|
deviceType: 'desktop',
|
|
121
117
|
} )
|
|
122
118
|
);
|
|
@@ -133,9 +129,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
133
129
|
const { result } = renderHook( () =>
|
|
134
130
|
useBlockVisibility( {
|
|
135
131
|
blockVisibility: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
viewport: {
|
|
133
|
+
mobile: true,
|
|
134
|
+
tablet: false,
|
|
135
|
+
desktop: false,
|
|
136
|
+
},
|
|
139
137
|
},
|
|
140
138
|
deviceType: 'desktop',
|
|
141
139
|
} )
|
|
@@ -152,7 +150,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
152
150
|
|
|
153
151
|
const { result } = renderHook( () =>
|
|
154
152
|
useBlockVisibility( {
|
|
155
|
-
blockVisibility: { tablet: false },
|
|
153
|
+
blockVisibility: { viewport: { tablet: false } },
|
|
156
154
|
deviceType: 'desktop',
|
|
157
155
|
} )
|
|
158
156
|
);
|
|
@@ -169,9 +167,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
169
167
|
const { result } = renderHook( () =>
|
|
170
168
|
useBlockVisibility( {
|
|
171
169
|
blockVisibility: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
viewport: {
|
|
171
|
+
mobile: false,
|
|
172
|
+
tablet: true,
|
|
173
|
+
desktop: false,
|
|
174
|
+
},
|
|
175
175
|
},
|
|
176
176
|
deviceType: 'desktop',
|
|
177
177
|
} )
|
|
@@ -188,7 +188,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
188
188
|
|
|
189
189
|
const { result } = renderHook( () =>
|
|
190
190
|
useBlockVisibility( {
|
|
191
|
-
blockVisibility: { desktop: false },
|
|
191
|
+
blockVisibility: { viewport: { desktop: false } },
|
|
192
192
|
deviceType: 'desktop',
|
|
193
193
|
} )
|
|
194
194
|
);
|
|
@@ -205,9 +205,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
205
205
|
const { result } = renderHook( () =>
|
|
206
206
|
useBlockVisibility( {
|
|
207
207
|
blockVisibility: {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
viewport: {
|
|
209
|
+
mobile: false,
|
|
210
|
+
tablet: false,
|
|
211
|
+
desktop: true,
|
|
212
|
+
},
|
|
211
213
|
},
|
|
212
214
|
deviceType: 'desktop',
|
|
213
215
|
} )
|
|
@@ -306,7 +308,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
306
308
|
|
|
307
309
|
const { result } = renderHook( () =>
|
|
308
310
|
useBlockVisibility( {
|
|
309
|
-
blockVisibility: { desktop: false },
|
|
311
|
+
blockVisibility: { viewport: { desktop: false } },
|
|
310
312
|
} )
|
|
311
313
|
);
|
|
312
314
|
|
|
@@ -21,7 +21,9 @@ describe( 'block-visibility utils', () => {
|
|
|
21
21
|
{
|
|
22
22
|
attributes: {
|
|
23
23
|
metadata: {
|
|
24
|
-
blockVisibility: {
|
|
24
|
+
blockVisibility: {
|
|
25
|
+
viewport: {},
|
|
26
|
+
},
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
},
|
|
@@ -75,7 +77,9 @@ describe( 'block-visibility utils', () => {
|
|
|
75
77
|
attributes: {
|
|
76
78
|
metadata: {
|
|
77
79
|
blockVisibility: {
|
|
78
|
-
|
|
80
|
+
viewport: {
|
|
81
|
+
mobile: false,
|
|
82
|
+
},
|
|
79
83
|
},
|
|
80
84
|
},
|
|
81
85
|
},
|
|
@@ -83,7 +87,9 @@ describe( 'block-visibility utils', () => {
|
|
|
83
87
|
{
|
|
84
88
|
attributes: {
|
|
85
89
|
metadata: {
|
|
86
|
-
blockVisibility: {
|
|
90
|
+
blockVisibility: {
|
|
91
|
+
viewport: {},
|
|
92
|
+
},
|
|
87
93
|
},
|
|
88
94
|
},
|
|
89
95
|
},
|
|
@@ -105,7 +111,9 @@ describe( 'block-visibility utils', () => {
|
|
|
105
111
|
{
|
|
106
112
|
attributes: {
|
|
107
113
|
metadata: {
|
|
108
|
-
blockVisibility: {
|
|
114
|
+
blockVisibility: {
|
|
115
|
+
viewport: {},
|
|
116
|
+
},
|
|
109
117
|
},
|
|
110
118
|
},
|
|
111
119
|
},
|
|
@@ -122,7 +130,9 @@ describe( 'block-visibility utils', () => {
|
|
|
122
130
|
attributes: {
|
|
123
131
|
metadata: {
|
|
124
132
|
blockVisibility: {
|
|
125
|
-
|
|
133
|
+
viewport: {
|
|
134
|
+
mobile: false,
|
|
135
|
+
},
|
|
126
136
|
},
|
|
127
137
|
},
|
|
128
138
|
},
|
|
@@ -188,7 +198,9 @@ describe( 'block-visibility utils', () => {
|
|
|
188
198
|
{
|
|
189
199
|
attributes: {
|
|
190
200
|
metadata: {
|
|
191
|
-
blockVisibility: {
|
|
201
|
+
blockVisibility: {
|
|
202
|
+
viewport: {},
|
|
203
|
+
},
|
|
192
204
|
},
|
|
193
205
|
},
|
|
194
206
|
},
|
|
@@ -245,7 +257,9 @@ describe( 'block-visibility utils', () => {
|
|
|
245
257
|
attributes: {
|
|
246
258
|
metadata: {
|
|
247
259
|
blockVisibility: {
|
|
248
|
-
|
|
260
|
+
viewport: {
|
|
261
|
+
mobile: false,
|
|
262
|
+
},
|
|
249
263
|
},
|
|
250
264
|
},
|
|
251
265
|
},
|
|
@@ -254,7 +268,9 @@ describe( 'block-visibility utils', () => {
|
|
|
254
268
|
attributes: {
|
|
255
269
|
metadata: {
|
|
256
270
|
blockVisibility: {
|
|
257
|
-
|
|
271
|
+
viewport: {
|
|
272
|
+
tablet: false,
|
|
273
|
+
},
|
|
258
274
|
},
|
|
259
275
|
},
|
|
260
276
|
},
|
|
@@ -53,10 +53,7 @@ export default function useBlockVisibility( options = {} ) {
|
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (
|
|
57
|
-
window.__experimentalHideBlocksBasedOnScreenSize &&
|
|
58
|
-
blockVisibility?.[ currentViewport ] === false
|
|
59
|
-
) {
|
|
56
|
+
if ( blockVisibility?.viewport?.[ currentViewport ] === false ) {
|
|
60
57
|
return true;
|
|
61
58
|
}
|
|
62
59
|
|
|
@@ -27,6 +27,14 @@ function isBlockHiddenForViewport( block, viewport ) {
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// Get viewport configuration from nested structure.
|
|
31
|
+
const viewportConfig = blockVisibility.viewport;
|
|
32
|
+
|
|
33
|
+
// If no viewport config, block is not hidden for any specific viewport.
|
|
34
|
+
if ( ! viewportConfig || 'object' !== typeof viewportConfig ) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
// Check if the viewport is valid.
|
|
31
39
|
if (
|
|
32
40
|
! BLOCK_VISIBILITY_VIEWPORT_ENTRIES.some(
|
|
@@ -37,7 +45,7 @@ function isBlockHiddenForViewport( block, viewport ) {
|
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
// Check if the specific viewport is hidden.
|
|
40
|
-
return
|
|
48
|
+
return viewportConfig[ viewport ] === false;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
/**
|
|
@@ -16,11 +16,17 @@ import { unlock } from '../../lock-unlock';
|
|
|
16
16
|
|
|
17
17
|
export default function BlockVisibilityViewportMenuItem( { clientIds } ) {
|
|
18
18
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
19
|
-
const areBlocksHiddenAnywhere = useSelect(
|
|
20
|
-
( select ) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
19
|
+
const { areBlocksHiddenAnywhere } = useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const { isBlockHiddenAnywhere } = unlock(
|
|
22
|
+
select( blockEditorStore )
|
|
23
|
+
);
|
|
24
|
+
return {
|
|
25
|
+
areBlocksHiddenAnywhere: clientIds?.every( ( clientId ) =>
|
|
26
|
+
isBlockHiddenAnywhere( clientId )
|
|
27
|
+
),
|
|
28
|
+
};
|
|
29
|
+
},
|
|
24
30
|
[ clientIds ]
|
|
25
31
|
);
|
|
26
32
|
return (
|
|
@@ -20,11 +20,8 @@ export default function BlockVisibilityViewportToolbar( { clientIds } ) {
|
|
|
20
20
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
21
21
|
const { canToggleBlockVisibility, areBlocksHiddenAnywhere } = useSelect(
|
|
22
22
|
( select ) => {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
getBlockName,
|
|
26
|
-
areBlocksHiddenAnywhere: _areBlocksHiddenAnywhere,
|
|
27
|
-
} = unlock( select( blockEditorStore ) );
|
|
23
|
+
const { getBlocksByClientId, getBlockName, isBlockHiddenAnywhere } =
|
|
24
|
+
unlock( select( blockEditorStore ) );
|
|
28
25
|
const _blocks = getBlocksByClientId( clientIds );
|
|
29
26
|
return {
|
|
30
27
|
canToggleBlockVisibility: _blocks.every( ( { clientId } ) =>
|
|
@@ -34,7 +31,9 @@ export default function BlockVisibilityViewportToolbar( { clientIds } ) {
|
|
|
34
31
|
true
|
|
35
32
|
)
|
|
36
33
|
),
|
|
37
|
-
areBlocksHiddenAnywhere:
|
|
34
|
+
areBlocksHiddenAnywhere: clientIds?.every( ( clientId ) =>
|
|
35
|
+
isBlockHiddenAnywhere( clientId )
|
|
36
|
+
),
|
|
38
37
|
};
|
|
39
38
|
},
|
|
40
39
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Icon,
|
|
6
|
+
__experimentalText as Text,
|
|
7
|
+
__experimentalHStack as HStack,
|
|
8
|
+
privateApis as componentsPrivateApis,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
12
|
+
import { unseen } from '@wordpress/icons';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
18
|
+
import { store as blockEditorStore } from '../../store';
|
|
19
|
+
import useBlockVisibility from './use-block-visibility';
|
|
20
|
+
import { deviceTypeKey } from '../../store/private-keys';
|
|
21
|
+
import { BLOCK_VISIBILITY_VIEWPORTS } from './constants';
|
|
22
|
+
|
|
23
|
+
const { Badge } = unlock( componentsPrivateApis );
|
|
24
|
+
const DEFAULT_VISIBILITY_STATE = {
|
|
25
|
+
currentBlockVisibility: undefined,
|
|
26
|
+
hasParentHiddenEverywhere: false,
|
|
27
|
+
selectedDeviceType: BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default function ViewportVisibilityInfo( { clientId } ) {
|
|
31
|
+
const {
|
|
32
|
+
currentBlockVisibility,
|
|
33
|
+
selectedDeviceType,
|
|
34
|
+
hasParentHiddenEverywhere,
|
|
35
|
+
} = useSelect(
|
|
36
|
+
( select ) => {
|
|
37
|
+
if ( ! clientId ) {
|
|
38
|
+
return DEFAULT_VISIBILITY_STATE;
|
|
39
|
+
}
|
|
40
|
+
const {
|
|
41
|
+
getBlockAttributes,
|
|
42
|
+
isBlockParentHiddenEverywhere,
|
|
43
|
+
getSettings,
|
|
44
|
+
} = unlock( select( blockEditorStore ) );
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
currentBlockVisibility:
|
|
48
|
+
getBlockAttributes( clientId )?.metadata?.blockVisibility,
|
|
49
|
+
selectedDeviceType:
|
|
50
|
+
getSettings()?.[ deviceTypeKey ]?.toLowerCase() ||
|
|
51
|
+
BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
|
|
52
|
+
hasParentHiddenEverywhere:
|
|
53
|
+
isBlockParentHiddenEverywhere( clientId ),
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
[ clientId ]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Use hook to get current viewport and if block is currently hidden (accurate viewport detection)
|
|
60
|
+
const { isBlockCurrentlyHidden, currentViewport } = useBlockVisibility( {
|
|
61
|
+
blockVisibility: currentBlockVisibility,
|
|
62
|
+
deviceType: selectedDeviceType,
|
|
63
|
+
} );
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Selector to check if any parent (immediate or further up the chain) is hidden at current viewport.
|
|
67
|
+
* Separated because it depends on currentViewport from the hook above.
|
|
68
|
+
*/
|
|
69
|
+
const isBlockParentHiddenAtViewport = useSelect(
|
|
70
|
+
( select ) => {
|
|
71
|
+
if ( ! clientId || ! currentViewport ) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return unlock(
|
|
75
|
+
select( blockEditorStore )
|
|
76
|
+
).isBlockParentHiddenAtViewport( clientId, currentViewport );
|
|
77
|
+
},
|
|
78
|
+
[ clientId, currentViewport ]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
! (
|
|
83
|
+
isBlockCurrentlyHidden ||
|
|
84
|
+
hasParentHiddenEverywhere ||
|
|
85
|
+
isBlockParentHiddenAtViewport
|
|
86
|
+
)
|
|
87
|
+
) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Determine label based on whether block or parent is hidden
|
|
92
|
+
let label;
|
|
93
|
+
if ( isBlockCurrentlyHidden ) {
|
|
94
|
+
// Block is currently hidden - check if hidden everywhere or at specific viewport
|
|
95
|
+
if ( currentBlockVisibility === false ) {
|
|
96
|
+
label = __( 'Block is hidden' );
|
|
97
|
+
} else {
|
|
98
|
+
const viewportLabel =
|
|
99
|
+
BLOCK_VISIBILITY_VIEWPORTS[ currentViewport ]?.label ||
|
|
100
|
+
currentViewport;
|
|
101
|
+
label = sprintf(
|
|
102
|
+
/* translators: %s: viewport name (Desktop, Tablet, Mobile) */
|
|
103
|
+
__( 'Block is hidden on %s' ),
|
|
104
|
+
viewportLabel
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Parent is hidden - check if hidden everywhere or at specific viewport
|
|
110
|
+
if ( hasParentHiddenEverywhere ) {
|
|
111
|
+
label = __( 'Parent block is hidden' );
|
|
112
|
+
} else if ( isBlockParentHiddenAtViewport ) {
|
|
113
|
+
const viewportLabel =
|
|
114
|
+
BLOCK_VISIBILITY_VIEWPORTS[ currentViewport ]?.label ||
|
|
115
|
+
currentViewport;
|
|
116
|
+
label = sprintf(
|
|
117
|
+
/* translators: %s: viewport name (Desktop, Tablet, Mobile) */
|
|
118
|
+
__( 'Parent block is hidden on %s' ),
|
|
119
|
+
viewportLabel
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Badge className="block-editor-block-visibility-info">
|
|
125
|
+
<HStack spacing={ 2 } justify="start">
|
|
126
|
+
<Icon icon={ unseen } />
|
|
127
|
+
<Text>{ label }</Text>
|
|
128
|
+
</HStack>
|
|
129
|
+
</Badge>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -54,6 +54,8 @@ function ButtonBlockAppender(
|
|
|
54
54
|
);
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
+
// Disable reason: There shouldn't be a case where this button is disabled but not visually hidden.
|
|
58
|
+
// eslint-disable-next-line @wordpress/components-no-unsafe-button-disabled
|
|
57
59
|
<Button
|
|
58
60
|
__next40pxDefaultSize
|
|
59
61
|
ref={ ref }
|
|
@@ -66,8 +68,6 @@ function ButtonBlockAppender(
|
|
|
66
68
|
onClick={ onToggle }
|
|
67
69
|
aria-haspopup={ isToggleButton ? 'true' : undefined }
|
|
68
70
|
aria-expanded={ isToggleButton ? isOpen : undefined }
|
|
69
|
-
// Disable reason: There shouldn't be a case where this button is disabled but not visually hidden.
|
|
70
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
71
71
|
disabled={ disabled }
|
|
72
72
|
label={ label }
|
|
73
73
|
showTooltip
|
|
@@ -9,7 +9,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
|
|
|
9
9
|
import { useSettings } from '../use-settings';
|
|
10
10
|
|
|
11
11
|
export default createHigherOrderComponent( ( WrappedComponent ) => {
|
|
12
|
-
return ( props )
|
|
12
|
+
return function WithColorContext( props ) {
|
|
13
13
|
// Get the default colors, theme colors, and custom colors
|
|
14
14
|
const [
|
|
15
15
|
defaultColors,
|
|
@@ -49,9 +49,8 @@ const ColorSelectorIcon = ( { style, className } ) => {
|
|
|
49
49
|
*
|
|
50
50
|
* @return {*} React toggle button component.
|
|
51
51
|
*/
|
|
52
|
-
const renderToggleComponent =
|
|
53
|
-
( {
|
|
54
|
-
( { onToggle, isOpen } ) => {
|
|
52
|
+
const renderToggleComponent = ( { TextColor, BackgroundColor } ) =>
|
|
53
|
+
function ToggleComponent( { onToggle, isOpen } ) {
|
|
55
54
|
const openOnArrowDown = ( event ) => {
|
|
56
55
|
if ( ! isOpen && event.keyCode === DOWN ) {
|
|
57
56
|
event.preventDefault();
|