@wordpress/block-editor 13.3.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 +13 -0
- package/README.md +11 -5
- package/build/components/alignment-control/ui.js +2 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +1 -1
- package/build/components/block-alignment-control/ui.native.js.map +1 -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-inspector/index.js +6 -3
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +26 -27
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +25 -9
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -2
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +2 -0
- package/build/components/block-lock/modal.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-removal-warning-modal/index.js +2 -0
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-switcher/index.js +1 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +11 -12
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +20 -17
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +5 -2
- package/build/components/block-toolbar/shuffle.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/use-show-block-tools.js +7 -8
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserter-button.js +45 -0
- package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
- package/build/components/block-tools/zoom-out-mode-inserters.js +35 -36
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +2 -1
- package/build/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +1 -2
- 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/date-format-picker/index.js +2 -11
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +7 -4
- package/build/components/default-block-appender/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-appearance-control/index.js +2 -7
- package/build/components/font-appearance-control/index.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 +63 -52
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -1
- package/build/components/global-styles/hooks.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 +26 -44
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +78 -7
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +82 -44
- 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 +93 -44
- 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 +2 -2
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +93 -45
- 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/index.js +1 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
- package/build/components/inserter/block-patterns-tab/patterns-filter.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/media-tab/media-panel.js +1 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +3 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +20 -3
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +10 -3
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/settings-tab.js +1 -2
- package/build/components/inspector-controls-tabs/settings-tab.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/list-view/block-select-button.js +2 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +2 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/utils.js +3 -1
- package/build/components/list-view/utils.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/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/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 +8 -8
- 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/image-url-input-ui.js +3 -3
- package/build/components/url-popover/image-url-input-ui.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/grid-visualizer.js +5 -8
- package/build/hooks/grid-visualizer.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +9 -2
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/line-height.js +0 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/position.js +3 -7
- package/build/hooks/position.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 +85 -50
- 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/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +2 -0
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +0 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +27 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +19 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +17 -5
- 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/alignment-control/ui.js +2 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +1 -1
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +1 -1
- package/build-module/components/block-alignment-control/ui.native.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-inspector/index.js +6 -3
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +27 -30
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +26 -9
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +3 -2
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +2 -0
- package/build-module/components/block-lock/modal.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-removal-warning-modal/index.js +2 -0
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +1 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +12 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +20 -17
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +5 -2
- package/build-module/components/block-toolbar/shuffle.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/use-show-block-tools.js +7 -8
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +37 -0
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +37 -38
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +2 -1
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +1 -2
- 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/date-format-picker/index.js +4 -12
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +7 -4
- package/build-module/components/default-block-appender/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-appearance-control/index.js +3 -6
- package/build-module/components/font-appearance-control/index.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 +63 -52
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -1
- package/build-module/components/global-styles/hooks.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 +27 -45
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +76 -7
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +81 -43
- 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 +96 -46
- 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 +2 -2
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +94 -46
- 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/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.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/media-tab/media-panel.js +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +3 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +20 -3
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +10 -3
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -2
- package/build-module/components/inspector-controls-tabs/settings-tab.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/list-view/block-select-button.js +3 -7
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +2 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/utils.js +3 -1
- package/build-module/components/list-view/utils.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/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/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 +8 -8
- 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/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.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/grid-visualizer.js +5 -8
- package/build-module/hooks/grid-visualizer.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/layout-child.js +9 -2
- package/build-module/hooks/layout-child.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/position.js +3 -7
- package/build-module/hooks/position.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 +84 -51
- 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/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +2 -0
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +1 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +24 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +18 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +14 -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 +11 -18
- package/build-style/content.css +11 -18
- 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 +242 -136
- package/build-style/style.css +242 -136
- package/build-types/components/block-context/index.d.ts +2 -2
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +31 -31
- package/src/autocompleters/style.scss +4 -0
- package/src/components/alignment-control/ui.js +2 -2
- package/src/components/block-alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/ui.native.js +1 -1
- package/src/components/block-breadcrumb/index.js +4 -2
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-context/README.md +4 -4
- package/src/components/block-draggable/index.js +3 -3
- package/src/components/block-inspector/index.js +8 -4
- package/src/components/block-list/content.scss +2 -16
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-block-props/use-block-refs.js +30 -30
- package/src/components/block-list/use-block-props/use-is-hovered.js +26 -11
- package/src/components/block-list/use-in-between-inserter.js +5 -1
- package/src/components/block-lock/modal.js +10 -2
- package/src/components/block-lock/style.scss +4 -8
- package/src/components/block-mover/index.js +5 -2
- package/src/components/block-patterns-paging/style.scss +0 -23
- 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-removal-warning-modal/index.js +10 -2
- package/src/components/block-switcher/index.js +1 -1
- package/src/components/block-switcher/pattern-transformations-menu.js +17 -15
- package/src/components/block-switcher/preview-block-popover.js +20 -14
- package/src/components/block-switcher/style.scss +8 -17
- package/src/components/block-toolbar/shuffle.js +8 -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/style.scss +8 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/src/components/block-tools/use-show-block-tools.js +12 -9
- package/src/components/block-tools/zoom-out-mode-inserter-button.js +47 -0
- package/src/components/block-tools/zoom-out-mode-inserters.js +48 -42
- package/src/components/block-tools/zoom-out-popover.js +1 -0
- package/src/components/block-tools/zoom-out-toolbar.js +1 -2
- 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/date-format-picker/index.js +2 -11
- package/src/components/default-block-appender/index.js +11 -4
- package/src/components/dimensions-tool/scale-tool.js +1 -0
- package/src/components/font-appearance-control/index.js +1 -5
- 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 +90 -62
- package/src/components/global-styles/hooks.js +5 -1
- package/src/components/global-styles/image-settings-panel.js +1 -0
- package/src/components/global-styles/style.scss +11 -9
- package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
- package/src/components/global-styles/test/typography-utils.js +325 -0
- package/src/components/global-styles/test/use-global-styles-output.js +52 -5
- 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 +36 -45
- package/src/components/global-styles/typography-utils.js +103 -7
- package/src/components/global-styles/use-global-styles-output.js +89 -50
- package/src/components/global-styles/utils.js +112 -0
- package/src/components/grid/grid-item-movers.js +141 -69
- package/src/components/grid/grid-item-resizer.js +11 -17
- package/src/components/grid/grid-visualizer.js +2 -2
- package/src/components/grid/style.scss +164 -0
- package/src/components/grid/use-grid-layout-sync.js +133 -40
- package/src/components/iframe/content.scss +3 -3
- package/src/components/iframe/index.js +3 -7
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/index.js +4 -1
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
- package/src/components/inserter/category-tabs/index.js +35 -2
- package/src/components/inserter/media-tab/media-panel.js +1 -0
- package/src/components/inserter/menu.js +3 -3
- package/src/components/inserter/preview-panel.js +27 -4
- package/src/components/inserter/style.scss +66 -47
- package/src/components/inserter-draggable-blocks/index.js +11 -3
- package/src/components/inspector-controls/README.md +5 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
- package/src/components/inspector-controls-tabs/style.scss +0 -21
- 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/list-view/block-select-button.js +3 -13
- package/src/components/list-view/block.js +10 -3
- package/src/components/list-view/style.scss +2 -1
- package/src/components/list-view/utils.js +13 -2
- 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/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/skip-to-selected-block/index.js +5 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -7
- 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/image-url-input-ui.js +3 -3
- package/src/components/url-popover/link-editor.js +0 -1
- package/src/components/url-popover/style.scss +1 -0
- 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/grid-visualizer.js +5 -7
- package/src/hooks/index.js +2 -1
- package/src/hooks/layout-child.js +12 -3
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/position.js +3 -13
- package/src/hooks/spacing-visualizer.js +1 -1
- package/src/hooks/use-bindings-attributes.js +93 -59
- 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/layouts/constrained.js +10 -2
- package/src/layouts/grid.js +2 -0
- package/src/private-apis.js +1 -8
- package/src/store/actions.js +28 -5
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +14 -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/components/inserter/reusable-block-rename-hint.js +0 -71
- package/build/components/inserter/reusable-block-rename-hint.js.map +0 -1
- package/build/components/inspector-controls-tabs/settings-tab-hint.js +0 -53
- package/build/components/inspector-controls-tabs/settings-tab-hint.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/build-module/components/inserter/reusable-block-rename-hint.js +0 -64
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +0 -1
- package/build-module/components/inspector-controls-tabs/settings-tab-hint.js +0 -47
- package/build-module/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
- package/src/components/inserter/reusable-block-rename-hint.js +0 -69
- package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
|
@@ -130,10 +130,6 @@ When hiding the URLInput using CSS (as is sometimes done for accessibility purpo
|
|
|
130
130
|
|
|
131
131
|
This prop allows the suggestions list to be programmatically not rendered by passing a boolean—it can be `true` to make sure suggestions aren't rendered, or `false`/`undefined` to fall back to the default behaviour of showing suggestions when matching autocompletion items are found.
|
|
132
132
|
|
|
133
|
-
### `__nextHasNoMarginBottom: Boolean`
|
|
134
|
-
|
|
135
|
-
Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4. (The prop can be safely removed once this happens.)
|
|
136
|
-
|
|
137
133
|
## Example
|
|
138
134
|
|
|
139
135
|
|
|
@@ -156,7 +152,6 @@ registerBlockType( /* ... */, {
|
|
|
156
152
|
edit( { className, attributes, setAttributes } ) {
|
|
157
153
|
return (
|
|
158
154
|
<URLInput
|
|
159
|
-
__nextHasNoMarginBottom
|
|
160
155
|
className={ className }
|
|
161
156
|
value={ attributes.url }
|
|
162
157
|
onChange={ ( url, post ) => setAttributes( { url, text: (post && post.title) || 'Click here' } ) }
|
|
@@ -6,7 +6,6 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import deprecated from '@wordpress/deprecated';
|
|
10
9
|
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
11
10
|
import { Component, createRef } from '@wordpress/element';
|
|
12
11
|
import { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';
|
|
@@ -416,8 +415,6 @@ class URLInput extends Component {
|
|
|
416
415
|
|
|
417
416
|
renderControl() {
|
|
418
417
|
const {
|
|
419
|
-
/** Start opting into the new margin-free styles that will become the default in a future version. */
|
|
420
|
-
__nextHasNoMarginBottom = false,
|
|
421
418
|
label = null,
|
|
422
419
|
className,
|
|
423
420
|
isFullWidth,
|
|
@@ -473,19 +470,8 @@ class URLInput extends Component {
|
|
|
473
470
|
return renderControl( controlProps, inputProps, loading );
|
|
474
471
|
}
|
|
475
472
|
|
|
476
|
-
if ( ! __nextHasNoMarginBottom ) {
|
|
477
|
-
deprecated( 'Bottom margin styles for wp.blockEditor.URLInput', {
|
|
478
|
-
since: '6.2',
|
|
479
|
-
version: '6.5',
|
|
480
|
-
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',
|
|
481
|
-
} );
|
|
482
|
-
}
|
|
483
|
-
|
|
484
473
|
return (
|
|
485
|
-
<BaseControl
|
|
486
|
-
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
|
|
487
|
-
{ ...controlProps }
|
|
488
|
-
>
|
|
474
|
+
<BaseControl __nextHasNoMarginBottom { ...controlProps }>
|
|
489
475
|
<input { ...inputProps } />
|
|
490
476
|
{ loading && <Spinner /> }
|
|
491
477
|
</BaseControl>
|
|
@@ -272,7 +272,7 @@ const ImageURLInputUI = ( {
|
|
|
272
272
|
icon={ linkOff }
|
|
273
273
|
label={ __( 'Disable expand on click' ) }
|
|
274
274
|
onClick={ () => {
|
|
275
|
-
onSetLightbox( false );
|
|
275
|
+
onSetLightbox?.( false );
|
|
276
276
|
} }
|
|
277
277
|
size="compact"
|
|
278
278
|
/>
|
|
@@ -302,7 +302,7 @@ const ImageURLInputUI = ( {
|
|
|
302
302
|
label={ __( 'Remove link' ) }
|
|
303
303
|
onClick={ () => {
|
|
304
304
|
onLinkRemove();
|
|
305
|
-
resetLightbox();
|
|
305
|
+
resetLightbox?.();
|
|
306
306
|
} }
|
|
307
307
|
size="compact"
|
|
308
308
|
/>
|
|
@@ -366,7 +366,7 @@ const ImageURLInputUI = ( {
|
|
|
366
366
|
LINK_DESTINATION_NONE,
|
|
367
367
|
href: '',
|
|
368
368
|
} );
|
|
369
|
-
onSetLightbox( true );
|
|
369
|
+
onSetLightbox?.( true );
|
|
370
370
|
stopEditLink();
|
|
371
371
|
} }
|
|
372
372
|
>
|
|
@@ -301,8 +301,10 @@ export default function useBlockDropZone( {
|
|
|
301
301
|
operation: 'insert',
|
|
302
302
|
} );
|
|
303
303
|
|
|
304
|
-
const { getBlockType } =
|
|
304
|
+
const { getBlockType, getBlockVariations, getGroupingBlockName } =
|
|
305
|
+
useSelect( blocksStore );
|
|
305
306
|
const {
|
|
307
|
+
canInsertBlockType,
|
|
306
308
|
getBlockListSettings,
|
|
307
309
|
getBlocks,
|
|
308
310
|
getBlockIndex,
|
|
@@ -310,6 +312,7 @@ export default function useBlockDropZone( {
|
|
|
310
312
|
getBlockNamesByClientId,
|
|
311
313
|
getAllowedBlocks,
|
|
312
314
|
isDragging,
|
|
315
|
+
isGroupable,
|
|
313
316
|
} = unlock( useSelect( blockEditorStore ) );
|
|
314
317
|
const {
|
|
315
318
|
showInsertionPoint,
|
|
@@ -385,21 +388,66 @@ export default function useBlockDropZone( {
|
|
|
385
388
|
};
|
|
386
389
|
} );
|
|
387
390
|
|
|
391
|
+
const dropTargetPosition = getDropTargetPosition(
|
|
392
|
+
blocksData,
|
|
393
|
+
{ x: event.clientX, y: event.clientY },
|
|
394
|
+
getBlockListSettings( targetRootClientId )?.orientation,
|
|
395
|
+
{
|
|
396
|
+
dropZoneElement,
|
|
397
|
+
parentBlockClientId,
|
|
398
|
+
parentBlockOrientation: parentBlockClientId
|
|
399
|
+
? getBlockListSettings( parentBlockClientId )
|
|
400
|
+
?.orientation
|
|
401
|
+
: undefined,
|
|
402
|
+
rootBlockIndex: getBlockIndex( targetRootClientId ),
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
|
|
388
406
|
const [ targetIndex, operation, nearestSide ] =
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
rootBlockIndex: getBlockIndex( targetRootClientId ),
|
|
401
|
-
}
|
|
407
|
+
dropTargetPosition;
|
|
408
|
+
|
|
409
|
+
if ( operation === 'group' ) {
|
|
410
|
+
const targetBlock = blocks[ targetIndex ];
|
|
411
|
+
const areAllImages = [
|
|
412
|
+
targetBlock.name,
|
|
413
|
+
...draggedBlockNames,
|
|
414
|
+
].every( ( name ) => name === 'core/image' );
|
|
415
|
+
const canInsertGalleryBlock = canInsertBlockType(
|
|
416
|
+
'core/gallery',
|
|
417
|
+
targetRootClientId
|
|
402
418
|
);
|
|
419
|
+
const areGroupableBlocks = isGroupable( [
|
|
420
|
+
targetBlock.clientId,
|
|
421
|
+
getDraggedBlockClientIds(),
|
|
422
|
+
] );
|
|
423
|
+
const groupBlockVariations = getBlockVariations(
|
|
424
|
+
getGroupingBlockName(),
|
|
425
|
+
'block'
|
|
426
|
+
);
|
|
427
|
+
const canInsertRow =
|
|
428
|
+
groupBlockVariations &&
|
|
429
|
+
groupBlockVariations.find(
|
|
430
|
+
( { name } ) => name === 'group-row'
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
// If the dragged blocks and the target block are all images,
|
|
434
|
+
// check if it is creatable either a Row variation or a Gallery block.
|
|
435
|
+
if (
|
|
436
|
+
areAllImages &&
|
|
437
|
+
! canInsertGalleryBlock &&
|
|
438
|
+
( ! areGroupableBlocks || ! canInsertRow )
|
|
439
|
+
) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
// If the dragged blocks and the target block are not all images,
|
|
443
|
+
// check if it is creatable a Row variation.
|
|
444
|
+
if (
|
|
445
|
+
! areAllImages &&
|
|
446
|
+
( ! areGroupableBlocks || ! canInsertRow )
|
|
447
|
+
) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
403
451
|
|
|
404
452
|
registry.batch( () => {
|
|
405
453
|
setDropTarget( {
|
|
@@ -436,6 +484,10 @@ export default function useBlockDropZone( {
|
|
|
436
484
|
showInsertionPoint,
|
|
437
485
|
isDragging,
|
|
438
486
|
startDragging,
|
|
487
|
+
canInsertBlockType,
|
|
488
|
+
getBlockVariations,
|
|
489
|
+
getGroupingBlockName,
|
|
490
|
+
isGroupable,
|
|
439
491
|
]
|
|
440
492
|
),
|
|
441
493
|
200
|
|
@@ -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
|
}
|