@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
|
@@ -113,8 +113,10 @@ export function focusListItem( focusClientId, treeGridElement ) {
|
|
|
113
113
|
resolve( null );
|
|
114
114
|
}, 3000 );
|
|
115
115
|
} ).then( ( element ) => {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
if ( element && element.isConnected ) {
|
|
117
|
+
// Focus the first focusable in the row, which is the ListViewBlockSelectButton.
|
|
118
|
+
focus.focusable.find( element )?.[ 0 ]?.focus();
|
|
119
|
+
}
|
|
118
120
|
} );
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -8,7 +8,7 @@ import userEvent from '@testing-library/user-event';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { useState } from '@wordpress/element';
|
|
11
|
-
|
|
11
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
@@ -19,16 +19,18 @@ const noop = () => {};
|
|
|
19
19
|
function TestWrapper() {
|
|
20
20
|
const [ mediaURL, setMediaURL ] = useState( 'https://example.media' );
|
|
21
21
|
return (
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
<SlotFillProvider>
|
|
23
|
+
<MediaReplaceFlow
|
|
24
|
+
mediaId={ 1 }
|
|
25
|
+
mediaURL={ mediaURL }
|
|
26
|
+
allowedTypes={ [ 'png' ] }
|
|
27
|
+
accept="image/*"
|
|
28
|
+
onSelect={ noop }
|
|
29
|
+
onSelectURL={ setMediaURL }
|
|
30
|
+
onError={ noop }
|
|
31
|
+
onCloseModal={ noop }
|
|
32
|
+
/>
|
|
33
|
+
</SlotFillProvider>
|
|
32
34
|
);
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -71,18 +71,19 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(
|
|
|
71
71
|
|
|
72
72
|
const mediaUploadSettings = useMediaUploadSettings( _settings );
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
const settings = useMemo( () => {
|
|
75
|
+
if (
|
|
76
|
+
window.__experimentalMediaProcessing &&
|
|
77
|
+
_settings?.mediaUpload
|
|
78
|
+
) {
|
|
79
|
+
// Create a new object so that the original props.settings.mediaUpload is not modified.
|
|
80
|
+
return {
|
|
80
81
|
..._settings,
|
|
81
82
|
mediaUpload: mediaUpload.bind( null, registry ),
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return _settings;
|
|
86
|
+
}, [ _settings, registry ] );
|
|
86
87
|
|
|
87
88
|
const { __experimentalUpdateSettings } = unlock(
|
|
88
89
|
useDispatch( blockEditorStore )
|
|
@@ -26,7 +26,7 @@ function getSubRegistry( subRegistries, registry, useSubRegistry ) {
|
|
|
26
26
|
|
|
27
27
|
const withRegistryProvider = createHigherOrderComponent(
|
|
28
28
|
( WrappedComponent ) =>
|
|
29
|
-
( { useSubRegistry = true, ...props } )
|
|
29
|
+
function WithRegistryProvider( { useSubRegistry = true, ...props } ) {
|
|
30
30
|
const registry = useRegistry();
|
|
31
31
|
const [ subRegistries ] = useState( () => new WeakMap() );
|
|
32
32
|
const subRegistry = getSubRegistry(
|
|
@@ -16,8 +16,6 @@ import {
|
|
|
16
16
|
plus as add,
|
|
17
17
|
group,
|
|
18
18
|
ungroup,
|
|
19
|
-
seen,
|
|
20
|
-
unseen,
|
|
21
19
|
} from '@wordpress/icons';
|
|
22
20
|
|
|
23
21
|
/**
|
|
@@ -25,7 +23,6 @@ import {
|
|
|
25
23
|
*/
|
|
26
24
|
import BlockIcon from '../block-icon';
|
|
27
25
|
import { store as blockEditorStore } from '../../store';
|
|
28
|
-
import { cleanEmptyObject } from '../../hooks/utils';
|
|
29
26
|
|
|
30
27
|
const getTransformCommands = () =>
|
|
31
28
|
function useTransformCommands() {
|
|
@@ -160,7 +157,6 @@ const getQuickActionsCommands = () =>
|
|
|
160
157
|
getBlockRootClientId,
|
|
161
158
|
getBlocksByClientId,
|
|
162
159
|
canRemoveBlocks,
|
|
163
|
-
getBlockName,
|
|
164
160
|
} = useSelect( blockEditorStore );
|
|
165
161
|
const { getDefaultBlockName, getGroupingBlockName } =
|
|
166
162
|
useSelect( blocksStore );
|
|
@@ -173,7 +169,6 @@ const getQuickActionsCommands = () =>
|
|
|
173
169
|
duplicateBlocks,
|
|
174
170
|
insertAfterBlock,
|
|
175
171
|
insertBeforeBlock,
|
|
176
|
-
updateBlockAttributes,
|
|
177
172
|
} = useDispatch( blockEditorStore );
|
|
178
173
|
|
|
179
174
|
const onGroup = () => {
|
|
@@ -223,11 +218,6 @@ const getQuickActionsCommands = () =>
|
|
|
223
218
|
} );
|
|
224
219
|
const canRemove = canRemoveBlocks( clientIds );
|
|
225
220
|
|
|
226
|
-
const canToggleBlockVisibility =
|
|
227
|
-
blocks.every( ( { clientId } ) =>
|
|
228
|
-
hasBlockSupport( getBlockName( clientId ), 'visibility', true )
|
|
229
|
-
) && ! window.__experimentalHideBlocksBasedOnScreenSize;
|
|
230
|
-
|
|
231
221
|
const commands = [];
|
|
232
222
|
|
|
233
223
|
if ( canDuplicate ) {
|
|
@@ -293,37 +283,6 @@ const getQuickActionsCommands = () =>
|
|
|
293
283
|
} );
|
|
294
284
|
}
|
|
295
285
|
|
|
296
|
-
if ( canToggleBlockVisibility ) {
|
|
297
|
-
const hasHiddenBlock = blocks.some(
|
|
298
|
-
( block ) =>
|
|
299
|
-
block.attributes.metadata?.blockVisibility === false
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
commands.push( {
|
|
303
|
-
name: 'core/toggle-block-visibility',
|
|
304
|
-
label: hasHiddenBlock ? __( 'Show' ) : __( 'Hide' ),
|
|
305
|
-
callback: () => {
|
|
306
|
-
const attributesByClientId = Object.fromEntries(
|
|
307
|
-
blocks?.map( ( { clientId, attributes } ) => [
|
|
308
|
-
clientId,
|
|
309
|
-
{
|
|
310
|
-
metadata: cleanEmptyObject( {
|
|
311
|
-
...attributes?.metadata,
|
|
312
|
-
blockVisibility: hasHiddenBlock
|
|
313
|
-
? undefined
|
|
314
|
-
: false,
|
|
315
|
-
} ),
|
|
316
|
-
},
|
|
317
|
-
] )
|
|
318
|
-
);
|
|
319
|
-
updateBlockAttributes( clientIds, attributesByClientId, {
|
|
320
|
-
uniqueByBlock: true,
|
|
321
|
-
} );
|
|
322
|
-
},
|
|
323
|
-
icon: hasHiddenBlock ? seen : unseen,
|
|
324
|
-
} );
|
|
325
|
-
}
|
|
326
|
-
|
|
327
286
|
return {
|
|
328
287
|
isLoading: false,
|
|
329
288
|
commands: commands.map( ( command ) => ( {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
privateApis as blocksPrivateApis,
|
|
6
|
+
getBlockType,
|
|
7
|
+
} from '@wordpress/blocks';
|
|
6
8
|
import {
|
|
7
9
|
__experimentalHStack as HStack,
|
|
8
10
|
__experimentalTruncate as Truncate,
|
|
9
11
|
} from '@wordpress/components';
|
|
10
|
-
import {
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
11
13
|
import { DataForm } from '@wordpress/dataviews';
|
|
12
14
|
import { useContext, useState, useMemo } from '@wordpress/element';
|
|
13
15
|
import { __ } from '@wordpress/i18n';
|
|
@@ -15,6 +17,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
15
17
|
/**
|
|
16
18
|
* Internal dependencies
|
|
17
19
|
*/
|
|
20
|
+
import { store as blockEditorStore } from '../../store';
|
|
18
21
|
import { unlock } from '../../lock-unlock';
|
|
19
22
|
import BlockIcon from '../../components/block-icon';
|
|
20
23
|
import useBlockDisplayTitle from '../../components/block-title/use-block-display-title';
|
|
@@ -22,34 +25,23 @@ import useBlockDisplayInformation from '../../components/use-block-display-infor
|
|
|
22
25
|
const { fieldsKey, formKey } = unlock( blocksPrivateApis );
|
|
23
26
|
import FieldsDropdownMenu from './fields-dropdown-menu';
|
|
24
27
|
import { PrivateBlockContext } from '../../components/block-list/private-block-context';
|
|
25
|
-
import
|
|
28
|
+
import InspectorControls from '../../components/inspector-controls/fill';
|
|
26
29
|
|
|
27
30
|
// controls
|
|
28
31
|
import RichText from './rich-text';
|
|
29
32
|
import Media from './media';
|
|
30
33
|
import Link from './link';
|
|
31
34
|
|
|
32
|
-
const CONTROLS = {
|
|
33
|
-
richtext: RichText,
|
|
34
|
-
media: Media,
|
|
35
|
-
link: Link,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
35
|
/**
|
|
39
36
|
* Creates a configured control component that wraps a custom control
|
|
40
37
|
* and passes configuration as props.
|
|
41
38
|
*
|
|
42
39
|
* @param {Component} ControlComponent The React component for the control.
|
|
43
|
-
* @param {string} type The type of control.
|
|
44
40
|
* @param {Object} config The control configuration passed as a prop.
|
|
45
41
|
*
|
|
46
42
|
* @return {Function} A wrapped control component
|
|
47
43
|
*/
|
|
48
|
-
function createConfiguredControl( ControlComponent,
|
|
49
|
-
if ( ! ControlComponent ) {
|
|
50
|
-
throw new Error( `Control type "${ type }" not found` );
|
|
51
|
-
}
|
|
52
|
-
|
|
44
|
+
function createConfiguredControl( ControlComponent, config = {} ) {
|
|
53
45
|
return function ConfiguredControl( props ) {
|
|
54
46
|
return <ControlComponent { ...props } config={ config } />;
|
|
55
47
|
};
|
|
@@ -60,7 +52,6 @@ function createConfiguredControl( ControlComponent, type, config ) {
|
|
|
60
52
|
* @param {Object} props
|
|
61
53
|
* @param {string} props.clientId The clientId of the block.
|
|
62
54
|
* @param {Object} props.blockType The blockType definition.
|
|
63
|
-
* @param {Object} props.attributes The block's attribute values.
|
|
64
55
|
* @param {Function} props.setAttributes Action to set the block's attributes.
|
|
65
56
|
* @param {boolean} props.isCollapsed Whether the DataForm is rendered as 'collapsed' with only the first field
|
|
66
57
|
* displayed by default. When collapsed a dropdown is displayed to allow
|
|
@@ -70,7 +61,6 @@ function createConfiguredControl( ControlComponent, type, config ) {
|
|
|
70
61
|
function BlockFields( {
|
|
71
62
|
clientId,
|
|
72
63
|
blockType,
|
|
73
|
-
attributes,
|
|
74
64
|
setAttributes,
|
|
75
65
|
isCollapsed = false,
|
|
76
66
|
} ) {
|
|
@@ -82,6 +72,11 @@ function BlockFields( {
|
|
|
82
72
|
|
|
83
73
|
const blockTypeFields = blockType?.[ fieldsKey ];
|
|
84
74
|
|
|
75
|
+
const attributes = useSelect(
|
|
76
|
+
( select ) => select( blockEditorStore ).getBlockAttributes( clientId ),
|
|
77
|
+
[ clientId ]
|
|
78
|
+
);
|
|
79
|
+
|
|
85
80
|
const computedForm = useMemo( () => {
|
|
86
81
|
if ( ! isCollapsed ) {
|
|
87
82
|
return blockType?.[ formKey ];
|
|
@@ -104,51 +99,33 @@ function BlockFields( {
|
|
|
104
99
|
|
|
105
100
|
return blockTypeFields.map( ( fieldDef ) => {
|
|
106
101
|
const field = {
|
|
107
|
-
|
|
108
|
-
label: fieldDef.label,
|
|
109
|
-
type: fieldDef.type, // Use the field's type; DataForm will use built-in or custom Edit
|
|
102
|
+
...fieldDef,
|
|
110
103
|
};
|
|
111
104
|
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return attributeUpdates;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Only add custom Edit component if one exists for this type
|
|
141
|
-
const ControlComponent = CONTROLS[ fieldDef.type ];
|
|
142
|
-
if ( ControlComponent ) {
|
|
143
|
-
// Use EditConfig pattern: Edit is an object with control type and config props
|
|
144
|
-
field.Edit = createConfiguredControl(
|
|
145
|
-
ControlComponent,
|
|
146
|
-
fieldDef.type,
|
|
147
|
-
{
|
|
148
|
-
clientId,
|
|
149
|
-
fieldDef,
|
|
150
|
-
}
|
|
151
|
-
);
|
|
105
|
+
// These should be custom Edit components, not replaced here.
|
|
106
|
+
//
|
|
107
|
+
// - rich-text control: it needs clientId
|
|
108
|
+
// - link control: does not need anything extra
|
|
109
|
+
// - media control: needs the Edit config
|
|
110
|
+
if (
|
|
111
|
+
'string' === typeof fieldDef.Edit &&
|
|
112
|
+
fieldDef.Edit === 'rich-text'
|
|
113
|
+
) {
|
|
114
|
+
field.Edit = createConfiguredControl( RichText, {
|
|
115
|
+
clientId,
|
|
116
|
+
} );
|
|
117
|
+
} else if (
|
|
118
|
+
'string' === typeof fieldDef.Edit &&
|
|
119
|
+
fieldDef.Edit === 'link'
|
|
120
|
+
) {
|
|
121
|
+
field.Edit = createConfiguredControl( Link );
|
|
122
|
+
} else if (
|
|
123
|
+
'object' === typeof fieldDef.Edit &&
|
|
124
|
+
fieldDef.Edit.control === 'media'
|
|
125
|
+
) {
|
|
126
|
+
field.Edit = createConfiguredControl( Media, {
|
|
127
|
+
...fieldDef.Edit,
|
|
128
|
+
} );
|
|
152
129
|
}
|
|
153
130
|
|
|
154
131
|
return field;
|
|
@@ -216,56 +193,34 @@ function BlockFields( {
|
|
|
216
193
|
);
|
|
217
194
|
}
|
|
218
195
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
blockEditingMode,
|
|
226
|
-
isSelected,
|
|
227
|
-
} = useContext( PrivateBlockContext );
|
|
228
|
-
|
|
229
|
-
const shouldShowBlockFields =
|
|
230
|
-
window?.__experimentalContentOnlyInspectorFields;
|
|
231
|
-
const blockTypeFields = blockType?.[ fieldsKey ];
|
|
196
|
+
function hasBlockFieldsSupport( blockName ) {
|
|
197
|
+
return !! (
|
|
198
|
+
window?.__experimentalContentOnlyInspectorFields &&
|
|
199
|
+
getBlockType( blockName )?.[ fieldsKey ]
|
|
200
|
+
);
|
|
201
|
+
}
|
|
232
202
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
203
|
+
export function BlockFieldsPanel( props ) {
|
|
204
|
+
const { blockType, isSelectionWithinCurrentSection } =
|
|
205
|
+
useContext( PrivateBlockContext );
|
|
236
206
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
forceDisplayControls
|
|
248
|
-
>
|
|
249
|
-
<BlockFields
|
|
250
|
-
{ ...props }
|
|
251
|
-
blockType={ blockType }
|
|
252
|
-
isCollapsed
|
|
253
|
-
/>
|
|
254
|
-
</PrivateInspectorControlsFill>
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
{ ! isSelectionWithinCurrentSection && isSelected && (
|
|
258
|
-
<PrivateInspectorControlsFill group="content">
|
|
259
|
-
<BlockFields { ...props } blockType={ blockType } />
|
|
260
|
-
</PrivateInspectorControlsFill>
|
|
261
|
-
) }
|
|
262
|
-
</>
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
);
|
|
207
|
+
return (
|
|
208
|
+
<InspectorControls group="content">
|
|
209
|
+
<BlockFields
|
|
210
|
+
{ ...props }
|
|
211
|
+
blockType={ blockType }
|
|
212
|
+
isCollapsed={ isSelectionWithinCurrentSection }
|
|
213
|
+
/>
|
|
214
|
+
</InspectorControls>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
266
217
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
218
|
+
/**
|
|
219
|
+
* Export block support definition.
|
|
220
|
+
*/
|
|
221
|
+
export default {
|
|
222
|
+
edit: BlockFieldsPanel,
|
|
223
|
+
hasSupport: hasBlockFieldsSupport,
|
|
224
|
+
attributeKeys: [],
|
|
225
|
+
supportsPatternEditing: true,
|
|
226
|
+
};
|
|
@@ -67,12 +67,11 @@ export function getUpdatedLinkAttributes( {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export default function Link( { data, field, onChange
|
|
70
|
+
export default function Link( { data, field, onChange } ) {
|
|
71
71
|
const [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false );
|
|
72
72
|
const { popoverProps } = useInspectorPopoverPlacement( {
|
|
73
73
|
isControl: true,
|
|
74
74
|
} );
|
|
75
|
-
const { fieldDef } = config;
|
|
76
75
|
const value = field.getValue( { item: data } );
|
|
77
76
|
const url = value?.url;
|
|
78
77
|
const rel = value?.rel || '';
|
|
@@ -148,21 +147,10 @@ export default function Link( { data, field, onChange, config = {} } ) {
|
|
|
148
147
|
);
|
|
149
148
|
} }
|
|
150
149
|
onRemove={ () => {
|
|
151
|
-
// Remove all link-related properties based on what's in the mapping
|
|
152
|
-
const removeValue = {};
|
|
153
|
-
|
|
154
|
-
if ( fieldDef?.mapping ) {
|
|
155
|
-
Object.keys( fieldDef.mapping ).forEach(
|
|
156
|
-
( key ) => {
|
|
157
|
-
removeValue[ key ] = undefined;
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
150
|
onChange(
|
|
163
151
|
field.setValue( {
|
|
164
152
|
item: data,
|
|
165
|
-
value:
|
|
153
|
+
value: {},
|
|
166
154
|
} )
|
|
167
155
|
);
|
|
168
156
|
} }
|
|
@@ -25,8 +25,7 @@ import { getMediaSelectKey } from '../../../store/private-keys';
|
|
|
25
25
|
import { store as blockEditorStore } from '../../../store';
|
|
26
26
|
|
|
27
27
|
function MediaThumbnail( { data, field, attachment, config } ) {
|
|
28
|
-
const {
|
|
29
|
-
const { allowedTypes = [], multiple = false } = fieldDef.args || {};
|
|
28
|
+
const { allowedTypes = [], multiple = false } = config || {};
|
|
30
29
|
|
|
31
30
|
if ( multiple ) {
|
|
32
31
|
return 'todo multiple';
|
|
@@ -85,12 +84,11 @@ export default function Media( { data, field, onChange, config = {} } ) {
|
|
|
85
84
|
isControl: true,
|
|
86
85
|
} );
|
|
87
86
|
const value = field.getValue( { item: data } );
|
|
88
|
-
const {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
fieldDef?.mapping && 'featuredImage' in fieldDef.mapping;
|
|
87
|
+
const {
|
|
88
|
+
allowedTypes = [],
|
|
89
|
+
multiple = false,
|
|
90
|
+
useFeaturedImage = false,
|
|
91
|
+
} = config;
|
|
94
92
|
|
|
95
93
|
const id = value?.id;
|
|
96
94
|
const url = value?.url;
|
|
@@ -140,23 +138,14 @@ export default function Media( { data, field, onChange, config = {} } ) {
|
|
|
140
138
|
multiple={ multiple }
|
|
141
139
|
popoverProps={ popoverProps }
|
|
142
140
|
onReset={ () => {
|
|
143
|
-
// Build reset value dynamically based on mapping
|
|
144
|
-
const resetValue = {};
|
|
145
|
-
|
|
146
|
-
if ( fieldDef?.mapping ) {
|
|
147
|
-
Object.keys( fieldDef.mapping ).forEach( ( key ) => {
|
|
148
|
-
resetValue[ key ] = undefined;
|
|
149
|
-
} );
|
|
150
|
-
}
|
|
151
|
-
|
|
152
141
|
onChange(
|
|
153
142
|
field.setValue( {
|
|
154
143
|
item: data,
|
|
155
|
-
value:
|
|
144
|
+
value: {},
|
|
156
145
|
} )
|
|
157
146
|
);
|
|
158
147
|
} }
|
|
159
|
-
{ ...(
|
|
148
|
+
{ ...( useFeaturedImage && {
|
|
160
149
|
useFeaturedImage: !! value?.featuredImage,
|
|
161
150
|
onToggleFeaturedImage: () => {
|
|
162
151
|
onChange(
|
|
@@ -171,14 +160,13 @@ export default function Media( { data, field, onChange, config = {} } ) {
|
|
|
171
160
|
} ) }
|
|
172
161
|
onSelect={ ( selectedMedia ) => {
|
|
173
162
|
if ( selectedMedia.id && selectedMedia.url ) {
|
|
174
|
-
// Build new value dynamically based on what's in the mapping
|
|
175
163
|
const newValue = {
|
|
176
164
|
...selectedMedia,
|
|
177
165
|
mediaType: selectedMedia.media_type,
|
|
178
166
|
};
|
|
179
167
|
|
|
180
168
|
// Turn off featured image when manually selecting media
|
|
181
|
-
if (
|
|
169
|
+
if ( useFeaturedImage ) {
|
|
182
170
|
newValue.featuredImage = false;
|
|
183
171
|
}
|
|
184
172
|
|
|
@@ -113,25 +113,26 @@ if ( window.crossOriginIsolated ) {
|
|
|
113
113
|
'credentialless' in window.HTMLIFrameElement.prototype;
|
|
114
114
|
|
|
115
115
|
const disableEmbedPreviews = createHigherOrderComponent(
|
|
116
|
-
( BlockEdit ) =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
( BlockEdit ) =>
|
|
117
|
+
function DisableEmbedPreviews( props ) {
|
|
118
|
+
if ( 'core/embed' !== props.name ) {
|
|
119
|
+
return <BlockEdit { ...props } />;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// List of embeds that do not support a preview is from packages/block-library/src/embed/variations.js.
|
|
123
|
+
const previewable =
|
|
124
|
+
supportsCredentialless &&
|
|
125
|
+
! [ 'facebook', 'smugmug' ].includes(
|
|
126
|
+
props.attributes.providerNameSlug
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<BlockEdit
|
|
131
|
+
{ ...props }
|
|
132
|
+
attributes={ { ...props.attributes, previewable } }
|
|
133
|
+
/>
|
|
126
134
|
);
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<BlockEdit
|
|
130
|
-
{ ...props }
|
|
131
|
-
attributes={ { ...props.attributes, previewable } }
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
134
|
-
},
|
|
135
|
+
},
|
|
135
136
|
'withDisabledEmbedPreview'
|
|
136
137
|
);
|
|
137
138
|
|