@wordpress/block-editor 14.5.0 → 14.6.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 +0 -8
- package/build/autocompleters/block.js +13 -5
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-canvas/index.js +10 -0
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +2 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-full-height-alignment-control/index.js +1 -1
- package/build/components/block-full-height-alignment-control/index.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +1 -7
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +5 -5
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -2
- 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 -3
- 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-selected-block-event-handlers.js +3 -6
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +1 -1
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-popover/index.js +2 -45
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js +4 -3
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +122 -0
- package/build/components/block-toolbar/change-design.js.map +1 -0
- package/build/components/block-toolbar/index.js +19 -7
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/index.js +4 -10
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +4 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +3 -9
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +20 -29
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +2 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +6 -10
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +7 -10
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/collab/block-comment-icon-slot.js +18 -0
- package/build/components/collab/block-comment-icon-slot.js.map +1 -0
- package/build/components/collab/block-comment-icon-toolbar-slot.js +18 -0
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -0
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +7 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +4 -4
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -4
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-context.native.js +6 -0
- package/build/components/global-styles/use-global-styles-context.native.js.map +1 -1
- package/build/components/iframe/index.js +17 -22
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/index.js +61 -20
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +9 -5
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -2
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +15 -2
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/menu.js +4 -2
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter-button/index.native.js +1 -1
- package/build/components/inserter-button/index.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +0 -2
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +3 -6
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/link-control/link-preview.js +12 -9
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/appender.js +4 -3
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/branch.js +6 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +1 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/index.js +3 -1
- package/build/components/rich-text/event-listeners/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -6
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +2 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -3
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/linked-button.js +1 -5
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build/components/tool-selector/index.js +1 -4
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +5 -5
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +0 -1
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-moving-animation/index.js +1 -3
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-settings/index.js +1 -3
- package/build/components/use-settings/index.js.map +1 -1
- package/build/components/writing-flow/index.js +5 -3
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +2 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/block-bindings.js +19 -8
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/contrast-checker.js +0 -1
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/duotone.js +2 -2
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/style.js +4 -1
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-zoom-out.js +13 -22
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/index.js +0 -7
- package/build/index.js.map +1 -1
- package/build/private-apis.js +6 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +2 -33
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/private-actions.js +57 -8
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +9 -21
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +16 -6
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/dom.js +16 -1
- package/build/utils/dom.js.map +1 -1
- package/build/utils/get-font-styles-and-weights.js +1 -1
- package/build/utils/get-font-styles-and-weights.js.map +1 -1
- package/build/utils/transform-styles/index.js +4 -3
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/autocompleters/block.js +14 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-canvas/index.js +11 -1
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +3 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-full-height-alignment-control/index.js +1 -1
- package/build-module/components/block-full-height-alignment-control/index.js.map +1 -1
- package/build-module/components/block-list/block.js +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +1 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +5 -5
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -2
- 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 -3
- 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-selected-block-event-handlers.js +3 -6
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +1 -1
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -45
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +5 -4
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +114 -0
- package/build-module/components/block-toolbar/change-design.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +19 -7
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -10
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +3 -9
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +20 -29
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +2 -2
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +6 -10
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +8 -11
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-slot.js +11 -0
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -0
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +11 -0
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -0
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +7 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +4 -4
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +2 -5
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-context.native.js +6 -0
- package/build-module/components/global-styles/use-global-styles-context.native.js.map +1 -1
- package/build-module/components/iframe/index.js +17 -22
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/index.js +62 -21
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -2
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +15 -2
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +5 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +1 -1
- package/build-module/components/inserter-button/index.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +0 -2
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +3 -6
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +13 -10
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/appender.js +4 -3
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/branch.js +7 -6
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +1 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/index.js +4 -2
- package/build-module/components/rich-text/event-listeners/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +2 -6
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +3 -3
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/linked-button.js +2 -6
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build-module/components/tool-selector/index.js +1 -4
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +5 -5
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +0 -1
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +1 -3
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +1 -3
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +5 -3
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +2 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/block-bindings.js +20 -9
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +0 -1
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/duotone.js +2 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/style.js +4 -1
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +15 -23
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +7 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -33
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/private-actions.js +54 -7
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +9 -20
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +16 -6
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +45 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/dom.js +16 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-module/utils/get-font-styles-and-weights.js +2 -2
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +3 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +9 -4
- package/build-style/content.css +9 -4
- package/build-style/style-rtl.css +33 -22
- package/build-style/style.css +33 -22
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/autocompleters/block.js +16 -7
- package/src/components/block-canvas/index.js +17 -1
- package/src/components/block-canvas/style.scss +2 -0
- package/src/components/block-card/index.js +3 -3
- package/src/components/block-full-height-alignment-control/index.js +1 -1
- package/src/components/block-inspector/style.scss +0 -6
- package/src/components/block-list/block.js +1 -2
- package/src/components/block-list/block.native.js +0 -4
- package/src/components/block-list/content.scss +1 -1
- package/src/components/block-list/index.js +4 -4
- package/src/components/block-list/use-block-props/index.js +0 -2
- package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -3
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +7 -20
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-patterns-list/stories/fixtures.js +834 -0
- package/src/components/block-patterns-list/stories/index.story.js +81 -0
- package/src/components/block-patterns-list/style.scss +2 -0
- package/src/components/block-patterns-paging/index.js +1 -1
- package/src/components/block-popover/index.js +0 -62
- package/src/components/block-preview/index.js +2 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-settings-menu/index.js +3 -0
- package/src/components/block-toolbar/change-design.js +133 -0
- package/src/components/block-toolbar/index.js +25 -8
- package/src/components/block-toolbar/style.scss +16 -0
- package/src/components/block-tools/index.js +4 -17
- package/src/components/block-tools/insertion-point.js +4 -3
- package/src/components/block-tools/style.scss +0 -20
- package/src/components/block-tools/use-show-block-tools.js +0 -13
- package/src/components/block-tools/zoom-out-mode-inserters.js +25 -40
- package/src/components/block-variation-transforms/index.js +2 -2
- package/src/components/block-vertical-alignment-control/ui.js +11 -15
- package/src/components/border-radius-control/linked-button.js +9 -11
- package/src/components/collab/block-comment-icon-slot.js +12 -0
- package/src/components/collab/block-comment-icon-toolbar-slot.js +12 -0
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +7 -1
- package/src/components/convert-to-group-buttons/toolbar.js +4 -4
- package/src/components/global-styles/color-panel.js +2 -10
- package/src/components/global-styles/test/use-global-styles-context.native.js +1 -0
- package/src/components/global-styles/use-global-styles-context.native.js +6 -0
- package/src/components/iframe/content.scss +4 -9
- package/src/components/iframe/index.js +31 -34
- package/src/components/iframe/style.scss +2 -3
- package/src/components/image-size-control/index.js +74 -43
- package/src/components/image-size-control/test/index.js +5 -63
- package/src/components/inner-blocks/index.js +12 -6
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -3
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/src/components/inserter/category-tabs/index.js +16 -2
- package/src/components/inserter/menu.js +6 -4
- package/src/components/inserter/style.scss +13 -0
- package/src/components/inserter-button/index.native.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +1 -6
- package/src/components/inspector-controls-tabs/utils.js +0 -3
- package/src/components/link-control/link-preview.js +15 -8
- package/src/components/link-control/test/index.js +63 -24
- package/src/components/list-view/appender.js +5 -6
- package/src/components/list-view/branch.js +8 -6
- package/src/components/list-view/index.js +1 -2
- package/src/components/provider/index.js +1 -3
- package/src/components/provider/test/experimental-provider.js +43 -1
- package/src/components/rich-text/event-listeners/index.js +4 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/spacing-sizes-control/index.js +3 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
- package/src/components/spacing-sizes-control/linked-button.js +2 -12
- package/src/components/tool-selector/index.js +1 -5
- package/src/components/url-input/index.js +1 -1
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +5 -5
- package/src/components/use-block-drop-zone/index.native.js +0 -1
- package/src/components/use-moving-animation/index.js +0 -1
- package/src/components/use-settings/index.js +0 -1
- package/src/components/writing-flow/index.js +5 -3
- package/src/components/writing-flow/use-tab-nav.js +1 -2
- package/src/hooks/block-bindings.js +48 -31
- package/src/hooks/contrast-checker.js +0 -1
- package/src/hooks/duotone.js +2 -2
- package/src/hooks/style.js +7 -3
- package/src/hooks/use-zoom-out.js +14 -34
- package/src/index.js +0 -1
- package/src/private-apis.js +6 -3
- package/src/store/actions.js +3 -52
- package/src/store/defaults.js +2 -1
- package/src/store/private-actions.js +71 -8
- package/src/store/private-selectors.js +9 -19
- package/src/store/reducer.js +25 -11
- package/src/store/selectors.js +59 -8
- package/src/store/test/actions.js +41 -0
- package/src/store/test/reducer.js +23 -0
- package/src/utils/dom.js +22 -2
- package/src/utils/get-font-styles-and-weights.js +2 -2
- package/src/utils/transform-styles/index.js +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +0 -57
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +0 -1
- package/build/components/block-toolbar/shuffle.js +0 -110
- package/build/components/block-toolbar/shuffle.js.map +0 -1
- package/build/components/block-tools/zoom-out-popover.js +0 -58
- package/build/components/block-tools/zoom-out-popover.js.map +0 -1
- package/build/components/block-tools/zoom-out-toolbar.js +0 -132
- package/build/components/block-tools/zoom-out-toolbar.js.map +0 -1
- package/build/components/block-vertical-alignment-control/icons.js +0 -48
- package/build/components/block-vertical-alignment-control/icons.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +0 -51
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +0 -1
- package/build-module/components/block-toolbar/shuffle.js +0 -103
- package/build-module/components/block-toolbar/shuffle.js.map +0 -1
- package/build-module/components/block-tools/zoom-out-popover.js +0 -49
- package/build-module/components/block-tools/zoom-out-popover.js.map +0 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +0 -124
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +0 -1
- package/build-module/components/block-vertical-alignment-control/icons.js +0 -41
- package/build-module/components/block-vertical-alignment-control/icons.js.map +0 -1
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +0 -65
- package/src/components/block-toolbar/shuffle.js +0 -111
- package/src/components/block-tools/zoom-out-popover.js +0 -47
- package/src/components/block-tools/zoom-out-toolbar.js +0 -135
- package/src/components/block-vertical-alignment-control/icons.js +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useContext","__","sprintf","__unstableGetBlockProps","getBlockProps","useMergeRefs","useDisabled","warning","useMovingAnimation","PrivateBlockContext","useFocusFirstElement","useIsHovered","blockBindingsKey","useBlockEditContext","useFocusHandler","useEventHandlers","useZoomOutModeExit","useBlockRefProvider","useIntersectionObserver","useScrollIntoView","useFlashEditableBlocks","canBindBlock","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","index","mode","name","blockApiVersion","blockTitle","isSelected","isSubtreeDisabled","hasOverlay","initialPosition","blockEditingMode","isHighlighted","isMultiSelected","isPartiallySelected","isReusable","isDragging","hasChildSelected","isEditingDisabled","hasEditableOutline","isTemporarilyEditingAsBlocks","defaultClassName","isSectionBlock","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","isDisabled","isEnabled","blockEditContext","hasBlockBindings","bindingsStyle","globalThis","SCRIPT_DEBUG","hasNegativeMargin","style","marginTop","charAt","marginBottom","marginLeft","marginRight","tabIndex","id","role","inert","undefined","save"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { PrivateBlockContext } from '../private-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport {\n\tblockBindingsKey,\n\tuseBlockEditContext,\n} from '../../block-edit/context';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useZoomOutModeExit } from './use-zoom-out-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useFlashEditableBlocks } from '../../use-flash-editable-blocks';\nimport { canBindBlock } from '../../../hooks/use-bindings-attributes';\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps( {\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * } )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisSelected,\n\t\tisSubtreeDisabled,\n\t\thasOverlay,\n\t\tinitialPosition,\n\t\tblockEditingMode,\n\t\tisHighlighted,\n\t\tisMultiSelected,\n\t\tisPartiallySelected,\n\t\tisReusable,\n\t\tisDragging,\n\t\thasChildSelected,\n\t\tisEditingDisabled,\n\t\thasEditableOutline,\n\t\tisTemporarilyEditingAsBlocks,\n\t\tdefaultClassName,\n\t\tisSectionBlock,\n\t} = useContext( PrivateBlockContext );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( { clientId, initialPosition } ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( { clientId, isSelected } ),\n\t\tuseZoomOutModeExit(),\n\t\tuseIsHovered( { clientId } ),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( { triggerAnimationOnChange: index, clientId } ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t\tuseFlashEditableBlocks( {\n\t\t\tclientId,\n\t\t\tisEnabled: isSectionBlock,\n\t\t} ),\n\t\tuseScrollIntoView( { isSelected } ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\tconst hasBlockBindings = !! blockEditContext[ blockBindingsKey ];\n\tconst bindingsStyle =\n\t\thasBlockBindings && canBindBlock( name )\n\t\t\t? {\n\t\t\t\t\t'--wp-admin-theme-color': 'var(--wp-block-synced-color)',\n\t\t\t\t\t'--wp-admin-theme-color--rgb':\n\t\t\t\t\t\t'var(--wp-block-synced-color--rgb)',\n\t\t\t }\n\t\t\t: {};\n\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\tlet hasNegativeMargin = false;\n\tif (\n\t\twrapperProps?.style?.marginTop?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginBottom?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginLeft?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginRight?.charAt( 0 ) === '-'\n\t) {\n\t\thasNegativeMargin = true;\n\t}\n\n\treturn {\n\t\ttabIndex: blockEditingMode === 'disabled' ? -1 : 0,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: clsx(\n\t\t\t'block-editor-block-list__block',\n\t\t\t{\n\t\t\t\t// The wp-block className is important for editor styles.\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected': isPartiallySelected,\n\t\t\t\t'is-reusable': isReusable,\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': hasChildSelected,\n\t\t\t\t'is-editing-disabled': isEditingDisabled,\n\t\t\t\t'has-editable-outline': hasEditableOutline,\n\t\t\t\t'has-negative-margin': hasNegativeMargin,\n\t\t\t\t'is-content-locked-temporarily-editing-as-blocks':\n\t\t\t\t\tisTemporarilyEditingAsBlocks,\n\t\t\t},\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tdefaultClassName\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style, ...bindingsStyle },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,uBAAuB,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ACzB,oBAAoB,EAAEC,gBAAgB;MACtC,qBAAqB,EAAEC,iBAAiB;MACxC,sBAAsB,EAAEC,kBAAkB;MAC1C,qBAAqB,EAAEgB,iBAAiB;MACxC,iDAAiD,EAChDf;IACF,CAAC,EACDrB,SAAS,EACTH,KAAK,CAACG,SAAS,EACfC,YAAY,CAACD,SAAS,EACtBsB,gBACD,CAAC;IACDe,KAAK,EAAE;MAAE,GAAGpC,YAAY,CAACoC,KAAK;MAAE,GAAGxC,KAAK,CAACwC,KAAK;MAAE,GAAGJ;IAAc;EAClE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACArC,aAAa,CAACoD,IAAI,GAAGtE,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useContext","__","sprintf","__unstableGetBlockProps","getBlockProps","useMergeRefs","useDisabled","warning","useMovingAnimation","PrivateBlockContext","useFocusFirstElement","useIsHovered","blockBindingsKey","useBlockEditContext","useFocusHandler","useEventHandlers","useBlockRefProvider","useIntersectionObserver","useScrollIntoView","useFlashEditableBlocks","canBindBlock","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","index","mode","name","blockApiVersion","blockTitle","isSelected","isSubtreeDisabled","hasOverlay","initialPosition","blockEditingMode","isHighlighted","isMultiSelected","isPartiallySelected","isReusable","isDragging","hasChildSelected","isEditingDisabled","hasEditableOutline","isTemporarilyEditingAsBlocks","defaultClassName","isSectionBlock","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","isDisabled","isEnabled","blockEditContext","hasBlockBindings","bindingsStyle","globalThis","SCRIPT_DEBUG","hasNegativeMargin","style","marginTop","charAt","marginBottom","marginLeft","marginRight","tabIndex","id","role","inert","undefined","save"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { PrivateBlockContext } from '../private-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport {\n\tblockBindingsKey,\n\tuseBlockEditContext,\n} from '../../block-edit/context';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useFlashEditableBlocks } from '../../use-flash-editable-blocks';\nimport { canBindBlock } from '../../../hooks/use-bindings-attributes';\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps( {\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * } )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisSelected,\n\t\tisSubtreeDisabled,\n\t\thasOverlay,\n\t\tinitialPosition,\n\t\tblockEditingMode,\n\t\tisHighlighted,\n\t\tisMultiSelected,\n\t\tisPartiallySelected,\n\t\tisReusable,\n\t\tisDragging,\n\t\thasChildSelected,\n\t\tisEditingDisabled,\n\t\thasEditableOutline,\n\t\tisTemporarilyEditingAsBlocks,\n\t\tdefaultClassName,\n\t\tisSectionBlock,\n\t} = useContext( PrivateBlockContext );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( { clientId, initialPosition } ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( { clientId, isSelected } ),\n\t\tuseIsHovered( { clientId } ),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( { triggerAnimationOnChange: index, clientId } ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t\tuseFlashEditableBlocks( {\n\t\t\tclientId,\n\t\t\tisEnabled: isSectionBlock,\n\t\t} ),\n\t\tuseScrollIntoView( { isSelected } ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\tconst hasBlockBindings = !! blockEditContext[ blockBindingsKey ];\n\tconst bindingsStyle =\n\t\thasBlockBindings && canBindBlock( name )\n\t\t\t? {\n\t\t\t\t\t'--wp-admin-theme-color': 'var(--wp-block-synced-color)',\n\t\t\t\t\t'--wp-admin-theme-color--rgb':\n\t\t\t\t\t\t'var(--wp-block-synced-color--rgb)',\n\t\t\t }\n\t\t\t: {};\n\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\tlet hasNegativeMargin = false;\n\tif (\n\t\twrapperProps?.style?.marginTop?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginBottom?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginLeft?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginRight?.charAt( 0 ) === '-'\n\t) {\n\t\thasNegativeMargin = true;\n\t}\n\n\treturn {\n\t\ttabIndex: blockEditingMode === 'disabled' ? -1 : 0,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: clsx(\n\t\t\t'block-editor-block-list__block',\n\t\t\t{\n\t\t\t\t// The wp-block className is important for editor styles.\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected': isPartiallySelected,\n\t\t\t\t'is-reusable': isReusable,\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': hasChildSelected,\n\t\t\t\t'is-editing-disabled': isEditingDisabled,\n\t\t\t\t'has-editable-outline': hasEditableOutline,\n\t\t\t\t'has-negative-margin': hasNegativeMargin,\n\t\t\t\t'is-content-locked-temporarily-editing-as-blocks':\n\t\t\t\t\tisTemporarilyEditingAsBlocks,\n\t\t\t},\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tdefaultClassName\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style, ...bindingsStyle },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,uBAAuB,IAAIC,aAAa,QAAQ,mBAAmB;AAC5E,SAASC,YAAY,EAAEC,WAAW,QAAQ,oBAAoB;AAC9D,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,gBAAgB,EAChBC,mBAAmB,QACb,0BAA0B;AACjC,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,gBAAgB,QAAQ,qCAAqC;AACtE,SAASC,mBAAmB,QAAQ,kBAAkB;AACtD,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,sBAAsB,QAAQ,iCAAiC;AACxE,SAASC,YAAY,QAAQ,wCAAwC;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAE;EAAEC;AAAiB,CAAC,GAAG,CAAC,CAAC,EAAG;EACtE,MAAM;IACLC,QAAQ;IACRC,SAAS;IACTC,YAAY,GAAG,CAAC,CAAC;IACjBC,SAAS;IACTC,KA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vB,mBAAmB,EAAEQ,UAAU;MAC/B,aAAa,EAAEF,UAAU;MACzB,gBAAgB,EAAEK,aAAa;MAC/B,mBAAmB,EAAEC,eAAe;MACpC,uBAAuB,EAAEC,mBAAmB;MAC5C,aAAa,EAAEC,UAAU;MACzB,aAAa,EAAEC,UAAU;MACzB,oBAAoB,EAAEC,gBAAgB;MACtC,qBAAqB,EAAEC,iBAAiB;MACxC,sBAAsB,EAAEC,kBAAkB;MAC1C,qBAAqB,EAAEgB,iBAAiB;MACxC,iDAAiD,EAChDf;IACF,CAAC,EACDrB,SAAS,EACTH,KAAK,CAACG,SAAS,EACfC,YAAY,CAACD,SAAS,EACtBsB,gBACD,CAAC;IACDe,KAAK,EAAE;MAAE,GAAGpC,YAAY,CAACoC,KAAK;MAAE,GAAGxC,KAAK,CAACwC,KAAK;MAAE,GAAGJ;IAAc;EAClE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACArC,aAAa,CAACoD,IAAI,GAAGrE,aAAa","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
10
10
|
*/
|
|
11
11
|
import { isInsideRootBlock } from '../../../utils/dom';
|
|
12
12
|
import { store as blockEditorStore } from '../../../store';
|
|
13
|
+
import { unlock } from '../../../lock-unlock';
|
|
13
14
|
|
|
14
15
|
/** @typedef {import('@wordpress/element').RefObject} RefObject */
|
|
15
16
|
|
|
@@ -29,11 +30,11 @@ export function useFocusFirstElement({
|
|
|
29
30
|
const {
|
|
30
31
|
isBlockSelected,
|
|
31
32
|
isMultiSelecting,
|
|
32
|
-
|
|
33
|
-
} = useSelect(blockEditorStore);
|
|
33
|
+
isZoomOut
|
|
34
|
+
} = unlock(useSelect(blockEditorStore));
|
|
34
35
|
useEffect(() => {
|
|
35
36
|
// Check if the block is still selected at the time this effect runs.
|
|
36
|
-
if (!isBlockSelected(clientId) || isMultiSelecting() ||
|
|
37
|
+
if (!isBlockSelected(clientId) || isMultiSelecting() || isZoomOut()) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
if (initialPosition === undefined || initialPosition === null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","focus","isFormElement","isTextField","placeCaretAtHorizontalEdge","useSelect","isInsideRootBlock","store","blockEditorStore","useFocusFirstElement","clientId","initialPosition","ref","isBlockSelected","isMultiSelecting","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","focus","isFormElement","isTextField","placeCaretAtHorizontalEdge","useSelect","isInsideRootBlock","store","blockEditorStore","unlock","useFocusFirstElement","clientId","initialPosition","ref","isBlockSelected","isMultiSelecting","isZoomOut","undefined","current","ownerDocument","activeElement","textInputs","tabbable","find","filter","node","isReverse","target","length","getAttribute","focusElement","findNext"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tfocus,\n\tisFormElement,\n\tisTextField,\n\tplaceCaretAtHorizontalEdge,\n} from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Transitions focus to the block or inner tabbable when the block becomes\n * selected and an initial position is set.\n *\n * @param {string} clientId Block client ID.\n *\n * @return {RefObject} React ref with the block element.\n */\nexport function useFocusFirstElement( { clientId, initialPosition } ) {\n\tconst ref = useRef();\n\tconst { isBlockSelected, isMultiSelecting, isZoomOut } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\n\tuseEffect( () => {\n\t\t// Check if the block is still selected at the time this effect runs.\n\t\tif (\n\t\t\t! isBlockSelected( clientId ) ||\n\t\t\tisMultiSelecting() ||\n\t\t\tisZoomOut()\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( initialPosition === undefined || initialPosition === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\n\t\t// Do not focus the block if it already contains the active element.\n\t\tif ( isInsideRootBlock( ref.current, ownerDocument.activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Find all tabbables within node.\n\t\tconst textInputs = focus.tabbable\n\t\t\t.find( ref.current )\n\t\t\t.filter( ( node ) => isTextField( node ) );\n\n\t\t// If reversed (e.g. merge via backspace), use the last in the set of\n\t\t// tabbables.\n\t\tconst isReverse = -1 === initialPosition;\n\t\tconst target =\n\t\t\ttextInputs[ isReverse ? textInputs.length - 1 : 0 ] || ref.current;\n\n\t\tif ( ! isInsideRootBlock( ref.current, target ) ) {\n\t\t\tref.current.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check to see if element is focussable before a generic caret insert.\n\t\tif ( ! ref.current.getAttribute( 'contenteditable' ) ) {\n\t\t\tconst focusElement = focus.tabbable.findNext( ref.current );\n\t\t\t// Make sure focusElement is valid, contained in the same block, and a form field.\n\t\t\tif (\n\t\t\t\tfocusElement &&\n\t\t\t\tisInsideRootBlock( ref.current, focusElement ) &&\n\t\t\t\tisFormElement( focusElement )\n\t\t\t) {\n\t\t\t\tfocusElement.focus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tplaceCaretAtHorizontalEdge( target, isReverse );\n\t}, [ initialPosition, clientId ] );\n\n\treturn ref;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SACCC,KAAK,EACLC,aAAa,EACbC,WAAW,EACXC,0BAA0B,QACpB,gBAAgB;AACvB,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,gBAAgB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CAAC;MACnB;IACD;;IAEA;IACA,IAAK,CAAEY,GAAG,CAACK,OAAO,CAACW,YAAY,CAAE,iBAAkB,CAAC,EAAG;MACtD,MAAMC,YAAY,GAAG7B,KAAK,CAACqB,QAAQ,CAACS,QAAQ,CAAElB,GAAG,CAACK,OAAQ,CAAC;MAC3D;MACA,IACCY,YAAY,IACZxB,iBAAiB,CAAEO,GAAG,CAACK,OAAO,EAAEY,YAAa,CAAC,IAC9C5B,aAAa,CAAE4B,YAAa,CAAC,EAC5B;QACDA,YAAY,CAAC7B,KAAK,CAAC,CAAC;QACpB;MACD;IACD;IACAG,0BAA0B,CAAEuB,MAAM,EAAED,SAAU,CAAC;EAChD,CAAC,EAAE,CAAEd,eAAe,EAAED,QAAQ,CAAG,CAAC;EAElC,OAAOE,GAAG;AACX","ignoreList":[]}
|
package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js
CHANGED
|
@@ -27,13 +27,11 @@ export function useEventHandlers({
|
|
|
27
27
|
const {
|
|
28
28
|
getBlockRootClientId,
|
|
29
29
|
getBlockIndex,
|
|
30
|
-
isZoomOut
|
|
31
|
-
__unstableGetEditorMode
|
|
30
|
+
isZoomOut
|
|
32
31
|
} = unlock(useSelect(blockEditorStore));
|
|
33
32
|
const {
|
|
34
33
|
insertAfterBlock,
|
|
35
34
|
removeBlock,
|
|
36
|
-
__unstableSetEditorMode,
|
|
37
35
|
resetZoomLevel
|
|
38
36
|
} = unlock(useDispatch(blockEditorStore));
|
|
39
37
|
return useRefEffect(node => {
|
|
@@ -62,8 +60,7 @@ export function useEventHandlers({
|
|
|
62
60
|
return;
|
|
63
61
|
}
|
|
64
62
|
event.preventDefault();
|
|
65
|
-
if (keyCode === ENTER &&
|
|
66
|
-
__unstableSetEditorMode('edit');
|
|
63
|
+
if (keyCode === ENTER && isZoomOut()) {
|
|
67
64
|
resetZoomLevel();
|
|
68
65
|
} else if (keyCode === ENTER) {
|
|
69
66
|
insertAfterBlock(clientId);
|
|
@@ -87,6 +84,6 @@ export function useEventHandlers({
|
|
|
87
84
|
node.removeEventListener('keydown', onKeyDown);
|
|
88
85
|
node.removeEventListener('dragstart', onDragStart);
|
|
89
86
|
};
|
|
90
|
-
}, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertAfterBlock, removeBlock,
|
|
87
|
+
}, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertAfterBlock, removeBlock, isZoomOut, resetZoomLevel]);
|
|
91
88
|
}
|
|
92
89
|
//# sourceMappingURL=use-selected-block-event-handlers.js.map
|
package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isTextField","ENTER","BACKSPACE","DELETE","useSelect","useDispatch","useRefEffect","store","blockEditorStore","unlock","useEventHandlers","clientId","isSelected","getBlockRootClientId","getBlockIndex","isZoomOut","
|
|
1
|
+
{"version":3,"names":["isTextField","ENTER","BACKSPACE","DELETE","useSelect","useDispatch","useRefEffect","store","blockEditorStore","unlock","useEventHandlers","clientId","isSelected","getBlockRootClientId","getBlockIndex","isZoomOut","insertAfterBlock","removeBlock","resetZoomLevel","node","onKeyDown","event","keyCode","target","preventDefault","onDragStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-selected-block-event-handlers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isTextField } from '@wordpress/dom';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\n/**\n * Adds block behaviour:\n * - Removes the block on BACKSPACE.\n * - Inserts a default block on ENTER.\n * - Disables dragging of block contents.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useEventHandlers( { clientId, isSelected } ) {\n\tconst { getBlockRootClientId, getBlockIndex, isZoomOut } = unlock(\n\t\tuseSelect( blockEditorStore )\n\t);\n\tconst { insertAfterBlock, removeBlock, resetZoomLevel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isSelected ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Interprets keydown event intent to remove or insert after block if\n\t\t\t * key event occurs on wrapper node. This can occur when the block has\n\t\t\t * no text fields of its own, particularly after initial insertion, to\n\t\t\t * allow for easy deletion and continuous writing flow to add additional\n\t\t\t * content.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keydown event.\n\t\t\t */\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tconst { keyCode, target } = event;\n\n\t\t\t\tif (\n\t\t\t\t\tkeyCode !== ENTER &&\n\t\t\t\t\tkeyCode !== BACKSPACE &&\n\t\t\t\t\tkeyCode !== DELETE\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( target !== node || isTextField( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( keyCode === ENTER && isZoomOut() ) {\n\t\t\t\t\tresetZoomLevel();\n\t\t\t\t} else if ( keyCode === ENTER ) {\n\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tremoveBlock( clientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Prevents default dragging behavior within a block. To do: we must\n\t\t\t * handle this in the future and clean up the drag target.\n\t\t\t *\n\t\t\t * @param {DragEvent} event Drag event.\n\t\t\t */\n\t\t\tfunction onDragStart( event ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'dragstart', onDragStart );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'dragstart', onDragStart );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tisSelected,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tinsertAfterBlock,\n\t\t\tremoveBlock,\n\t\t\tisZoomOut,\n\t\t\tresetZoomLevel,\n\t\t]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AAC9D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,gBAAgB;AAC1D,SAASC,MAAM,QAAQ,sBAAsB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAE;EAAEC,QAAQ;EAAEC;AAAW,CAAC,EAAG;EAC5D,MAAM;IAAEC,oBAAoB;IAAEC,aAAa;IAAEC;EAAU,CAAC,GAAGN,MAAM,CAChEL,SAAS,CAAEI,gBAAiB,CAC7B,CAAC;EACD,MAAM;IAAEQ,gBAAgB;IAAEC,WAAW;IAAEC;EAAe,CAAC,GAAGT,MAAM,CAC/DJ,WAAW,CAAEG,gBAAiB,CAC/B,CAAC;EAED,OAAOF,YAAY,CAChBa,IAAI,IAAM;IACX,IAAK,CAAEP,UAAU,EAAG;MACnB;IACD;;IAEA;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACG,SAASQ,SAASA,CAAEC,KAAK,EAAG;MAC3B,MAAM;QAAEC,OAAO;QAAEC;MAAO,CAAC,GAAGF,KAAK;MAEjC,IACCC,OAAO,KAAKrB,KAAK,IACjBqB,OAAO,KAAKpB,SAAS,IACrBoB,OAAO,KAAKnB,MAAM,EACjB;QACD;MACD;MAEA,IAAKoB,MAAM,KAAKJ,IAAI,IAAInB,WAAW,CAAEuB,MAAO,CAAC,EAAG;QAC/C;MACD;MAEAF,KAAK,CAACG,cAAc,CAAC,CAAC;MAEtB,IAAKF,OAAO,KAAKrB,KAAK,IAAIc,SAAS,CAAC,CAAC,EAAG;QACvCG,cAAc,CAAC,CAAC;MACjB,CAAC,MAAM,IAAKI,OAAO,KAAKrB,KAAK,EAAG;QAC/Be,gBAAgB,CAAEL,QAAS,CAAC;MAC7B,CAAC,MAAM;QACNM,WAAW,CAAEN,QAAS,CAAC;MACxB;IACD;;IAEA;AACH;AACA;AACA;AACA;AACA;IACG,SAASc,WAAWA,CAAEJ,KAAK,EAAG;MAC7BA,KAAK,CAACG,cAAc,CAAC,CAAC;IACvB;IAEAL,IAAI,CAACO,gBAAgB,CAAE,SAAS,EAAEN,SAAU,CAAC;IAC7CD,IAAI,CAACO,gBAAgB,CAAE,WAAW,EAAED,WAAY,CAAC;IAEjD,OAAO,MAAM;MACZN,IAAI,CAACQ,mBAAmB,CAAE,SAAS,EAAEP,SAAU,CAAC;MAChDD,IAAI,CAACQ,mBAAmB,CAAE,WAAW,EAAEF,WAAY,CAAC;IACrD,CAAC;EACF,CAAC,EACD,CACCd,QAAQ,EACRC,UAAU,EACVC,oBAAoB,EACpBC,aAAa,EACbE,gBAAgB,EAChBC,WAAW,EACXF,SAAS,EACTG,cAAc,CAEhB,CAAC;AACF","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ import { InsertionPointOpenRef } from '../block-tools/insertion-point';
|
|
|
14
14
|
import { unlock } from '../../lock-unlock';
|
|
15
15
|
export function useInBetweenInserter() {
|
|
16
16
|
const openRef = useContext(InsertionPointOpenRef);
|
|
17
|
-
const isInBetweenInserterDisabled = useSelect(select => select(blockEditorStore).getSettings().isDistractionFree || select(blockEditorStore).
|
|
17
|
+
const isInBetweenInserterDisabled = useSelect(select => select(blockEditorStore).getSettings().isDistractionFree || unlock(select(blockEditorStore)).isZoomOut(), []);
|
|
18
18
|
const {
|
|
19
19
|
getBlockListSettings,
|
|
20
20
|
getBlockIndex,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRefEffect","useSelect","useDispatch","useContext","isRTL","store","blockEditorStore","InsertionPointOpenRef","unlock","useInBetweenInserter","openRef","isInBetweenInserterDisabled","select","getSettings","isDistractionFree","__unstableGetEditorMode","getBlockListSettings","getBlockIndex","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","getBlockEditingMode","getBlockName","getBlockAttributes","getParentSectionBlock","showInsertionPoint","hideInsertionPoint","node","onMouseMove","event","undefined","current","target","nodeType","TEXT_NODE","classList","contains","rootClientId","blockElement","getAttribute","closest","layout","isManualPlacement","blockListSettings","orientation","captureToolbars","__experimentalCaptureToolbars","offsetTop","clientY","offsetLeft","clientX","children","Array","from","element","find","blockEl","blockElRect","getBoundingClientRect","top","right","left","id","firstElementChild","clientId","slice","length","includes","hasFixedToolbar","elementRect","bottom","index","__unstableWithInserter","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\nimport { unlock } from '../../lock-unlock';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().isDistractionFree ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockIndex,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSettings,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t\tgetBlockEditingMode,\n\t\tgetBlockName,\n\t\tgetBlockAttributes,\n\t\tgetParentSectionBlock,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\t// openRef is the reference to the insertion point between blocks.\n\t\t\t\t// If the reference is not set or the insertion point is already open, return.\n\t\t\t\tif ( openRef === undefined || openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Ignore text nodes sometimes detected in FireFox.\n\t\t\t\tif ( event.target.nodeType === event.target.TEXT_NODE ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tgetTemplateLock( rootClientId ) ||\n\t\t\t\t\tgetBlockEditingMode( rootClientId ) === 'disabled' ||\n\t\t\t\t\tgetBlockName( rootClientId ) === 'core/block' ||\n\t\t\t\t\t( rootClientId &&\n\t\t\t\t\t\tgetBlockAttributes( rootClientId ).layout\n\t\t\t\t\t\t\t?.isManualPlacement )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blockListSettings = getBlockListSettings( rootClientId );\n\t\t\t\tconst orientation =\n\t\t\t\t\tblockListSettings?.orientation || 'vertical';\n\t\t\t\tconst captureToolbars =\n\t\t\t\t\t!! blockListSettings?.__experimentalCaptureToolbars;\n\t\t\t\tconst offsetTop = event.clientY;\n\t\t\t\tconst offsetLeft = event.clientX;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\tconst blockElRect = blockEl.getBoundingClientRect();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockElRect.top > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\t( isRTL()\n\t\t\t\t\t\t\t\t? blockElRect.right < offsetLeft\n\t\t\t\t\t\t\t\t: blockElRect.left > offsetLeft ) )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId ) ||\n\t\t\t\t\t!! getParentSectionBlock( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter if the following conditions are met,\n\t\t\t\t// as it conflicts with the block toolbar:\n\t\t\t\t// 1. when hovering above or inside selected block(s)\n\t\t\t\t// 2. when the orientation is vertical\n\t\t\t\t// 3. when the __experimentalCaptureToolbars is not enabled\n\t\t\t\t// 4. when the Top Toolbar is not disabled\n\t\t\t\tif (\n\t\t\t\t\tgetSelectedBlockClientIds().includes( clientId ) &&\n\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t! captureToolbars &&\n\t\t\t\t\t! getSettings().hasFixedToolbar\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tshowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockIndex,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,qBAAqB,QAAQ,gCAAgC;AACtE,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,MAAMC,OAAO,GAAGP,UAAU,CAAEI,qBAAsB,CAAC;EACnD,MAAMI,2BAA2B,GAAGV,SAAS,CAC1CW,MAAM,IACPA,MAAM,CAAEN,gBAAiB,CAAC,CAACO,WAAW,CAAC,CAAC,CAACC,iBAAiB,IAC1DF,MAAM,CAAEN,gBAAiB,CAAC,CAACS,uBAAuB,CAAC,CAAC,KAAK,UAAU,EACpE,EACD,CAAC;EACD,MAAM;IACLC,oBAAoB;IACpBC,aAAa;IACbC,gBAAgB;IAChBC,yBAAyB;IACzBN,WAAW;IACXO,eAAe;IACfC,8BAA8B;IAC9BC,mBAAmB;IACnBC,YAAY;IACZC,kBAAkB;IAClBC;EACD,CAAC,GAAGjB,MAAM,CAAEP,SAAS,CAAEK,gBAAiB,CAAE,CAAC;EAC3C,MAAM;IAAEoB,kBAAkB;IAAEC;EAAmB,CAAC,GAC/CzB,WAAW,CAAEI,gBAAiB,CAAC;EAEhC,OAAON,Y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K,UAAU,IAC1B,CAAEC,eAAe,IACjB,CAAEjC,WAAW,CAAC,CAAC,CAACwD,eAAe,EAC9B;QACD;MACD;MACA,MAAMC,WAAW,GAAGf,OAAO,CAACI,qBAAqB,CAAC,CAAC;MAEnD,IACGd,WAAW,KAAK,YAAY,KAC3Bf,KAAK,CAACmB,OAAO,GAAGqB,WAAW,CAACC,MAAM,IACnCzC,KAAK,CAACmB,OAAO,GAAGqB,WAAW,CAACV,GAAG,CAAE,IACjCf,WAAW,KAAK,UAAU,KACzBf,KAAK,CAACqB,OAAO,GAAGmB,WAAW,CAACT,KAAK,IAClC/B,KAAK,CAACqB,OAAO,GAAGmB,WAAW,CAACR,IAAI,CAAI,EACrC;QACDnC,kBAAkB,CAAC,CAAC;QACpB;MACD;MAEA,MAAM6C,KAAK,GAAGvD,aAAa,CAAEgD,QAAS,CAAC;;MAEvC;MACA;MACA,IAAKO,KAAK,KAAK,CAAC,EAAG;QAClB7C,kBAAkB,CAAC,CAAC;QACpB;MACD;MAEAD,kBAAkB,CAAEY,YAAY,EAAEkC,KAAK,EAAE;QACxCC,sBAAsB,EAAE;MACzB,CAAE,CAAC;IACJ;IAEA7C,IAAI,CAAC8C,gBAAgB,CAAE,WAAW,EAAE7C,WAAY,CAAC;IAEjD,OAAO,MAAM;MACZD,IAAI,CAAC+C,mBAAmB,CAAE,WAAW,EAAE9C,WAAY,CAAC;IACrD,CAAC;EACF,CAAC,EACD,CACCnB,OAAO,EACPM,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBQ,kBAAkB,EAClBC,kBAAkB,EAClBR,yBAAyB,EACzBR,2BAA2B,CAE7B,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRefEffect","useSelect","useDispatch","useContext","isRTL","store","blockEditorStore","InsertionPointOpenRef","unlock","useInBetweenInserter","openRef","isInBetweenInserterDisabled","select","getSettings","isDistractionFree","isZoomOut","getBlockListSettings","getBlockIndex","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","getBlockEditingMode","getBlockName","getBlockAttributes","getParentSectionBlock","showInsertionPoint","hideInsertionPoint","node","onMouseMove","event","undefined","current","target","nodeType","TEXT_NODE","classList","contains","rootClientId","blockElement","getAttribute","closest","layout","isManualPlacement","blockListSettings","orientation","captureToolbars","__experimentalCaptureToolbars","offsetTop","clientY","offsetLeft","clientX","children","Array","from","element","find","blockEl","blockElRect","getBoundingClientRect","top","right","left","id","firstElementChild","clientId","slice","length","includes","hasFixedToolbar","elementRect","bottom","index","__unstableWithInserter","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\nimport { unlock } from '../../lock-unlock';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().isDistractionFree ||\n\t\t\tunlock( select( blockEditorStore ) ).isZoomOut(),\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockIndex,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSettings,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t\tgetBlockEditingMode,\n\t\tgetBlockName,\n\t\tgetBlockAttributes,\n\t\tgetParentSectionBlock,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\t// openRef is the reference to the insertion point between blocks.\n\t\t\t\t// If the reference is not set or the insertion point is already open, return.\n\t\t\t\tif ( openRef === undefined || openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Ignore text nodes sometimes detected in FireFox.\n\t\t\t\tif ( event.target.nodeType === event.target.TEXT_NODE ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tgetTemplateLock( rootClientId ) ||\n\t\t\t\t\tgetBlockEditingMode( rootClientId ) === 'disabled' ||\n\t\t\t\t\tgetBlockName( rootClientId ) === 'core/block' ||\n\t\t\t\t\t( rootClientId &&\n\t\t\t\t\t\tgetBlockAttributes( rootClientId ).layout\n\t\t\t\t\t\t\t?.isManualPlacement )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blockListSettings = getBlockListSettings( rootClientId );\n\t\t\t\tconst orientation =\n\t\t\t\t\tblockListSettings?.orientation || 'vertical';\n\t\t\t\tconst captureToolbars =\n\t\t\t\t\t!! blockListSettings?.__experimentalCaptureToolbars;\n\t\t\t\tconst offsetTop = event.clientY;\n\t\t\t\tconst offsetLeft = event.clientX;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\tconst blockElRect = blockEl.getBoundingClientRect();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockElRect.top > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\t( isRTL()\n\t\t\t\t\t\t\t\t? blockElRect.right < offsetLeft\n\t\t\t\t\t\t\t\t: blockElRect.left > offsetLeft ) )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId ) ||\n\t\t\t\t\t!! getParentSectionBlock( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter if the following conditions are met,\n\t\t\t\t// as it conflicts with the block toolbar:\n\t\t\t\t// 1. when hovering above or inside selected block(s)\n\t\t\t\t// 2. when the orientation is vertical\n\t\t\t\t// 3. when the __experimentalCaptureToolbars is not enabled\n\t\t\t\t// 4. when the Top Toolbar is not disabled\n\t\t\t\tif (\n\t\t\t\t\tgetSelectedBlockClientIds().includes( clientId ) &&\n\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t! captureToolbars &&\n\t\t\t\t\t! getSettings().hasFixedToolbar\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tshowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockIndex,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n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ACV,GAAG,CAAE,IACjCf,WAAW,KAAK,UAAU,KACzBf,KAAK,CAACqB,OAAO,GAAGmB,WAAW,CAACT,KAAK,IAClC/B,KAAK,CAACqB,OAAO,GAAGmB,WAAW,CAACR,IAAI,CAAI,EACrC;QACDnC,kBAAkB,CAAC,CAAC;QACpB;MACD;MAEA,MAAM6C,KAAK,GAAGvD,aAAa,CAAEgD,QAAS,CAAC;;MAEvC;MACA;MACA,IAAKO,KAAK,KAAK,CAAC,EAAG;QAClB7C,kBAAkB,CAAC,CAAC;QACpB;MACD;MAEAD,kBAAkB,CAAEY,YAAY,EAAEkC,KAAK,EAAE;QACxCC,sBAAsB,EAAE;MACzB,CAAE,CAAC;IACJ;IAEA7C,IAAI,CAAC8C,gBAAgB,CAAE,WAAW,EAAE7C,WAAY,CAAC;IAEjD,OAAO,MAAM;MACZD,IAAI,CAAC+C,mBAAmB,CAAE,WAAW,EAAE9C,WAAY,CAAC;IACrD,CAAC;EACF,CAAC,EACD,CACCnB,OAAO,EACPM,oBAAoB,EACpBC,aAAa,EACbC,gBAAgB,EAChBQ,kBAAkB,EAClBC,kBAAkB,EAClBR,yBAAyB,EACzBR,2BAA2B,CAE7B,CAAC;AACF","ignoreList":[]}
|
|
@@ -52,7 +52,7 @@ export default function Pagination({
|
|
|
52
52
|
}), /*#__PURE__*/_jsx(Text, {
|
|
53
53
|
variant: "muted",
|
|
54
54
|
children: sprintf(
|
|
55
|
-
// translators:
|
|
55
|
+
// translators: 1: Current page number. 2: Total number of pages.
|
|
56
56
|
_x('%1$s of %2$s', 'paging'), currentPage, numPages)
|
|
57
57
|
}), /*#__PURE__*/_jsxs(HStack, {
|
|
58
58
|
expanded: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","__experimentalText","Text","Button","__","_x","_n","sprintf","jsx","_jsx","jsxs","_jsxs","Pagination","currentPage","numPages","changePage","totalItems","className","children","variant","expanded","spacing","justify","onClick","disabled","size","accessibleWhenDisabled"],"sources":["@wordpress/block-editor/src/components/block-patterns-paging/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\tButton,\n} from '@wordpress/components';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\n\nexport default function Pagination( {\n\tcurrentPage,\n\tnumPages,\n\tchangePage,\n\ttotalItems,\n} ) {\n\treturn (\n\t\t<VStack className=\"block-editor-patterns__grid-pagination-wrapper\">\n\t\t\t<Text variant=\"muted\">\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s: Total number of patterns.\n\t\t\t\t\t_n( '%s item', '%s items', totalItems ),\n\t\t\t\t\ttotalItems\n\t\t\t\t) }\n\t\t\t</Text>\n\n\t\t\t{ numPages > 1 && (\n\t\t\t\t<HStack\n\t\t\t\t\texpanded={ false }\n\t\t\t\t\tspacing={ 3 }\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-previous\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => changePage( 1 ) }\n\t\t\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\t\t\taria-label={ __( 'First page' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>«</span>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => changePage( currentPage - 1 ) }\n\t\t\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\t\t\taria-label={ __( 'Previous page' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>‹</span>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t// translators:
|
|
1
|
+
{"version":3,"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","__experimentalText","Text","Button","__","_x","_n","sprintf","jsx","_jsx","jsxs","_jsxs","Pagination","currentPage","numPages","changePage","totalItems","className","children","variant","expanded","spacing","justify","onClick","disabled","size","accessibleWhenDisabled"],"sources":["@wordpress/block-editor/src/components/block-patterns-paging/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\tButton,\n} from '@wordpress/components';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\n\nexport default function Pagination( {\n\tcurrentPage,\n\tnumPages,\n\tchangePage,\n\ttotalItems,\n} ) {\n\treturn (\n\t\t<VStack className=\"block-editor-patterns__grid-pagination-wrapper\">\n\t\t\t<Text variant=\"muted\">\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %s: Total number of patterns.\n\t\t\t\t\t_n( '%s item', '%s items', totalItems ),\n\t\t\t\t\ttotalItems\n\t\t\t\t) }\n\t\t\t</Text>\n\n\t\t\t{ numPages > 1 && (\n\t\t\t\t<HStack\n\t\t\t\t\texpanded={ false }\n\t\t\t\t\tspacing={ 3 }\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-previous\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => changePage( 1 ) }\n\t\t\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\t\t\taria-label={ __( 'First page' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>«</span>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => changePage( currentPage - 1 ) }\n\t\t\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\t\t\taria-label={ __( 'Previous page' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>‹</span>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t// translators: 1: Current page number. 2: Total number of pages.\n\t\t\t\t\t\t\t_x( '%1$s of %2$s', 'paging' ),\n\t\t\t\t\t\t\tcurrentPage,\n\t\t\t\t\t\t\tnumPages\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-next\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => changePage( currentPage + 1 ) }\n\t\t\t\t\t\t\tdisabled={ currentPage === numPages }\n\t\t\t\t\t\t\taria-label={ __( 'Next page' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>›</span>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => changePage( numPages ) }\n\t\t\t\t\t\t\tdisabled={ currentPage === numPages }\n\t\t\t\t\t\t\taria-label={ __( 'Last page' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"block-editor-patterns__grid-pagination-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span>»</span>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,MAAM,QACA,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtD,eAAe,SAASC,UAAUA,CAAE;EACnCC,WAAW;EACXC,QAAQ;EACRC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,oBACCL,KAAA,CAACb,MAAM;IAACmB,SAAS,EAAC,gDAAgD;IAAAC,QAAA,gBACjET,IAAA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E,cAAc,EAAE,QAAS,CAAC,EAC9BQ,WAAW,EACXC,QACD;MAAC,CACI,CAAC,eACPH,KAAA,CAACX,MAAM;QACNoB,QAAQ,EAAG,KAAO;QAClBC,OAAO,EAAG,CAAG;QACbJ,SAAS,EAAC,6CAA6C;QAAAC,QAAA,gBAEvDT,IAAA,CAACN,MAAM;UACNgB,OAAO,EAAC,UAAU;UAClBI,OAAO,EAAGA,CAAA,KAAMR,UAAU,CAAEF,WAAW,GAAG,CAAE,CAAG;UAC/CW,QAAQ,EAAGX,WAAW,KAAKC,QAAU;UACrC,cAAaV,EAAE,CAAE,WAAY,CAAG;UAChCqB,IAAI,EAAC,SAAS;UACdC,sBAAsB;UACtBT,SAAS,EAAC,+CAA+C;UAAAC,QAAA,eAEzDT,IAAA;YAAAS,QAAA,EAAM;UAAC,CAAM;QAAC,CACP,CAAC,eACTT,IAAA,CAACN,MAAM;UACNgB,OAAO,EAAC,UAAU;UAClBI,OAAO,EAAGA,CAAA,KAAMR,UAAU,CAAED,QAAS,CAAG;UACxCU,QAAQ,EAAGX,WAAW,KAAKC,QAAU;UACrC,cAAaV,EAAE,CAAE,WAAY,CAAG;UAChCqB,IAAI,EAAC,SAAS;UACdC,sBAAsB;UACtBT,SAAS,EAAC,+CAA+C;UAAAC,QAAA,eAEzDT,IAAA;YAAAS,QAAA,EAAM;UAAC,CAAM;QAAC,CACP,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CACR;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -8,7 +8,6 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { useMergeRefs } from '@wordpress/compose';
|
|
10
10
|
import { Popover } from '@wordpress/components';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
12
11
|
import { forwardRef, useMemo, useReducer, useLayoutEffect } from '@wordpress/element';
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -17,8 +16,6 @@ import { forwardRef, useMemo, useReducer, useLayoutEffect } from '@wordpress/ele
|
|
|
17
16
|
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
18
17
|
import usePopoverScroll from './use-popover-scroll';
|
|
19
18
|
import { rectUnion, getVisibleElementBounds } from '../../utils/dom';
|
|
20
|
-
import { store as blockEditorStore } from '../../store';
|
|
21
|
-
import { unlock } from '../../lock-unlock';
|
|
22
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
20
|
const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
|
|
24
21
|
function BlockPopover({
|
|
@@ -56,61 +53,21 @@ function BlockPopover({
|
|
|
56
53
|
observer.disconnect();
|
|
57
54
|
};
|
|
58
55
|
}, [selectedElement]);
|
|
59
|
-
const {
|
|
60
|
-
isZoomOut,
|
|
61
|
-
parentSectionBlock,
|
|
62
|
-
isSectionSelected
|
|
63
|
-
} = useSelect(select => {
|
|
64
|
-
var _getParentSectionBloc;
|
|
65
|
-
const {
|
|
66
|
-
isZoomOut: isZoomOutSelector,
|
|
67
|
-
getSectionRootClientId,
|
|
68
|
-
getParentSectionBlock,
|
|
69
|
-
getBlockOrder
|
|
70
|
-
} = unlock(select(blockEditorStore));
|
|
71
|
-
return {
|
|
72
|
-
isZoomOut: isZoomOutSelector(),
|
|
73
|
-
parentSectionBlock: (_getParentSectionBloc = getParentSectionBlock(clientId)) !== null && _getParentSectionBloc !== void 0 ? _getParentSectionBloc : clientId,
|
|
74
|
-
isSectionSelected: getBlockOrder(getSectionRootClientId()).includes(clientId)
|
|
75
|
-
};
|
|
76
|
-
}, [clientId]);
|
|
77
|
-
|
|
78
|
-
// This element is used to position the zoom out view vertical toolbar
|
|
79
|
-
// correctly, relative to the selected section.
|
|
80
|
-
const parentSectionElement = useBlockElement(parentSectionBlock);
|
|
81
56
|
const popoverAnchor = useMemo(() => {
|
|
82
57
|
if (
|
|
83
58
|
// popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
84
59
|
// than 0. This check is only there to satisfy the correctness of the
|
|
85
60
|
// exhaustive-deps rule for the `useMemo` hook.
|
|
86
|
-
popoverDimensionsRecomputeCounter < 0 ||
|
|
61
|
+
popoverDimensionsRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement) {
|
|
87
62
|
return undefined;
|
|
88
63
|
}
|
|
89
64
|
return {
|
|
90
65
|
getBoundingClientRect() {
|
|
91
|
-
// The zoom out view has a vertical block toolbar that should always
|
|
92
|
-
// be on the edge of the canvas, aligned to the top of the currently
|
|
93
|
-
// selected section. This condition changes the anchor of the toolbar
|
|
94
|
-
// to the section instead of the block to handle blocks that are
|
|
95
|
-
// not full width and nested blocks to keep section height.
|
|
96
|
-
if (isZoomOut && isSectionSelected) {
|
|
97
|
-
// Compute the height based on the parent section of the
|
|
98
|
-
// selected block, because the selected block may be
|
|
99
|
-
// shorter than the section.
|
|
100
|
-
const canvasElementRect = getVisibleElementBounds(__unstableContentRef.current);
|
|
101
|
-
const parentSectionElementRect = getVisibleElementBounds(parentSectionElement);
|
|
102
|
-
const anchorHeight = parentSectionElementRect.bottom - parentSectionElementRect.top;
|
|
103
|
-
|
|
104
|
-
// Always use the width of the section root element to make sure
|
|
105
|
-
// the toolbar is always on the edge of the canvas.
|
|
106
|
-
const anchorWidth = canvasElementRect.width;
|
|
107
|
-
return new window.DOMRectReadOnly(canvasElementRect.left, parentSectionElementRect.top, anchorWidth, anchorHeight);
|
|
108
|
-
}
|
|
109
66
|
return lastSelectedElement ? rectUnion(getVisibleElementBounds(selectedElement), getVisibleElementBounds(lastSelectedElement)) : getVisibleElementBounds(selectedElement);
|
|
110
67
|
},
|
|
111
68
|
contextElement: selectedElement
|
|
112
69
|
};
|
|
113
|
-
}, [popoverDimensionsRecomputeCounter,
|
|
70
|
+
}, [popoverDimensionsRecomputeCounter, selectedElement, bottomClientId, lastSelectedElement]);
|
|
114
71
|
if (!selectedElement || bottomClientId && !lastSelectedElement) {
|
|
115
72
|
return null;
|
|
116
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useMergeRefs","Popover","useSelect","forwardRef","useMemo","useReducer","useLayoutEffect","useBlockElement","usePopoverScroll","rectUnion","getVisibleElementBounds","store","blockEditorStore","unlock","jsx","_jsx","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","lastSelectedElement","mergedRefs","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","s","observer","window","MutationObserver","observe","attributes","disconnect","isZoomOut","parentSectionBlock","isSectionSelected","select","_getParentSectionBloc","isZoomOutSelector","getSectionRootClientId","getParentSectionBlock","getBlockOrder","includes","parentSectionElement","popoverAnchor","undefined","getBoundingClientRect","canvasElementRect","current","parentSectionElementRect","anchorHeight","bottom","top","anchorWidth","width","DOMRectReadOnly","left","contextElement","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","variant","PrivateBlockPopover","PublicBlockPopover"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\nimport { rectUnion, getVisibleElementBounds } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst { isZoomOut, parentSectionBlock, isSectionSelected } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisZoomOut: isZoomOutSelector,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tgetParentSectionBlock,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\treturn {\n\t\t\t\tisZoomOut: isZoomOutSelector(),\n\t\t\t\tparentSectionBlock:\n\t\t\t\t\tgetParentSectionBlock( clientId ) ?? clientId,\n\t\t\t\tisSectionSelected: getBlockOrder(\n\t\t\t\t\tgetSectionRootClientId()\n\t\t\t\t).includes( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This element is used to position the zoom out view vertical toolbar\n\t// correctly, relative to the selected section.\n\tconst parentSectionElement = useBlockElement( parentSectionBlock );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t( isZoomOut && ! parentSectionElement ) ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\t// The zoom out view has a vertical block toolbar that should always\n\t\t\t\t// be on the edge of the canvas, aligned to the top of the currently\n\t\t\t\t// selected section. This condition changes the anchor of the toolbar\n\t\t\t\t// to the section instead of the block to handle blocks that are\n\t\t\t\t// not full width and nested blocks to keep section height.\n\t\t\t\tif ( isZoomOut && isSectionSelected ) {\n\t\t\t\t\t// Compute the height based on the parent section of the\n\t\t\t\t\t// selected block, because the selected block may be\n\t\t\t\t\t// shorter than the section.\n\t\t\t\t\tconst canvasElementRect = getVisibleElementBounds(\n\t\t\t\t\t\t__unstableContentRef.current\n\t\t\t\t\t);\n\t\t\t\t\tconst parentSectionElementRect =\n\t\t\t\t\t\tgetVisibleElementBounds( parentSectionElement );\n\t\t\t\t\tconst anchorHeight =\n\t\t\t\t\t\tparentSectionElementRect.bottom -\n\t\t\t\t\t\tparentSectionElementRect.top;\n\n\t\t\t\t\t// Always use the width of the section root element to make sure\n\t\t\t\t\t// the toolbar is always on the edge of the canvas.\n\t\t\t\t\tconst anchorWidth = canvasElementRect.width;\n\t\t\t\t\treturn new window.DOMRectReadOnly(\n\t\t\t\t\t\tcanvasElementRect.left,\n\t\t\t\t\t\tparentSectionElementRect.top,\n\t\t\t\t\t\tanchorWidth,\n\t\t\t\t\t\tanchorHeight\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn lastSelectedElement\n\t\t\t\t\t? rectUnion(\n\t\t\t\t\t\t\tgetVisibleElementBounds( selectedElement ),\n\t\t\t\t\t\t\tgetVisibleElementBounds( lastSelectedElement )\n\t\t\t\t\t )\n\t\t\t\t\t: getVisibleElementBounds( selectedElement );\n\t\t\t},\n\t\t\tcontextElement: selectedElement,\n\t\t};\n\t}, [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tisZoomOut,\n\t\tparentSectionElement,\n\t\tselectedElement,\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tisSectionSelected,\n\t\t__unstableContentRef,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx( 'block-editor-block-popover', props.className ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ children }\n\t\t</Popover>\n\t);\n}\n\nexport const PrivateBlockPopover = forwardRef( BlockPopover );\n\nconst PublicBlockPopover = (\n\t{ clientId, bottomClientId, children, ...props },\n\tref\n) => (\n\t<PrivateBlockPopover\n\t\t{ ...props }\n\t\tbottomClientId={ bottomClientId }\n\t\tclientId={ clientId }\n\t\t__unstableContentRef={ undefined }\n\t\t__unstablePopoverSlot={ undefined }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</PrivateBlockPopover>\n);\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-popover/README.md\n */\nexport default forwardRef( PublicBlockPopover );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,UAAU,EACVC,OAAO,EACPC,UAAU,EACVC,eAAe,QACT,oBAAoB;;AAE3B;AACA;AACA;AACA,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,SAASC,SAAS,EAAEC,uBAAuB,QAAQ,iBAAiB;AACpE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAE7D,SAASC,YAAYA,CACpB;EACCC,QAAQ;EACRC,cAAc;EACdC,QAAQ;EACRC,qBAAqB;EACrBC,oBAAoB;EACpBC,KAAK,GAAG,IAAI;EACZ,GAAGC;AACJ,CAAC,EACDC,GAAG,EACF;EACD,MAAMC,eAAe,GAAGrB,eAAe,CAAEa,QAAS,CAAC;EACnD,MAAMS,mBAAmB,GAAGtB,eAAe,CAAEc,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAID,QAAS,CAAC;EACzE,MAAMU,UAAU,GAAG9B,YAAY,CAAE,CAChC2B,GAAG,EACHnB,gBAAgB,CAAEgB,oBAAqB,CAAC,CACvC,CAAC;EAEH,MAAM,CACLO,iCAAiC,EACjCC,+BAA+B,CAC/B,GAAG3B,UAAU;EACb;EACE4B,CAAC,IAAM,CAAEA,CAAC,GAAG,CAAC,IAAKjB,6BAA6B,EAClD,CACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA;EACA;EAC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C,KAAK,EAAGA,KAAO;IAAA,GACVC,KAAK;IACV+C,SAAS,EAAG1E,IAAI,CAAE,4BAA4B,EAAE2B,KAAK,CAAC+C,SAAU,CAAG;IACnEC,OAAO,EAAC,UAAU;IAAApD,QAAA,EAEhBA;EAAQ,CACF,CAAC;AAEZ;AAEA,OAAO,MAAMqD,mBAAmB,GAAGxE,UAAU,CAAEgB,YAAa,CAAC;AAE7D,MAAMyD,kBAAkB,GAAGA,CAC1B;EAAExD,QAAQ;EAAEC,cAAc;EAAEC,QAAQ;EAAE,GAAGI;AAAM,CAAC,EAChDC,GAAG,kBAEHZ,IAAA,CAAC4D,mBAAmB;EAAA,GACdjD,KAAK;EACVL,cAAc,EAAGA,cAAgB;EACjCD,QAAQ,EAAGA,QAAU;EACrBI,oBAAoB,EAAG4B,SAAW;EAClC7B,qBAAqB,EAAG6B,SAAW;EACnCzB,GAAG,EAAGA,GAAK;EAAAL,QAAA,EAETA;AAAQ,CACU,CACrB;;AAED;AACA;AACA;AACA,eAAenB,UAAU,CAAEyE,kBAAmB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useMergeRefs","Popover","forwardRef","useMemo","useReducer","useLayoutEffect","useBlockElement","usePopoverScroll","rectUnion","getVisibleElementBounds","jsx","_jsx","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","lastSelectedElement","mergedRefs","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","contextElement","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","variant","PrivateBlockPopover","PublicBlockPopover"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\nimport { rectUnion, getVisibleElementBounds } from '../../utils/dom';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn lastSelectedElement\n\t\t\t\t\t? rectUnion(\n\t\t\t\t\t\t\tgetVisibleElementBounds( selectedElement ),\n\t\t\t\t\t\t\tgetVisibleElementBounds( lastSelectedElement )\n\t\t\t\t\t )\n\t\t\t\t\t: getVisibleElementBounds( selectedElement );\n\t\t\t},\n\t\t\tcontextElement: selectedElement,\n\t\t};\n\t}, [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tselectedElement,\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx( 'block-editor-block-popover', props.className ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ children }\n\t\t</Popover>\n\t);\n}\n\nexport const PrivateBlockPopover = forwardRef( BlockPopover );\n\nconst PublicBlockPopover = (\n\t{ clientId, bottomClientId, children, ...props },\n\tref\n) => (\n\t<PrivateBlockPopover\n\t\t{ ...props }\n\t\tbottomClientId={ bottomClientId }\n\t\tclientId={ clientId }\n\t\t__unstableContentRef={ undefined }\n\t\t__unstablePopoverSlot={ undefined }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</PrivateBlockPopover>\n);\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-popover/README.md\n */\nexport default forwardRef( PublicBlockPopover );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SACCC,UAAU,EACVC,OAAO,EACPC,UAAU,EACVC,eAAe,QACT,oBAAoB;;AAE3B;AACA;AACA;AACA,SAASC,eAAe,QAAQ,8CAA8C;AAC9E,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,SAASC,SAAS,EAAEC,uBAAuB,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErE,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAE7D,SAASC,YAAYA,CACpB;EACCC,QAAQ;EACRC,cAAc;EACdC,QAAQ;EACRC,qBAAqB;EACrBC,oBAAoB;EACpBC,KAAK,GAAG,IAAI;EACZ,GAAGC;AACJ,CAAC,EACDC,GAAG,EACF;EACD,MAAMC,eAAe,GAAGlB,eAAe,CAAEU,QAAS,CAAC;EACnD,MAAMS,mBAAmB,GAAGnB,eAAe,CAAEW,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAID,QAAS,CAAC;EACzE,MAAMU,UAAU,GAAG1B,YAAY,CAAE,CAChCuB,GAAG,EACHhB,gBAAgB,CAAEa,oBAAqB,CAAC,CACvC,CAAC;EAEH,MAAM,CACLO,iCAAiC,EACjCC,+BAA+B,CAC/B,GAAGxB,UAAU;EACb;EACEyB,CAAC,IAAM,CAAEA,CAAC,GAAG,CAAC,IAAKjB,6BAA6B,E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,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACd1B,KAAK,EAAGA,KAAO;IAAA,GACVC,KAAK;IACV0B,SAAS,EAAGjD,IAAI,CAAE,4BAA4B,EAAEuB,KAAK,CAAC0B,SAAU,CAAG;IACnEC,OAAO,EAAC,UAAU;IAAA/B,QAAA,EAEhBA;EAAQ,CACF,CAAC;AAEZ;AAEA,OAAO,MAAMgC,mBAAmB,GAAGhD,UAAU,CAAEa,YAAa,CAAC;AAE7D,MAAMoC,kBAAkB,GAAGA,CAC1B;EAAEnC,QAAQ;EAAEC,cAAc;EAAEC,QAAQ;EAAE,GAAGI;AAAM,CAAC,EAChDC,GAAG,kBAEHZ,IAAA,CAACuC,mBAAmB;EAAA,GACd5B,KAAK;EACVL,cAAc,EAAGA,cAAgB;EACjCD,QAAQ,EAAGA,QAAU;EACrBI,oBAAoB,EAAGiB,SAAW;EAClClB,qBAAqB,EAAGkB,SAAW;EACnCd,GAAG,EAAGA,GAAK;EAAAL,QAAA,EAETA;AAAQ,CACU,CACrB;;AAED;AACA;AACA;AACA,eAAehB,UAAU,CAAEiD,kBAAmB,CAAC","ignoreList":[]}
|
|
@@ -53,7 +53,7 @@ export function BlockPreview({
|
|
|
53
53
|
...originalSettings,
|
|
54
54
|
focusMode: false,
|
|
55
55
|
// Disable "Spotlight mode".
|
|
56
|
-
|
|
56
|
+
isPreviewMode: true
|
|
57
57
|
}), [originalSettings]);
|
|
58
58
|
const renderedBlocks = useMemo(() => Array.isArray(blocks) ? blocks : [blocks], [blocks]);
|
|
59
59
|
if (!blocks || blocks.length === 0) {
|
|
@@ -110,7 +110,7 @@ export function useBlockPreview({
|
|
|
110
110
|
// Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
|
|
111
111
|
focusMode: false,
|
|
112
112
|
// Disable "Spotlight mode".
|
|
113
|
-
|
|
113
|
+
isPreviewMode: true
|
|
114
114
|
}), [originalSettings]);
|
|
115
115
|
const disabledRef = useDisabled();
|
|
116
116
|
const ref = useMergeRefs([props.ref, disabledRef]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useDisabled","useMergeRefs","useSelect","memo","useMemo","deprecated","ExperimentalBlockEditorProvider","AutoHeightBlockPreview","EditorStyles","store","blockEditorStore","BlockListItems","jsx","_jsx","jsxs","_jsxs","EMPTY_ADDITIONAL_STYLES","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","since","version","alternative","css","originalSettings","select","getSettings","settings","focusMode","
|
|
1
|
+
{"version":3,"names":["clsx","useDisabled","useMergeRefs","useSelect","memo","useMemo","deprecated","ExperimentalBlockEditorProvider","AutoHeightBlockPreview","EditorStyles","store","blockEditorStore","BlockListItems","jsx","_jsx","jsxs","_jsxs","EMPTY_ADDITIONAL_STYLES","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","since","version","alternative","css","originalSettings","select","getSettings","settings","focusMode","isPreviewMode","renderedBlocks","Array","isArray","length","value","children","useBlockPreview","props","layout","styles","undefined","disabledRef","ref","renderAppender","className"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nconst EMPTY_ADDITIONAL_STYLES = [];\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = EMPTY_ADDITIONAL_STYLES,\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {Component} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MA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EL,gBAAgB,CACnB,CAAC;EACD,MAAMiB,WAAW,GAAG7C,WAAW,CAAC,CAAC;EACjC,MAAM8C,GAAG,GAAG7C,YAAY,CAAE,CAAEwC,KAAK,CAACK,GAAG,EAAED,WAAW,CAAG,CAAC;EACtD,MAAMX,cAAc,GAAG9B,OAAO,CAC7B,MAAQ+B,KAAK,CAACC,OAAO,CAAElB,MAAO,CAAC,GAAGA,MAAM,GAAG,CAAEA,MAAM,CAAI,EACvD,CAAEA,MAAM,CACT,CAAC;EAED,MAAMqB,QAAQ,gBACbxB,KAAA,CAACT,+BAA+B;IAC/BgC,KAAK,EAAGJ,cAAgB;IACxBH,QAAQ,EAAGA,QAAU;IAAAQ,QAAA,gBAErB1B,IAAA,CAACL,YAAY,IAAE,CAAC,eAChBK,IAAA,CAACF,cAAc;MAACoC,cAAc,EAAG,KAAO;MAACL,MAAM,EAAGA;IAAQ,CAAE,CAAC;EAAA,CAC7B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRK,GAAG;IACHE,SAAS,EAAEjD,IAAI,CACd0C,KAAK,CAACO,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDT,QAAQ,EAAErB,MAAM,EAAEmB,MAAM,GAAGE,QAAQ,GAAG;EACvC,CAAC;AACF","ignoreList":[]}
|
|
@@ -15,6 +15,7 @@ import { pipe, useCopyToClipboard } from '@wordpress/compose';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import BlockActions from '../block-actions';
|
|
18
|
+
import __unstableCommentIconFill from '../../components/collab/block-comment-icon-slot';
|
|
18
19
|
import BlockHTMLConvertButton from './block-html-convert-button';
|
|
19
20
|
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
|
|
20
21
|
import BlockSettingsMenuControls from '../block-settings-menu-controls';
|
|
@@ -212,6 +213,10 @@ export function BlockSettingsDropdown({
|
|
|
212
213
|
shortcut: shortcuts.insertAfter,
|
|
213
214
|
children: __('Add after')
|
|
214
215
|
})]
|
|
216
|
+
}), /*#__PURE__*/_jsx(__unstableCommentIconFill.Slot, {
|
|
217
|
+
fillProps: {
|
|
218
|
+
onClose
|
|
219
|
+
}
|
|
215
220
|
})]
|
|
216
221
|
}), canCopyStyles && !isContentOnly && /*#__PURE__*/_jsxs(MenuGroup, {
|
|
217
222
|
children: [/*#__PURE__*/_jsx(CopyMenuItem, {
|