@wordpress/block-editor 12.5.0 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +0 -4
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +2 -2
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +14 -18
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.native.js +21 -42
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/index.native.js +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +1 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -2
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build/components/block-toolbar/index.js +4 -3
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +62 -3
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/global-styles/color-panel.js +21 -15
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +4 -8
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +13 -23
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +18 -3
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +12 -18
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +6 -6
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +36 -48
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +3 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +2 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +21 -32
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/link-control/index.js +4 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +1 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +65 -31
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +118 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +49 -8
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-setting/index.js +5 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +1 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +7 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +5 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +0 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +19 -8
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +38 -2
- package/build/utils/object.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +2 -2
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +14 -18
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +24 -43
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +3 -3
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +1 -4
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +3 -3
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +4 -3
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +60 -4
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +21 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +4 -8
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +12 -22
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +18 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +13 -18
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +5 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +37 -49
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +3 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +22 -33
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/link-control/index.js +4 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +1 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +66 -33
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +105 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +50 -8
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-setting/index.js +5 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +2 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +5 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +0 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +16 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +34 -2
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +2 -1
- package/build-style/content.css +2 -1
- package/build-style/style-rtl.css +7 -1
- package/build-style/style.css +7 -1
- package/package.json +32 -32
- package/src/components/block-controls/README.md +89 -0
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-draggable/index.native.js +7 -3
- package/src/components/block-draggable/test/index.native.js +0 -54
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- package/src/components/block-list/block-outline.native.js +26 -25
- package/src/components/block-list/block.native.js +24 -38
- package/src/components/block-list/block.native.scss +18 -40
- package/src/components/block-list/style.native.scss +3 -3
- package/src/components/block-mover/index.native.js +3 -3
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +16 -6
- package/src/components/block-removal-warning-modal/index.js +0 -3
- package/src/components/block-settings/button.native.js +12 -6
- package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
- package/src/components/block-toolbar/index.js +2 -3
- package/src/components/block-toolbar/index.native.js +86 -6
- package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
- package/src/components/block-toolbar/test/index.native.js +42 -0
- package/src/components/button-block-appender/styles.native.scss +2 -2
- package/src/components/caption/README.md +49 -0
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/global-styles/color-panel.js +23 -16
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/global-styles/get-block-css-selector.js +5 -9
- package/src/components/global-styles/hooks.js +20 -26
- package/src/components/global-styles/typography-panel.js +17 -5
- package/src/components/global-styles/use-global-styles-output.js +36 -18
- package/src/components/global-styles/utils.js +15 -6
- package/src/components/iframe/index.js +30 -56
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/README.md +10 -0
- package/src/components/inner-blocks/index.js +4 -0
- package/src/components/inner-blocks/index.native.js +4 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
- package/src/components/inserter/index.js +2 -3
- package/src/components/inserter/index.native.js +17 -36
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/inserter/style.native.scss +10 -15
- package/src/components/link-control/index.js +4 -1
- package/src/components/link-control/search-item.js +1 -1
- package/src/components/link-control/style.scss +8 -1
- package/src/components/link-control/test/index.js +26 -0
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/media-placeholder/index.native.js +108 -59
- package/src/components/media-placeholder/styles.native.scss +59 -24
- package/src/components/preview-options/README.md +18 -17
- package/src/components/preview-options/index.js +2 -2
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/get-rich-text-values.js +105 -0
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/text-transform-control/README.md +44 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/components/use-block-drop-zone/index.native.js +65 -28
- package/src/components/use-setting/index.js +8 -8
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/hooks/utils.js +5 -7
- package/src/private-apis.js +7 -1
- package/src/store/actions.js +1 -2
- package/src/store/private-selectors.js +3 -6
- package/src/store/reducer.js +0 -1
- package/src/store/selectors.js +33 -5
- package/src/store/test/actions.js +3 -0
- package/src/store/test/private-selectors.js +5 -5
- package/src/store/test/reducer.js +14 -7
- package/src/store/test/selectors.js +1 -1
- package/src/utils/object.js +32 -2
- package/src/utils/test/object.js +36 -0
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build/components/block-mobile-toolbar/index.native.js +0 -135
- package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
- package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.native.js +0 -127
- package/src/components/block-mobile-toolbar/style.native.scss +0 -16
- /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
within,
|
|
10
10
|
getEditorHtml,
|
|
11
11
|
typeInRichText,
|
|
12
|
+
openBlockActionsMenu,
|
|
12
13
|
} from 'test/helpers';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -36,15 +37,14 @@ describe( 'Block Actions Menu', () => {
|
|
|
36
37
|
<p></p>
|
|
37
38
|
<!-- /wp:paragraph -->`,
|
|
38
39
|
} );
|
|
39
|
-
const {
|
|
40
|
+
const { getByRole } = screen;
|
|
40
41
|
|
|
41
42
|
// Get block
|
|
42
43
|
const paragraphBlock = await getBlock( screen, 'Paragraph' );
|
|
43
44
|
fireEvent.press( paragraphBlock );
|
|
44
45
|
|
|
45
46
|
// Open block actions menu
|
|
46
|
-
|
|
47
|
-
fireEvent.press( blockActionsButton );
|
|
47
|
+
await openBlockActionsMenu( screen );
|
|
48
48
|
|
|
49
49
|
// Get Picker title
|
|
50
50
|
const pickerHeader = getByRole( 'header' );
|
|
@@ -56,10 +56,8 @@ describe( 'Block Actions Menu', () => {
|
|
|
56
56
|
|
|
57
57
|
describe( 'moving blocks', () => {
|
|
58
58
|
it( 'moves blocks up and down', async () => {
|
|
59
|
-
const screen = await initializeEditor(
|
|
60
|
-
|
|
61
|
-
} );
|
|
62
|
-
const { getByLabelText, getByTestId } = screen;
|
|
59
|
+
const screen = await initializeEditor();
|
|
60
|
+
const { getByLabelText } = screen;
|
|
63
61
|
|
|
64
62
|
// Add Paragraph block
|
|
65
63
|
await addBlock( screen, 'Paragraph' );
|
|
@@ -85,16 +83,8 @@ describe( 'Block Actions Menu', () => {
|
|
|
85
83
|
} );
|
|
86
84
|
fireEvent.press( spacerBlock );
|
|
87
85
|
|
|
88
|
-
// Open block actions menu
|
|
89
|
-
fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
|
|
90
|
-
|
|
91
|
-
// Get block actions modal
|
|
92
|
-
let blockActionsMenu = await getByTestId( 'block-actions-menu' );
|
|
93
|
-
|
|
94
86
|
// Tap on the Move Down button
|
|
95
|
-
fireEvent.press(
|
|
96
|
-
within( blockActionsMenu ).getByLabelText( 'Move block down' )
|
|
97
|
-
);
|
|
87
|
+
fireEvent.press( getByLabelText( /Move block down/ ) );
|
|
98
88
|
|
|
99
89
|
// Get Heading block
|
|
100
90
|
const headingBlock = await getBlock( screen, 'Heading', {
|
|
@@ -102,25 +92,15 @@ describe( 'Block Actions Menu', () => {
|
|
|
102
92
|
} );
|
|
103
93
|
fireEvent.press( headingBlock );
|
|
104
94
|
|
|
105
|
-
// Open block actions menu
|
|
106
|
-
fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
|
|
107
|
-
|
|
108
|
-
// Get block actions modal
|
|
109
|
-
blockActionsMenu = await getByTestId( 'block-actions-menu' );
|
|
110
|
-
|
|
111
95
|
// Tap on the Move Up button
|
|
112
|
-
fireEvent.press(
|
|
113
|
-
within( blockActionsMenu ).getByLabelText( 'Move block up' )
|
|
114
|
-
);
|
|
96
|
+
fireEvent.press( getByLabelText( /Move block up/ ) );
|
|
115
97
|
|
|
116
98
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
117
99
|
} );
|
|
118
100
|
|
|
119
101
|
it( 'disables the Move Up button for the first block', async () => {
|
|
120
|
-
const screen = await initializeEditor(
|
|
121
|
-
|
|
122
|
-
} );
|
|
123
|
-
const { getByLabelText, getByTestId } = screen;
|
|
102
|
+
const screen = await initializeEditor();
|
|
103
|
+
const { getByLabelText } = screen;
|
|
124
104
|
|
|
125
105
|
// Add Paragraph block
|
|
126
106
|
await addBlock( screen, 'Paragraph' );
|
|
@@ -144,15 +124,8 @@ describe( 'Block Actions Menu', () => {
|
|
|
144
124
|
paragraphBlock = await getBlock( screen, 'Paragraph' );
|
|
145
125
|
fireEvent.press( paragraphBlock );
|
|
146
126
|
|
|
147
|
-
// Open block actions menu
|
|
148
|
-
fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
|
|
149
|
-
|
|
150
|
-
// Get block actions modal
|
|
151
|
-
const blockActionsMenu = await getByTestId( 'block-actions-menu' );
|
|
152
|
-
|
|
153
127
|
// Get the Move Up button
|
|
154
|
-
const upButton =
|
|
155
|
-
within( blockActionsMenu ).getByLabelText( 'Move block up' );
|
|
128
|
+
const upButton = getByLabelText( /Move block up/ );
|
|
156
129
|
const isUpButtonDisabled =
|
|
157
130
|
upButton.props.accessibilityState?.disabled;
|
|
158
131
|
expect( isUpButtonDisabled ).toBe( true );
|
|
@@ -167,7 +140,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
167
140
|
const screen = await initializeEditor( {
|
|
168
141
|
screenWidth: 100,
|
|
169
142
|
} );
|
|
170
|
-
const { getByLabelText
|
|
143
|
+
const { getByLabelText } = screen;
|
|
171
144
|
|
|
172
145
|
// Add Paragraph block
|
|
173
146
|
await addBlock( screen, 'Paragraph' );
|
|
@@ -193,15 +166,8 @@ describe( 'Block Actions Menu', () => {
|
|
|
193
166
|
} );
|
|
194
167
|
fireEvent.press( headingBlock );
|
|
195
168
|
|
|
196
|
-
// Open block actions menu
|
|
197
|
-
fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
|
|
198
|
-
|
|
199
|
-
// Get block actions modal
|
|
200
|
-
const blockActionsMenu = await getByTestId( 'block-actions-menu' );
|
|
201
|
-
|
|
202
169
|
// Get the Move Down button
|
|
203
|
-
const downButton =
|
|
204
|
-
within( blockActionsMenu ).getByLabelText( 'Move block down' );
|
|
170
|
+
const downButton = getByLabelText( /Move block down/ );
|
|
205
171
|
const isDownButtonDisabled =
|
|
206
172
|
downButton.props.accessibilityState?.disabled;
|
|
207
173
|
expect( isDownButtonDisabled ).toBe( true );
|
|
@@ -243,7 +209,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
243
209
|
fireEvent.press( headingBlock );
|
|
244
210
|
|
|
245
211
|
// Open block actions menu
|
|
246
|
-
|
|
212
|
+
await openBlockActionsMenu( screen );
|
|
247
213
|
|
|
248
214
|
// Tap on the Copy button
|
|
249
215
|
fireEvent.press( getByLabelText( /Copy/ ) );
|
|
@@ -253,7 +219,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
253
219
|
fireEvent.press( paragraphBlock );
|
|
254
220
|
|
|
255
221
|
// Open block actions menu
|
|
256
|
-
|
|
222
|
+
await openBlockActionsMenu( screen );
|
|
257
223
|
|
|
258
224
|
// Tap on the Paste block after button
|
|
259
225
|
fireEvent.press( getByLabelText( /Paste block after/ ) );
|
|
@@ -290,7 +256,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
290
256
|
fireEvent.press( headingBlock );
|
|
291
257
|
|
|
292
258
|
// Open block actions menu
|
|
293
|
-
|
|
259
|
+
await openBlockActionsMenu( screen );
|
|
294
260
|
|
|
295
261
|
// Tap on the Copy button
|
|
296
262
|
fireEvent.press( getByLabelText( /Copy/ ) );
|
|
@@ -300,7 +266,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
300
266
|
fireEvent.press( paragraphBlock );
|
|
301
267
|
|
|
302
268
|
// Open block actions menu
|
|
303
|
-
|
|
269
|
+
await openBlockActionsMenu( screen );
|
|
304
270
|
|
|
305
271
|
// Tap on the Past block after button
|
|
306
272
|
fireEvent.press( getByLabelText( /Paste block after/ ) );
|
|
@@ -335,7 +301,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
335
301
|
fireEvent.press( paragraphBlock );
|
|
336
302
|
|
|
337
303
|
// Open block actions menu
|
|
338
|
-
|
|
304
|
+
await openBlockActionsMenu( screen );
|
|
339
305
|
|
|
340
306
|
// Tap on the Cut button
|
|
341
307
|
fireEvent.press( getByLabelText( /Cut block/ ) );
|
|
@@ -346,7 +312,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
346
312
|
fireEvent.press( headingBlock );
|
|
347
313
|
|
|
348
314
|
// Open block actions menu
|
|
349
|
-
|
|
315
|
+
await openBlockActionsMenu( screen );
|
|
350
316
|
|
|
351
317
|
// Tap on the Cut button
|
|
352
318
|
fireEvent.press( getByLabelText( /Paste block after/ ) );
|
|
@@ -383,7 +349,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
383
349
|
fireEvent.press( spacerBlock );
|
|
384
350
|
|
|
385
351
|
// Open block actions menu
|
|
386
|
-
|
|
352
|
+
await openBlockActionsMenu( screen );
|
|
387
353
|
|
|
388
354
|
// Tap on the Duplicate button
|
|
389
355
|
fireEvent.press( getByLabelText( /Duplicate block/ ) );
|
|
@@ -418,7 +384,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
418
384
|
fireEvent.press( paragraphBlock );
|
|
419
385
|
|
|
420
386
|
// Open block actions menu
|
|
421
|
-
|
|
387
|
+
await openBlockActionsMenu( screen );
|
|
422
388
|
|
|
423
389
|
// Tap on the Transform block button
|
|
424
390
|
fireEvent.press( getByLabelText( /Transform block…/ ) );
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
addBlock,
|
|
6
|
+
fireEvent,
|
|
7
|
+
getBlock,
|
|
8
|
+
initializeEditor,
|
|
9
|
+
setupCoreBlocks,
|
|
10
|
+
} from 'test/helpers';
|
|
11
|
+
|
|
12
|
+
setupCoreBlocks();
|
|
13
|
+
|
|
14
|
+
describe( 'Block Toolbar', () => {
|
|
15
|
+
it( "doesn't render the block settings button if there aren't any settings for the current selected block", async () => {
|
|
16
|
+
// Arrange
|
|
17
|
+
const screen = await initializeEditor();
|
|
18
|
+
await addBlock( screen, 'Image' );
|
|
19
|
+
|
|
20
|
+
// Act
|
|
21
|
+
fireEvent(
|
|
22
|
+
screen.getByTestId( 'media-options-picker' ),
|
|
23
|
+
'backdropPress'
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Assert
|
|
27
|
+
expect( screen.queryByLabelText( 'Open Settings' ) ).toBeNull();
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
it( 'renders the block settings button for the current selected block', async () => {
|
|
31
|
+
// Arrange
|
|
32
|
+
const screen = await initializeEditor();
|
|
33
|
+
await addBlock( screen, 'Paragraph' );
|
|
34
|
+
|
|
35
|
+
// Act
|
|
36
|
+
const paragraphBlock = await getBlock( screen, 'Paragraph' );
|
|
37
|
+
fireEvent.press( paragraphBlock );
|
|
38
|
+
|
|
39
|
+
// Assert
|
|
40
|
+
expect( screen.queryByLabelText( 'Open Settings' ) ).toBeVisible();
|
|
41
|
+
} );
|
|
42
|
+
} );
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
## Caption
|
|
2
|
+
|
|
3
|
+
The `Caption` component renders the [caption part](https://wordpress.org/documentation/article/gallery-block/#caption) of some blocks (image, gallery...).
|
|
4
|
+
|
|
5
|
+
This component encapsulates the "caption" behaviour and styles over a `<RichText>` so it can be used in other components such as the `BlockCaption` component.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
1. [Development guidelines](#development-guidelines)
|
|
10
|
+
2. [Related components](#related-components)
|
|
11
|
+
|
|
12
|
+
## Development guidelines
|
|
13
|
+
|
|
14
|
+
### Usage
|
|
15
|
+
|
|
16
|
+
Renders a Caption area:
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import { Caption } from '@wordpress/block-editor';
|
|
20
|
+
const BlockCaption = ( {
|
|
21
|
+
onBlur,
|
|
22
|
+
onChange,
|
|
23
|
+
onFocus,
|
|
24
|
+
isSelected,
|
|
25
|
+
shouldDisplay,
|
|
26
|
+
text,
|
|
27
|
+
insertBlocksAfter,
|
|
28
|
+
} ) => (
|
|
29
|
+
<View >
|
|
30
|
+
<Caption
|
|
31
|
+
isSelected={ isSelected }
|
|
32
|
+
onBlur={ onBlur }
|
|
33
|
+
onChange={ onChange }
|
|
34
|
+
onFocus={ onFocus }
|
|
35
|
+
shouldDisplay={ shouldDisplay }
|
|
36
|
+
value={ text }
|
|
37
|
+
insertBlocksAfter={ insertBlocksAfter }
|
|
38
|
+
/>
|
|
39
|
+
</View>
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Props
|
|
44
|
+
|
|
45
|
+
The properties `isSelected`, `onBlur`, `onChange`, `onFocus`, `shouldDisplay`, `value`, `insertBlocksAfter` of this component are passed directly to their related props of its inner `<RichText>` component ([see detailed info about the RichText component's props](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md)).
|
|
46
|
+
|
|
47
|
+
## Related components
|
|
48
|
+
|
|
49
|
+
Caption components is mostly used by the [`BlockCaption`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-caption) component.
|
|
@@ -6,6 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
9
10
|
import {
|
|
10
11
|
BaseControl,
|
|
11
12
|
__experimentalVStack as VStack,
|
|
@@ -28,12 +29,12 @@ const colorsAndGradientKeys = [
|
|
|
28
29
|
|
|
29
30
|
const TAB_COLOR = {
|
|
30
31
|
name: 'color',
|
|
31
|
-
title: 'Solid',
|
|
32
|
+
title: __( 'Solid' ),
|
|
32
33
|
value: 'color',
|
|
33
34
|
};
|
|
34
35
|
const TAB_GRADIENT = {
|
|
35
36
|
name: 'gradient',
|
|
36
|
-
title: 'Gradient',
|
|
37
|
+
title: __( 'Gradient' ),
|
|
37
38
|
value: 'gradient',
|
|
38
39
|
};
|
|
39
40
|
|
|
@@ -328,22 +328,6 @@ export default function ColorPanel( {
|
|
|
328
328
|
: gradientValue;
|
|
329
329
|
};
|
|
330
330
|
|
|
331
|
-
// Text Color
|
|
332
|
-
const showTextPanel = useHasTextPanel( settings );
|
|
333
|
-
const textColor = decodeValue( inheritedValue?.color?.text );
|
|
334
|
-
const userTextColor = decodeValue( value?.color?.text );
|
|
335
|
-
const hasTextColor = () => !! userTextColor;
|
|
336
|
-
const setTextColor = ( newColor ) => {
|
|
337
|
-
onChange(
|
|
338
|
-
setImmutably(
|
|
339
|
-
value,
|
|
340
|
-
[ 'color', 'text' ],
|
|
341
|
-
encodeColorValue( newColor )
|
|
342
|
-
)
|
|
343
|
-
);
|
|
344
|
-
};
|
|
345
|
-
const resetTextColor = () => setTextColor( undefined );
|
|
346
|
-
|
|
347
331
|
// BackgroundColor
|
|
348
332
|
const showBackgroundPanel = useHasBackgroundPanel( settings );
|
|
349
333
|
const backgroundColor = decodeValue( inheritedValue?.color?.background );
|
|
@@ -424,6 +408,29 @@ export default function ColorPanel( {
|
|
|
424
408
|
onChange( newValue );
|
|
425
409
|
};
|
|
426
410
|
|
|
411
|
+
// Text Color
|
|
412
|
+
const showTextPanel = useHasTextPanel( settings );
|
|
413
|
+
const textColor = decodeValue( inheritedValue?.color?.text );
|
|
414
|
+
const userTextColor = decodeValue( value?.color?.text );
|
|
415
|
+
const hasTextColor = () => !! userTextColor;
|
|
416
|
+
const setTextColor = ( newColor ) => {
|
|
417
|
+
let changedObject = setImmutably(
|
|
418
|
+
value,
|
|
419
|
+
[ 'color', 'text' ],
|
|
420
|
+
encodeColorValue( newColor )
|
|
421
|
+
);
|
|
422
|
+
if ( textColor === linkColor ) {
|
|
423
|
+
changedObject = setImmutably(
|
|
424
|
+
changedObject,
|
|
425
|
+
[ 'elements', 'link', 'color', 'text' ],
|
|
426
|
+
encodeColorValue( newColor )
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
onChange( changedObject );
|
|
431
|
+
};
|
|
432
|
+
const resetTextColor = () => setTextColor( undefined );
|
|
433
|
+
|
|
427
434
|
// Elements
|
|
428
435
|
const elements = [
|
|
429
436
|
{
|
|
@@ -207,18 +207,24 @@ export default function DimensionsPanel( {
|
|
|
207
207
|
// in global styles but not in block inspector.
|
|
208
208
|
includeLayoutControls = false,
|
|
209
209
|
} ) {
|
|
210
|
+
const { dimensions, spacing } = settings;
|
|
211
|
+
|
|
210
212
|
const decodeValue = ( rawValue ) => {
|
|
211
213
|
if ( rawValue && typeof rawValue === 'object' ) {
|
|
212
214
|
return Object.keys( rawValue ).reduce( ( acc, key ) => {
|
|
213
215
|
acc[ key ] = getValueFromVariable(
|
|
214
|
-
{ settings },
|
|
216
|
+
{ settings: { dimensions, spacing } },
|
|
215
217
|
'',
|
|
216
218
|
rawValue[ key ]
|
|
217
219
|
);
|
|
218
220
|
return acc;
|
|
219
221
|
}, {} );
|
|
220
222
|
}
|
|
221
|
-
return getValueFromVariable(
|
|
223
|
+
return getValueFromVariable(
|
|
224
|
+
{ settings: { dimensions, spacing } },
|
|
225
|
+
'',
|
|
226
|
+
rawValue
|
|
227
|
+
);
|
|
222
228
|
};
|
|
223
229
|
|
|
224
230
|
const showSpacingPresetsControl = useHasSpacingPresets( settings );
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { scopeSelector } from './utils';
|
|
5
|
+
import { getValueFromObjectPath } from '../../utils/object';
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Determine the CSS selector for the block type and target provided, returning
|
|
@@ -69,15 +65,15 @@ export function getBlockCSSSelector(
|
|
|
69
65
|
if ( hasSelectors ) {
|
|
70
66
|
// Get selector from either `feature.root` or shorthand path.
|
|
71
67
|
const featureSelector =
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
getValueFromObjectPath( selectors, `${ path }.root`, null ) ||
|
|
69
|
+
getValueFromObjectPath( selectors, path, null );
|
|
74
70
|
|
|
75
71
|
// Return feature selector if found or any available fallback.
|
|
76
72
|
return featureSelector || fallbackSelector;
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
// Try getting old experimental supports selector value.
|
|
80
|
-
const featureSelector =
|
|
76
|
+
const featureSelector = getValueFromObjectPath(
|
|
81
77
|
supports,
|
|
82
78
|
`${ path }.__experimentalSelector`,
|
|
83
79
|
null
|
|
@@ -98,7 +94,7 @@ export function getBlockCSSSelector(
|
|
|
98
94
|
|
|
99
95
|
// Use selectors API if available.
|
|
100
96
|
if ( hasSelectors ) {
|
|
101
|
-
subfeatureSelector =
|
|
97
|
+
subfeatureSelector = getValueFromObjectPath( selectors, path, null );
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
// Only return if we have a subfeature selector.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
-
import { get, set } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -16,6 +15,7 @@ import { _x } from '@wordpress/i18n';
|
|
|
16
15
|
* Internal dependencies
|
|
17
16
|
*/
|
|
18
17
|
import { getValueFromVariable, getPresetVariableFromValue } from './utils';
|
|
18
|
+
import { getValueFromObjectPath, setImmutably } from '../../utils/object';
|
|
19
19
|
import { GlobalStylesContext } from './context';
|
|
20
20
|
import { unlock } from '../../lock-unlock';
|
|
21
21
|
|
|
@@ -103,20 +103,21 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
|
103
103
|
|
|
104
104
|
if ( propertyPath ) {
|
|
105
105
|
return (
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
getValueFromObjectPath( configToUse, contextualPath ) ??
|
|
107
|
+
getValueFromObjectPath( configToUse, globalPath )
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
let result = {};
|
|
112
112
|
VALID_SETTINGS.forEach( ( setting ) => {
|
|
113
113
|
const value =
|
|
114
|
-
|
|
114
|
+
getValueFromObjectPath(
|
|
115
115
|
configToUse,
|
|
116
116
|
`settings${ appendedBlockPath }.${ setting }`
|
|
117
|
-
) ??
|
|
117
|
+
) ??
|
|
118
|
+
getValueFromObjectPath( configToUse, `settings.${ setting }` );
|
|
118
119
|
if ( value ) {
|
|
119
|
-
|
|
120
|
+
result = setImmutably( result, setting.split( '.' ), value );
|
|
120
121
|
}
|
|
121
122
|
} );
|
|
122
123
|
return result;
|
|
@@ -130,13 +131,9 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
|
130
131
|
] );
|
|
131
132
|
|
|
132
133
|
const setSetting = ( newValue ) => {
|
|
133
|
-
setUserConfig( ( currentConfig ) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
set( newUserConfig, contextualPath, newValue );
|
|
137
|
-
|
|
138
|
-
return newUserConfig;
|
|
139
|
-
} );
|
|
134
|
+
setUserConfig( ( currentConfig ) =>
|
|
135
|
+
setImmutably( currentConfig, contextualPath.split( '.' ), newValue )
|
|
136
|
+
);
|
|
140
137
|
};
|
|
141
138
|
|
|
142
139
|
return [ settingValue, setSetting ];
|
|
@@ -160,12 +157,10 @@ export function useGlobalStyle(
|
|
|
160
157
|
: `styles.blocks.${ blockName }${ appendedPath }`;
|
|
161
158
|
|
|
162
159
|
const setStyle = ( newValue ) => {
|
|
163
|
-
setUserConfig( ( currentConfig ) =>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
newUserConfig,
|
|
168
|
-
finalPath,
|
|
160
|
+
setUserConfig( ( currentConfig ) =>
|
|
161
|
+
setImmutably(
|
|
162
|
+
currentConfig,
|
|
163
|
+
finalPath.split( '.' ),
|
|
169
164
|
shouldDecodeEncode
|
|
170
165
|
? getPresetVariableFromValue(
|
|
171
166
|
mergedConfig.settings,
|
|
@@ -174,27 +169,26 @@ export function useGlobalStyle(
|
|
|
174
169
|
newValue
|
|
175
170
|
)
|
|
176
171
|
: newValue
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
} );
|
|
172
|
+
)
|
|
173
|
+
);
|
|
180
174
|
};
|
|
181
175
|
|
|
182
176
|
let rawResult, result;
|
|
183
177
|
switch ( source ) {
|
|
184
178
|
case 'all':
|
|
185
|
-
rawResult =
|
|
179
|
+
rawResult = getValueFromObjectPath( mergedConfig, finalPath );
|
|
186
180
|
result = shouldDecodeEncode
|
|
187
181
|
? getValueFromVariable( mergedConfig, blockName, rawResult )
|
|
188
182
|
: rawResult;
|
|
189
183
|
break;
|
|
190
184
|
case 'user':
|
|
191
|
-
rawResult =
|
|
185
|
+
rawResult = getValueFromObjectPath( userConfig, finalPath );
|
|
192
186
|
result = shouldDecodeEncode
|
|
193
187
|
? getValueFromVariable( mergedConfig, blockName, rawResult )
|
|
194
188
|
: rawResult;
|
|
195
189
|
break;
|
|
196
190
|
case 'base':
|
|
197
|
-
rawResult =
|
|
191
|
+
rawResult = getValueFromObjectPath( baseConfig, finalPath );
|
|
198
192
|
result = shouldDecodeEncode
|
|
199
193
|
? getValueFromVariable( baseConfig, blockName, rawResult )
|
|
200
194
|
: rawResult;
|
|
@@ -114,6 +114,21 @@ function useHasTextColumnsControl( settings ) {
|
|
|
114
114
|
return settings?.typography?.textColumns;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
function getUniqueFontSizesBySlug( settings ) {
|
|
118
|
+
const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
|
|
119
|
+
const fontSizes = []
|
|
120
|
+
.concat( fontSizesPerOrigin?.custom ?? [] )
|
|
121
|
+
.concat( fontSizesPerOrigin?.theme ?? [] )
|
|
122
|
+
.concat( fontSizesPerOrigin.default ?? [] );
|
|
123
|
+
|
|
124
|
+
return fontSizes.reduce( ( acc, currentSize ) => {
|
|
125
|
+
if ( ! acc.some( ( { slug } ) => slug === currentSize.slug ) ) {
|
|
126
|
+
acc.push( currentSize );
|
|
127
|
+
}
|
|
128
|
+
return acc;
|
|
129
|
+
}, [] );
|
|
130
|
+
}
|
|
131
|
+
|
|
117
132
|
function TypographyToolsPanel( {
|
|
118
133
|
resetAllFilter,
|
|
119
134
|
onChange,
|
|
@@ -189,11 +204,8 @@ export default function TypographyPanel( {
|
|
|
189
204
|
// Font Size
|
|
190
205
|
const hasFontSizeEnabled = useHasFontSizeControl( settings );
|
|
191
206
|
const disableCustomFontSizes = ! settings?.typography?.customFontSize;
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
.concat( fontSizesPerOrigin?.custom ?? [] )
|
|
195
|
-
.concat( fontSizesPerOrigin?.theme ?? [] )
|
|
196
|
-
.concat( fontSizesPerOrigin.default ?? [] );
|
|
207
|
+
const fontSizes = getUniqueFontSizesBySlug( settings );
|
|
208
|
+
|
|
197
209
|
const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
|
|
198
210
|
const setFontSize = ( newValue, metadata ) => {
|
|
199
211
|
const actualValue = !! metadata?.slug
|