@wordpress/block-editor 12.15.0 → 12.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +9 -4
- package/build/components/block-canvas/index.js +22 -6
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +1 -1
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -23
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-edit/context.js +5 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +18 -9
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +3 -4
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-list/block.js +28 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +14 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +61 -18
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -9
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js +3 -0
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings/container.native.js +6 -4
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +1 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +3 -2
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +89 -27
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build/components/block-tools/block-toolbar-popover.js +86 -0
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build/components/block-tools/index.js +27 -24
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -3
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +2 -1
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +28 -17
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -4
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +22 -20
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +9 -3
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +20 -31
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/image-link-destinations/index.native.js +118 -0
- package/build/components/image-link-destinations/index.native.js.map +1 -0
- package/build/components/index.native.js +8 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +2 -2
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +14 -7
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +2 -2
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter-button/index.native.js +98 -0
- package/build/components/inserter-button/index.native.js.map +1 -0
- package/build/components/inserter-button/sparkles.js +23 -0
- package/build/components/inserter-button/sparkles.js.map +1 -0
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +3 -3
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +2 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/preview-options/index.js +6 -62
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +26 -23
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +2 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/rich-text/index.js +2 -30
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +9 -16
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +7 -34
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +5 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +50 -0
- package/build/components/rich-text/with-deprecations.js.map +1 -0
- package/build/components/use-block-drop-zone/index.js +70 -8
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +4 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +14 -0
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/align.js +20 -68
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +11 -1
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +13 -29
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +28 -31
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +24 -32
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +18 -22
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/border.js +58 -80
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +76 -89
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +29 -29
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +12 -29
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +24 -38
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/dimensions.js +21 -17
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +31 -61
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +16 -25
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -119
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +25 -14
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +10 -3
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout-child.js +68 -0
- package/build/hooks/layout-child.js.map +1 -0
- package/build/hooks/layout.js +16 -101
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/padding.js +2 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +40 -62
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +51 -88
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +34 -14
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +154 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +34 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +8 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +10 -60
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +66 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/object.js +21 -61
- package/build/utils/object.js.map +1 -1
- package/build/utils/selection.js +9 -1
- package/build/utils/selection.js.map +1 -1
- package/build-module/components/block-canvas/index.js +23 -7
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +1 -1
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -24
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-edit/context.js +2 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +19 -10
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +3 -3
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-list/block.js +29 -10
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +14 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +62 -19
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -1
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -10
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +3 -0
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +4 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +3 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +88 -25
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build-module/components/block-tools/index.js +27 -24
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +2 -1
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +29 -18
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -4
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +23 -21
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +10 -4
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +20 -31
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +109 -0
- package/build-module/components/image-link-destinations/index.native.js.map +1 -0
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +14 -7
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +2 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +89 -0
- package/build-module/components/inserter-button/index.native.js.map +1 -0
- package/build-module/components/inserter-button/sparkles.js +15 -0
- package/build-module/components/inserter-button/sparkles.js.map +1 -0
- package/build-module/components/inserter-draggable-blocks/index.js +9 -5
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +3 -3
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +2 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +6 -62
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +25 -21
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +2 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -32
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +10 -18
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +7 -34
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +5 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +42 -0
- package/build-module/components/rich-text/with-deprecations.js.map +1 -0
- package/build-module/components/use-block-drop-zone/index.js +69 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +4 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +13 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/align.js +19 -66
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -0
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +11 -26
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +26 -28
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +22 -30
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +17 -21
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/border.js +57 -78
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +74 -86
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +27 -27
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +11 -27
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +20 -39
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/dimensions.js +21 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +30 -61
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +14 -23
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +49 -119
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +18 -14
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +5 -3
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout-child.js +60 -0
- package/build-module/hooks/layout-child.js.map +1 -0
- package/build-module/hooks/layout.js +13 -98
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/padding.js +2 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +38 -59
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +51 -84
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +33 -12
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +149 -6
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +33 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +8 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +3 -53
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +56 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/object.js +21 -60
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/selection.js +9 -1
- package/build-module/utils/selection.js.map +1 -1
- package/build-style/style-rtl.css +113 -293
- package/build-style/style.css +113 -293
- package/package.json +31 -31
- package/src/components/block-canvas/index.js +31 -17
- package/src/components/block-caption/README.md +2 -2
- package/src/components/block-card/index.js +5 -3
- package/src/components/block-card/style.scss +7 -3
- package/src/components/block-controls/hook.js +8 -30
- package/src/components/block-controls/test/index.js +3 -3
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +36 -10
- package/src/components/block-info-slot-fill/index.js +6 -3
- package/src/components/block-inspector/style.scss +0 -4
- package/src/components/block-list/block.js +39 -5
- package/src/components/block-list/block.native.js +18 -4
- package/src/components/block-list/use-block-props/index.js +74 -21
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-removal-warning-modal/index.js +7 -14
- package/src/components/block-rename/modal.js +7 -1
- package/src/components/block-settings/container.native.js +3 -5
- package/src/components/block-styles/index.js +1 -1
- package/src/components/block-styles/index.native.js +4 -2
- package/src/components/block-styles/style.scss +0 -11
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
- package/src/components/block-toolbar/index.js +180 -95
- package/src/components/block-toolbar/style.scss +50 -66
- package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
- package/src/components/block-tools/block-toolbar-popover.js +90 -0
- package/src/components/block-tools/index.js +42 -29
- package/src/components/block-tools/style.scss +60 -172
- package/src/components/block-types-list/index.native.js +2 -1
- package/src/components/block-variation-picker/index.native.js +1 -1
- package/src/components/colors-gradients/control.js +49 -30
- package/src/components/colors-gradients/style.scss +0 -7
- package/src/components/duotone-control/index.js +2 -5
- package/src/components/duotone-control/style.scss +1 -6
- package/src/components/global-styles/color-panel.js +34 -25
- package/src/components/global-styles/filters-panel.js +8 -4
- package/src/components/global-styles/typography-panel.js +23 -43
- package/src/components/image-link-destinations/index.native.js +152 -0
- package/src/components/image-link-destinations/style.native.scss +16 -0
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/README.md +13 -2
- package/src/components/inserter/media-tab/media-panel.js +1 -1
- package/src/components/inserter/menu.js +16 -8
- package/src/components/inserter/preview-panel.js +2 -2
- package/src/components/inserter/style.scss +15 -17
- package/src/components/inserter-button/README.md +62 -0
- package/src/components/inserter-button/index.native.js +116 -0
- package/src/components/inserter-button/sparkles.js +15 -0
- package/src/components/inserter-button/style.native.scss +72 -0
- package/src/components/inserter-draggable-blocks/index.js +18 -5
- package/src/components/inspector-controls/fill.js +6 -3
- package/src/components/inspector-controls/fill.native.js +6 -3
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/navigable-toolbar/README.md +2 -0
- package/src/components/navigable-toolbar/index.js +2 -2
- package/src/components/preview-options/index.js +6 -86
- package/src/components/rich-text/content.js +27 -20
- package/src/components/rich-text/get-rich-text-values.js +6 -1
- package/src/components/rich-text/index.js +5 -46
- package/src/components/rich-text/index.native.js +8 -25
- package/src/components/rich-text/native/get-format-colors.native.js +33 -40
- package/src/components/rich-text/native/index.native.js +7 -48
- package/src/components/rich-text/use-input-rules.js +6 -1
- package/src/components/rich-text/with-deprecations.js +51 -0
- package/src/components/use-block-drop-zone/index.js +114 -14
- package/src/components/use-on-block-drop/index.js +2 -1
- package/src/components/use-resize-canvas/README.md +3 -3
- package/src/components/use-resize-canvas/index.js +4 -1
- package/src/components/use-settings/index.js +15 -1
- package/src/hooks/align.js +15 -76
- package/src/hooks/align.native.js +1 -0
- package/src/hooks/anchor.js +13 -33
- package/src/hooks/background.js +28 -23
- package/src/hooks/block-hooks.js +22 -51
- package/src/hooks/block-renaming.js +23 -37
- package/src/hooks/border.js +67 -118
- package/src/hooks/color.js +100 -132
- package/src/hooks/content-lock-ui.js +110 -122
- package/src/hooks/custom-class-name.js +8 -40
- package/src/hooks/custom-fields.js +20 -47
- package/src/hooks/dimensions.js +20 -16
- package/src/hooks/duotone.js +70 -127
- package/src/hooks/font-family.js +10 -29
- package/src/hooks/font-size.js +66 -162
- package/src/hooks/index.js +42 -14
- package/src/hooks/index.native.js +6 -3
- package/src/hooks/layout-child.js +53 -0
- package/src/hooks/layout.js +13 -102
- package/src/hooks/padding.js +2 -2
- package/src/hooks/position.js +50 -90
- package/src/hooks/style.js +117 -187
- package/src/hooks/test/align.js +1 -178
- package/src/hooks/typography.js +20 -16
- package/src/hooks/utils.js +187 -6
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +8 -0
- package/src/store/private-selectors.js +45 -0
- package/src/store/reducer.js +8 -0
- package/src/store/selectors.js +5 -69
- package/src/store/utils.js +74 -0
- package/src/style.scss +0 -2
- package/src/utils/object.js +18 -69
- package/src/utils/selection.js +9 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build/components/block-tools/back-compat.js +0 -45
- package/build/components/block-tools/back-compat.js.map +0 -1
- package/build/components/block-tools/block-contextual-toolbar.js +0 -91
- package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build/components/block-tools/selected-block-tools.js +0 -113
- package/build/components/block-tools/selected-block-tools.js.map +0 -1
- package/build/components/inserter/hooks/use-debounced-input.js +0 -22
- package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build/components/use-display-block-controls/index.js +0 -39
- package/build/components/use-display-block-controls/index.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -39
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build-module/components/block-tools/back-compat.js +0 -35
- package/build-module/components/block-tools/back-compat.js.map +0 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build-module/components/block-tools/selected-block-tools.js +0 -105
- package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.js +0 -32
- package/build-module/components/use-display-block-controls/index.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -32
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
- package/src/components/block-parent-selector/style.scss +0 -11
- package/src/components/block-tools/back-compat.js +0 -35
- package/src/components/block-tools/block-contextual-toolbar.js +0 -100
- package/src/components/block-tools/selected-block-tools.js +0 -127
- package/src/components/inserter/hooks/use-debounced-input.js +0 -18
- package/src/components/preview-options/README.md +0 -94
- package/src/components/preview-options/style.scss +0 -64
- package/src/components/use-display-block-controls/index.js +0 -36
- package/src/components/use-display-block-controls/index.native.js +0 -37
- package/src/hooks/test/color.js +0 -112
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BottomSheet","ColorSettings","FocalPointSettingsPanel","LinkPickerScreen","useDispatch","useSelect","styles","InspectorControls","ImageLinkDestinationsScreen","useMultipleOriginColorsAndGradients","blockSettingsScreens","settings","color","focalPoint","linkPicker","imageLinkDestinations","BottomSheetSettings","props","colorSettings","closeGeneralSidebar","editorSidebarOpened","select","isEditorSidebarOpened","createElement","isVisible","onClose","hideHeader","contentStyle","content","hasNavigation","testID","NavigationContainer","animate","main","NavigationScreen","name","Slot","SubSheet","screenName","defaultSettings","fullScreen","isScrollable","returnScreenName"],"sources":["@wordpress/block-editor/src/components/block-settings/container.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBottomSheet,\n\tColorSettings,\n\tFocalPointSettingsPanel,\n\tLinkPickerScreen,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport styles from './container.native.scss';\nimport InspectorControls from '../inspector-controls';\nimport ImageLinkDestinationsScreen from '../image-link-destinations';\nimport useMultipleOriginColorsAndGradients from '../colors-gradients/use-multiple-origin-colors-and-gradients';\n\nexport const blockSettingsScreens = {\n\tsettings: 'Settings',\n\tcolor: 'Color',\n\tfocalPoint: 'FocalPoint',\n\tlinkPicker: 'linkPicker',\n\timageLinkDestinations: 'imageLinkDestinations',\n};\n\nexport default function BottomSheetSettings( props ) {\n\tconst colorSettings = useMultipleOriginColorsAndGradients();\n\tconst { closeGeneralSidebar } = useDispatch( 'core/edit-post' );\n\tconst editorSidebarOpened = useSelect( ( select ) =>\n\t\tselect( 'core/edit-post' ).isEditorSidebarOpened()\n\t);\n\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible={ editorSidebarOpened }\n\t\t\tonClose={ closeGeneralSidebar }\n\t\t\thideHeader\n\t\t\tcontentStyle={ styles.content }\n\t\t\thasNavigation\n\t\t\ttestID=\"block-settings-modal\"\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\tname={ blockSettingsScreens.settings }\n\t\t\t\t>\n\t\t\t\t\t<InspectorControls.Slot />\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\tname={ BottomSheet.SubSheet.screenName }\n\t\t\t\t>\n\t\t\t\t\t<BottomSheet.SubSheet.Slot />\n\t\t\t\t</BottomSheet.NavigationScreen>\n\n\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\tname={ blockSettingsScreens.color }\n\t\t\t\t>\n\t\t\t\t\t<ColorSettings defaultSettings={ colorSettings } />\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\tname={ blockSettingsScreens.focalPoint }\n\t\t\t\t\tfullScreen\n\t\t\t\t>\n\t\t\t\t\t<FocalPointSettingsPanel />\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\tname={ blockSettingsScreens.linkPicker }\n\t\t\t\t\tfullScreen\n\t\t\t\t\tisScrollable\n\t\t\t\t>\n\t\t\t\t\t<LinkPickerScreen\n\t\t\t\t\t\treturnScreenName={ blockSettingsScreens.settings }\n\t\t\t\t\t/>\n\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\tname={ blockSettingsScreens.imageLinkDestinations }\n\t\t\t\t>\n\t\t\t\t\t<ImageLinkDestinationsScreen { ...props } />\n\t\t\t\t</BottomSheet.NavigationSc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,CAAC,EAC/Bb,aAAA,CAACvB,WAAW,CAACkC,gBAAgB;IAC5BC,IAAI,EAAGnC,WAAW,CAACqC,QAAQ,CAACC;EAAY,GAExCf,aAAA,CAACvB,WAAW,CAACqC,QAAQ,CAACD,IAAI,MAAE,CACC,CAAC,EAE/Bb,aAAA,CAACvB,WAAW,CAACkC,gBAAgB;IAC5BC,IAAI,EAAGzB,oBAAoB,CAACE;EAAO,GAEnCW,aAAA,CAACtB,aAAa;IAACsC,eAAe,EAAGrB;EAAe,CAAE,CACrB,CAAC,EAC/BK,aAAA,CAACvB,WAAW,CAACkC,gBAAgB;IAC5BC,IAAI,EAAGzB,oBAAoB,CAACG,UAAY;IACxC2B,UAAU;EAAA,GAEVjB,aAAA,CAACrB,uBAAuB,MAAE,CACG,CAAC,EAC/BqB,aAAA,CAACvB,WAAW,CAACkC,gBAAgB;IAC5BC,IAAI,EAAGzB,oBAAoB,CAACI,UAAY;IACxC0B,UAAU;IACVC,YAAY;EAAA,GAEZlB,aAAA,CAACpB,gBAAgB;IAChBuC,gBAAgB,EAAGhC,oBAAoB,CAACC;EAAU,CAClD,CAC4B,CAAC,EAC/BY,aAAA,CAACvB,WAAW,CAACkC,gBAAgB;IAC5BC,IAAI,EAAGzB,oBAAoB,CAACK;EAAuB,GAEnDQ,aAAA,CAACf,2BAA2B;IAAA,GAAMS;EAAK,CAAI,CACd,CACE,CACrB,CAAC;AAEhB"}
|
|
@@ -81,7 +81,7 @@ function BlockStyles({
|
|
|
81
81
|
}, buttonText));
|
|
82
82
|
})), hoveredStyle && !isMobileViewport && createElement(Popover, {
|
|
83
83
|
placement: "left-start",
|
|
84
|
-
offset:
|
|
84
|
+
offset: 34,
|
|
85
85
|
focusOnMount: false
|
|
86
86
|
}, createElement("div", {
|
|
87
87
|
className: "block-editor-block-styles__preview-panel",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useState","debounce","useViewportMatch","Button","__experimentalTruncate","Truncate","Popover","BlockStylesPreviewPanel","useStylesForBlocks","noop","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","isMobileViewport","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","_item$name","name","createElement","map","buttonText","label","__next40pxDefaultSize","key","variant","onMouseEnter","onFocus","onMouseLeave","onBlur","onClick","numberOfLines","placement","offset","focusOnMount"],"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { debounce, useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalTruncate as Truncate,\n\tPopover,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nconst noop = () => {};\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\taria-current={ activeStyle.name === style.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"left-start\"\n\t\t\t\t\toffset={
|
|
1
|
+
{"version":3,"names":["classnames","useState","debounce","useViewportMatch","Button","__experimentalTruncate","Truncate","Popover","BlockStylesPreviewPanel","useStylesForBlocks","noop","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","isMobileViewport","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","_item$name","name","createElement","map","buttonText","label","__next40pxDefaultSize","key","variant","onMouseEnter","onFocus","onMouseLeave","onBlur","onClick","numberOfLines","placement","offset","focusOnMount"],"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { debounce, useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalTruncate as Truncate,\n\tPopover,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nconst noop = () => {};\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\taria-current={ activeStyle.name === style.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"left-start\"\n\t\t\t\t\toffset={ 34 }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"block-editor-block-styles__preview-panel\"\n\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockStylesPreviewPanel\n\t\t\t\t\t\t\tactiveStyle={ activeStyle }\n\t\t\t\t\t\t\tclassName={ previewClassName }\n\t\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\t\tstyle={ hoveredStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default BlockStyles;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,oBAAoB;AAC/D,SACCC,MAAM,EACNC,sBAAsB,IAAIC,QAAQ,EAClCC,OAAO,QACD,uBAAuB;;AAE9B;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,iBAAiB;AACrD,OAAOC,kBAAkB,MAAM,wBAAwB;AAEvD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA,SAASC,WAAWA,CAAE;EAAEC,QAAQ;EAAEC,QAAQ,GAAGH,IAAI;EAAEI,gBAAgB,GAAGJ;AAAK,CAAC,EAAG;EAC9E,MAAM;IACLK,QAAQ;IACRC,cAAc;IACdC,WAAW;IACXC,mBAAmB;IACnBC,SAAS,EAAEC;EACZ,CAAC,GAAGX,kBAAkB,CAAE;IACvBG,QAAQ;IACRC;EACD,CAAE,CAAC;EACH,MAAM,CAAEQ,YAAY,EAAEC,eAAe,CAAE,GAAGrB,QAAQ,CAAE,IAAK,CAAC;EAC1D,MA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CAAG;MAChDc,OAAO,EAAGA,CAAA,KAAMZ,gBAAgB,CAAEF,KAAM,CAAG;MAC3Ce,YAAY,EAAGA,CAAA,KAAMb,gBAAgB,CAAE,IAAK,CAAG;MAC/Cc,MAAM,EAAGA,CAAA,KAAMd,gBAAgB,CAAE,IAAK,CAAG;MACzCe,OAAO,EAAGA,CAAA,KAAMlB,oBAAoB,CAAEC,KAAM,CAAG;MAC/C,gBAAeV,WAAW,CAACe,IAAI,KAAKL,KAAK,CAACK;IAAM,GAEhDC,aAAA,CAAC3B,QAAQ;MACRuC,aAAa,EAAG,CAAG;MACnB1B,SAAS,EAAC;IAAsC,GAE9CgB,UACO,CACH,CAAC;EAEX,CAAE,CACE,CAAC,EACJd,YAAY,IAAI,CAAEE,gBAAgB,IACnCU,aAAA,CAAC1B,OAAO;IACPuC,SAAS,EAAC,YAAY;IACtBC,MAAM,EAAG,EAAI;IACbC,YAAY,EAAG;EAAO,GAEtBf,aAAA;IACCd,SAAS,EAAC,0CAA0C;IACpDuB,YAAY,EAAGA,CAAA,KAAMb,gBAAgB,CAAE,IAAK;EAAG,GAE/CI,aAAA,CAACzB,uBAAuB;IACvBS,WAAW,EAAGA,WAAa;IAC3BE,SAAS,EAAGC,gBAAkB;IAC9BF,mBAAmB,EAAGA,mBAAqB;IAC3CS,KAAK,EAAGN;EAAc,CACtB,CACG,CACG,CAEN,CAAC;AAER;AAEA,eAAeV,WAAW"}
|
|
@@ -19,6 +19,7 @@ import { getActiveStyle, replaceActiveStyle } from './utils';
|
|
|
19
19
|
import StylePreview from './preview';
|
|
20
20
|
import containerStyles from './style.scss';
|
|
21
21
|
import { store as blockEditorStore } from '../../store';
|
|
22
|
+
const EMPTY_ARRAY = [];
|
|
22
23
|
function BlockStyles({
|
|
23
24
|
clientId,
|
|
24
25
|
url
|
|
@@ -32,8 +33,8 @@ function BlockStyles({
|
|
|
32
33
|
} = select(blocksStore);
|
|
33
34
|
const block = getBlock(clientId);
|
|
34
35
|
return {
|
|
35
|
-
styles: getBlockStyles(block
|
|
36
|
-
className: block
|
|
36
|
+
styles: getBlockStyles(block?.name) || EMPTY_ARRAY,
|
|
37
|
+
className: block?.attributes?.className || ''
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ScrollView","store","blocksStore","useSelect","useDispatch","useMemo","_x","getActiveStyle","replaceActiveStyle","StylePreview","containerStyles","blockEditorStore","BlockStyles","clientId","url","selector","select","getBlock","getBlockStyles","block","styles","name","className","attributes","updateBlockAttributes","renderedStyles","find","style","isDefault","label","mappedRenderedStyles","activeStyle","map","styleClassName","isActive","onStylePress","createElement","onPress","key","length","horizontal","showsHorizontalScrollIndicator","contentContainerStyle","content"],"sources":["@wordpress/block-editor/src/components/block-styles/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ScrollView } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getActiveStyle, replaceActiveStyle } from './utils';\nimport StylePreview from './preview';\nimport containerStyles from './style.scss';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockStyles( { clientId, url } ) {\n\tconst selector = ( select ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\t\tconst { getBlockStyles } = select( blocksStore );\n\t\tconst block = getBlock( clientId );\n\t\treturn {\n\t\t\tstyles: getBlockStyles( block
|
|
1
|
+
{"version":3,"names":["ScrollView","store","blocksStore","useSelect","useDispatch","useMemo","_x","getActiveStyle","replaceActiveStyle","StylePreview","containerStyles","blockEditorStore","EMPTY_ARRAY","BlockStyles","clientId","url","selector","select","getBlock","getBlockStyles","block","styles","name","className","attributes","updateBlockAttributes","renderedStyles","find","style","isDefault","label","mappedRenderedStyles","activeStyle","map","styleClassName","isActive","onStylePress","createElement","onPress","key","length","horizontal","showsHorizontalScrollIndicator","contentContainerStyle","content"],"sources":["@wordpress/block-editor/src/components/block-styles/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ScrollView } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getActiveStyle, replaceActiveStyle } from './utils';\nimport StylePreview from './preview';\nimport containerStyles from './style.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction BlockStyles( { clientId, url } ) {\n\tconst selector = ( select ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\t\tconst { getBlockStyles } = select( blocksStore );\n\t\tconst block = getBlock( clientId );\n\t\treturn {\n\t\t\tstyles: getBlockStyles( block?.name ) || EMPTY_ARRAY,\n\t\t\tclassName: block?.attributes?.className || '',\n\t\t};\n\t};\n\n\tconst { styles, className } = useSelect( selector, [ clientId ] );\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst renderedStyles = styles?.find( ( style ) => style.isDefault )\n\t\t? styles\n\t\t: [\n\t\t\t\t{\n\t\t\t\t\tname: 'default',\n\t\t\t\t\tlabel: _x( 'Default', 'block style' ),\n\t\t\t\t\tisDefault: true,\n\t\t\t\t},\n\t\t\t\t...styles,\n\t\t ];\n\n\tconst mappedRenderedStyles = useMemo( () => {\n\t\tconst activeStyle = getActiveStyle( renderedStyles, className );\n\n\t\treturn renderedStyles.map( ( style ) => {\n\t\t\tconst styleClassName = replaceActiveStyle(\n\t\t\t\tclassName,\n\t\t\t\tactiveStyle,\n\t\t\t\tstyle\n\t\t\t);\n\t\t\tconst isActive = activeStyle === style;\n\n\t\t\tconst onStylePress = () => {\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tclassName: styleClassName,\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<StylePreview\n\t\t\t\t\tonPress={ onStylePress }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\tkey={ style.name }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\turl={ url }\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ renderedStyles, className, clientId ] );\n\n\tif ( ! styles || styles.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ScrollView\n\t\t\thorizontal\n\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\tcontentContainerStyle={ containerStyles.content }\n\t\t>\n\t\t\t{ mappedRenderedStyles }\n\t\t</ScrollView>\n\t);\n}\n\nexport default BlockStyles;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,SAAS;AAC5D,OAAOC,YAAY,MAAM,WAAW;AACpC,OAAOC,eAAe,MAAM,cAAc;AAC1C,SAAST,KAAK,IAAIU,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,WAAW,GAAG,EAAE;AAEtB,SAASC,WAAWA,CAAE;EAAEC,QAAQ;EAAEC;AAAI,CAAC,EAAG;EACzC,MAAMC,QAAQ,GAAKC,MAAM,IAAM;IAC9B,MAAM;MAAEC;IAAS,CAAC,GAAGD,MAAM,CAAEN,gBAAiB,CAAC;IAC/C,MAAM;MAAEQ;IAAe,CAAC,GAAGF,MAAM,CAAEf,WAAY,CAAC;IAChD,MAAMkB,KAAK,GAAGF,QAAQ,CAAEJ,QAAS,CAAC;IAClC,OAAO;MACNO,MAA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AAEH,SAAS,EAAET,QAAQ,CAAG,CAAC;EAE5C,IAAK,CAAEO,MAAM,IAAIA,MAAM,CAACmB,MAAM,KAAK,CAAC,EAAG;IACtC,OAAO,IAAI;EACZ;EAEA,OACCH,aAAA,CAACrC,UAAU;IACVyC,UAAU;IACVC,8BAA8B,EAAG,KAAO;IACxCC,qBAAqB,EAAGjC,eAAe,CAACkC;EAAS,GAE/Cb,oBACS,CAAC;AAEf;AAEA,eAAelB,WAAW"}
|
|
@@ -7,6 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
10
11
|
import { useSelect } from '@wordpress/data';
|
|
11
12
|
import { useRef } from '@wordpress/element';
|
|
12
13
|
import { useViewportMatch } from '@wordpress/compose';
|
|
@@ -28,19 +29,40 @@ import BlockEditVisuallyButton from '../block-edit-visually-button';
|
|
|
28
29
|
import { useShowHoveredOrFocusedGestures } from './utils';
|
|
29
30
|
import { store as blockEditorStore } from '../../store';
|
|
30
31
|
import __unstableBlockNameContext from './block-name-context';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
import NavigableToolbar from '../navigable-toolbar';
|
|
33
|
+
import { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Renders the block toolbar.
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} props Components props.
|
|
41
|
+
* @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.
|
|
42
|
+
* @param {boolean} props.focusOnMount Focus the toolbar when mounted.
|
|
43
|
+
* @param {number} props.__experimentalInitialIndex The initial index of the toolbar item to focus.
|
|
44
|
+
* @param {Function} props.__experimentalOnIndexChange Callback function to be called when the index of the focused toolbar item changes.
|
|
45
|
+
* @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.
|
|
46
|
+
*/
|
|
47
|
+
export function PrivateBlockToolbar({
|
|
48
|
+
hideDragHandle,
|
|
49
|
+
focusOnMount,
|
|
50
|
+
__experimentalInitialIndex,
|
|
51
|
+
__experimentalOnIndexChange,
|
|
52
|
+
variant = 'unstyled'
|
|
53
|
+
}) {
|
|
34
54
|
const {
|
|
55
|
+
blockClientId,
|
|
35
56
|
blockClientIds,
|
|
57
|
+
isDefaultEditingMode,
|
|
36
58
|
blockType,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
blockEditingMode
|
|
59
|
+
shouldShowVisualToolbar,
|
|
60
|
+
showParentSelector
|
|
40
61
|
} = useSelect(select => {
|
|
41
62
|
const {
|
|
42
63
|
getBlockName,
|
|
43
64
|
getBlockMode,
|
|
65
|
+
getBlockParents,
|
|
44
66
|
getSelectedBlockClientIds,
|
|
45
67
|
isBlockValid,
|
|
46
68
|
getBlockRootClientId,
|
|
@@ -49,13 +71,21 @@ const BlockToolbar = ({
|
|
|
49
71
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
50
72
|
const selectedBlockClientId = selectedBlockClientIds[0];
|
|
51
73
|
const blockRootClientId = getBlockRootClientId(selectedBlockClientId);
|
|
74
|
+
const parents = getBlockParents(selectedBlockClientId);
|
|
75
|
+
const firstParentClientId = parents[parents.length - 1];
|
|
76
|
+
const parentBlockName = getBlockName(firstParentClientId);
|
|
77
|
+
const parentBlockType = getBlockType(parentBlockName);
|
|
78
|
+
const _isDefaultEditingMode = getBlockEditingMode(selectedBlockClientId) === 'default';
|
|
79
|
+
const isValid = selectedBlockClientIds.every(id => isBlockValid(id));
|
|
80
|
+
const isVisual = selectedBlockClientIds.every(id => getBlockMode(id) === 'visual');
|
|
52
81
|
return {
|
|
82
|
+
blockClientId: selectedBlockClientId,
|
|
53
83
|
blockClientIds: selectedBlockClientIds,
|
|
84
|
+
isDefaultEditingMode: _isDefaultEditingMode,
|
|
54
85
|
blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)),
|
|
86
|
+
shouldShowVisualToolbar: isValid && isVisual,
|
|
55
87
|
rootClientId: blockRootClientId,
|
|
56
|
-
|
|
57
|
-
isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual'),
|
|
58
|
-
blockEditingMode: getBlockEditingMode(selectedBlockClientId)
|
|
88
|
+
showParentSelector: parentBlockType && getBlockEditingMode(firstParentClientId) === 'default' && hasBlockSupport(parentBlockType, '__experimentalParentSelector', true) && selectedBlockClientIds.length === 1 && _isDefaultEditingMode
|
|
59
89
|
};
|
|
60
90
|
}, []);
|
|
61
91
|
const toolbarWrapperRef = useRef(null);
|
|
@@ -67,24 +97,40 @@ const BlockToolbar = ({
|
|
|
67
97
|
ref: nodeRef
|
|
68
98
|
});
|
|
69
99
|
const isLargeViewport = !useViewportMatch('medium', '<');
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (blockClientIds.length === 0) {
|
|
100
|
+
const isToolbarEnabled = blockType && hasBlockSupport(blockType, '__experimentalToolbar', true);
|
|
101
|
+
const hasAnyBlockControls = useHasAnyBlockControls();
|
|
102
|
+
if (!isToolbarEnabled || !isDefaultEditingMode && !hasAnyBlockControls) {
|
|
76
103
|
return null;
|
|
77
104
|
}
|
|
78
|
-
const shouldShowVisualToolbar = isValid && isVisual;
|
|
79
105
|
const isMultiToolbar = blockClientIds.length > 1;
|
|
80
106
|
const isSynced = isReusableBlock(blockType) || isTemplatePart(blockType);
|
|
81
|
-
|
|
107
|
+
|
|
108
|
+
// Shifts the toolbar to make room for the parent block selector.
|
|
109
|
+
const classes = classnames('block-editor-block-contextual-toolbar', {
|
|
110
|
+
'has-parent': showParentSelector
|
|
111
|
+
});
|
|
112
|
+
const innerClasses = classnames('block-editor-block-toolbar', {
|
|
82
113
|
'is-synced': isSynced
|
|
83
114
|
});
|
|
84
|
-
return createElement(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
115
|
+
return createElement(NavigableToolbar, {
|
|
116
|
+
focusEditorOnEscape: true,
|
|
117
|
+
className: classes
|
|
118
|
+
/* translators: accessibility text for the block toolbar */,
|
|
119
|
+
"aria-label": __('Block tools')
|
|
120
|
+
// The variant is applied as "toolbar" when undefined, which is the black border style of the dropdown from the toolbar popover.
|
|
121
|
+
,
|
|
122
|
+
variant: variant === 'toolbar' ? undefined : variant,
|
|
123
|
+
focusOnMount: focusOnMount,
|
|
124
|
+
__experimentalInitialIndex: __experimentalInitialIndex,
|
|
125
|
+
__experimentalOnIndexChange: __experimentalOnIndexChange
|
|
126
|
+
// Resets the index whenever the active block changes so
|
|
127
|
+
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
128
|
+
,
|
|
129
|
+
key: blockClientId
|
|
130
|
+
}, createElement("div", {
|
|
131
|
+
ref: toolbarWrapperRef,
|
|
132
|
+
className: innerClasses
|
|
133
|
+
}, !isMultiToolbar && isLargeViewport && isDefaultEditingMode && createElement(BlockParentSelector, null), (shouldShowVisualToolbar || isMultiToolbar) && isDefaultEditingMode && createElement("div", {
|
|
88
134
|
ref: nodeRef,
|
|
89
135
|
...showHoveredOrFocusedGestures
|
|
90
136
|
}, createElement(ToolbarGroup, {
|
|
@@ -115,13 +161,30 @@ const BlockToolbar = ({
|
|
|
115
161
|
value: blockType?.name
|
|
116
162
|
}, createElement(__unstableBlockToolbarLastItem.Slot, null))), createElement(BlockEditVisuallyButton, {
|
|
117
163
|
clientIds: blockClientIds
|
|
118
|
-
}),
|
|
164
|
+
}), isDefaultEditingMode && createElement(BlockSettingsMenu, {
|
|
119
165
|
clientIds: blockClientIds
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
166
|
+
})));
|
|
167
|
+
}
|
|
122
168
|
|
|
123
169
|
/**
|
|
170
|
+
* Renders the block toolbar.
|
|
171
|
+
*
|
|
124
172
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md
|
|
173
|
+
*
|
|
174
|
+
* @param {Object} props Components props.
|
|
175
|
+
* @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.
|
|
176
|
+
* @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.
|
|
125
177
|
*/
|
|
126
|
-
export default BlockToolbar
|
|
178
|
+
export default function BlockToolbar({
|
|
179
|
+
hideDragHandle,
|
|
180
|
+
variant
|
|
181
|
+
}) {
|
|
182
|
+
return createElement(PrivateBlockToolbar, {
|
|
183
|
+
hideDragHandle: hideDragHandle,
|
|
184
|
+
variant: variant,
|
|
185
|
+
focusOnMount: undefined,
|
|
186
|
+
__experimentalInitialIndex: undefined,
|
|
187
|
+
__experimentalOnIndexChange: undefined
|
|
188
|
+
});
|
|
189
|
+
}
|
|
127
190
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useSelect","useRef","useViewportMatch","getBlockType","hasBlockSupport","isReusableBlock","isTemplatePart","ToolbarGroup","BlockMover","BlockParentSelector","BlockSwitcher","BlockControls","__unstableBlockToolbarLastItem","BlockSettingsMenu","BlockLockToolbar","BlockGroupToolbar","BlockEditVisuallyButton","useShowHoveredOrFocusedGestures","store","blockEditorStore","__unstableBlockNameContext","BlockToolbar","hideDragHandle","blockClientIds","blockType","isValid","isVisual","blockEditingMode","select","getBlockName","getBlockMode","getSelectedBlockClientIds","isBlockValid","getBlockRootClientId","getBlockEditingMode","selectedBlockClientIds","selectedBlockClientId","blockRootClientId","rootClientId","every","id","toolbarWrapperRef","nodeRef","showHoveredOrFocusedGestures","ref","isLargeViewport","length","shouldShowVisualToolbar","isMultiToolbar","isSynced","classes","createElement","className","clientIds","clientId","wrapperRef","Fragment","Slot","group","Provider","value","name"],"sources":["@wordpress/block-editor/src/components/block-toolbar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockSwitcher from '../block-switcher';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowHoveredOrFocusedGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport __unstableBlockNameContext from './block-name-context';\n\nconst BlockToolbar = ( { hideDragHandle } ) => {\n\tconst { blockClientIds, blockType, isValid, isVisual, blockEditingMode } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tisBlockValid,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst blockRootClientId = getBlockRootClientId(\n\t\t\t\tselectedBlockClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\t\tblockType:\n\t\t\t\t\tselectedBlockClientId &&\n\t\t\t\t\tgetBlockType( getBlockName( selectedBlockClientId ) ),\n\t\t\t\trootClientId: blockRootClientId,\n\t\t\t\tisValid: selectedBlockClientIds.every( ( id ) =>\n\t\t\t\t\tisBlockValid( id )\n\t\t\t\t),\n\t\t\t\tisVisual: selectedBlockClientIds.every(\n\t\t\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t\t\t),\n\t\t\t\tblockEditingMode: getBlockEditingMode( selectedBlockClientId ),\n\t\t\t};\n\t\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t} );\n\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tif ( blockType ) {\n\t\tif ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tif ( blockClientIds.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst shouldShowVisualToolbar = isValid && isVisual;\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\tconst classes = classnames( 'block-editor-block-toolbar', {\n\t\t'is-synced': isSynced,\n\t} );\n\n\treturn (\n\t\t<div className={ classes } ref={ toolbarWrapperRef }>\n\t\t\t{ ! isMultiToolbar &&\n\t\t\t\tisLargeViewport &&\n\t\t\t\tblockEditingMode === 'default' && <BlockParentSelector /> }\n\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) &&\n\t\t\t\tblockEditingMode === 'default' && (\n\t\t\t\t\t<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockSwitcher clientIds={ blockClientIds } />\n\t\t\t\t\t\t\t{ ! isMultiToolbar && (\n\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\tclientId={ blockClientIds[ 0 ] }\n\t\t\t\t\t\t\t\t\twrapperRef={ toolbarWrapperRef }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t{ shouldShowVisualToolbar && isMultiToolbar && (\n\t\t\t\t<BlockGroupToolbar />\n\t\t\t) }\n\t\t\t{ shouldShowVisualToolbar && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t/>\n\t\t\t\t\t<__unstableBlockNameContext.Provider\n\t\t\t\t\t\tvalue={ blockType?.name }\n\t\t\t\t\t>\n\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t</__unstableBlockNameContext.Provider>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n */\nexport default BlockToolbar;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SACCC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,cAAc,QACR,mBAAmB;AAC1B,SAASC,YAAY,QAAQ,uBAAuB;;AAEpD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,8BAA8B,MAAM,2BAA2B;AACtE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,OAAOC,uBAAuB,MAAM,+BAA+B;AACnE,SAASC,+BAA+B,QAAQ,SAAS;AACzD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,0BAA0B,MAAM,sBAAsB;AAE7D,MAAMC,YAAY,GAAGA,CAAE;EAAEC;AAAe,CAAC,KAAM;EAC9C,MAAM;IAAEC,cAAc;IAAEC,SAAS;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAiB,CAAC,GACvE3B,SAAS,CAAI4B,MAAM,IAAM;IACxB,MAAM;MACLC,YAAY;MACZC,YAAY;MACZC,yBAAyB;MACzBC,YAAY;MACZC,oBAAoB;MACpBC;IACD,CAAC,GAAGN,MAAM,CAAET,gBAAiB,CAAC;IAC9B,MAAMgB,sBAAsB,GAAGJ,yBAAyB,CAAC,CAAC;IAC1D,MAAMK,qBAAqB,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C5C,CAAC,EACFD,aAAA,CAACxC,aAAa,CAAC8C,IAAI;IAClBC,KAAK,EAAC,OAAO;IACbN,SAAS,EAAC;EAAkC,CAC5C,CAAC,EACFD,aAAA,CAAC/B,0BAA0B,CAACuC,QAAQ;IACnCC,KAAK,EAAGpC,SAAS,EAAEqC;EAAM,GAEzBV,aAAA,CAACvC,8BAA8B,CAAC6C,IAAI,MAAE,CACF,CACpC,CACF,EACDN,aAAA,CAACnC,uBAAuB;IAACqC,SAAS,EAAG9B;EAAgB,CAAE,CAAC,EACtDI,gBAAgB,KAAK,SAAS,IAC/BwB,aAAA,CAACtC,iBAAiB;IAACwC,SAAS,EAAG9B;EAAgB,CAAE,CAE9C,CAAC;AAER,CAAC;;AAED;AACA;AACA;AACA,eAAeF,YAAY"}
|
|
1
|
+
{"version":3,"names":["classnames","__","useSelect","useRef","useViewportMatch","getBlockType","hasBlockSupport","isReusableBlock","isTemplatePart","ToolbarGroup","BlockMover","BlockParentSelector","BlockSwitcher","BlockControls","__unstableBlockToolbarLastItem","BlockSettingsMenu","BlockLockToolbar","BlockGroupToolbar","BlockEditVisuallyButton","useShowHoveredOrFocusedGestures","store","blockEditorStore","__unstableBlockNameContext","NavigableToolbar","useHasAnyBlockControls","PrivateBlockToolbar","hideDragHandle","focusOnMount","__experimentalInitialIndex","__experimentalOnIndexChange","variant","blockClientId","blockClientIds","isDefaultEditingMode","blockType","shouldShowVisualToolbar","showParentSelector","select","getBlockName","getBlockMode","getBlockParents","getSelectedBlockClientIds","isBlockValid","getBlockRootClientId","getBlockEditingMode","selectedBlockClientIds","selectedBlockClientId","blockRootClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","_isDefaultEditingMode","isValid","every","id","isVisual","rootClientId","toolbarWrapperRef","nodeRef","showHoveredOrFocusedGestures","ref","isLargeViewport","isToolbarEnabled","hasAnyBlockControls","isMultiToolbar","isSynced","classes","innerClasses","createElement","focusEditorOnEscape","className","undefined","key","clientIds","clientId","wrapperRef","Fragment","Slot","group","Provider","value","name","BlockToolbar"],"sources":["@wordpress/block-editor/src/components/block-toolbar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockSwitcher from '../block-switcher';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowHoveredOrFocusedGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport __unstableBlockNameContext from './block-name-context';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {boolean} props.focusOnMount Focus the toolbar when mounted.\n * @param {number} props.__experimentalInitialIndex The initial index of the toolbar item to focus.\n * @param {Function} props.__experimentalOnIndexChange Callback function to be called when the index of the focused toolbar item changes.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport function PrivateBlockToolbar( {\n\thideDragHandle,\n\tfocusOnMount,\n\t__experimentalInitialIndex,\n\t__experimentalOnIndexChange,\n\tvariant = 'unstyled',\n} ) {\n\tconst {\n\t\tblockClientId,\n\t\tblockClientIds,\n\t\tisDefaultEditingMode,\n\t\tblockType,\n\t\tshouldShowVisualToolbar,\n\t\tshowParentSelector,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockEditingMode,\n\t\t} = select( blockEditorStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst blockRootClientId = getBlockRootClientId( selectedBlockClientId );\n\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\t\tconst _isDefaultEditingMode =\n\t\t\tgetBlockEditingMode( selectedBlockClientId ) === 'default';\n\t\tconst isValid = selectedBlockClientIds.every( ( id ) =>\n\t\t\tisBlockValid( id )\n\t\t);\n\t\tconst isVisual = selectedBlockClientIds.every(\n\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t);\n\t\treturn {\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tisDefaultEditingMode: _isDefaultEditingMode,\n\t\t\tblockType:\n\t\t\t\tselectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( selectedBlockClientId ) ),\n\n\t\t\tshouldShowVisualToolbar: isValid && isVisual,\n\t\t\trootClientId: blockRootClientId,\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length === 1 &&\n\t\t\t\t_isDefaultEditingMode,\n\t\t};\n\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t} );\n\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tconst isToolbarEnabled =\n\t\tblockType &&\n\t\thasBlockSupport( blockType, '__experimentalToolbar', true );\n\tconst hasAnyBlockControls = useHasAnyBlockControls();\n\n\tif (\n\t\t! isToolbarEnabled ||\n\t\t( ! isDefaultEditingMode && ! hasAnyBlockControls )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': showParentSelector,\n\t} );\n\n\tconst innerClasses = classnames( 'block-editor-block-toolbar', {\n\t\t'is-synced': isSynced,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusEditorOnEscape\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant={ variant === 'toolbar' ? undefined : variant }\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\t__experimentalInitialIndex={ __experimentalInitialIndex }\n\t\t\t__experimentalOnIndexChange={ __experimentalOnIndexChange }\n\t\t\t// Resets the index whenever the active block changes so\n\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\tkey={ blockClientId }\n\t\t>\n\t\t\t<div ref={ toolbarWrapperRef } className={ innerClasses }>\n\t\t\t\t{ ! isMultiToolbar &&\n\t\t\t\t\tisLargeViewport &&\n\t\t\t\t\tisDefaultEditingMode && <BlockParentSelector /> }\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) &&\n\t\t\t\t\tisDefaultEditingMode && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ nodeRef }\n\t\t\t\t\t\t\t{ ...showHoveredOrFocusedGestures }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t\t<BlockSwitcher clientIds={ blockClientIds } />\n\t\t\t\t\t\t\t\t{ ! isMultiToolbar && (\n\t\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\t\tclientId={ blockClientIds[ 0 ] }\n\t\t\t\t\t\t\t\t\t\twrapperRef={ toolbarWrapperRef }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t{ shouldShowVisualToolbar && isMultiToolbar && (\n\t\t\t\t\t<BlockGroupToolbar />\n\t\t\t\t) }\n\t\t\t\t{ shouldShowVisualToolbar && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<__unstableBlockNameContext.Provider\n\t\t\t\t\t\t\tvalue={ blockType?.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t\t</__unstableBlockNameContext.Provider>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t\t{ isDefaultEditingMode && (\n\t\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport default function BlockToolbar( { hideDragHandle, variant } ) {\n\treturn (\n\t\t<PrivateBlockToolbar\n\t\t\thideDragHandle={ hideDragHandle }\n\t\t\tvariant={ variant }\n\t\t\tfocusOnMount={ undefined }\n\t\t\t__experimentalInitialIndex={ undefined }\n\t\t\t__experimentalOnIndexChange={ undefined }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACp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B,CAACiE,IAAI,MAAE,CACF,CACpC,CACF,EACDT,aAAA,CAACpD,uBAAuB;IAACyD,SAAS,EAAG3C;EAAgB,CAAE,CAAC,EACtDC,oBAAoB,IACrBqC,aAAA,CAACvD,iBAAiB;IAAC4D,SAAS,EAAG3C;EAAgB,CAAE,CAE9C,CACY,CAAC;AAErB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASoD,YAAYA,CAAE;EAAE1D,cAAc;EAAEI;AAAQ,CAAC,EAAG;EACnE,OACCwC,aAAA,CAAC7C,mBAAmB;IACnBC,cAAc,EAAGA,cAAgB;IACjCI,OAAO,EAAGA,OAAS;IACnBH,YAAY,EAAG8C,SAAW;IAC1B7C,0BAA0B,EAAG6C,SAAW;IACxC5C,2BAA2B,EAAG4C;EAAW,CACzC,CAAC;AAEJ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import BlockSelectionButton from './block-selection-button';
|
|
11
|
+
import BlockPopover from '../block-popover';
|
|
12
|
+
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
13
|
+
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
14
|
+
export default function BlockToolbarBreadcrumb({
|
|
15
|
+
clientId,
|
|
16
|
+
__unstableContentRef
|
|
17
|
+
}) {
|
|
18
|
+
const {
|
|
19
|
+
capturingClientId,
|
|
20
|
+
isInsertionPointVisible,
|
|
21
|
+
lastClientId,
|
|
22
|
+
rootClientId
|
|
23
|
+
} = useSelectedBlockToolProps(clientId);
|
|
24
|
+
const popoverProps = useBlockToolbarPopoverProps({
|
|
25
|
+
contentElement: __unstableContentRef?.current,
|
|
26
|
+
clientId
|
|
27
|
+
});
|
|
28
|
+
return createElement(BlockPopover, {
|
|
29
|
+
clientId: capturingClientId || clientId,
|
|
30
|
+
bottomClientId: lastClientId,
|
|
31
|
+
className: classnames('block-editor-block-list__block-popover', {
|
|
32
|
+
'is-insertion-point-visible': isInsertionPointVisible
|
|
33
|
+
}),
|
|
34
|
+
resize: false,
|
|
35
|
+
...popoverProps
|
|
36
|
+
}, createElement(BlockSelectionButton, {
|
|
37
|
+
clientId: clientId,
|
|
38
|
+
rootClientId: rootClientId
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=block-toolbar-breadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["classnames","BlockSelectionButton","BlockPopover","useBlockToolbarPopoverProps","useSelectedBlockToolProps","BlockToolbarBreadcrumb","clientId","__unstableContentRef","capturingClientId","isInsertionPointVisible","lastClientId","rootClientId","popoverProps","contentElement","current","createElement","bottomClientId","className","resize"],"sources":["@wordpress/block-editor/src/components/block-tools/block-toolbar-breadcrumb.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport useSelectedBlockToolProps from './use-selected-block-tool-props';\n\nexport default function BlockToolbarBreadcrumb( {\n\tclientId,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tcapturingClientId,\n\t\tisInsertionPointVisible,\n\t\tlastClientId,\n\t\trootClientId,\n\t} = useSelectedBlockToolProps( clientId );\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\tresize={ false }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t<BlockSelectionButton\n\t\t\t\tclientId={ clientId }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t</BlockPopover>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,yBAAyB,MAAM,iCAAiC;AAEvE,eAAe,SAASC,sBAAsBA,CAAE;EAC/CC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,iBAAiB;IACjBC,uBAAuB;IACvBC,YAAY;IACZC;EACD,CAAC,GAAGP,yBAAyB,CAAEE,QAAS,CAAC;EAEzC,MAAMM,YAAY,GAAGT,2BAA2B,CAAE;IACjDU,cAAc,EAAEN,oBAAoB,EAAEO,OAAO;IAC7CR;EACD,CAAE,CAAC;EAEH,OACCS,aAAA,CAACb,YAAY;IACZI,QAAQ,EAAGE,iBAAiB,IAAIF,QAAU;IAC1CU,cAAc,EAAGN,YAAc;IAC/BO,SAAS,EAAGjB,UAAU,CAAE,wCAAwC,EAAE;MACjE,4BAA4B,EAAES;IAC/B,CAAE,CAAG;IACLS,MAAM,EAAG,KAAO;IAAA,GACXN;EAAY,GAEjBG,aAAA,CAACd,oBAAoB;IACpBK,QAAQ,EAAGA,QAAU;IACrBK,YAAY,EAAGA;EAAc,CAC7B,CACY,CAAC;AAEjB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useDispatch } from '@wordpress/data';
|
|
10
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
11
|
+
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import BlockPopover from '../block-popover';
|
|
16
|
+
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
17
|
+
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
18
|
+
import { store as blockEditorStore } from '../../store';
|
|
19
|
+
import { PrivateBlockToolbar } from '../block-toolbar';
|
|
20
|
+
export default function BlockToolbarPopover({
|
|
21
|
+
clientId,
|
|
22
|
+
isTyping,
|
|
23
|
+
__unstableContentRef
|
|
24
|
+
}) {
|
|
25
|
+
const {
|
|
26
|
+
capturingClientId,
|
|
27
|
+
isInsertionPointVisible,
|
|
28
|
+
lastClientId
|
|
29
|
+
} = useSelectedBlockToolProps(clientId);
|
|
30
|
+
|
|
31
|
+
// Stores the active toolbar item index so the block toolbar can return focus
|
|
32
|
+
// to it when re-mounting.
|
|
33
|
+
const initialToolbarItemIndexRef = useRef();
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
// Resets the index whenever the active block changes so this is not
|
|
36
|
+
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
37
|
+
initialToolbarItemIndexRef.current = undefined;
|
|
38
|
+
}, [clientId]);
|
|
39
|
+
const {
|
|
40
|
+
stopTyping
|
|
41
|
+
} = useDispatch(blockEditorStore);
|
|
42
|
+
const isToolbarForced = useRef(false);
|
|
43
|
+
useShortcut('core/block-editor/focus-toolbar', () => {
|
|
44
|
+
isToolbarForced.current = true;
|
|
45
|
+
stopTyping(true);
|
|
46
|
+
}, {
|
|
47
|
+
isDisabled: false
|
|
48
|
+
});
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
isToolbarForced.current = false;
|
|
51
|
+
});
|
|
52
|
+
const popoverProps = useBlockToolbarPopoverProps({
|
|
53
|
+
contentElement: __unstableContentRef?.current,
|
|
54
|
+
clientId
|
|
55
|
+
});
|
|
56
|
+
return !isTyping && createElement(BlockPopover, {
|
|
57
|
+
clientId: capturingClientId || clientId,
|
|
58
|
+
bottomClientId: lastClientId,
|
|
59
|
+
className: classnames('block-editor-block-list__block-popover', {
|
|
60
|
+
'is-insertion-point-visible': isInsertionPointVisible
|
|
61
|
+
}),
|
|
62
|
+
resize: false,
|
|
63
|
+
...popoverProps
|
|
64
|
+
}, createElement(PrivateBlockToolbar
|
|
65
|
+
// If the toolbar is being shown because of being forced
|
|
66
|
+
// it should focus the toolbar right after the mount.
|
|
67
|
+
, {
|
|
68
|
+
focusOnMount: isToolbarForced.current,
|
|
69
|
+
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
70
|
+
__experimentalOnIndexChange: index => {
|
|
71
|
+
initialToolbarItemIndexRef.current = index;
|
|
72
|
+
},
|
|
73
|
+
variant: "toolbar"
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=block-toolbar-popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["classnames","useDispatch","useEffect","useRef","useShortcut","BlockPopover","useBlockToolbarPopoverProps","useSelectedBlockToolProps","store","blockEditorStore","PrivateBlockToolbar","BlockToolbarPopover","clientId","isTyping","__unstableContentRef","capturingClientId","isInsertionPointVisible","lastClientId","initialToolbarItemIndexRef","current","undefined","stopTyping","isToolbarForced","isDisabled","popoverProps","contentElement","createElement","bottomClientId","className","resize","focusOnMount","__experimentalInitialIndex","__experimentalOnIndexChange","index","variant"],"sources":["@wordpress/block-editor/src/components/block-tools/block-toolbar-popover.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n/**\n * Internal dependencies\n */\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport useSelectedBlockToolProps from './use-selected-block-tool-props';\nimport { store as blockEditorStore } from '../../store';\nimport { PrivateBlockToolbar } from '../block-toolbar';\n\nexport default function BlockToolbarPopover( {\n\tclientId,\n\tisTyping,\n\t__unstableContentRef,\n} ) {\n\tconst { capturingClientId, isInsertionPointVisible, lastClientId } =\n\t\tuseSelectedBlockToolProps( clientId );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tuseEffect( () => {\n\t\t// Resets the index whenever the active block changes so this is not\n\t\t// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\tinitialToolbarItemIndexRef.current = undefined;\n\t}, [ clientId ] );\n\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\tconst isToolbarForced = useRef( false );\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: false,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\treturn (\n\t\t! isTyping && (\n\t\t\t<BlockPopover\n\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__block-popover',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tresize={ false }\n\t\t\t\t{ ...popoverProps }\n\t\t\t>\n\t\t\t\t<PrivateBlockToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t/>\n\t\t\t</BlockPopover>\n\t\t)\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AACnC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,+BAA+B;AAC3D;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,mBAAmB,QAAQ,kBAAkB;AAEtD,eAAe,SAASC,mBAAmBA,CAAE;EAC5CC,QAAQ;EACRC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAa,CAAC,GACjEV,yBAAyB,CAAEK,QAAS,CAAC;;EAEtC;EACA;EACA,MAAMM,0BAA0B,GAAGf,MAAM,CAAC,CAAC;EAE3CD,SAAS,CAAE,MAAM;IAChB;IACA;IACAgB,0BAA0B,CAACC,OAAO,GAAGC,SAAS;EAC/C,CAAC,EAAE,CAAER,QAAQ,CAAG,CAAC;EAEjB,MAAM;IAAES;EAAW,CAAC,GAAGpB,WAAW,CAAEQ,gBAAiB,CAAC;EACtD,MAAMa,eAAe,GAAGnB,MAAM,CAAE,KAAM,CAAC;EAEvCC,WAAW,CACV,iCAAiC,EACjC,MAAM;IACLkB,eAAe,CAACH,OAAO,GAAG,IAAI;IAC9BE,UAAU,CAAE,IAAK,CAAC;EACnB,CAAC,EACD;IACCE,UAAU,EAAE;EACb,CACD,CAAC;EAEDrB,SAAS,CAAE,MAAM;IAChBoB,eAAe,CAACH,OAAO,GAAG,KAAK;EAChC,CAAE,CAAC;EAEH,MAAMK,YAAY,GAAGlB,2BAA2B,CAAE;IACjDmB,cAAc,EAAEX,oBAAoB,EAAEK,OAAO;IAC7CP;EACD,CAAE,CAAC;EAEH,OACC,CAAEC,QAAQ,IACTa,aAAA,CAACrB,YAAY;IACZO,QAAQ,EAAGG,iBAAiB,IAAIH,QAAU;IAC1Ce,cAAc,EAAGV,YAAc;IAC/BW,SAAS,EAAG5B,UAAU,CACrB,wCAAwC,EACxC;MACC,4BAA4B,EAAEgB;IAC/B,CACD,CAAG;IACHa,MAAM,EAAG,KAAO;IAAA,GACXL;EAAY,GAEjBE,aAAA,CAAChB;EACA;EACA;EAAA;IACAoB,YAAY,EAAGR,eAAe,CAACH,OAAS;IACxCY,0BAA0B,EACzBb,0BAA0B,CAACC,OAC3B;IACDa,2BAA2B,EAAKC,KAAK,IAAM;MAC1Cf,0BAA0B,CAACC,OAAO,GAAGc,KAAK;IAC3C,CAAG;IACHC,OAAO,EAAC;EAAS,CACjB,CACY,CACd;AAEH"}
|
|
@@ -3,7 +3,6 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
7
6
|
import { Popover } from '@wordpress/components';
|
|
8
7
|
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
|
|
9
8
|
import { useRef } from '@wordpress/element';
|
|
@@ -14,9 +13,9 @@ import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
|
14
13
|
*/
|
|
15
14
|
import EmptyBlockInserter from './empty-block-inserter';
|
|
16
15
|
import { InsertionPointOpenRef, default as InsertionPoint } from './insertion-point';
|
|
17
|
-
import
|
|
16
|
+
import BlockToolbarPopover from './block-toolbar-popover';
|
|
17
|
+
import BlockToolbarBreadcrumb from './block-toolbar-breadcrumb';
|
|
18
18
|
import { store as blockEditorStore } from '../../store';
|
|
19
|
-
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
20
19
|
import usePopoverScroll from '../block-popover/use-popover-scroll';
|
|
21
20
|
import ZoomOutModeInserters from './zoom-out-mode-inserters';
|
|
22
21
|
function selector(select) {
|
|
@@ -25,6 +24,7 @@ function selector(select) {
|
|
|
25
24
|
getFirstMultiSelectedBlockClientId,
|
|
26
25
|
getBlock,
|
|
27
26
|
getSettings,
|
|
27
|
+
hasMultiSelection,
|
|
28
28
|
__unstableGetEditorMode,
|
|
29
29
|
isTyping
|
|
30
30
|
} = select(blockEditorStore);
|
|
@@ -33,16 +33,25 @@ function selector(select) {
|
|
|
33
33
|
name = '',
|
|
34
34
|
attributes = {}
|
|
35
35
|
} = getBlock(clientId) || {};
|
|
36
|
+
const editorMode = __unstableGetEditorMode();
|
|
37
|
+
const hasSelectedBlock = clientId && name;
|
|
38
|
+
const isEmptyDefaultBlock = isUnmodifiedDefaultBlock({
|
|
39
|
+
name,
|
|
40
|
+
attributes
|
|
41
|
+
});
|
|
42
|
+
const _showEmptyBlockSideInserter = clientId && !isTyping() && editorMode === 'edit' && isUnmodifiedDefaultBlock({
|
|
43
|
+
name,
|
|
44
|
+
attributes
|
|
45
|
+
});
|
|
46
|
+
const maybeShowBreadcrumb = hasSelectedBlock && !hasMultiSelection() && (editorMode === 'navigation' || editorMode === 'zoom-out');
|
|
36
47
|
return {
|
|
37
48
|
clientId,
|
|
38
49
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
39
|
-
hasSelectedBlock: clientId && name,
|
|
40
50
|
isTyping: isTyping(),
|
|
41
|
-
isZoomOutMode:
|
|
42
|
-
showEmptyBlockSideInserter:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
51
|
+
isZoomOutMode: editorMode === 'zoom-out',
|
|
52
|
+
showEmptyBlockSideInserter: _showEmptyBlockSideInserter,
|
|
53
|
+
showBreadcrumb: !_showEmptyBlockSideInserter && maybeShowBreadcrumb,
|
|
54
|
+
showBlockToolbar: !getSettings().hasFixedToolbar && !_showEmptyBlockSideInserter && hasSelectedBlock && !isEmptyDefaultBlock && !maybeShowBreadcrumb
|
|
46
55
|
};
|
|
47
56
|
}
|
|
48
57
|
|
|
@@ -60,14 +69,14 @@ export default function BlockTools({
|
|
|
60
69
|
__unstableContentRef,
|
|
61
70
|
...props
|
|
62
71
|
}) {
|
|
63
|
-
const isLargeViewport = useViewportMatch('medium');
|
|
64
72
|
const {
|
|
65
73
|
clientId,
|
|
66
74
|
hasFixedToolbar,
|
|
67
|
-
hasSelectedBlock,
|
|
68
75
|
isTyping,
|
|
69
76
|
isZoomOutMode,
|
|
70
|
-
showEmptyBlockSideInserter
|
|
77
|
+
showEmptyBlockSideInserter,
|
|
78
|
+
showBreadcrumb,
|
|
79
|
+
showBlockToolbar
|
|
71
80
|
} = useSelect(selector, []);
|
|
72
81
|
const isMatch = useShortcutEventMatch();
|
|
73
82
|
const {
|
|
@@ -152,12 +161,6 @@ export default function BlockTools({
|
|
|
152
161
|
}
|
|
153
162
|
const blockToolbarRef = usePopoverScroll(__unstableContentRef);
|
|
154
163
|
const blockToolbarAfterRef = usePopoverScroll(__unstableContentRef);
|
|
155
|
-
|
|
156
|
-
// Conditions for fixed toolbar
|
|
157
|
-
// 1. Not zoom out mode
|
|
158
|
-
// 2. It's a large viewport. If it's a smaller viewport, let the floating toolbar handle it as it already has styles attached to make it render that way.
|
|
159
|
-
// 3. Fixed toolbar is enabled
|
|
160
|
-
const isTopToolbar = !isZoomOutMode && hasFixedToolbar && isLargeViewport;
|
|
161
164
|
return (
|
|
162
165
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
163
166
|
createElement("div", {
|
|
@@ -167,17 +170,17 @@ export default function BlockTools({
|
|
|
167
170
|
value: useRef(false)
|
|
168
171
|
}, !isTyping && createElement(InsertionPoint, {
|
|
169
172
|
__unstableContentRef: __unstableContentRef
|
|
170
|
-
}), !isLargeViewport &&
|
|
171
|
-
// Small viewports always get a fixed toolbar
|
|
172
|
-
createElement(BlockContextualToolbar, {
|
|
173
|
-
isFixed: true
|
|
174
173
|
}), showEmptyBlockSideInserter && createElement(EmptyBlockInserter, {
|
|
175
174
|
__unstableContentRef: __unstableContentRef,
|
|
176
175
|
clientId: clientId
|
|
177
|
-
}),
|
|
176
|
+
}), showBlockToolbar && createElement(BlockToolbarPopover, {
|
|
177
|
+
__unstableContentRef: __unstableContentRef,
|
|
178
|
+
clientId: clientId,
|
|
179
|
+
isTyping: isTyping
|
|
180
|
+
}), showBreadcrumb && createElement(BlockToolbarBreadcrumb, {
|
|
178
181
|
__unstableContentRef: __unstableContentRef,
|
|
179
182
|
clientId: clientId
|
|
180
|
-
}), !
|
|
183
|
+
}), !isZoomOutMode && !hasFixedToolbar && createElement(Popover.Slot, {
|
|
181
184
|
name: "block-toolbar",
|
|
182
185
|
ref: blockToolbarRef
|
|
183
186
|
}), children, createElement(Popover.Slot, {
|