@wordpress/block-editor 15.11.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/build/components/block-controls/index.cjs +1 -1
- package/build/components/block-controls/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +6 -19
- package/build/components/block-inspector/index.cjs.map +3 -3
- 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/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/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 +12 -2
- 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 +2 -2
- 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/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 +4 -0
- 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 +9 -5
- package/build/hooks/list-view.cjs.map +3 -3
- package/build/hooks/utils.cjs +2 -2
- 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/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-inspector/index.mjs +6 -19
- package/build-module/components/block-inspector/index.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/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/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 +12 -2
- 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 +2 -2
- 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/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 +4 -0
- 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 +10 -6
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +2 -2
- 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/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/test/edit.js +10 -0
- package/src/components/block-inspector/index.js +14 -32
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +49 -29
- 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/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/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 +25 -5
- 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 +3 -4
- 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/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 +4 -0
- package/src/hooks/layout.js +55 -43
- package/src/hooks/list-view.js +10 -6
- 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 +123 -119
- 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/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
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
isMoveLockedBlock,
|
|
20
20
|
isRemoveLockedBlock,
|
|
21
21
|
isLockedBlock,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
isBlockHiddenAnywhere,
|
|
23
|
+
isBlockHiddenAtViewport,
|
|
24
24
|
} from '../private-selectors';
|
|
25
25
|
import { getBlockEditingMode } from '../selectors';
|
|
26
26
|
import { deviceTypeKey } from '../private-keys';
|
|
@@ -932,10 +932,11 @@ describe( 'private selectors', () => {
|
|
|
932
932
|
} );
|
|
933
933
|
} );
|
|
934
934
|
|
|
935
|
-
describe( '
|
|
935
|
+
describe( 'isBlockHiddenAnywhere', () => {
|
|
936
936
|
beforeAll( () => {
|
|
937
937
|
// Register a block with visibility support
|
|
938
938
|
registerBlockType( 'core/test-block-with-visibility', {
|
|
939
|
+
apiVersion: 3,
|
|
939
940
|
save: () => null,
|
|
940
941
|
category: 'text',
|
|
941
942
|
title: 'Test Block With Visibility',
|
|
@@ -946,6 +947,7 @@ describe( 'private selectors', () => {
|
|
|
946
947
|
|
|
947
948
|
// Register a block without visibility support
|
|
948
949
|
registerBlockType( 'core/test-block-without-visibility', {
|
|
950
|
+
apiVersion: 3,
|
|
949
951
|
save: () => null,
|
|
950
952
|
category: 'text',
|
|
951
953
|
title: 'Test Block Without Visibility',
|
|
@@ -956,6 +958,7 @@ describe( 'private selectors', () => {
|
|
|
956
958
|
|
|
957
959
|
// Register a block with no supports defined (defaults to true for visibility)
|
|
958
960
|
registerBlockType( 'core/test-block-default-visibility', {
|
|
961
|
+
apiVersion: 3,
|
|
959
962
|
save: () => null,
|
|
960
963
|
category: 'text',
|
|
961
964
|
title: 'Test Block Default Visibility',
|
|
@@ -990,7 +993,7 @@ describe( 'private selectors', () => {
|
|
|
990
993
|
},
|
|
991
994
|
};
|
|
992
995
|
|
|
993
|
-
expect(
|
|
996
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( false );
|
|
994
997
|
} );
|
|
995
998
|
|
|
996
999
|
it( 'should return true when block has visibility support and is hidden', () => {
|
|
@@ -1015,7 +1018,7 @@ describe( 'private selectors', () => {
|
|
|
1015
1018
|
},
|
|
1016
1019
|
};
|
|
1017
1020
|
|
|
1018
|
-
expect(
|
|
1021
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( true );
|
|
1019
1022
|
} );
|
|
1020
1023
|
|
|
1021
1024
|
it( 'should return false when block does not have visibility support', () => {
|
|
@@ -1042,7 +1045,7 @@ describe( 'private selectors', () => {
|
|
|
1042
1045
|
|
|
1043
1046
|
// Even though blockVisibility is false, the block doesn't support visibility,
|
|
1044
1047
|
// so it should return false
|
|
1045
|
-
expect(
|
|
1048
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( false );
|
|
1046
1049
|
} );
|
|
1047
1050
|
|
|
1048
1051
|
it( 'should return false when block has default visibility support and is not hidden', () => {
|
|
@@ -1067,7 +1070,7 @@ describe( 'private selectors', () => {
|
|
|
1067
1070
|
},
|
|
1068
1071
|
};
|
|
1069
1072
|
|
|
1070
|
-
expect(
|
|
1073
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( false );
|
|
1071
1074
|
} );
|
|
1072
1075
|
|
|
1073
1076
|
it( 'should return true when block has default visibility support and is hidden', () => {
|
|
@@ -1092,7 +1095,7 @@ describe( 'private selectors', () => {
|
|
|
1092
1095
|
},
|
|
1093
1096
|
};
|
|
1094
1097
|
|
|
1095
|
-
expect(
|
|
1098
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( true );
|
|
1096
1099
|
} );
|
|
1097
1100
|
|
|
1098
1101
|
it( 'should return false when block has no metadata', () => {
|
|
@@ -1108,7 +1111,7 @@ describe( 'private selectors', () => {
|
|
|
1108
1111
|
},
|
|
1109
1112
|
};
|
|
1110
1113
|
|
|
1111
|
-
expect(
|
|
1114
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( false );
|
|
1112
1115
|
} );
|
|
1113
1116
|
|
|
1114
1117
|
it( 'should return false when block has metadata but no blockVisibility property', () => {
|
|
@@ -1133,7 +1136,7 @@ describe( 'private selectors', () => {
|
|
|
1133
1136
|
},
|
|
1134
1137
|
};
|
|
1135
1138
|
|
|
1136
|
-
expect(
|
|
1139
|
+
expect( isBlockHiddenAnywhere( state, 'block-1' ) ).toBe( false );
|
|
1137
1140
|
} );
|
|
1138
1141
|
|
|
1139
1142
|
it( 'should handle non-existent block gracefully', () => {
|
|
@@ -1146,25 +1149,93 @@ describe( 'private selectors', () => {
|
|
|
1146
1149
|
|
|
1147
1150
|
// When block doesn't exist, getBlockName returns null,
|
|
1148
1151
|
// and hasBlockSupport should handle null gracefully
|
|
1149
|
-
expect(
|
|
1152
|
+
expect( isBlockHiddenAnywhere( state, 'non-existent-block' ) ).toBe(
|
|
1150
1153
|
false
|
|
1151
1154
|
);
|
|
1152
1155
|
} );
|
|
1153
1156
|
} );
|
|
1154
1157
|
|
|
1155
|
-
describe( '
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
+
describe( 'isBlockHiddenAtViewport', () => {
|
|
1159
|
+
beforeAll( () => {
|
|
1160
|
+
registerBlockType( 'core/test-block-with-visibility', {
|
|
1161
|
+
apiVersion: 3,
|
|
1162
|
+
save: () => null,
|
|
1163
|
+
category: 'text',
|
|
1164
|
+
title: 'Test Block With Visibility',
|
|
1165
|
+
supports: {
|
|
1166
|
+
visibility: true,
|
|
1167
|
+
},
|
|
1168
|
+
} );
|
|
1169
|
+
} );
|
|
1170
|
+
|
|
1171
|
+
afterAll( () => {
|
|
1172
|
+
unregisterBlockType( 'core/test-block-with-visibility' );
|
|
1173
|
+
} );
|
|
1174
|
+
|
|
1175
|
+
it( 'returns true when block is hidden everywhere', () => {
|
|
1176
|
+
const state = {
|
|
1177
|
+
blocks: {
|
|
1178
|
+
byClientId: new Map( [
|
|
1179
|
+
[
|
|
1180
|
+
'block-1',
|
|
1181
|
+
{ name: 'core/test-block-with-visibility' },
|
|
1182
|
+
],
|
|
1183
|
+
] ),
|
|
1184
|
+
attributes: new Map( [
|
|
1185
|
+
[
|
|
1186
|
+
'block-1',
|
|
1187
|
+
{
|
|
1188
|
+
metadata: {
|
|
1189
|
+
blockVisibility: false,
|
|
1190
|
+
},
|
|
1191
|
+
},
|
|
1192
|
+
],
|
|
1193
|
+
] ),
|
|
1194
|
+
},
|
|
1195
|
+
};
|
|
1158
1196
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1197
|
+
expect(
|
|
1198
|
+
isBlockHiddenAtViewport( state, 'block-1', 'Desktop' )
|
|
1199
|
+
).toBe( true );
|
|
1161
1200
|
} );
|
|
1162
1201
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1202
|
+
it( 'returns visibility based on the requested viewport', () => {
|
|
1203
|
+
const state = {
|
|
1204
|
+
blocks: {
|
|
1205
|
+
byClientId: new Map( [
|
|
1206
|
+
[
|
|
1207
|
+
'block-1',
|
|
1208
|
+
{ name: 'core/test-block-with-visibility' },
|
|
1209
|
+
],
|
|
1210
|
+
] ),
|
|
1211
|
+
attributes: new Map( [
|
|
1212
|
+
[
|
|
1213
|
+
'block-1',
|
|
1214
|
+
{
|
|
1215
|
+
metadata: {
|
|
1216
|
+
blockVisibility: {
|
|
1217
|
+
viewport: {
|
|
1218
|
+
mobile: false,
|
|
1219
|
+
tablet: true,
|
|
1220
|
+
},
|
|
1221
|
+
},
|
|
1222
|
+
},
|
|
1223
|
+
},
|
|
1224
|
+
],
|
|
1225
|
+
] ),
|
|
1226
|
+
},
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
expect(
|
|
1230
|
+
isBlockHiddenAtViewport( state, 'block-1', 'Mobile' )
|
|
1231
|
+
).toBe( true );
|
|
1232
|
+
expect(
|
|
1233
|
+
isBlockHiddenAtViewport( state, 'block-1', 'Tablet' )
|
|
1234
|
+
).toBe( false );
|
|
1166
1235
|
} );
|
|
1236
|
+
} );
|
|
1167
1237
|
|
|
1238
|
+
describe( 'isBlockHiddenAnywhere in different devices', () => {
|
|
1168
1239
|
const createState = ( blockVisibility, deviceType = 'Desktop' ) => ( {
|
|
1169
1240
|
settings: {
|
|
1170
1241
|
[ deviceTypeKey ]: deviceType,
|
|
@@ -1196,132 +1267,58 @@ describe( 'private selectors', () => {
|
|
|
1196
1267
|
},
|
|
1197
1268
|
} );
|
|
1198
1269
|
|
|
1199
|
-
it( 'returns
|
|
1200
|
-
window.__experimentalHideBlocksBasedOnScreenSize = false;
|
|
1201
|
-
const state = createState( { mobile: false, tablet: true } );
|
|
1202
|
-
const result = isBlockHidden( state, 'test-block' );
|
|
1203
|
-
expect( result ).toBe( false );
|
|
1204
|
-
} );
|
|
1205
|
-
|
|
1206
|
-
it( 'returns false when Desktop is selected and block has breakpoint visibility', () => {
|
|
1270
|
+
it( 'returns true when block is hidden at any viewport (mobile)', () => {
|
|
1207
1271
|
const state = createState(
|
|
1208
|
-
{ mobile: false, tablet: true },
|
|
1272
|
+
{ viewport: { mobile: false, tablet: true } },
|
|
1209
1273
|
'Desktop'
|
|
1210
1274
|
);
|
|
1211
|
-
const result =
|
|
1212
|
-
expect( result ).toBe(
|
|
1275
|
+
const result = isBlockHiddenAnywhere( state, 'test-block' );
|
|
1276
|
+
expect( result ).toBe( true );
|
|
1213
1277
|
} );
|
|
1214
1278
|
|
|
1215
|
-
it( 'returns true when
|
|
1216
|
-
const state = createState(
|
|
1217
|
-
|
|
1279
|
+
it( 'returns true when block is hidden on desktop', () => {
|
|
1280
|
+
const state = createState(
|
|
1281
|
+
{ viewport: { desktop: false } },
|
|
1282
|
+
'Desktop'
|
|
1283
|
+
);
|
|
1284
|
+
const result = isBlockHiddenAnywhere( state, 'test-block' );
|
|
1218
1285
|
expect( result ).toBe( true );
|
|
1219
1286
|
} );
|
|
1220
1287
|
|
|
1221
|
-
it( 'returns true when
|
|
1288
|
+
it( 'returns true when block is hidden on tablet', () => {
|
|
1222
1289
|
const state = createState(
|
|
1223
|
-
{ mobile: true, tablet: false },
|
|
1290
|
+
{ viewport: { mobile: true, tablet: false } },
|
|
1224
1291
|
'Tablet'
|
|
1225
1292
|
);
|
|
1226
|
-
const result =
|
|
1293
|
+
const result = isBlockHiddenAnywhere( state, 'test-block' );
|
|
1227
1294
|
expect( result ).toBe( true );
|
|
1228
1295
|
} );
|
|
1229
1296
|
|
|
1230
|
-
it( 'returns true when
|
|
1297
|
+
it( 'returns true when block is hidden on mobile', () => {
|
|
1231
1298
|
const state = createState(
|
|
1232
|
-
{ mobile: false, tablet: true },
|
|
1299
|
+
{ viewport: { mobile: false, tablet: true } },
|
|
1233
1300
|
'Mobile'
|
|
1234
1301
|
);
|
|
1235
|
-
const result =
|
|
1302
|
+
const result = isBlockHiddenAnywhere( state, 'test-block' );
|
|
1236
1303
|
expect( result ).toBe( true );
|
|
1237
1304
|
} );
|
|
1238
1305
|
|
|
1239
|
-
it( 'returns
|
|
1306
|
+
it( 'returns true when block is hidden at any viewport even if visible at current device', () => {
|
|
1240
1307
|
const state = createState(
|
|
1241
|
-
{ mobile: false, tablet: true },
|
|
1308
|
+
{ viewport: { mobile: false, tablet: true } },
|
|
1242
1309
|
'Tablet'
|
|
1243
1310
|
);
|
|
1244
|
-
const result =
|
|
1245
|
-
expect( result ).toBe(
|
|
1246
|
-
} );
|
|
1247
|
-
} );
|
|
1248
|
-
|
|
1249
|
-
describe( 'areBlocksHiddenAnywhere', () => {
|
|
1250
|
-
it( 'should return false when clientIds array is empty', () => {
|
|
1251
|
-
const state = {
|
|
1252
|
-
blocks: {
|
|
1253
|
-
attributes: new Map(),
|
|
1254
|
-
},
|
|
1255
|
-
};
|
|
1256
|
-
expect( areBlocksHiddenAnywhere( state, [] ) ).toBe( false );
|
|
1257
|
-
expect( areBlocksHiddenAnywhere( state, null ) ).toBe( false );
|
|
1258
|
-
expect( areBlocksHiddenAnywhere( state, undefined ) ).toBe( false );
|
|
1259
|
-
} );
|
|
1260
|
-
|
|
1261
|
-
it( 'should return false when no blocks are hidden', () => {
|
|
1262
|
-
const state = {
|
|
1263
|
-
blocks: {
|
|
1264
|
-
attributes: new Map( [
|
|
1265
|
-
[ 'block-1', { metadata: { blockVisibility: true } } ],
|
|
1266
|
-
[ 'block-2', { metadata: {} } ],
|
|
1267
|
-
] ),
|
|
1268
|
-
},
|
|
1269
|
-
};
|
|
1270
|
-
expect(
|
|
1271
|
-
areBlocksHiddenAnywhere( state, [ 'block-1', 'block-2' ] )
|
|
1272
|
-
).toBe( false );
|
|
1273
|
-
} );
|
|
1274
|
-
|
|
1275
|
-
it( 'should return true when a block is hidden everywhere', () => {
|
|
1276
|
-
const state = {
|
|
1277
|
-
blocks: {
|
|
1278
|
-
attributes: new Map( [
|
|
1279
|
-
[ 'block-1', { metadata: { blockVisibility: false } } ],
|
|
1280
|
-
[ 'block-2', { metadata: { blockVisibility: true } } ],
|
|
1281
|
-
] ),
|
|
1282
|
-
},
|
|
1283
|
-
};
|
|
1284
|
-
expect(
|
|
1285
|
-
areBlocksHiddenAnywhere( state, [ 'block-1', 'block-2' ] )
|
|
1286
|
-
).toBe( true );
|
|
1287
|
-
} );
|
|
1288
|
-
|
|
1289
|
-
it( 'should return true when a block is hidden in any viewport', () => {
|
|
1290
|
-
const state = {
|
|
1291
|
-
blocks: {
|
|
1292
|
-
attributes: new Map( [
|
|
1293
|
-
[
|
|
1294
|
-
'block-1',
|
|
1295
|
-
{
|
|
1296
|
-
metadata: {
|
|
1297
|
-
blockVisibility: {
|
|
1298
|
-
mobile: false,
|
|
1299
|
-
tablet: true,
|
|
1300
|
-
},
|
|
1301
|
-
},
|
|
1302
|
-
},
|
|
1303
|
-
],
|
|
1304
|
-
[ 'block-2', { metadata: { blockVisibility: true } } ],
|
|
1305
|
-
] ),
|
|
1306
|
-
},
|
|
1307
|
-
};
|
|
1308
|
-
expect(
|
|
1309
|
-
areBlocksHiddenAnywhere( state, [ 'block-1', 'block-2' ] )
|
|
1310
|
-
).toBe( true );
|
|
1311
|
+
const result = isBlockHiddenAnywhere( state, 'test-block' );
|
|
1312
|
+
expect( result ).toBe( true );
|
|
1311
1313
|
} );
|
|
1312
1314
|
|
|
1313
|
-
it( '
|
|
1314
|
-
const state =
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
[ 'block-1', { metadata: { blockVisibility: false } } ],
|
|
1318
|
-
] ),
|
|
1319
|
-
},
|
|
1320
|
-
};
|
|
1321
|
-
expect( areBlocksHiddenAnywhere( state, [ null ] ) ).toBe( false );
|
|
1322
|
-
expect( areBlocksHiddenAnywhere( state, [ undefined ] ) ).toBe(
|
|
1323
|
-
false
|
|
1315
|
+
it( 'returns false when block is visible at all viewports', () => {
|
|
1316
|
+
const state = createState(
|
|
1317
|
+
{ mobile: true, tablet: true, desktop: true },
|
|
1318
|
+
'Desktop'
|
|
1324
1319
|
);
|
|
1320
|
+
const result = isBlockHiddenAnywhere( state, 'test-block' );
|
|
1321
|
+
expect( result ).toBe( false );
|
|
1325
1322
|
} );
|
|
1326
1323
|
} );
|
|
1327
1324
|
} );
|
|
@@ -199,6 +199,7 @@ describe( 'state', () => {
|
|
|
199
199
|
describe( 'blocks()', () => {
|
|
200
200
|
beforeAll( () => {
|
|
201
201
|
registerBlockType( 'core/test-block', {
|
|
202
|
+
apiVersion: 3,
|
|
202
203
|
save: noop,
|
|
203
204
|
edit: noop,
|
|
204
205
|
category: 'text',
|
|
@@ -213,12 +214,14 @@ describe( 'state', () => {
|
|
|
213
214
|
describe( 'replace inner blocks', () => {
|
|
214
215
|
beforeAll( () => {
|
|
215
216
|
registerBlockType( 'core/test-parent-block', {
|
|
217
|
+
apiVersion: 3,
|
|
216
218
|
save: noop,
|
|
217
219
|
edit: noop,
|
|
218
220
|
category: 'text',
|
|
219
221
|
title: 'test parent block',
|
|
220
222
|
} );
|
|
221
223
|
registerBlockType( 'core/test-child-block', {
|
|
224
|
+
apiVersion: 3,
|
|
222
225
|
save: noop,
|
|
223
226
|
edit: noop,
|
|
224
227
|
category: 'text',
|
|
@@ -2994,6 +2997,7 @@ describe( 'state', () => {
|
|
|
2994
2997
|
blockAttributes?.fruit === variationAttributes.fruit,
|
|
2995
2998
|
} ) );
|
|
2996
2999
|
registerBlockType( blockWithVariations, {
|
|
3000
|
+
apiVersion: 3,
|
|
2997
3001
|
save: noop,
|
|
2998
3002
|
edit: noop,
|
|
2999
3003
|
title: 'Fruit with variations',
|
|
@@ -12,6 +12,7 @@ import { store } from '../';
|
|
|
12
12
|
describe( 'selectors', () => {
|
|
13
13
|
beforeEach( () => {
|
|
14
14
|
registerBlockType( 'core/test-block-a', {
|
|
15
|
+
apiVersion: 3,
|
|
15
16
|
save: ( props ) => props.attributes.text,
|
|
16
17
|
category: 'design',
|
|
17
18
|
title: 'Test Block A',
|
|
@@ -20,6 +21,7 @@ describe( 'selectors', () => {
|
|
|
20
21
|
} );
|
|
21
22
|
|
|
22
23
|
registerBlockType( 'core/test-block-b', {
|
|
24
|
+
apiVersion: 3,
|
|
23
25
|
save: ( props ) => props.attributes.text,
|
|
24
26
|
category: 'text',
|
|
25
27
|
title: 'Test Block B',
|
|
@@ -85,6 +85,7 @@ describe( 'selectors', () => {
|
|
|
85
85
|
|
|
86
86
|
beforeEach( () => {
|
|
87
87
|
registerBlockType( 'core/block', {
|
|
88
|
+
apiVersion: 3,
|
|
88
89
|
save: () => null,
|
|
89
90
|
category: 'reusable',
|
|
90
91
|
title: 'Reusable Block Stub',
|
|
@@ -94,6 +95,7 @@ describe( 'selectors', () => {
|
|
|
94
95
|
} );
|
|
95
96
|
|
|
96
97
|
registerBlockType( 'core/test-block-a', {
|
|
98
|
+
apiVersion: 3,
|
|
97
99
|
save: ( props ) => props.attributes.text,
|
|
98
100
|
category: 'design',
|
|
99
101
|
title: 'Test Block A',
|
|
@@ -102,6 +104,7 @@ describe( 'selectors', () => {
|
|
|
102
104
|
} );
|
|
103
105
|
|
|
104
106
|
registerBlockType( 'core/test-block-b', {
|
|
107
|
+
apiVersion: 3,
|
|
105
108
|
save: ( props ) => props.attributes.text,
|
|
106
109
|
category: 'text',
|
|
107
110
|
title: 'Test Block B',
|
|
@@ -113,6 +116,7 @@ describe( 'selectors', () => {
|
|
|
113
116
|
} );
|
|
114
117
|
|
|
115
118
|
registerBlockType( 'core/test-block-c', {
|
|
119
|
+
apiVersion: 3,
|
|
116
120
|
save: ( props ) => props.attributes.text,
|
|
117
121
|
category: 'text',
|
|
118
122
|
title: 'Test Block C',
|
|
@@ -122,6 +126,7 @@ describe( 'selectors', () => {
|
|
|
122
126
|
} );
|
|
123
127
|
|
|
124
128
|
registerBlockType( 'core/freeform', {
|
|
129
|
+
apiVersion: 3,
|
|
125
130
|
save: ( props ) => <RawHTML>{ props.attributes.content }</RawHTML>,
|
|
126
131
|
category: 'text',
|
|
127
132
|
title: 'Test Freeform Content Handler',
|
|
@@ -134,6 +139,7 @@ describe( 'selectors', () => {
|
|
|
134
139
|
} );
|
|
135
140
|
|
|
136
141
|
registerBlockType( 'core/post-content-child', {
|
|
142
|
+
apiVersion: 3,
|
|
137
143
|
save: () => null,
|
|
138
144
|
category: 'text',
|
|
139
145
|
title: 'Test Block Post Content Child',
|
|
@@ -143,6 +149,7 @@ describe( 'selectors', () => {
|
|
|
143
149
|
} );
|
|
144
150
|
|
|
145
151
|
registerBlockType( 'core/test-block-ancestor', {
|
|
152
|
+
apiVersion: 3,
|
|
146
153
|
save: ( props ) => props.attributes.text,
|
|
147
154
|
category: 'text',
|
|
148
155
|
title: 'Test Block required as ancestor',
|
|
@@ -151,6 +158,7 @@ describe( 'selectors', () => {
|
|
|
151
158
|
} );
|
|
152
159
|
|
|
153
160
|
registerBlockType( 'core/test-block-parent', {
|
|
161
|
+
apiVersion: 3,
|
|
154
162
|
save: ( props ) => props.attributes.text,
|
|
155
163
|
category: 'text',
|
|
156
164
|
title: 'Test Block required as parent',
|
|
@@ -159,6 +167,7 @@ describe( 'selectors', () => {
|
|
|
159
167
|
} );
|
|
160
168
|
|
|
161
169
|
registerBlockType( 'core/test-block-requires-ancestor', {
|
|
170
|
+
apiVersion: 3,
|
|
162
171
|
save: ( props ) => props.attributes.text,
|
|
163
172
|
category: 'text',
|
|
164
173
|
title: 'Test Block that requires ancestor',
|
|
@@ -168,6 +177,7 @@ describe( 'selectors', () => {
|
|
|
168
177
|
} );
|
|
169
178
|
|
|
170
179
|
registerBlockType( 'core/test-block-requires-ancestor-parent', {
|
|
180
|
+
apiVersion: 3,
|
|
171
181
|
save: ( props ) => props.attributes.text,
|
|
172
182
|
category: 'text',
|
|
173
183
|
title: 'Test Block that requires both ancestor and parent',
|
|
@@ -3548,6 +3558,7 @@ describe( 'selectors', () => {
|
|
|
3548
3558
|
describe( 'getBlockTransformItems', () => {
|
|
3549
3559
|
beforeAll( () => {
|
|
3550
3560
|
registerBlockType( 'core/with-tranforms-a', {
|
|
3561
|
+
apiVersion: 3,
|
|
3551
3562
|
category: 'text',
|
|
3552
3563
|
title: 'Transforms a',
|
|
3553
3564
|
edit: () => {},
|
|
@@ -3577,6 +3588,7 @@ describe( 'selectors', () => {
|
|
|
3577
3588
|
},
|
|
3578
3589
|
} );
|
|
3579
3590
|
registerBlockType( 'core/with-tranforms-b', {
|
|
3591
|
+
apiVersion: 3,
|
|
3580
3592
|
category: 'text',
|
|
3581
3593
|
title: 'Transforms b',
|
|
3582
3594
|
edit: () => {},
|
|
@@ -3592,6 +3604,7 @@ describe( 'selectors', () => {
|
|
|
3592
3604
|
},
|
|
3593
3605
|
} );
|
|
3594
3606
|
registerBlockType( 'core/with-tranforms-c', {
|
|
3607
|
+
apiVersion: 3,
|
|
3595
3608
|
category: 'text',
|
|
3596
3609
|
title: 'Transforms c',
|
|
3597
3610
|
edit: () => {},
|
|
@@ -4259,18 +4272,21 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
4259
4272
|
// the core blocks (usually by using the `init` action), thus affecting the display order.
|
|
4260
4273
|
beforeEach( () => {
|
|
4261
4274
|
registerBlockType( 'plugin/block-a', {
|
|
4275
|
+
apiVersion: 3,
|
|
4262
4276
|
save() {},
|
|
4263
4277
|
category: 'text',
|
|
4264
4278
|
title: 'Plugin Block A',
|
|
4265
4279
|
icon: 'test',
|
|
4266
4280
|
} );
|
|
4267
4281
|
registerBlockType( 'another-plugin/block-b', {
|
|
4282
|
+
apiVersion: 3,
|
|
4268
4283
|
save() {},
|
|
4269
4284
|
category: 'text',
|
|
4270
4285
|
title: 'Another Plugin Block B',
|
|
4271
4286
|
icon: 'test',
|
|
4272
4287
|
} );
|
|
4273
4288
|
registerBlockType( 'plugin/block-c-with-variations', {
|
|
4289
|
+
apiVersion: 3,
|
|
4274
4290
|
save() {},
|
|
4275
4291
|
category: 'text',
|
|
4276
4292
|
title: 'Plugin Block C with variations',
|
|
@@ -4278,11 +4294,13 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
4278
4294
|
variations: [ { name: 'variation-a' }, { name: 'variation-b' } ],
|
|
4279
4295
|
} );
|
|
4280
4296
|
registerBlockType( 'core/block', {
|
|
4297
|
+
apiVersion: 3,
|
|
4281
4298
|
save() {},
|
|
4282
4299
|
category: 'text',
|
|
4283
4300
|
title: 'Core Block A',
|
|
4284
4301
|
} );
|
|
4285
4302
|
registerBlockType( 'core/test-block-a', {
|
|
4303
|
+
apiVersion: 3,
|
|
4286
4304
|
save: ( props ) => props.attributes.text,
|
|
4287
4305
|
category: 'design',
|
|
4288
4306
|
title: 'Core Block B',
|
|
@@ -4290,6 +4308,7 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
4290
4308
|
keywords: [ 'testing' ],
|
|
4291
4309
|
} );
|
|
4292
4310
|
registerBlockType( 'core/test-block-with-variations', {
|
|
4311
|
+
apiVersion: 3,
|
|
4293
4312
|
save() {},
|
|
4294
4313
|
category: 'text',
|
|
4295
4314
|
title: 'Core Block C with variations',
|
|
@@ -22,7 +22,7 @@ function findOptimalFontSize( textElement, applyFontSize ) {
|
|
|
22
22
|
const paddingRight = parseFloat( computedStyle.paddingRight ) || 0;
|
|
23
23
|
const range = document.createRange();
|
|
24
24
|
range.selectNodeContents( textElement );
|
|
25
|
-
|
|
25
|
+
let maxclientHeight = textElement.clientHeight;
|
|
26
26
|
while ( minSize <= maxSize ) {
|
|
27
27
|
const midSize = Math.floor( ( minSize + maxSize ) / 2 );
|
|
28
28
|
applyFontSize( midSize );
|
|
@@ -41,7 +41,17 @@ function findOptimalFontSize( textElement, applyFontSize ) {
|
|
|
41
41
|
// Check if text fits within the element's height.
|
|
42
42
|
const fitsHeight =
|
|
43
43
|
alreadyHasScrollableHeight ||
|
|
44
|
-
textElement.scrollHeight <= textElement.clientHeight
|
|
44
|
+
textElement.scrollHeight <= textElement.clientHeight ||
|
|
45
|
+
textElement.scrollHeight <= maxclientHeight;
|
|
46
|
+
|
|
47
|
+
// When there are calculated line heights, text may jump in height
|
|
48
|
+
// the available space may decrease while the font size decreases,
|
|
49
|
+
// making text not fit.
|
|
50
|
+
// We store a maximum reference height: the maximum reference element height that was observed
|
|
51
|
+
// during the loop to avoid issues with such jumps.
|
|
52
|
+
if ( textElement.clientHeight > maxclientHeight ) {
|
|
53
|
+
maxclientHeight = textElement.clientHeight;
|
|
54
|
+
}
|
|
45
55
|
|
|
46
56
|
if ( fitsWidth && fitsHeight ) {
|
|
47
57
|
bestSize = midSize;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/block-editor/src/components/block-visibility/block-visibility-info.js
|
|
21
|
-
var block_visibility_info_exports = {};
|
|
22
|
-
__export(block_visibility_info_exports, {
|
|
23
|
-
default: () => BlockVisibilityInfo
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(block_visibility_info_exports);
|
|
26
|
-
var import_components = require("@wordpress/components");
|
|
27
|
-
var import_data = require("@wordpress/data");
|
|
28
|
-
var import_i18n = require("@wordpress/i18n");
|
|
29
|
-
var import_icons = require("@wordpress/icons");
|
|
30
|
-
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
31
|
-
var import_store = require("../../store/index.cjs");
|
|
32
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var { Badge } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
34
|
-
function BlockVisibilityInfo({ clientId }) {
|
|
35
|
-
const { isBlockHidden, hasHiddenParent } = (0, import_data.useSelect)(
|
|
36
|
-
(select) => {
|
|
37
|
-
if (!clientId) {
|
|
38
|
-
return { isBlockHidden: false, hasHiddenParent: false };
|
|
39
|
-
}
|
|
40
|
-
const { isBlockHidden: _isBlockHidden, getBlockParents } = (0, import_lock_unlock.unlock)(
|
|
41
|
-
select(import_store.store)
|
|
42
|
-
);
|
|
43
|
-
const blockHidden = _isBlockHidden(clientId);
|
|
44
|
-
const parents = getBlockParents(clientId);
|
|
45
|
-
const parentHidden = parents.some(
|
|
46
|
-
(parentId) => _isBlockHidden(parentId)
|
|
47
|
-
);
|
|
48
|
-
return {
|
|
49
|
-
isBlockHidden: blockHidden,
|
|
50
|
-
hasHiddenParent: parentHidden
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
[clientId]
|
|
54
|
-
);
|
|
55
|
-
if (!(isBlockHidden || hasHiddenParent)) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, { className: "block-editor-block-visibility-info", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 2, justify: "start", children: [
|
|
59
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: import_icons.unseen }),
|
|
60
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { children: isBlockHidden ? (0, import_i18n.__)("Block is hidden") : (0, import_i18n.__)("Parent block is hidden") })
|
|
61
|
-
] }) });
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=block-visibility-info.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-visibility/block-visibility-info.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { unseen } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as blockEditorStore } from '../../store';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\nexport default function BlockVisibilityInfo( { clientId } ) {\n\tconst { isBlockHidden, hasHiddenParent } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn { isBlockHidden: false, hasHiddenParent: false };\n\t\t\t}\n\t\t\tconst { isBlockHidden: _isBlockHidden, getBlockParents } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\n\t\t\tconst blockHidden = _isBlockHidden( clientId );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\tconst parentHidden = parents.some( ( parentId ) =>\n\t\t\t\t_isBlockHidden( parentId )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tisBlockHidden: blockHidden,\n\t\t\t\thasHiddenParent: parentHidden,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! ( isBlockHidden || hasHiddenParent ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Badge className=\"block-editor-block-visibility-info\">\n\t\t\t<HStack spacing={ 2 } justify=\"start\">\n\t\t\t\t<Icon icon={ unseen } />\n\t\t\t\t<Text>\n\t\t\t\t\t{ isBlockHidden\n\t\t\t\t\t\t? __( 'Block is hidden' )\n\t\t\t\t\t\t: __( 'Parent block is hidden' ) }\n\t\t\t\t</Text>\n\t\t\t</HStack>\n\t\t</Badge>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAKO;AACP,kBAA0B;AAC1B,kBAAmB;AACnB,mBAAuB;AAKvB,yBAAuB;AACvB,mBAA0C;AAkCvC;AAhCH,IAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAEjC,SAAR,oBAAsC,EAAE,SAAS,GAAI;AAC3D,QAAM,EAAE,eAAe,gBAAgB,QAAI;AAAA,IAC1C,CAAE,WAAY;AACb,UAAK,CAAE,UAAW;AACjB,eAAO,EAAE,eAAe,OAAO,iBAAiB,MAAM;AAAA,MACvD;AACA,YAAM,EAAE,eAAe,gBAAgB,gBAAgB,QAAI;AAAA,QAC1D,OAAQ,aAAAC,KAAiB;AAAA,MAC1B;AAEA,YAAM,cAAc,eAAgB,QAAS;AAC7C,YAAM,UAAU,gBAAiB,QAAS;AAC1C,YAAM,eAAe,QAAQ;AAAA,QAAM,CAAE,aACpC,eAAgB,QAAS;AAAA,MAC1B;AAEA,aAAO;AAAA,QACN,eAAe;AAAA,QACf,iBAAiB;AAAA,MAClB;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAK,EAAI,iBAAiB,kBAAoB;AAC7C,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,SAAM,WAAU,sCAChB,uDAAC,kBAAAC,sBAAA,EAAO,SAAU,GAAI,SAAQ,SAC7B;AAAA,gDAAC,0BAAK,MAAO,qBAAS;AAAA,IACtB,4CAAC,kBAAAC,oBAAA,EACE,8BACC,gBAAI,iBAAkB,QACtB,gBAAI,wBAAyB,GACjC;AAAA,KACD,GACD;AAEF;",
|
|
6
|
-
"names": ["componentsPrivateApis", "blockEditorStore", "HStack", "Text"]
|
|
7
|
-
}
|