@wordpress/block-editor 13.4.0 → 14.0.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 +11 -0
- package/README.md +11 -1
- package/build/components/block-breadcrumb/index.js +3 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -2
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +24 -32
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-mover/index.js +1 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/cover.js +1 -1
- package/build/components/block-popover/cover.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +15 -16
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +0 -1
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/child-layout-control/index.js +3 -1
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/dimensions-tool/scale-tool.js +1 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/font-family/index.js +12 -0
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +55 -51
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +1 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/theme-file-uri-utils.js +0 -59
- package/build/components/global-styles/theme-file-uri-utils.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +0 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +58 -39
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +96 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +30 -26
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +14 -15
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +1 -1
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +56 -20
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/iframe/index.js +4 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +29 -2
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/menu.js +2 -2
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/line-height-control/index.js +0 -15
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/resolution-tool/index.js +1 -0
- package/build/components/resolution-tool/index.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -2
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -6
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-input/button.js +0 -1
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +1 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/link-editor.js +0 -1
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -4
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +3 -6
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -3
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -1
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/block-bindings.js +248 -36
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-hooks.js +1 -0
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +2 -2
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/contrast-checker.js +6 -6
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/line-height.js +0 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +1 -1
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +4 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +1 -1
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/hooks/utils.js +20 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +0 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +9 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-editor-region.js +1 -1
- package/build/utils/get-editor-region.js.map +1 -1
- package/build/utils/get-px-from-css-unit.js +1 -1
- package/build/utils/get-px-from-css-unit.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +3 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +24 -34
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/cover.js +1 -1
- package/build-module/components/block-popover/cover.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +16 -17
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +0 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +3 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/font-family/index.js +11 -0
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +55 -51
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +1 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/theme-file-uri-utils.js +0 -58
- package/build-module/components/global-styles/theme-file-uri-utils.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +0 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +57 -38
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +92 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +30 -26
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +14 -15
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +1 -1
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +56 -20
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +30 -3
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -2
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/line-height-control/index.js +0 -14
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +1 -0
- package/build-module/components/resolution-tool/index.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +5 -3
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -6
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/button.js +0 -1
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +0 -1
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +30 -4
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -6
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -3
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/block-bindings.js +253 -40
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-hooks.js +1 -0
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +3 -3
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +7 -7
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +1 -1
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +3 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +1 -1
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/hooks/utils.js +19 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +1 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +9 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-editor-region.js +1 -1
- package/build-module/utils/get-editor-region.js.map +1 -1
- package/build-module/utils/get-px-from-css-unit.js +1 -1
- package/build-module/utils/get-px-from-css-unit.js.map +1 -1
- package/build-style/content-rtl.css +5 -12
- package/build-style/content.css +5 -12
- package/build-style/default-editor-styles-rtl.css +3 -0
- package/build-style/default-editor-styles.css +3 -0
- package/build-style/style-rtl.css +88 -46
- package/build-style/style.css +88 -46
- package/package.json +31 -31
- package/src/autocompleters/style.scss +4 -0
- package/src/components/block-breadcrumb/index.js +4 -2
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-draggable/index.js +3 -3
- package/src/components/block-list/use-block-props/use-block-refs.js +27 -43
- package/src/components/block-mover/index.js +5 -2
- package/src/components/block-popover/cover.js +1 -1
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-tools/block-selection-button.js +1 -2
- package/src/components/block-tools/index.js +5 -6
- package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/src/components/block-tools/zoom-out-mode-inserters.js +14 -18
- package/src/components/block-tools/zoom-out-toolbar.js +0 -1
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
- package/src/components/colors-gradients/test/control.js +3 -2
- package/src/components/dimensions-tool/scale-tool.js +1 -0
- package/src/components/font-family/README.md +8 -0
- package/src/components/font-family/index.js +16 -0
- package/src/components/font-family/stories/index.story.js +54 -0
- package/src/components/global-styles/background-panel.js +69 -61
- package/src/components/global-styles/image-settings-panel.js +1 -0
- package/src/components/global-styles/style.scss +0 -10
- package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
- package/src/components/global-styles/test/use-global-styles-output.js +49 -4
- package/src/components/global-styles/test/utils.js +120 -0
- package/src/components/global-styles/theme-file-uri-utils.js +0 -59
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/global-styles/use-global-styles-output.js +67 -48
- package/src/components/global-styles/utils.js +112 -0
- package/src/components/grid/grid-item-movers.js +46 -44
- package/src/components/grid/grid-item-resizer.js +11 -17
- package/src/components/grid/grid-visualizer.js +1 -1
- package/src/components/grid/style.scss +60 -10
- package/src/components/grid/use-grid-layout-sync.js +68 -14
- package/src/components/iframe/content.scss +2 -2
- package/src/components/iframe/index.js +3 -7
- package/src/components/inserter/category-tabs/index.js +35 -2
- package/src/components/inserter/menu.js +2 -2
- package/src/components/inserter/style.scss +16 -11
- package/src/components/inspector-controls/README.md +5 -0
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +1 -21
- package/src/components/line-height-control/stories/index.story.js +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +3 -1
- package/src/components/resolution-tool/index.js +1 -0
- package/src/components/responsive-block-control/test/index.js +5 -1
- package/src/components/skip-to-selected-block/index.js +5 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -6
- package/src/components/tabbed-sidebar/style.scss +1 -19
- package/src/components/url-input/README.md +0 -5
- package/src/components/url-input/button.js +0 -1
- package/src/components/url-input/index.js +1 -15
- package/src/components/url-popover/link-editor.js +0 -1
- package/src/components/use-block-drop-zone/index.js +66 -14
- package/src/components/use-on-block-drop/index.js +1 -9
- package/src/components/use-resize-canvas/index.js +1 -3
- package/src/components/use-settings/index.js +2 -1
- package/src/hooks/block-bindings.js +303 -52
- package/src/hooks/block-bindings.scss +13 -2
- package/src/hooks/block-hooks.js +1 -0
- package/src/hooks/block-hooks.scss +1 -0
- package/src/hooks/block-style-variation.js +3 -3
- package/src/hooks/contrast-checker.js +7 -7
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/index.js +2 -1
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/spacing-visualizer.js +1 -1
- package/src/hooks/use-bindings-attributes.js +4 -0
- package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
- package/src/hooks/use-zoom-out.js +1 -1
- package/src/hooks/utils.js +14 -1
- package/src/index.js +1 -0
- package/src/private-apis.js +1 -2
- package/src/store/actions.js +13 -5
- package/src/store/selectors.js +4 -4
- package/src/style.scss +1 -1
- package/src/utils/get-editor-region.js +1 -1
- package/src/utils/get-px-from-css-unit.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -23
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
|
@@ -232,7 +232,6 @@ export default function useOnBlockDrop(
|
|
|
232
232
|
getBlocksByClientId,
|
|
233
233
|
getSettings,
|
|
234
234
|
getBlock,
|
|
235
|
-
isGroupable,
|
|
236
235
|
} = useSelect( blockEditorStore );
|
|
237
236
|
const { getGroupingBlockName } = useSelect( blocksStore );
|
|
238
237
|
const {
|
|
@@ -255,17 +254,11 @@ export default function useOnBlockDrop(
|
|
|
255
254
|
if ( ! Array.isArray( blocks ) ) {
|
|
256
255
|
blocks = [ blocks ];
|
|
257
256
|
}
|
|
258
|
-
|
|
259
257
|
const clientIds = getBlockOrder( targetRootClientId );
|
|
260
258
|
const clientId = clientIds[ targetBlockIndex ];
|
|
261
|
-
const blocksClientIds = blocks.map( ( block ) => block.clientId );
|
|
262
|
-
const areGroupableBlocks = isGroupable( [
|
|
263
|
-
...blocksClientIds,
|
|
264
|
-
clientId,
|
|
265
|
-
] );
|
|
266
259
|
if ( operation === 'replace' ) {
|
|
267
260
|
replaceBlocks( clientId, blocks, undefined, initialPosition );
|
|
268
|
-
} else if ( operation === 'group'
|
|
261
|
+
} else if ( operation === 'group' ) {
|
|
269
262
|
const targetBlock = getBlock( clientId );
|
|
270
263
|
if ( nearestSide === 'left' ) {
|
|
271
264
|
blocks.push( targetBlock );
|
|
@@ -325,7 +318,6 @@ export default function useOnBlockDrop(
|
|
|
325
318
|
getBlockOrder,
|
|
326
319
|
targetRootClientId,
|
|
327
320
|
targetBlockIndex,
|
|
328
|
-
isGroupable,
|
|
329
321
|
operation,
|
|
330
322
|
replaceBlocks,
|
|
331
323
|
getBlock,
|
|
@@ -43,7 +43,7 @@ export default function useResizeCanvas( deviceType ) {
|
|
|
43
43
|
return deviceWidth < actualWidth ? deviceWidth : actualWidth;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const marginValue = () => ( window.innerHeight < 800 ? 36 :
|
|
46
|
+
const marginValue = () => ( window.innerHeight < 800 ? 36 : 64 );
|
|
47
47
|
|
|
48
48
|
const contentInlineStyles = ( device ) => {
|
|
49
49
|
const height = device === 'Mobile' ? '768px' : '1024px';
|
|
@@ -62,8 +62,6 @@ export default function useResizeCanvas( deviceType ) {
|
|
|
62
62
|
marginLeft: marginHorizontal,
|
|
63
63
|
marginRight: marginHorizontal,
|
|
64
64
|
height,
|
|
65
|
-
borderRadius: '2px 2px 2px 2px',
|
|
66
|
-
border: '1px solid #ddd',
|
|
67
65
|
overflowY: 'auto',
|
|
68
66
|
};
|
|
69
67
|
default:
|
|
@@ -43,9 +43,10 @@ export function useSettings( ...paths ) {
|
|
|
43
43
|
* It looks up the setting first in the block instance hierarchy.
|
|
44
44
|
* If none is found, it'll look it up in the block editor settings.
|
|
45
45
|
*
|
|
46
|
+
* @deprecated 6.5.0 Use useSettings instead.
|
|
47
|
+
*
|
|
46
48
|
* @param {string} path The path to the setting.
|
|
47
49
|
* @return {any} Returns the value defined for the setting.
|
|
48
|
-
* @deprecated 6.5.0 Use useSettings instead.
|
|
49
50
|
* @example
|
|
50
51
|
* ```js
|
|
51
52
|
* const isEnabled = useSetting( 'typography.dropCap' );
|
|
@@ -2,42 +2,199 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
|
|
6
6
|
import {
|
|
7
|
-
BaseControl,
|
|
8
|
-
PanelBody,
|
|
9
|
-
__experimentalHStack as HStack,
|
|
10
7
|
__experimentalItemGroup as ItemGroup,
|
|
11
8
|
__experimentalItem as Item,
|
|
9
|
+
__experimentalText as Text,
|
|
10
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
11
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
12
|
+
__experimentalTruncate as Truncate,
|
|
13
|
+
__experimentalVStack as VStack,
|
|
14
|
+
privateApis as componentsPrivateApis,
|
|
12
15
|
} from '@wordpress/components';
|
|
13
|
-
import { useSelect } from '@wordpress/data';
|
|
16
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
17
|
+
import { useContext, Fragment } from '@wordpress/element';
|
|
18
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Internal dependencies
|
|
17
22
|
*/
|
|
18
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
canBindAttribute,
|
|
25
|
+
getBindableAttributes,
|
|
26
|
+
} from '../hooks/use-bindings-attributes';
|
|
27
|
+
import { store as blockEditorStore } from '../store';
|
|
19
28
|
import { unlock } from '../lock-unlock';
|
|
20
29
|
import InspectorControls from '../components/inspector-controls';
|
|
30
|
+
import BlockContext from '../components/block-context';
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
DropdownMenuV2: DropdownMenu,
|
|
34
|
+
DropdownMenuGroupV2: DropdownMenuGroup,
|
|
35
|
+
DropdownMenuRadioItemV2: DropdownMenuRadioItem,
|
|
36
|
+
DropdownMenuItemLabelV2: DropdownMenuItemLabel,
|
|
37
|
+
DropdownMenuItemHelpTextV2: DropdownMenuItemHelpText,
|
|
38
|
+
DropdownMenuSeparatorV2: DropdownMenuSeparator,
|
|
39
|
+
} = unlock( componentsPrivateApis );
|
|
40
|
+
|
|
41
|
+
const useToolsPanelDropdownMenuProps = () => {
|
|
42
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
43
|
+
return ! isMobile
|
|
44
|
+
? {
|
|
45
|
+
popoverProps: {
|
|
46
|
+
placement: 'left-start',
|
|
47
|
+
// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
|
|
48
|
+
offset: 259,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
: {};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function BlockBindingsPanelDropdown( {
|
|
55
|
+
fieldsList,
|
|
56
|
+
addConnection,
|
|
57
|
+
attribute,
|
|
58
|
+
binding,
|
|
59
|
+
} ) {
|
|
60
|
+
const currentKey = binding?.args?.key;
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
{ Object.entries( fieldsList ).map( ( [ label, fields ], i ) => (
|
|
64
|
+
<Fragment key={ label }>
|
|
65
|
+
<DropdownMenuGroup>
|
|
66
|
+
{ Object.keys( fieldsList ).length > 1 && (
|
|
67
|
+
<Text
|
|
68
|
+
className="block-editor-bindings__source-label"
|
|
69
|
+
upperCase
|
|
70
|
+
variant="muted"
|
|
71
|
+
aria-hidden
|
|
72
|
+
>
|
|
73
|
+
{ label }
|
|
74
|
+
</Text>
|
|
75
|
+
) }
|
|
76
|
+
{ Object.entries( fields ).map( ( [ key, value ] ) => (
|
|
77
|
+
<DropdownMenuRadioItem
|
|
78
|
+
key={ key }
|
|
79
|
+
onChange={ () =>
|
|
80
|
+
addConnection( key, attribute )
|
|
81
|
+
}
|
|
82
|
+
name={ attribute + '-binding' }
|
|
83
|
+
value={ key }
|
|
84
|
+
checked={ key === currentKey }
|
|
85
|
+
>
|
|
86
|
+
<DropdownMenuItemLabel>
|
|
87
|
+
{ key }
|
|
88
|
+
</DropdownMenuItemLabel>
|
|
89
|
+
<DropdownMenuItemHelpText>
|
|
90
|
+
{ value }
|
|
91
|
+
</DropdownMenuItemHelpText>
|
|
92
|
+
</DropdownMenuRadioItem>
|
|
93
|
+
) ) }
|
|
94
|
+
</DropdownMenuGroup>
|
|
95
|
+
{ i !== Object.keys( fieldsList ).length - 1 && (
|
|
96
|
+
<DropdownMenuSeparator />
|
|
97
|
+
) }
|
|
98
|
+
</Fragment>
|
|
99
|
+
) ) }
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function BlockBindingsAttribute( { attribute, binding } ) {
|
|
105
|
+
const { source: sourceName, args } = binding || {};
|
|
106
|
+
const sourceProps =
|
|
107
|
+
unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );
|
|
108
|
+
return (
|
|
109
|
+
<VStack>
|
|
110
|
+
<Truncate>{ attribute }</Truncate>
|
|
111
|
+
{ !! binding && (
|
|
112
|
+
<Text
|
|
113
|
+
variant="muted"
|
|
114
|
+
className="block-editor-bindings__item-explanation"
|
|
115
|
+
>
|
|
116
|
+
<Truncate>
|
|
117
|
+
{ args?.key || sourceProps?.label || sourceName }
|
|
118
|
+
</Truncate>
|
|
119
|
+
</Text>
|
|
120
|
+
) }
|
|
121
|
+
</VStack>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function ReadOnlyBlockBindingsPanelItems( { bindings } ) {
|
|
126
|
+
return (
|
|
127
|
+
<>
|
|
128
|
+
{ Object.entries( bindings ).map( ( [ attribute, binding ] ) => (
|
|
129
|
+
<Item key={ attribute }>
|
|
130
|
+
<BlockBindingsAttribute
|
|
131
|
+
attribute={ attribute }
|
|
132
|
+
binding={ binding }
|
|
133
|
+
/>
|
|
134
|
+
</Item>
|
|
135
|
+
) ) }
|
|
136
|
+
</>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function EditableBlockBindingsPanelItems( {
|
|
141
|
+
attributes,
|
|
142
|
+
bindings,
|
|
143
|
+
fieldsList,
|
|
144
|
+
addConnection,
|
|
145
|
+
removeConnection,
|
|
146
|
+
} ) {
|
|
147
|
+
const isMobile = useViewportMatch( 'medium', '<' );
|
|
148
|
+
return (
|
|
149
|
+
<>
|
|
150
|
+
{ attributes.map( ( attribute ) => {
|
|
151
|
+
const binding = bindings[ attribute ];
|
|
152
|
+
return (
|
|
153
|
+
<ToolsPanelItem
|
|
154
|
+
key={ attribute }
|
|
155
|
+
hasValue={ () => !! binding }
|
|
156
|
+
label={ attribute }
|
|
157
|
+
onDeselect={ () => {
|
|
158
|
+
removeConnection( attribute );
|
|
159
|
+
} }
|
|
160
|
+
>
|
|
161
|
+
<DropdownMenu
|
|
162
|
+
placement={
|
|
163
|
+
isMobile ? 'bottom-start' : 'left-start'
|
|
164
|
+
}
|
|
165
|
+
gutter={ isMobile ? 8 : 36 }
|
|
166
|
+
className="block-editor-bindings__popover"
|
|
167
|
+
trigger={
|
|
168
|
+
<Item>
|
|
169
|
+
<BlockBindingsAttribute
|
|
170
|
+
attribute={ attribute }
|
|
171
|
+
binding={ binding }
|
|
172
|
+
/>
|
|
173
|
+
</Item>
|
|
174
|
+
}
|
|
175
|
+
>
|
|
176
|
+
<BlockBindingsPanelDropdown
|
|
177
|
+
fieldsList={ fieldsList }
|
|
178
|
+
addConnection={ addConnection }
|
|
179
|
+
attribute={ attribute }
|
|
180
|
+
binding={ binding }
|
|
181
|
+
/>
|
|
182
|
+
</DropdownMenu>
|
|
183
|
+
</ToolsPanelItem>
|
|
184
|
+
);
|
|
185
|
+
} ) }
|
|
186
|
+
</>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
21
189
|
|
|
22
190
|
export const BlockBindingsPanel = ( { name, metadata } ) => {
|
|
191
|
+
const registry = useRegistry();
|
|
192
|
+
const blockContext = useContext( BlockContext );
|
|
23
193
|
const { bindings } = metadata || {};
|
|
24
|
-
const { sources } = useSelect( ( select ) => {
|
|
25
|
-
const _sources = unlock(
|
|
26
|
-
select( blocksStore )
|
|
27
|
-
).getAllBlockBindingsSources();
|
|
28
194
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
}, [] );
|
|
33
|
-
|
|
34
|
-
if ( ! bindings ) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
195
|
+
const bindableAttributes = getBindableAttributes( name );
|
|
196
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
37
197
|
|
|
38
|
-
// Don't show not allowed attributes.
|
|
39
|
-
// Don't show the bindings connected to pattern overrides in the inspectors panel.
|
|
40
|
-
// TODO: Explore if this should be abstracted to let other sources decide.
|
|
41
198
|
const filteredBindings = { ...bindings };
|
|
42
199
|
Object.keys( filteredBindings ).forEach( ( key ) => {
|
|
43
200
|
if (
|
|
@@ -48,43 +205,137 @@ export const BlockBindingsPanel = ( { name, metadata } ) => {
|
|
|
48
205
|
}
|
|
49
206
|
} );
|
|
50
207
|
|
|
51
|
-
|
|
208
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
209
|
+
|
|
210
|
+
const { _id } = useSelect( ( select ) => {
|
|
211
|
+
const { getSelectedBlockClientId } = select( blockEditorStore );
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
_id: getSelectedBlockClientId(),
|
|
215
|
+
};
|
|
216
|
+
}, [] );
|
|
217
|
+
|
|
218
|
+
if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const removeAllConnections = () => {
|
|
223
|
+
const newMetadata = { ...metadata };
|
|
224
|
+
delete newMetadata.bindings;
|
|
225
|
+
updateBlockAttributes( _id, {
|
|
226
|
+
metadata:
|
|
227
|
+
Object.keys( newMetadata ).length === 0
|
|
228
|
+
? undefined
|
|
229
|
+
: newMetadata,
|
|
230
|
+
} );
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const addConnection = ( value, attribute ) => {
|
|
234
|
+
// Assuming the block expects a flat structure for its metadata attribute
|
|
235
|
+
const newMetadata = {
|
|
236
|
+
...metadata,
|
|
237
|
+
// Adjust this according to the actual structure expected by your block
|
|
238
|
+
bindings: {
|
|
239
|
+
...metadata?.bindings,
|
|
240
|
+
[ attribute ]: {
|
|
241
|
+
source: 'core/post-meta',
|
|
242
|
+
args: { key: value },
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
// Update the block's attributes with the new metadata
|
|
247
|
+
updateBlockAttributes( _id, {
|
|
248
|
+
metadata: newMetadata,
|
|
249
|
+
} );
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const removeConnection = ( key ) => {
|
|
253
|
+
const newMetadata = { ...metadata };
|
|
254
|
+
if ( ! newMetadata.bindings ) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
delete newMetadata.bindings[ key ];
|
|
259
|
+
if ( Object.keys( newMetadata.bindings ).length === 0 ) {
|
|
260
|
+
delete newMetadata.bindings;
|
|
261
|
+
}
|
|
262
|
+
updateBlockAttributes( _id, {
|
|
263
|
+
metadata:
|
|
264
|
+
Object.keys( newMetadata ).length === 0
|
|
265
|
+
? undefined
|
|
266
|
+
: newMetadata,
|
|
267
|
+
} );
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const fieldsList = {};
|
|
271
|
+
const { getBlockBindingsSources } = unlock( blocksPrivateApis );
|
|
272
|
+
const registeredSources = getBlockBindingsSources();
|
|
273
|
+
Object.values( registeredSources ).forEach(
|
|
274
|
+
( { getFieldsList, label, usesContext } ) => {
|
|
275
|
+
if ( getFieldsList ) {
|
|
276
|
+
// Populate context.
|
|
277
|
+
const context = {};
|
|
278
|
+
if ( usesContext?.length ) {
|
|
279
|
+
for ( const key of usesContext ) {
|
|
280
|
+
context[ key ] = blockContext[ key ];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const sourceList = getFieldsList( {
|
|
284
|
+
registry,
|
|
285
|
+
context,
|
|
286
|
+
} );
|
|
287
|
+
// Only add source if the list is not empty.
|
|
288
|
+
if ( sourceList ) {
|
|
289
|
+
fieldsList[ label ] = { ...sourceList };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
// Remove empty sources.
|
|
295
|
+
Object.entries( fieldsList ).forEach( ( [ key, value ] ) => {
|
|
296
|
+
if ( ! Object.keys( value ).length ) {
|
|
297
|
+
delete fieldsList[ key ];
|
|
298
|
+
}
|
|
299
|
+
} );
|
|
300
|
+
|
|
301
|
+
// Lock the UI when the experiment is not enabled or there are no fields to connect to.
|
|
302
|
+
const readOnly =
|
|
303
|
+
! window.__experimentalBlockBindingsUI ||
|
|
304
|
+
! Object.keys( fieldsList ).length;
|
|
305
|
+
|
|
306
|
+
if ( readOnly && Object.keys( filteredBindings ).length === 0 ) {
|
|
52
307
|
return null;
|
|
53
308
|
}
|
|
54
309
|
|
|
55
310
|
return (
|
|
56
311
|
<InspectorControls>
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
312
|
+
<ToolsPanel
|
|
313
|
+
label={ __( 'Attributes' ) }
|
|
314
|
+
resetAll={ () => {
|
|
315
|
+
removeAllConnections();
|
|
316
|
+
} }
|
|
317
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
318
|
+
className="block-editor-bindings__panel"
|
|
60
319
|
>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</span>
|
|
81
|
-
</HStack>
|
|
82
|
-
</Item>
|
|
83
|
-
);
|
|
84
|
-
} ) }
|
|
85
|
-
</ItemGroup>
|
|
86
|
-
</BaseControl>
|
|
87
|
-
</PanelBody>
|
|
320
|
+
<ItemGroup isBordered isSeparated>
|
|
321
|
+
{ readOnly ? (
|
|
322
|
+
<ReadOnlyBlockBindingsPanelItems
|
|
323
|
+
bindings={ filteredBindings }
|
|
324
|
+
/>
|
|
325
|
+
) : (
|
|
326
|
+
<EditableBlockBindingsPanelItems
|
|
327
|
+
attributes={ bindableAttributes }
|
|
328
|
+
bindings={ filteredBindings }
|
|
329
|
+
fieldsList={ fieldsList }
|
|
330
|
+
addConnection={ addConnection }
|
|
331
|
+
removeConnection={ removeConnection }
|
|
332
|
+
/>
|
|
333
|
+
) }
|
|
334
|
+
</ItemGroup>
|
|
335
|
+
<Text variant="muted">
|
|
336
|
+
{ __( 'Attributes connected to various sources.' ) }
|
|
337
|
+
</Text>
|
|
338
|
+
</ToolsPanel>
|
|
88
339
|
</InspectorControls>
|
|
89
340
|
);
|
|
90
341
|
};
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
1
|
+
div.block-editor-bindings__panel {
|
|
2
|
+
grid-template-columns: auto;
|
|
3
|
+
button:hover .block-editor-bindings__item-explanation {
|
|
4
|
+
color: inherit;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.block-editor-bindings__popover {
|
|
9
|
+
// This won't be needed if `DropdownMenuGroup` component handles the label.
|
|
10
|
+
.block-editor-bindings__source-label {
|
|
11
|
+
grid-column: 2;
|
|
12
|
+
margin: $grid-unit-10 0;
|
|
13
|
+
}
|
|
3
14
|
}
|
package/src/hooks/block-hooks.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* we need to right-align the toggle.
|
|
5
5
|
*/
|
|
6
6
|
.components-toggle-control .components-h-stack {
|
|
7
|
+
/* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the row-reverse value. */
|
|
7
8
|
flex-direction: row-reverse;
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
toStyles,
|
|
14
14
|
getBlockSelectors,
|
|
15
15
|
} from '../components/global-styles';
|
|
16
|
-
import {
|
|
16
|
+
import { usePrivateStyleOverride } from './utils';
|
|
17
17
|
import { getValueFromObjectPath } from '../utils/object';
|
|
18
18
|
import { store as blockEditorStore } from '../store';
|
|
19
19
|
import { globalStylesDataKey } from '../store/private-keys';
|
|
@@ -63,7 +63,7 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
|
|
|
63
63
|
|
|
64
64
|
// A helper component to apply a style override using the useStyleOverride hook.
|
|
65
65
|
function OverrideStyles( { override } ) {
|
|
66
|
-
|
|
66
|
+
usePrivateStyleOverride( override );
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -351,7 +351,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
351
351
|
);
|
|
352
352
|
}, [ variation, settings, styles, getBlockStyles, clientId ] );
|
|
353
353
|
|
|
354
|
-
|
|
354
|
+
usePrivateStyleOverride( {
|
|
355
355
|
id: `variation-${ clientId }`,
|
|
356
356
|
css: variationStyles,
|
|
357
357
|
__unstableType: 'variation',
|
|
@@ -7,7 +7,7 @@ import { useState, useEffect } from '@wordpress/element';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import ContrastChecker from '../components/contrast-checker';
|
|
10
|
-
import {
|
|
10
|
+
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
11
11
|
|
|
12
12
|
function getComputedStyle( node ) {
|
|
13
13
|
return node.ownerDocument.defaultView.getComputedStyle( node );
|
|
@@ -17,23 +17,23 @@ export default function BlockColorContrastChecker( { clientId } ) {
|
|
|
17
17
|
const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
|
|
18
18
|
const [ detectedColor, setDetectedColor ] = useState();
|
|
19
19
|
const [ detectedLinkColor, setDetectedLinkColor ] = useState();
|
|
20
|
-
const
|
|
20
|
+
const blockEl = useBlockElement( clientId );
|
|
21
21
|
|
|
22
22
|
// There are so many things that can change the color of a block
|
|
23
23
|
// So we perform this check on every render.
|
|
24
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
25
|
useEffect( () => {
|
|
26
|
-
if ( !
|
|
26
|
+
if ( ! blockEl ) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
setDetectedColor( getComputedStyle(
|
|
29
|
+
setDetectedColor( getComputedStyle( blockEl ).color );
|
|
30
30
|
|
|
31
|
-
const firstLinkElement =
|
|
31
|
+
const firstLinkElement = blockEl.querySelector( 'a' );
|
|
32
32
|
if ( firstLinkElement && !! firstLinkElement.innerText ) {
|
|
33
33
|
setDetectedLinkColor( getComputedStyle( firstLinkElement ).color );
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
let backgroundColorNode =
|
|
36
|
+
let backgroundColorNode = blockEl;
|
|
37
37
|
let backgroundColor =
|
|
38
38
|
getComputedStyle( backgroundColorNode ).backgroundColor;
|
|
39
39
|
while (
|
|
@@ -48,7 +48,7 @@ export default function BlockColorContrastChecker( { clientId } ) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
setDetectedBackgroundColor( backgroundColor );
|
|
51
|
-
} );
|
|
51
|
+
}, [ blockEl ] );
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
54
|
<ContrastChecker
|
package/src/hooks/duotone.js
CHANGED
|
@@ -32,10 +32,10 @@ import {
|
|
|
32
32
|
} from '../components/duotone/utils';
|
|
33
33
|
import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
|
|
34
34
|
import { scopeSelector } from '../components/global-styles/utils';
|
|
35
|
-
import { useBlockSettings,
|
|
35
|
+
import { useBlockSettings, usePrivateStyleOverride } from './utils';
|
|
36
36
|
import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
|
|
37
37
|
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
38
|
-
import {
|
|
38
|
+
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
39
39
|
|
|
40
40
|
const EMPTY_ARRAY = [];
|
|
41
41
|
|
|
@@ -265,7 +265,7 @@ function useDuotoneStyles( {
|
|
|
265
265
|
|
|
266
266
|
const isValidFilter = Array.isArray( colors ) || colors === 'unset';
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
usePrivateStyleOverride(
|
|
269
269
|
isValidFilter
|
|
270
270
|
? {
|
|
271
271
|
css:
|
|
@@ -276,7 +276,7 @@ function useDuotoneStyles( {
|
|
|
276
276
|
}
|
|
277
277
|
: undefined
|
|
278
278
|
);
|
|
279
|
-
|
|
279
|
+
usePrivateStyleOverride(
|
|
280
280
|
isValidFilter
|
|
281
281
|
? {
|
|
282
282
|
assets:
|
package/src/hooks/index.js
CHANGED
|
@@ -37,7 +37,6 @@ import './grid-visualizer';
|
|
|
37
37
|
|
|
38
38
|
createBlockEditFilter(
|
|
39
39
|
[
|
|
40
|
-
blockBindingsPanel,
|
|
41
40
|
align,
|
|
42
41
|
textAlign,
|
|
43
42
|
anchor,
|
|
@@ -48,6 +47,7 @@ createBlockEditFilter(
|
|
|
48
47
|
layout,
|
|
49
48
|
contentLockUI,
|
|
50
49
|
blockHooks,
|
|
50
|
+
blockBindingsPanel,
|
|
51
51
|
childLayout,
|
|
52
52
|
].filter( Boolean )
|
|
53
53
|
);
|
|
@@ -91,3 +91,4 @@ export { useCachedTruthy } from './use-cached-truthy';
|
|
|
91
91
|
export { setBackgroundStyleDefaults } from './background';
|
|
92
92
|
export { useZoomOut } from './use-zoom-out';
|
|
93
93
|
export { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';
|
|
94
|
+
export { useStyleOverride } from './utils';
|
package/src/hooks/line-height.js
CHANGED
|
@@ -14,7 +14,7 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import BlockPopoverCover from '../components/block-popover/cover';
|
|
17
|
-
import {
|
|
17
|
+
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
18
18
|
|
|
19
19
|
function SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {
|
|
20
20
|
const blockElement = useBlockElement( clientId );
|
|
@@ -91,6 +91,10 @@ export function canBindAttribute( blockName, attributeName ) {
|
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
export function getBindableAttributes( blockName ) {
|
|
95
|
+
return BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];
|
|
96
|
+
}
|
|
97
|
+
|
|
94
98
|
export const withBlockBindingSupport = createHigherOrderComponent(
|
|
95
99
|
( BlockEdit ) => ( props ) => {
|
|
96
100
|
const registry = useRegistry();
|
|
@@ -49,5 +49,5 @@ export function useZoomOut( zoomOut = true ) {
|
|
|
49
49
|
) {
|
|
50
50
|
__unstableSetEditorMode( originalEditingMode.current );
|
|
51
51
|
}
|
|
52
|
-
}, [ __unstableSetEditorMode, zoomOut
|
|
52
|
+
}, [ __unstableGetEditorMode, __unstableSetEditorMode, zoomOut ] ); // Mode is deliberately excluded from the dependencies so that the effect does not run when mode changes.
|
|
53
53
|
}
|
package/src/hooks/utils.js
CHANGED
|
@@ -135,7 +135,20 @@ export function shouldSkipSerialization(
|
|
|
135
135
|
|
|
136
136
|
const pendingStyleOverrides = new WeakMap();
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Override a block editor settings style. Leave the ID blank to create a new
|
|
140
|
+
* style.
|
|
141
|
+
*
|
|
142
|
+
* @param {Object} override Override object.
|
|
143
|
+
* @param {?string} override.id Id of the style override, leave blank to create
|
|
144
|
+
* a new style.
|
|
145
|
+
* @param {string} override.css CSS to apply.
|
|
146
|
+
*/
|
|
147
|
+
export function useStyleOverride( { id, css } ) {
|
|
148
|
+
return usePrivateStyleOverride( { id, css } );
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function usePrivateStyleOverride( {
|
|
139
152
|
id,
|
|
140
153
|
css,
|
|
141
154
|
assets,
|