@wordpress/block-editor 14.9.0 → 14.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/README.md +40 -0
- package/build/components/audio-player/index.native.js +1 -1
- package/build/components/audio-player/index.native.js.map +1 -1
- package/build/components/background-image-control/index.js +4 -0
- package/build/components/background-image-control/index.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +32 -0
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-card/index.js +45 -8
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-edit/edit.js +147 -10
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-list/index.js +1 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +2 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/zoom-out-separator.js +20 -3
- package/build/components/block-list/zoom-out-separator.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -8
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +19 -6
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/button-block-appender/index.js +1 -5
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +6 -0
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +51 -11
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/contrast-checker/index.native.js +1 -1
- package/build/components/contrast-checker/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +7 -16
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +9 -0
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +10 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +3 -0
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +1 -1
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +9 -0
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/utils.js +12 -1
- package/build/components/grid/utils.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +11 -11
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +1 -1
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +1 -2
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/index.js +6 -15
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -13
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/line-height-control/index.js +9 -0
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +26 -26
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/plain-text/index.js +34 -0
- package/build/components/plain-text/index.js.map +1 -1
- package/build/components/provider/index.js +61 -5
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-media-upload-settings.js +28 -0
- package/build/components/provider/use-media-upload-settings.js.map +1 -0
- package/build/components/resolution-tool/index.js +3 -1
- package/build/components/resolution-tool/index.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -1
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/delete.js +7 -1
- package/build/components/rich-text/event-listeners/delete.js.map +1 -1
- package/build/components/rich-text/index.js +2 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +2 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/hooks/background.js +2 -0
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-bindings.js +15 -14
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/gap.js +2 -2
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +7 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/style.js +7 -7
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -7
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +6 -6
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-zoom-out.js +12 -1
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/hooks/utils.js +1 -1
- package/build/hooks/utils.js.map +1 -1
- package/build/store/private-actions.js +1 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +11 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +93 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -8
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-bindings.js +95 -0
- package/build/utils/block-bindings.js.map +1 -1
- package/build-module/components/audio-player/index.native.js +2 -2
- package/build-module/components/audio-player/index.native.js.map +1 -1
- package/build-module/components/background-image-control/index.js +5 -1
- package/build-module/components/background-image-control/index.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +32 -0
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -8
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-edit/edit.js +148 -11
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/zoom-out-separator.js +20 -3
- package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -8
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +19 -6
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -6
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +7 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +51 -11
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/contrast-checker/index.native.js +2 -2
- package/build-module/components/contrast-checker/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +7 -16
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +8 -0
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +10 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +1 -1
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +9 -0
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/utils.js +12 -1
- package/build-module/components/grid/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +12 -12
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +1 -2
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/index.js +6 -15
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -13
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +2 -2
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +8 -0
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +3 -3
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +28 -28
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/plain-text/index.js +34 -0
- package/build-module/components/plain-text/index.js.map +1 -1
- package/build-module/components/provider/index.js +62 -5
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-media-upload-settings.js +22 -0
- package/build-module/components/provider/use-media-upload-settings.js.map +1 -0
- package/build-module/components/resolution-tool/index.js +3 -1
- package/build-module/components/resolution-tool/index.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -1
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/delete.js +7 -1
- package/build-module/components/rich-text/event-listeners/delete.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/use-block-drop-zone/index.js +2 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/hooks/background.js +2 -0
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-bindings.js +13 -12
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/gap.js +2 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/style.js +7 -7
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -7
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +6 -6
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +12 -2
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/hooks/utils.js +1 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/store/private-actions.js +1 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +11 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +93 -12
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-bindings.js +90 -0
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-style/style-rtl.css +27 -9
- package/build-style/style.css +27 -9
- package/package.json +33 -33
- package/src/components/audio-player/index.native.js +2 -2
- package/src/components/background-image-control/index.js +4 -0
- package/src/components/background-image-control/style.scss +4 -2
- package/src/components/block-alignment-matrix-control/README.md +29 -6
- package/src/components/block-alignment-matrix-control/index.js +31 -0
- package/src/components/block-alignment-matrix-control/stories/index.story.js +78 -0
- package/src/components/block-card/README.md +7 -0
- package/src/components/block-card/index.js +41 -12
- package/src/components/block-card/stories/index.story.js +79 -0
- package/src/components/block-card/style.scss +9 -1
- package/src/components/block-edit/edit.js +218 -11
- package/src/components/block-list/index.js +2 -7
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/zoom-out-separator.js +30 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +17 -20
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-title/stories/index.story.js +76 -0
- package/src/components/block-tools/style.scss +1 -0
- package/src/components/block-tools/zoom-out-mode-inserters.js +21 -3
- package/src/components/border-radius-control/README.md +59 -0
- package/src/components/border-radius-control/stories/index.story.js +58 -0
- package/src/components/button-block-appender/index.js +2 -7
- package/src/components/child-layout-control/index.js +14 -0
- package/src/components/colors-gradients/dropdown.js +57 -8
- package/src/components/colors-gradients/style.scss +5 -0
- package/src/components/contrast-checker/index.native.js +2 -2
- package/src/components/contrast-checker/stories/index.story.js +117 -0
- package/src/components/date-format-picker/README.md +6 -13
- package/src/components/date-format-picker/index.js +10 -17
- package/src/components/date-format-picker/stories/index.story.js +69 -0
- package/src/components/date-format-picker/style.scss +3 -1
- package/src/components/default-block-appender/content.scss +1 -0
- package/src/components/dimensions-tool/stories/aspect-ratio-tool.story.js +2 -1
- package/src/components/dimensions-tool/stories/index.story.js +2 -1
- package/src/components/dimensions-tool/stories/scale-tool.story.js +2 -1
- package/src/components/dimensions-tool/stories/width-height-tool.story.js +2 -1
- package/src/components/font-appearance-control/index.js +15 -0
- package/src/components/font-family/README.md +1 -0
- package/src/components/font-family/index.js +17 -1
- package/src/components/font-family/stories/index.story.js +1 -0
- package/src/components/global-styles/color-panel.js +3 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-utils.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/grid/grid-visualizer.js +11 -0
- package/src/components/grid/utils.js +19 -1
- package/src/components/iframe/index.js +1 -1
- package/src/components/inner-blocks/use-inner-block-template-sync.js +17 -10
- package/src/components/inserter/block-patterns-explorer/index.js +2 -3
- package/src/components/inserter/block-patterns-tab/index.js +3 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
- package/src/components/inserter/category-tabs/index.js +3 -2
- package/src/components/inserter/index.js +1 -13
- package/src/components/inserter/quick-inserter.js +2 -25
- package/src/components/keyboard-shortcuts/index.js +2 -2
- package/src/components/line-height-control/README.md +1 -0
- package/src/components/line-height-control/index.js +12 -0
- package/src/components/line-height-control/stories/index.story.js +1 -0
- package/src/components/line-height-control/test/index.js +7 -1
- package/src/components/list-view/style.scss +10 -5
- package/src/components/media-placeholder/index.js +3 -3
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +28 -36
- package/src/components/media-replace-flow/style.scss +6 -6
- package/src/components/plain-text/README.md +2 -2
- package/src/components/plain-text/index.js +34 -0
- package/src/components/plain-text/stories/index.story.js +75 -0
- package/src/components/provider/index.js +81 -4
- package/src/components/provider/use-media-upload-settings.js +25 -0
- package/src/components/resolution-tool/index.js +2 -0
- package/src/components/resolution-tool/stories/index.story.js +36 -8
- package/src/components/responsive-block-control/index.js +1 -1
- package/src/components/rich-text/event-listeners/delete.js +6 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/text-alignment-control/README.md +49 -0
- package/src/components/text-alignment-control/stories/index.story.js +56 -18
- package/src/components/text-decoration-control/README.md +0 -1
- package/src/components/text-decoration-control/stories/index.story.js +51 -16
- package/src/components/text-transform-control/README.md +3 -4
- package/src/components/text-transform-control/stories/index.story.js +53 -16
- package/src/components/use-block-drop-zone/index.js +8 -1
- package/src/components/warning/stories/index.story.js +86 -0
- package/src/hooks/background.js +6 -0
- package/src/hooks/block-bindings.js +17 -18
- package/src/hooks/border.js +9 -3
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/font-family.js +1 -1
- package/src/hooks/gap.js +2 -2
- package/src/hooks/index.js +0 -1
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/style.js +13 -7
- package/src/hooks/supports.js +7 -7
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/typography.js +6 -6
- package/src/hooks/use-zoom-out.js +10 -2
- package/src/hooks/utils.js +1 -1
- package/src/store/private-actions.js +1 -0
- package/src/store/private-selectors.js +15 -5
- package/src/store/reducer.js +112 -19
- package/src/store/selectors.js +6 -8
- package/src/store/test/private-selectors.js +53 -9
- package/src/store/test/reducer.js +172 -166
- package/src/store/test/selectors.js +23 -0
- package/src/utils/block-bindings.js +95 -0
- package/tsconfig.json +2 -5
- package/build/hooks/use-bindings-attributes.js +0 -262
- package/build/hooks/use-bindings-attributes.js.map +0 -1
- package/build-module/hooks/use-bindings-attributes.js +0 -253
- package/build-module/hooks/use-bindings-attributes.js.map +0 -1
- package/src/hooks/use-bindings-attributes.js +0 -322
|
@@ -6,22 +6,55 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import deprecated from '@wordpress/deprecated';
|
|
10
9
|
import {
|
|
11
10
|
Button,
|
|
12
11
|
__experimentalText as Text,
|
|
13
12
|
__experimentalVStack as VStack,
|
|
13
|
+
privateApis as componentsPrivateApis,
|
|
14
14
|
} from '@wordpress/components';
|
|
15
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
16
|
+
import deprecated from '@wordpress/deprecated';
|
|
17
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
15
18
|
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
16
|
-
import { __, _x, isRTL, sprintf } from '@wordpress/i18n';
|
|
17
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
21
22
|
*/
|
|
22
|
-
import
|
|
23
|
+
import { unlock } from '../../lock-unlock';
|
|
23
24
|
import { store as blockEditorStore } from '../../store';
|
|
25
|
+
import BlockIcon from '../block-icon';
|
|
24
26
|
|
|
27
|
+
const { Badge } = unlock( componentsPrivateApis );
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A card component that displays block information including title, icon, and description.
|
|
31
|
+
* Can be used to show block metadata and navigation controls for parent blocks.
|
|
32
|
+
*
|
|
33
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-card/README.md
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```jsx
|
|
37
|
+
* function Example() {
|
|
38
|
+
* return (
|
|
39
|
+
* <BlockCard
|
|
40
|
+
* title="My Block"
|
|
41
|
+
* icon="smiley"
|
|
42
|
+
* description="A simple block example"
|
|
43
|
+
* name="Custom Block"
|
|
44
|
+
* />
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} props Component props.
|
|
50
|
+
* @param {string} props.title The title of the block.
|
|
51
|
+
* @param {string|Object} props.icon The icon of the block. This can be any of [WordPress' Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element.
|
|
52
|
+
* @param {string} props.description The description of the block.
|
|
53
|
+
* @param {Object} [props.blockType] Deprecated: Object containing block type data.
|
|
54
|
+
* @param {string} [props.className] Additional classes to apply to the card.
|
|
55
|
+
* @param {string} [props.name] Custom block name to display before the title.
|
|
56
|
+
* @return {Element} Block card component.
|
|
57
|
+
*/
|
|
25
58
|
function BlockCard( { title, icon, description, blockType, className, name } ) {
|
|
26
59
|
if ( blockType ) {
|
|
27
60
|
deprecated( '`blockType` property in `BlockCard component`', {
|
|
@@ -66,14 +99,10 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
|
|
|
66
99
|
<BlockIcon icon={ icon } showColors />
|
|
67
100
|
<VStack spacing={ 1 }>
|
|
68
101
|
<h2 className="block-editor-block-card__title">
|
|
69
|
-
|
|
70
|
-
?
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
name,
|
|
74
|
-
title
|
|
75
|
-
)
|
|
76
|
-
: title }
|
|
102
|
+
<span className="block-editor-block-card__name">
|
|
103
|
+
{ !! name?.length ? name : title }
|
|
104
|
+
</span>
|
|
105
|
+
{ !! name?.length && <Badge>{ title }</Badge> }
|
|
77
106
|
</h2>
|
|
78
107
|
{ description && (
|
|
79
108
|
<Text className="block-editor-block-card__description">
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { box, button, cog, paragraph } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BlockCard from '../';
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'BlockEditor/BlockCard',
|
|
13
|
+
component: BlockCard,
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
description: {
|
|
17
|
+
component:
|
|
18
|
+
'The `BlockCard` component allows to display a "card" which contains the title of a block, its icon and its description.',
|
|
19
|
+
},
|
|
20
|
+
canvas: { sourceState: 'shown' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
title: {
|
|
25
|
+
control: 'text',
|
|
26
|
+
description: 'The title of the block.',
|
|
27
|
+
table: {
|
|
28
|
+
type: { summary: 'string' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
control: 'text',
|
|
33
|
+
description: 'A description of the block functionality.',
|
|
34
|
+
table: {
|
|
35
|
+
type: { summary: 'string' },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
icon: {
|
|
39
|
+
control: 'select',
|
|
40
|
+
options: [ 'paragraph', 'cog', 'box', 'button' ],
|
|
41
|
+
mapping: {
|
|
42
|
+
paragraph,
|
|
43
|
+
cog,
|
|
44
|
+
box,
|
|
45
|
+
button,
|
|
46
|
+
},
|
|
47
|
+
description:
|
|
48
|
+
'The icon of the block. This can be any of [WordPress Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element.',
|
|
49
|
+
table: {
|
|
50
|
+
type: { summary: 'string | object' },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
name: {
|
|
54
|
+
control: 'text',
|
|
55
|
+
description: 'Optional custom name for the block.',
|
|
56
|
+
table: {
|
|
57
|
+
type: { summary: 'string' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
className: {
|
|
61
|
+
control: 'text',
|
|
62
|
+
description: 'Additional CSS class names.',
|
|
63
|
+
table: {
|
|
64
|
+
type: { summary: 'string' },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default meta;
|
|
71
|
+
|
|
72
|
+
export const Default = {
|
|
73
|
+
args: {
|
|
74
|
+
title: 'Paragraph',
|
|
75
|
+
icon: paragraph,
|
|
76
|
+
description: 'This is a paragraph block description.',
|
|
77
|
+
name: 'Paragraph Block',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -7,15 +7,22 @@
|
|
|
7
7
|
|
|
8
8
|
.block-editor-block-card__title {
|
|
9
9
|
font-weight: 500;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
gap: calc($grid-unit-10 / 2) $grid-unit-10;
|
|
10
14
|
|
|
11
15
|
&.block-editor-block-card__title {
|
|
12
16
|
font-size: $default-font-size;
|
|
13
17
|
line-height: $default-line-height;
|
|
14
18
|
margin: 0;
|
|
15
|
-
padding: 3px 0; // This makes the title as high as the icon.
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
.block-editor-block-card__name {
|
|
23
|
+
padding: 3px 0; // This makes the title as high as the icon.
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
.block-editor-block-card .block-editor-block-icon {
|
|
20
27
|
flex: 0 0 $button-size-small;
|
|
21
28
|
margin-left: 0;
|
|
@@ -27,3 +34,4 @@
|
|
|
27
34
|
.block-editor-block-card.is-synced .block-editor-block-icon {
|
|
28
35
|
color: var(--wp-block-synced-color);
|
|
29
36
|
}
|
|
37
|
+
|
|
@@ -6,18 +6,27 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { withFilters } from '@wordpress/components';
|
|
10
9
|
import {
|
|
11
10
|
getBlockDefaultClassName,
|
|
12
|
-
hasBlockSupport,
|
|
13
11
|
getBlockType,
|
|
12
|
+
hasBlockSupport,
|
|
13
|
+
store as blocksStore,
|
|
14
14
|
} from '@wordpress/blocks';
|
|
15
|
-
import {
|
|
15
|
+
import { withFilters } from '@wordpress/components';
|
|
16
|
+
import { useRegistry, useSelect } from '@wordpress/data';
|
|
17
|
+
import { useCallback, useContext, useMemo } from '@wordpress/element';
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Internal dependencies
|
|
19
21
|
*/
|
|
20
22
|
import BlockContext from '../block-context';
|
|
23
|
+
import isURLLike from '../link-control/is-url-like';
|
|
24
|
+
import {
|
|
25
|
+
canBindAttribute,
|
|
26
|
+
hasPatternOverridesDefaultBinding,
|
|
27
|
+
replacePatternOverridesDefaultBinding,
|
|
28
|
+
} from '../../utils/block-bindings';
|
|
29
|
+
import { unlock } from '../../lock-unlock';
|
|
21
30
|
|
|
22
31
|
/**
|
|
23
32
|
* Default value used for blocks which do not define their own context needs,
|
|
@@ -48,27 +57,223 @@ const Edit = ( props ) => {
|
|
|
48
57
|
const EditWithFilters = withFilters( 'editor.BlockEdit' )( Edit );
|
|
49
58
|
|
|
50
59
|
const EditWithGeneratedProps = ( props ) => {
|
|
51
|
-
const {
|
|
60
|
+
const { name, clientId, attributes, setAttributes } = props;
|
|
61
|
+
const registry = useRegistry();
|
|
52
62
|
const blockType = getBlockType( name );
|
|
53
63
|
const blockContext = useContext( BlockContext );
|
|
64
|
+
const registeredSources = useSelect(
|
|
65
|
+
( select ) =>
|
|
66
|
+
unlock( select( blocksStore ) ).getAllBlockBindingsSources(),
|
|
67
|
+
[]
|
|
68
|
+
);
|
|
54
69
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
const { blockBindings, context, hasPatternOverrides } = useMemo( () => {
|
|
71
|
+
// Assign context values using the block type's declared context needs.
|
|
72
|
+
const computedContext = blockType?.usesContext
|
|
58
73
|
? Object.fromEntries(
|
|
59
74
|
Object.entries( blockContext ).filter( ( [ key ] ) =>
|
|
60
75
|
blockType.usesContext.includes( key )
|
|
61
76
|
)
|
|
62
77
|
)
|
|
63
78
|
: DEFAULT_BLOCK_CONTEXT;
|
|
64
|
-
|
|
79
|
+
// Add context requested by Block Bindings sources.
|
|
80
|
+
if ( attributes?.metadata?.bindings ) {
|
|
81
|
+
Object.values( attributes?.metadata?.bindings || {} ).forEach(
|
|
82
|
+
( binding ) => {
|
|
83
|
+
registeredSources[ binding?.source ]?.usesContext?.forEach(
|
|
84
|
+
( key ) => {
|
|
85
|
+
computedContext[ key ] = blockContext[ key ];
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
blockBindings: replacePatternOverridesDefaultBinding(
|
|
93
|
+
name,
|
|
94
|
+
attributes?.metadata?.bindings
|
|
95
|
+
),
|
|
96
|
+
context: computedContext,
|
|
97
|
+
hasPatternOverrides: hasPatternOverridesDefaultBinding(
|
|
98
|
+
attributes?.metadata?.bindings
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
}, [
|
|
102
|
+
name,
|
|
103
|
+
blockType?.usesContext,
|
|
104
|
+
blockContext,
|
|
105
|
+
attributes?.metadata?.bindings,
|
|
106
|
+
registeredSources,
|
|
107
|
+
] );
|
|
108
|
+
|
|
109
|
+
const computedAttributes = useSelect(
|
|
110
|
+
( select ) => {
|
|
111
|
+
if ( ! blockBindings ) {
|
|
112
|
+
return attributes;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const attributesFromSources = {};
|
|
116
|
+
const blockBindingsBySource = new Map();
|
|
117
|
+
|
|
118
|
+
for ( const [ attributeName, binding ] of Object.entries(
|
|
119
|
+
blockBindings
|
|
120
|
+
) ) {
|
|
121
|
+
const { source: sourceName, args: sourceArgs } = binding;
|
|
122
|
+
const source = registeredSources[ sourceName ];
|
|
123
|
+
if ( ! source || ! canBindAttribute( name, attributeName ) ) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
blockBindingsBySource.set( source, {
|
|
128
|
+
...blockBindingsBySource.get( source ),
|
|
129
|
+
[ attributeName ]: {
|
|
130
|
+
args: sourceArgs,
|
|
131
|
+
},
|
|
132
|
+
} );
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if ( blockBindingsBySource.size ) {
|
|
136
|
+
for ( const [ source, bindings ] of blockBindingsBySource ) {
|
|
137
|
+
// Get values in batch if the source supports it.
|
|
138
|
+
let values = {};
|
|
139
|
+
if ( ! source.getValues ) {
|
|
140
|
+
Object.keys( bindings ).forEach( ( attr ) => {
|
|
141
|
+
// Default to the the source label when `getValues` doesn't exist.
|
|
142
|
+
values[ attr ] = source.label;
|
|
143
|
+
} );
|
|
144
|
+
} else {
|
|
145
|
+
values = source.getValues( {
|
|
146
|
+
select,
|
|
147
|
+
context,
|
|
148
|
+
clientId,
|
|
149
|
+
bindings,
|
|
150
|
+
} );
|
|
151
|
+
}
|
|
152
|
+
for ( const [ attributeName, value ] of Object.entries(
|
|
153
|
+
values
|
|
154
|
+
) ) {
|
|
155
|
+
if (
|
|
156
|
+
attributeName === 'url' &&
|
|
157
|
+
( ! value || ! isURLLike( value ) )
|
|
158
|
+
) {
|
|
159
|
+
// Return null if value is not a valid URL.
|
|
160
|
+
attributesFromSources[ attributeName ] = null;
|
|
161
|
+
} else {
|
|
162
|
+
attributesFromSources[ attributeName ] = value;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
...attributes,
|
|
170
|
+
...attributesFromSources,
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
[
|
|
174
|
+
attributes,
|
|
175
|
+
blockBindings,
|
|
176
|
+
clientId,
|
|
177
|
+
context,
|
|
178
|
+
name,
|
|
179
|
+
registeredSources,
|
|
180
|
+
]
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const setBoundAttributes = useCallback(
|
|
184
|
+
( nextAttributes ) => {
|
|
185
|
+
if ( ! blockBindings ) {
|
|
186
|
+
setAttributes( nextAttributes );
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
registry.batch( () => {
|
|
191
|
+
const keptAttributes = { ...nextAttributes };
|
|
192
|
+
const blockBindingsBySource = new Map();
|
|
193
|
+
|
|
194
|
+
// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.
|
|
195
|
+
for ( const [ attributeName, newValue ] of Object.entries(
|
|
196
|
+
keptAttributes
|
|
197
|
+
) ) {
|
|
198
|
+
if (
|
|
199
|
+
! blockBindings[ attributeName ] ||
|
|
200
|
+
! canBindAttribute( name, attributeName )
|
|
201
|
+
) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const binding = blockBindings[ attributeName ];
|
|
206
|
+
const source = registeredSources[ binding?.source ];
|
|
207
|
+
if ( ! source?.setValues ) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
blockBindingsBySource.set( source, {
|
|
211
|
+
...blockBindingsBySource.get( source ),
|
|
212
|
+
[ attributeName ]: {
|
|
213
|
+
args: binding.args,
|
|
214
|
+
newValue,
|
|
215
|
+
},
|
|
216
|
+
} );
|
|
217
|
+
delete keptAttributes[ attributeName ];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if ( blockBindingsBySource.size ) {
|
|
221
|
+
for ( const [
|
|
222
|
+
source,
|
|
223
|
+
bindings,
|
|
224
|
+
] of blockBindingsBySource ) {
|
|
225
|
+
source.setValues( {
|
|
226
|
+
select: registry.select,
|
|
227
|
+
dispatch: registry.dispatch,
|
|
228
|
+
context,
|
|
229
|
+
clientId,
|
|
230
|
+
bindings,
|
|
231
|
+
} );
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const hasParentPattern = !! context[ 'pattern/overrides' ];
|
|
236
|
+
|
|
237
|
+
if (
|
|
238
|
+
// Don't update non-connected attributes if the block is using pattern overrides
|
|
239
|
+
// and the editing is happening while overriding the pattern (not editing the original).
|
|
240
|
+
! ( hasPatternOverrides && hasParentPattern ) &&
|
|
241
|
+
Object.keys( keptAttributes ).length
|
|
242
|
+
) {
|
|
243
|
+
// Don't update caption and href until they are supported.
|
|
244
|
+
if ( hasPatternOverrides ) {
|
|
245
|
+
delete keptAttributes.caption;
|
|
246
|
+
delete keptAttributes.href;
|
|
247
|
+
}
|
|
248
|
+
setAttributes( keptAttributes );
|
|
249
|
+
}
|
|
250
|
+
} );
|
|
251
|
+
},
|
|
252
|
+
[
|
|
253
|
+
blockBindings,
|
|
254
|
+
clientId,
|
|
255
|
+
context,
|
|
256
|
+
hasPatternOverrides,
|
|
257
|
+
setAttributes,
|
|
258
|
+
registeredSources,
|
|
259
|
+
name,
|
|
260
|
+
registry,
|
|
261
|
+
]
|
|
262
|
+
);
|
|
65
263
|
|
|
66
264
|
if ( ! blockType ) {
|
|
67
265
|
return null;
|
|
68
266
|
}
|
|
69
267
|
|
|
70
268
|
if ( blockType.apiVersion > 1 ) {
|
|
71
|
-
return
|
|
269
|
+
return (
|
|
270
|
+
<EditWithFilters
|
|
271
|
+
{ ...props }
|
|
272
|
+
attributes={ computedAttributes }
|
|
273
|
+
context={ context }
|
|
274
|
+
setAttributes={ setBoundAttributes }
|
|
275
|
+
/>
|
|
276
|
+
);
|
|
72
277
|
}
|
|
73
278
|
|
|
74
279
|
// Generate a class name for the block's editable form.
|
|
@@ -77,15 +282,17 @@ const EditWithGeneratedProps = ( props ) => {
|
|
|
77
282
|
: null;
|
|
78
283
|
const className = clsx(
|
|
79
284
|
generatedClassName,
|
|
80
|
-
attributes
|
|
285
|
+
attributes?.className,
|
|
81
286
|
props.className
|
|
82
287
|
);
|
|
83
288
|
|
|
84
289
|
return (
|
|
85
290
|
<EditWithFilters
|
|
86
291
|
{ ...props }
|
|
87
|
-
|
|
292
|
+
attributes={ computedAttributes }
|
|
88
293
|
className={ className }
|
|
294
|
+
context={ context }
|
|
295
|
+
setAttributes={ setBoundAttributes }
|
|
89
296
|
/>
|
|
90
297
|
);
|
|
91
298
|
};
|
|
@@ -12,11 +12,7 @@ import {
|
|
|
12
12
|
useDispatch,
|
|
13
13
|
useRegistry,
|
|
14
14
|
} from '@wordpress/data';
|
|
15
|
-
import {
|
|
16
|
-
useViewportMatch,
|
|
17
|
-
useMergeRefs,
|
|
18
|
-
useDebounce,
|
|
19
|
-
} from '@wordpress/compose';
|
|
15
|
+
import { useMergeRefs, useDebounce } from '@wordpress/compose';
|
|
20
16
|
import {
|
|
21
17
|
createContext,
|
|
22
18
|
useMemo,
|
|
@@ -46,7 +42,6 @@ export const IntersectionObserver = createContext();
|
|
|
46
42
|
const pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();
|
|
47
43
|
|
|
48
44
|
function Root( { className, ...settings } ) {
|
|
49
|
-
const isLargeViewport = useViewportMatch( 'medium' );
|
|
50
45
|
const { isOutlineMode, isFocusMode, temporarilyEditingAsBlocks } =
|
|
51
46
|
useSelect( ( select ) => {
|
|
52
47
|
const { getSettings, getTemporarilyEditingAsBlocks, isTyping } =
|
|
@@ -105,7 +100,7 @@ function Root( { className, ...settings } ) {
|
|
|
105
100
|
] ),
|
|
106
101
|
className: clsx( 'is-root-container', className, {
|
|
107
102
|
'is-outline-mode': isOutlineMode,
|
|
108
|
-
'is-focus-mode': isFocusMode
|
|
103
|
+
'is-focus-mode': isFocusMode,
|
|
109
104
|
} ),
|
|
110
105
|
},
|
|
111
106
|
settings
|
|
@@ -29,7 +29,7 @@ import { useBlockRefProvider } from './use-block-refs';
|
|
|
29
29
|
import { useIntersectionObserver } from './use-intersection-observer';
|
|
30
30
|
import { useScrollIntoView } from './use-scroll-into-view';
|
|
31
31
|
import { useFlashEditableBlocks } from '../../use-flash-editable-blocks';
|
|
32
|
-
import { canBindBlock } from '../../../
|
|
32
|
+
import { canBindBlock } from '../../../utils/block-bindings';
|
|
33
33
|
import { useFirefoxDraggableCompatibility } from './use-firefox-draggable-compatibility';
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -33,6 +33,7 @@ export function ZoomOutSeparator( {
|
|
|
33
33
|
insertionPoint,
|
|
34
34
|
blockInsertionPointVisible,
|
|
35
35
|
blockInsertionPoint,
|
|
36
|
+
blocksBeingDragged,
|
|
36
37
|
} = useSelect( ( select ) => {
|
|
37
38
|
const {
|
|
38
39
|
getInsertionPoint,
|
|
@@ -40,6 +41,7 @@ export function ZoomOutSeparator( {
|
|
|
40
41
|
getSectionRootClientId,
|
|
41
42
|
isBlockInsertionPointVisible,
|
|
42
43
|
getBlockInsertionPoint,
|
|
44
|
+
getDraggedBlockClientIds,
|
|
43
45
|
} = unlock( select( blockEditorStore ) );
|
|
44
46
|
|
|
45
47
|
const root = getSectionRootClientId();
|
|
@@ -51,6 +53,7 @@ export function ZoomOutSeparator( {
|
|
|
51
53
|
insertionPoint: getInsertionPoint(),
|
|
52
54
|
blockInsertionPoint: getBlockInsertionPoint(),
|
|
53
55
|
blockInsertionPointVisible: isBlockInsertionPointVisible(),
|
|
56
|
+
blocksBeingDragged: getDraggedBlockClientIds(),
|
|
54
57
|
};
|
|
55
58
|
}, [] );
|
|
56
59
|
|
|
@@ -78,6 +81,7 @@ export function ZoomOutSeparator( {
|
|
|
78
81
|
insertionPoint &&
|
|
79
82
|
insertionPoint.hasOwnProperty( 'index' ) &&
|
|
80
83
|
clientId === sectionClientIds[ insertionPoint.index - 1 ];
|
|
84
|
+
|
|
81
85
|
// We want to show the zoom out separator in either of these conditions:
|
|
82
86
|
// 1. If the inserter has an insertion index set
|
|
83
87
|
// 2. We are dragging a pattern over an insertion point
|
|
@@ -97,6 +101,32 @@ export function ZoomOutSeparator( {
|
|
|
97
101
|
sectionClientIds[ blockInsertionPoint.index - 1 ] );
|
|
98
102
|
}
|
|
99
103
|
|
|
104
|
+
const blockBeingDraggedClientId = blocksBeingDragged[ 0 ];
|
|
105
|
+
|
|
106
|
+
const isCurrentBlockBeingDragged = blocksBeingDragged.includes( clientId );
|
|
107
|
+
|
|
108
|
+
const blockBeingDraggedIndex = sectionClientIds.indexOf(
|
|
109
|
+
blockBeingDraggedClientId
|
|
110
|
+
);
|
|
111
|
+
const blockBeingDraggedPreviousSiblingClientId =
|
|
112
|
+
blockBeingDraggedIndex > 0
|
|
113
|
+
? sectionClientIds[ blockBeingDraggedIndex - 1 ]
|
|
114
|
+
: null;
|
|
115
|
+
|
|
116
|
+
const isCurrentBlockPreviousSiblingOfBlockBeingDragged =
|
|
117
|
+
blockBeingDraggedPreviousSiblingClientId === clientId;
|
|
118
|
+
|
|
119
|
+
// The separators are visually top/bottom of the block, but in actual fact
|
|
120
|
+
// the "top" separator is the "bottom" separator of the previous block.
|
|
121
|
+
// Therefore, this logic hides the separator if the current block is being dragged
|
|
122
|
+
// or if the current block is the previous sibling of the block being dragged.
|
|
123
|
+
if (
|
|
124
|
+
isCurrentBlockBeingDragged ||
|
|
125
|
+
isCurrentBlockPreviousSiblingOfBlockBeingDragged
|
|
126
|
+
) {
|
|
127
|
+
isVisible = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
100
130
|
return (
|
|
101
131
|
<AnimatePresence>
|
|
102
132
|
{ isVisible && (
|
|
@@ -65,7 +65,6 @@ export function BlockSettingsDropdown( {
|
|
|
65
65
|
selectedBlockClientIds,
|
|
66
66
|
openedBlockSettingsMenu,
|
|
67
67
|
isContentOnly,
|
|
68
|
-
isZoomOut,
|
|
69
68
|
} = useSelect(
|
|
70
69
|
( select ) => {
|
|
71
70
|
const {
|
|
@@ -76,7 +75,6 @@ export function BlockSettingsDropdown( {
|
|
|
76
75
|
getBlockAttributes,
|
|
77
76
|
getOpenedBlockSettingsMenu,
|
|
78
77
|
getBlockEditingMode,
|
|
79
|
-
isZoomOut: _isZoomOut,
|
|
80
78
|
} = unlock( select( blockEditorStore ) );
|
|
81
79
|
|
|
82
80
|
const { getActiveBlockVariation } = select( blocksStore );
|
|
@@ -101,7 +99,6 @@ export function BlockSettingsDropdown( {
|
|
|
101
99
|
openedBlockSettingsMenu: getOpenedBlockSettingsMenu(),
|
|
102
100
|
isContentOnly:
|
|
103
101
|
getBlockEditingMode( firstBlockClientId ) === 'contentOnly',
|
|
104
|
-
isZoomOut: _isZoomOut(),
|
|
105
102
|
};
|
|
106
103
|
},
|
|
107
104
|
[ firstBlockClientId ]
|
|
@@ -253,15 +250,13 @@ export function BlockSettingsDropdown( {
|
|
|
253
250
|
clientId={ firstBlockClientId }
|
|
254
251
|
/>
|
|
255
252
|
) }
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
/>
|
|
264
|
-
) }
|
|
253
|
+
<CopyMenuItem
|
|
254
|
+
clientIds={ clientIds }
|
|
255
|
+
onCopy={ onCopy }
|
|
256
|
+
shortcut={ displayShortcut.primary(
|
|
257
|
+
'c'
|
|
258
|
+
) }
|
|
259
|
+
/>
|
|
265
260
|
{ canDuplicate && (
|
|
266
261
|
<MenuItem
|
|
267
262
|
onClick={ pipe(
|
|
@@ -316,14 +311,16 @@ export function BlockSettingsDropdown( {
|
|
|
316
311
|
</MenuItem>
|
|
317
312
|
</MenuGroup>
|
|
318
313
|
) }
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
314
|
+
{ ! isContentOnly && (
|
|
315
|
+
<BlockSettingsMenuControls.Slot
|
|
316
|
+
fillProps={ {
|
|
317
|
+
onClose,
|
|
318
|
+
count,
|
|
319
|
+
firstBlockClientId,
|
|
320
|
+
} }
|
|
321
|
+
clientIds={ clientIds }
|
|
322
|
+
/>
|
|
323
|
+
) }
|
|
327
324
|
{ typeof children === 'function'
|
|
328
325
|
? children( { onClose } )
|
|
329
326
|
: Children.map( ( child ) =>
|
|
@@ -10,7 +10,7 @@ import { _x } from '@wordpress/i18n';
|
|
|
10
10
|
* @param {Array} styles Block styles.
|
|
11
11
|
* @param {string} className Class name
|
|
12
12
|
*
|
|
13
|
-
* @return {Object
|
|
13
|
+
* @return {?Object} The active style.
|
|
14
14
|
*/
|
|
15
15
|
export function getActiveStyle( styles, className ) {
|
|
16
16
|
for ( const style of new TokenList( className ).values() ) {
|
|
@@ -34,7 +34,7 @@ export function getActiveStyle( styles, className ) {
|
|
|
34
34
|
* Replaces the active style in the block's className.
|
|
35
35
|
*
|
|
36
36
|
* @param {string} className Class name.
|
|
37
|
-
* @param {Object
|
|
37
|
+
* @param {?Object} activeStyle The replaced style.
|
|
38
38
|
* @param {Object} newStyle The replacing style.
|
|
39
39
|
*
|
|
40
40
|
* @return {string} The updated className.
|
|
@@ -83,7 +83,7 @@ export function getRenderedStyles( styles ) {
|
|
|
83
83
|
*
|
|
84
84
|
* @param {Array} styles Block styles.
|
|
85
85
|
*
|
|
86
|
-
* @return {Object
|
|
86
|
+
* @return {?Object} The default style object, if found.
|
|
87
87
|
*/
|
|
88
88
|
export function getDefaultStyle( styles ) {
|
|
89
89
|
return styles?.find( ( style ) => style.isDefault );
|