@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,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { getBlockType, getBlockDefaultClassName } from '@wordpress/blocks';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { store as blockEditorStore } from '../../../store';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the default class name if the block is a light block and it supports
|
|
14
|
-
* `className`.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} clientId The block client ID.
|
|
17
|
-
*
|
|
18
|
-
* @return {string} The class name, e.g. `wp-block-paragraph`.
|
|
19
|
-
*/
|
|
20
|
-
export function useBlockDefaultClassName( clientId ) {
|
|
21
|
-
return useSelect(
|
|
22
|
-
( select ) => {
|
|
23
|
-
const name = select( blockEditorStore ).getBlockName( clientId );
|
|
24
|
-
const blockType = getBlockType( name );
|
|
25
|
-
const hasLightBlockWrapper = blockType?.apiVersion > 1;
|
|
26
|
-
|
|
27
|
-
if ( ! hasLightBlockWrapper ) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return getBlockDefaultClassName( name );
|
|
32
|
-
},
|
|
33
|
-
[ clientId ]
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
.block-editor-block-parent-selector {
|
|
2
|
-
background: $white;
|
|
3
|
-
border-radius: $radius-block-ui;
|
|
4
|
-
|
|
5
|
-
.block-editor-block-parent-selector__button {
|
|
6
|
-
width: $grid-unit-60;
|
|
7
|
-
height: $grid-unit-60;
|
|
8
|
-
border: $border-width solid $gray-900;
|
|
9
|
-
border-radius: $radius-block-ui;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useContext } from '@wordpress/element';
|
|
5
|
-
import { Disabled } from '@wordpress/components';
|
|
6
|
-
import deprecated from '@wordpress/deprecated';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import InsertionPoint, { InsertionPointOpenRef } from './insertion-point';
|
|
12
|
-
import BlockPopover from './selected-block-tools';
|
|
13
|
-
|
|
14
|
-
export default function BlockToolsBackCompat( { children } ) {
|
|
15
|
-
const openRef = useContext( InsertionPointOpenRef );
|
|
16
|
-
const isDisabled = useContext( Disabled.Context );
|
|
17
|
-
|
|
18
|
-
// If context is set, `BlockTools` is a parent component.
|
|
19
|
-
if ( openRef || isDisabled ) {
|
|
20
|
-
return children;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
deprecated( 'wp.components.Popover.Slot name="block-toolbar"', {
|
|
24
|
-
alternative: 'wp.blockEditor.BlockTools',
|
|
25
|
-
since: '5.8',
|
|
26
|
-
version: '6.3',
|
|
27
|
-
} );
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<InsertionPoint __unstablePopoverSlot="block-toolbar">
|
|
31
|
-
<BlockPopover __unstablePopoverSlot="block-toolbar" />
|
|
32
|
-
{ children }
|
|
33
|
-
</InsertionPoint>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import NavigableToolbar from '../navigable-toolbar';
|
|
17
|
-
import BlockToolbar from '../block-toolbar';
|
|
18
|
-
import { store as blockEditorStore } from '../../store';
|
|
19
|
-
import { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';
|
|
20
|
-
|
|
21
|
-
export default function BlockContextualToolbar( {
|
|
22
|
-
focusOnMount,
|
|
23
|
-
isFixed,
|
|
24
|
-
...props
|
|
25
|
-
} ) {
|
|
26
|
-
const {
|
|
27
|
-
blockType,
|
|
28
|
-
blockEditingMode,
|
|
29
|
-
hasParents,
|
|
30
|
-
showParentSelector,
|
|
31
|
-
selectedBlockClientId,
|
|
32
|
-
} = useSelect( ( select ) => {
|
|
33
|
-
const {
|
|
34
|
-
getBlockName,
|
|
35
|
-
getBlockParents,
|
|
36
|
-
getSelectedBlockClientIds,
|
|
37
|
-
getBlockEditingMode,
|
|
38
|
-
} = select( blockEditorStore );
|
|
39
|
-
const { getBlockType } = select( blocksStore );
|
|
40
|
-
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
41
|
-
const _selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
42
|
-
const parents = getBlockParents( _selectedBlockClientId );
|
|
43
|
-
const firstParentClientId = parents[ parents.length - 1 ];
|
|
44
|
-
const parentBlockName = getBlockName( firstParentClientId );
|
|
45
|
-
const parentBlockType = getBlockType( parentBlockName );
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
selectedBlockClientId: _selectedBlockClientId,
|
|
49
|
-
blockType:
|
|
50
|
-
_selectedBlockClientId &&
|
|
51
|
-
getBlockType( getBlockName( _selectedBlockClientId ) ),
|
|
52
|
-
blockEditingMode: getBlockEditingMode( _selectedBlockClientId ),
|
|
53
|
-
hasParents: parents.length,
|
|
54
|
-
showParentSelector:
|
|
55
|
-
parentBlockType &&
|
|
56
|
-
getBlockEditingMode( firstParentClientId ) === 'default' &&
|
|
57
|
-
hasBlockSupport(
|
|
58
|
-
parentBlockType,
|
|
59
|
-
'__experimentalParentSelector',
|
|
60
|
-
true
|
|
61
|
-
) &&
|
|
62
|
-
selectedBlockClientIds.length <= 1 &&
|
|
63
|
-
getBlockEditingMode( _selectedBlockClientId ) === 'default',
|
|
64
|
-
};
|
|
65
|
-
}, [] );
|
|
66
|
-
|
|
67
|
-
const isToolbarEnabled =
|
|
68
|
-
blockType &&
|
|
69
|
-
hasBlockSupport( blockType, '__experimentalToolbar', true );
|
|
70
|
-
const hasAnyBlockControls = useHasAnyBlockControls();
|
|
71
|
-
if (
|
|
72
|
-
! isToolbarEnabled ||
|
|
73
|
-
( blockEditingMode !== 'default' && ! hasAnyBlockControls )
|
|
74
|
-
) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Shifts the toolbar to make room for the parent block selector.
|
|
79
|
-
const classes = classnames( 'block-editor-block-contextual-toolbar', {
|
|
80
|
-
'has-parent': hasParents && showParentSelector,
|
|
81
|
-
'is-fixed': isFixed,
|
|
82
|
-
} );
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<NavigableToolbar
|
|
86
|
-
focusOnMount={ focusOnMount }
|
|
87
|
-
focusEditorOnEscape
|
|
88
|
-
className={ classes }
|
|
89
|
-
/* translators: accessibility text for the block toolbar */
|
|
90
|
-
aria-label={ __( 'Block tools' ) }
|
|
91
|
-
variant={ isFixed ? 'unstyled' : undefined }
|
|
92
|
-
// Resets the index whenever the active block changes so
|
|
93
|
-
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
94
|
-
key={ selectedBlockClientId }
|
|
95
|
-
{ ...props }
|
|
96
|
-
>
|
|
97
|
-
<BlockToolbar hideDragHandle={ isFixed } />
|
|
98
|
-
</NavigableToolbar>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useRef, useEffect } from '@wordpress/element';
|
|
10
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import BlockSelectionButton from './block-selection-button';
|
|
17
|
-
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
18
|
-
import { store as blockEditorStore } from '../../store';
|
|
19
|
-
import BlockPopover from '../block-popover';
|
|
20
|
-
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
21
|
-
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
22
|
-
import { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';
|
|
23
|
-
|
|
24
|
-
export default function SelectedBlockTools( {
|
|
25
|
-
clientId,
|
|
26
|
-
showEmptyBlockSideInserter,
|
|
27
|
-
__unstableContentRef,
|
|
28
|
-
} ) {
|
|
29
|
-
const {
|
|
30
|
-
capturingClientId,
|
|
31
|
-
isInsertionPointVisible,
|
|
32
|
-
lastClientId,
|
|
33
|
-
rootClientId,
|
|
34
|
-
} = useSelectedBlockToolProps( clientId );
|
|
35
|
-
|
|
36
|
-
const { shouldShowBreadcrumb } = useSelect( ( select ) => {
|
|
37
|
-
const { hasMultiSelection, __unstableGetEditorMode } =
|
|
38
|
-
select( blockEditorStore );
|
|
39
|
-
|
|
40
|
-
const editorMode = __unstableGetEditorMode();
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
shouldShowBreadcrumb:
|
|
44
|
-
! hasMultiSelection() &&
|
|
45
|
-
( editorMode === 'navigation' || editorMode === 'zoom-out' ),
|
|
46
|
-
};
|
|
47
|
-
}, [] );
|
|
48
|
-
|
|
49
|
-
const isToolbarForced = useRef( false );
|
|
50
|
-
const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
|
|
51
|
-
useShouldContextualToolbarShow();
|
|
52
|
-
|
|
53
|
-
const { stopTyping } = useDispatch( blockEditorStore );
|
|
54
|
-
|
|
55
|
-
useShortcut(
|
|
56
|
-
'core/block-editor/focus-toolbar',
|
|
57
|
-
() => {
|
|
58
|
-
isToolbarForced.current = true;
|
|
59
|
-
stopTyping( true );
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
isDisabled: ! canFocusHiddenToolbar,
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
useEffect( () => {
|
|
67
|
-
isToolbarForced.current = false;
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
|
-
// Stores the active toolbar item index so the block toolbar can return focus
|
|
71
|
-
// to it when re-mounting.
|
|
72
|
-
const initialToolbarItemIndexRef = useRef();
|
|
73
|
-
|
|
74
|
-
useEffect( () => {
|
|
75
|
-
// Resets the index whenever the active block changes so this is not
|
|
76
|
-
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
77
|
-
initialToolbarItemIndexRef.current = undefined;
|
|
78
|
-
}, [ clientId ] );
|
|
79
|
-
|
|
80
|
-
const popoverProps = useBlockToolbarPopoverProps( {
|
|
81
|
-
contentElement: __unstableContentRef?.current,
|
|
82
|
-
clientId,
|
|
83
|
-
} );
|
|
84
|
-
|
|
85
|
-
if ( showEmptyBlockSideInserter ) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {
|
|
90
|
-
return (
|
|
91
|
-
<BlockPopover
|
|
92
|
-
clientId={ capturingClientId || clientId }
|
|
93
|
-
bottomClientId={ lastClientId }
|
|
94
|
-
className={ classnames(
|
|
95
|
-
'block-editor-block-list__block-popover',
|
|
96
|
-
{
|
|
97
|
-
'is-insertion-point-visible': isInsertionPointVisible,
|
|
98
|
-
}
|
|
99
|
-
) }
|
|
100
|
-
resize={ false }
|
|
101
|
-
{ ...popoverProps }
|
|
102
|
-
>
|
|
103
|
-
{ shouldShowContextualToolbar && (
|
|
104
|
-
<BlockContextualToolbar
|
|
105
|
-
// If the toolbar is being shown because of being forced
|
|
106
|
-
// it should focus the toolbar right after the mount.
|
|
107
|
-
focusOnMount={ isToolbarForced.current }
|
|
108
|
-
__experimentalInitialIndex={
|
|
109
|
-
initialToolbarItemIndexRef.current
|
|
110
|
-
}
|
|
111
|
-
__experimentalOnIndexChange={ ( index ) => {
|
|
112
|
-
initialToolbarItemIndexRef.current = index;
|
|
113
|
-
} }
|
|
114
|
-
/>
|
|
115
|
-
) }
|
|
116
|
-
{ shouldShowBreadcrumb && (
|
|
117
|
-
<BlockSelectionButton
|
|
118
|
-
clientId={ clientId }
|
|
119
|
-
rootClientId={ rootClientId }
|
|
120
|
-
/>
|
|
121
|
-
) }
|
|
122
|
-
</BlockPopover>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useState } from '@wordpress/element';
|
|
5
|
-
import { useDebounce } from '@wordpress/compose';
|
|
6
|
-
|
|
7
|
-
export default function useDebouncedInput( defaultValue = '' ) {
|
|
8
|
-
const [ input, setInput ] = useState( defaultValue );
|
|
9
|
-
const [ debouncedInput, setDebouncedState ] = useState( defaultValue );
|
|
10
|
-
|
|
11
|
-
const setDebouncedInput = useDebounce( setDebouncedState, 250 );
|
|
12
|
-
|
|
13
|
-
useEffect( () => {
|
|
14
|
-
setDebouncedInput( input );
|
|
15
|
-
}, [ input ] );
|
|
16
|
-
|
|
17
|
-
return [ input, setInput, debouncedInput ];
|
|
18
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Preview Options
|
|
2
|
-
|
|
3
|
-
The `PreviewOptions` component displays the list of different preview options available in the editor.
|
|
4
|
-
|
|
5
|
-
It returns a [`DropdownMenu`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/dropdown-menu) component with these different options. The options currently available in the editor are Desktop, Mobile, Tablet and "Preview in new tab".
|
|
6
|
-
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
## Table of contents
|
|
10
|
-
|
|
11
|
-
1. [Development guidelines](#development-guidelines)
|
|
12
|
-
2. [Related components](#related-components)
|
|
13
|
-
|
|
14
|
-
## Development guidelines
|
|
15
|
-
|
|
16
|
-
### Usage
|
|
17
|
-
|
|
18
|
-
Renders the previews options of the editor in a dropdown menu.
|
|
19
|
-
|
|
20
|
-
```jsx
|
|
21
|
-
import { Icon, MenuGroup } from '@wordpress/components';
|
|
22
|
-
import { PostPreviewButton } from '@wordpress/editor';
|
|
23
|
-
import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
|
|
24
|
-
|
|
25
|
-
const MyPreviewOptions = () => (
|
|
26
|
-
<PreviewOptions
|
|
27
|
-
isEnabled={ true }
|
|
28
|
-
className="edit-post-post-preview-dropdown"
|
|
29
|
-
deviceType={ deviceType }
|
|
30
|
-
setDeviceType={ setPreviewDeviceType }
|
|
31
|
-
> { ( { onClose } ) => (
|
|
32
|
-
<MenuGroup>
|
|
33
|
-
<div className="edit-post-header-preview__grouping-external">
|
|
34
|
-
<PostPreviewButton
|
|
35
|
-
className="edit-post-header-preview__button-external"
|
|
36
|
-
role="menuitem"
|
|
37
|
-
forceIsAutosaveable={ hasActiveMetaboxes }
|
|
38
|
-
textContent={
|
|
39
|
-
<>
|
|
40
|
-
{ __( 'Preview in new tab' ) }
|
|
41
|
-
<Icon icon={ external } />
|
|
42
|
-
</>
|
|
43
|
-
}
|
|
44
|
-
onPreview={ onClose }
|
|
45
|
-
/>
|
|
46
|
-
</div>
|
|
47
|
-
</MenuGroup>
|
|
48
|
-
) }
|
|
49
|
-
</PreviewOptions>
|
|
50
|
-
);
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Props
|
|
54
|
-
|
|
55
|
-
#### className
|
|
56
|
-
|
|
57
|
-
The CSS classes added to the component.
|
|
58
|
-
|
|
59
|
-
- Type: `String`
|
|
60
|
-
- Required: no
|
|
61
|
-
|
|
62
|
-
#### isEnabled
|
|
63
|
-
|
|
64
|
-
Wheter or not the preview options are enabled for the current post.
|
|
65
|
-
And example of when the preview options are not enabled is when the current post is not savable.
|
|
66
|
-
|
|
67
|
-
- Type: `boolean`
|
|
68
|
-
- Required: no
|
|
69
|
-
- Default: true
|
|
70
|
-
|
|
71
|
-
#### deviceType
|
|
72
|
-
|
|
73
|
-
The device type in the preview options. It can be either Desktop or Tablet or Mobile among others.
|
|
74
|
-
|
|
75
|
-
- Type: `String`
|
|
76
|
-
- Required: yes
|
|
77
|
-
|
|
78
|
-
#### setDeviceType
|
|
79
|
-
|
|
80
|
-
Used to set the device type that will be used to display the preview inside the editor.
|
|
81
|
-
|
|
82
|
-
- Type: `func`
|
|
83
|
-
- Required: yes
|
|
84
|
-
|
|
85
|
-
#### children
|
|
86
|
-
|
|
87
|
-
A function that returns nodes to be rendered within the dropdown.
|
|
88
|
-
|
|
89
|
-
- Type: `Function`
|
|
90
|
-
- Required: No
|
|
91
|
-
|
|
92
|
-
## Related components
|
|
93
|
-
|
|
94
|
-
Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
.block-editor-post-preview__dropdown {
|
|
2
|
-
padding: 0;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.block-editor-post-preview__button-resize.block-editor-post-preview__button-resize {
|
|
6
|
-
padding-left: $button-size-small + $grid-unit-10 + $grid-unit-10;
|
|
7
|
-
|
|
8
|
-
&.has-icon {
|
|
9
|
-
padding-left: $grid-unit-10;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.block-editor-post-preview__dropdown-content {
|
|
14
|
-
&.edit-post-post-preview-dropdown {
|
|
15
|
-
.components-menu-group {
|
|
16
|
-
&:first-child {
|
|
17
|
-
padding-bottom: $grid-unit-10;
|
|
18
|
-
}
|
|
19
|
-
&:last-child {
|
|
20
|
-
margin-bottom: 0;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.components-menu-group + .components-menu-group {
|
|
26
|
-
padding: $grid-unit-10;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.edit-post-header__settings,
|
|
31
|
-
.edit-site-header-edit-mode__actions {
|
|
32
|
-
@include break-small () {
|
|
33
|
-
.editor-post-preview {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Reduced UI.
|
|
40
|
-
.edit-post-header.has-reduced-ui {
|
|
41
|
-
@include break-small() {
|
|
42
|
-
// Apply transition to first two buttons.
|
|
43
|
-
.edit-post-header__settings .editor-post-save-draft,
|
|
44
|
-
.edit-post-header__settings .editor-post-saved-state,
|
|
45
|
-
.edit-post-header__settings .block-editor-post-preview__button-toggle {
|
|
46
|
-
transition: opacity 0.1s linear;
|
|
47
|
-
@include reduce-motion("transition");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Zero out opacity unless hovered.
|
|
51
|
-
&:not(:hover) {
|
|
52
|
-
.edit-post-header__settings .editor-post-save-draft,
|
|
53
|
-
.edit-post-header__settings .editor-post-saved-state,
|
|
54
|
-
.edit-post-header__settings .block-editor-post-preview__button-toggle {
|
|
55
|
-
opacity: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// ... or opened.
|
|
59
|
-
.edit-post-header__settings .block-editor-post-preview__button-toggle.is-opened {
|
|
60
|
-
opacity: 1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useBlockEditContext } from '../block-edit/context';
|
|
10
|
-
import { store as blockEditorStore } from '../../store';
|
|
11
|
-
|
|
12
|
-
export default function useDisplayBlockControls() {
|
|
13
|
-
const { isSelected, clientId, name } = useBlockEditContext();
|
|
14
|
-
return useSelect(
|
|
15
|
-
( select ) => {
|
|
16
|
-
if ( isSelected ) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
getBlockName,
|
|
22
|
-
isFirstMultiSelectedBlock,
|
|
23
|
-
getMultiSelectedBlockClientIds,
|
|
24
|
-
} = select( blockEditorStore );
|
|
25
|
-
|
|
26
|
-
if ( isFirstMultiSelectedBlock( clientId ) ) {
|
|
27
|
-
return getMultiSelectedBlockClientIds().every(
|
|
28
|
-
( id ) => getBlockName( id ) === name
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
},
|
|
34
|
-
[ clientId, isSelected, name ]
|
|
35
|
-
);
|
|
36
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { useBlockEditContext } from '../block-edit/context';
|
|
11
|
-
import { store as blockEditorStore } from '../../store';
|
|
12
|
-
|
|
13
|
-
export default function useDisplayBlockControls() {
|
|
14
|
-
const { isSelected, clientId, name } = useBlockEditContext();
|
|
15
|
-
return useSelect(
|
|
16
|
-
( select ) => {
|
|
17
|
-
const { getBlockName, getBlockRootClientId } =
|
|
18
|
-
select( blockEditorStore );
|
|
19
|
-
|
|
20
|
-
const parentId = getBlockRootClientId( clientId );
|
|
21
|
-
const parentBlockName = getBlockName( parentId );
|
|
22
|
-
|
|
23
|
-
const hideControls = hasBlockSupport(
|
|
24
|
-
parentBlockName,
|
|
25
|
-
'__experimentalHideChildBlockControls',
|
|
26
|
-
false
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if ( ! hideControls && isSelected ) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return false;
|
|
34
|
-
},
|
|
35
|
-
[ clientId, isSelected, name ]
|
|
36
|
-
);
|
|
37
|
-
}
|
package/src/hooks/test/color.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import BlockEditorProvider from '../../components/provider';
|
|
15
|
-
import { withColorPaletteStyles } from '../color';
|
|
16
|
-
|
|
17
|
-
describe( 'withColorPaletteStyles', () => {
|
|
18
|
-
const settings = {
|
|
19
|
-
__experimentalFeatures: {
|
|
20
|
-
color: {
|
|
21
|
-
palette: {
|
|
22
|
-
default: [
|
|
23
|
-
{
|
|
24
|
-
name: 'Pale pink',
|
|
25
|
-
slug: 'pale-pink',
|
|
26
|
-
color: '#f78da7',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'Vivid green cyan',
|
|
30
|
-
slug: 'vivid-green-cyan',
|
|
31
|
-
color: '#00d084',
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const EnhancedComponent = withColorPaletteStyles(
|
|
40
|
-
( { getStyleObj, wrapperProps } ) => (
|
|
41
|
-
<div>{ getStyleObj( wrapperProps.style ) }</div>
|
|
42
|
-
)
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
beforeAll( () => {
|
|
46
|
-
registerBlockType( 'core/test-block', {
|
|
47
|
-
save: () => undefined,
|
|
48
|
-
edit: () => undefined,
|
|
49
|
-
category: 'text',
|
|
50
|
-
title: 'test block',
|
|
51
|
-
supports: {
|
|
52
|
-
color: {
|
|
53
|
-
text: true,
|
|
54
|
-
background: true,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
} );
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
|
-
afterAll( () => {
|
|
61
|
-
unregisterBlockType( 'core/test-block' );
|
|
62
|
-
} );
|
|
63
|
-
|
|
64
|
-
it( 'should add color styles from attributes', () => {
|
|
65
|
-
const getStyleObj = jest.fn();
|
|
66
|
-
|
|
67
|
-
render(
|
|
68
|
-
<BlockEditorProvider settings={ settings } value={ [] }>
|
|
69
|
-
<EnhancedComponent
|
|
70
|
-
attributes={ {
|
|
71
|
-
backgroundColor: 'vivid-green-cyan',
|
|
72
|
-
textColor: 'pale-pink',
|
|
73
|
-
} }
|
|
74
|
-
name="core/test-block"
|
|
75
|
-
getStyleObj={ getStyleObj }
|
|
76
|
-
/>
|
|
77
|
-
</BlockEditorProvider>
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
expect( getStyleObj ).toHaveBeenLastCalledWith( {
|
|
81
|
-
color: '#f78da7',
|
|
82
|
-
backgroundColor: '#00d084',
|
|
83
|
-
} );
|
|
84
|
-
} );
|
|
85
|
-
|
|
86
|
-
it( 'should not add undefined style values', () => {
|
|
87
|
-
// This test ensures that undefined `color` and `backgroundColor` styles
|
|
88
|
-
// are not added to the styles object. An undefined `backgroundColor`
|
|
89
|
-
// style causes a React warning when gradients are used, as the gradient
|
|
90
|
-
// style currently uses the `background` shorthand syntax.
|
|
91
|
-
// See: https://github.com/WordPress/gutenberg/issues/36899.
|
|
92
|
-
const getStyleObj = jest.fn();
|
|
93
|
-
|
|
94
|
-
render(
|
|
95
|
-
<BlockEditorProvider settings={ settings } value={ [] }>
|
|
96
|
-
<EnhancedComponent
|
|
97
|
-
attributes={ {
|
|
98
|
-
backgroundColor: undefined,
|
|
99
|
-
textColor: undefined,
|
|
100
|
-
} }
|
|
101
|
-
name="core/test-block"
|
|
102
|
-
getStyleObj={ getStyleObj }
|
|
103
|
-
/>
|
|
104
|
-
</BlockEditorProvider>
|
|
105
|
-
);
|
|
106
|
-
// Check explictly for the object used in the call, because
|
|
107
|
-
// `toHaveBeenCalledWith` does not check for empty keys.
|
|
108
|
-
expect(
|
|
109
|
-
getStyleObj.mock.calls[ getStyleObj.mock.calls.length - 1 ][ 0 ]
|
|
110
|
-
).toStrictEqual( {} );
|
|
111
|
-
} );
|
|
112
|
-
} );
|