@wordpress/block-editor 14.1.0 → 14.2.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 +1 -10
- package/build/components/block-alignment-matrix-control/index.js +2 -2
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +8 -2
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-canvas/index.js +8 -1
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-compare/block-view.js +4 -1
- package/build/components/block-compare/block-view.js.map +1 -1
- package/build/components/block-draggable/index.js +4 -4
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.js +25 -25
- package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build/components/block-edit/multiple-usage-warning.js +8 -2
- package/build/components/block-edit/multiple-usage-warning.js.map +1 -1
- package/build/components/block-inspector/index.js +27 -9
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +6 -3
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-list/block.js +5 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +5 -1
- 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 +1 -0
- 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-zoom-out-mode-exit.js +46 -0
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
- package/build/components/block-lock/toolbar.js +3 -3
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +4 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +4 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +4 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +1 -4
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +22 -7
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-list/index.js +11 -14
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +12 -3
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-popover/index.js +2 -15
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +4 -1
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +4 -0
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +22 -17
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +12 -11
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +6 -2
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +8 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-popover.js +10 -6
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +2 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +4 -9
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +3 -4
- package/build/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +14 -5
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.js +4 -1
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +4 -1
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/button-block-appender/index.js +14 -3
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +4 -1
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/content-lock/index.js +13 -0
- package/build/components/content-lock/index.js.map +1 -0
- package/build/components/content-lock/modify-content-lock-menu-item.js +64 -0
- package/build/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +8 -12
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +8 -5
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +1 -1
- package/build/components/global-styles/color-panel.native.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +34 -37
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +4 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +13 -7
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +17 -6
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/utils.js +4 -6
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +2 -2
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/iframe/index.js +5 -5
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -3
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +4 -1
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/library.js +2 -4
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +3 -3
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +1 -4
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +8 -2
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +4 -1
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/menu.js +7 -24
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -4
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inserter-listbox/index.js +3 -7
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/inserter-listbox/item.js +4 -1
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +4 -1
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/inspector-popover-header/index.js +8 -2
- package/build/components/inspector-popover-header/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +7 -4
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +19 -10
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +4 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/media-placeholder/index.js +28 -7
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +8 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +19 -19
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/event-listeners/paste-handler.js +12 -1
- package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build/components/rich-text/index.js +38 -30
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-mark-persistent.js +5 -5
- package/build/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -1
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/tool-selector/index.js +4 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-input/button.js +12 -3
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +4 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +4 -6
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/writing-flow/index.js +2 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +4 -1
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-event-redirect.js +66 -0
- package/build/components/writing-flow/use-event-redirect.js.map +1 -0
- package/build/components/writing-flow/use-input.js +31 -1
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +14 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +20 -6
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +4 -4
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-flow/utils.js +27 -0
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/hooks/block-bindings.js +32 -29
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/content-lock-ui.js +8 -26
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/duotone.js +0 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +4 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +3 -3
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/style.js +1 -5
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +19 -20
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +7 -7
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/layouts/constrained.js +41 -41
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +4 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/utils.js +1 -7
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +2 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +2 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +1 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/private-selectors.js +13 -15
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +19 -43
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +48 -0
- package/build/store/utils.js.map +1 -1
- package/build/utils/block-bindings.js +16 -11
- package/build/utils/block-bindings.js.map +1 -1
- package/build/utils/dom.js +101 -0
- package/build/utils/dom.js.map +1 -1
- package/build/utils/get-font-styles-and-weights.js +4 -4
- package/build/utils/get-font-styles-and-weights.js.map +1 -1
- package/build/utils/transform-styles/index.js +120 -16
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +8 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-canvas/index.js +9 -1
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-compare/block-view.js +4 -1
- package/build-module/components/block-compare/block-view.js.map +1 -1
- package/build-module/components/block-draggable/index.js +4 -4
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.js +25 -25
- package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build-module/components/block-edit/multiple-usage-warning.js +8 -2
- package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
- package/build-module/components/block-inspector/index.js +27 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +6 -3
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-list/block.js +5 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +5 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -0
- 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-zoom-out-mode-exit.js +40 -0
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
- package/build-module/components/block-lock/toolbar.js +3 -3
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +4 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +4 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -4
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +23 -8
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +11 -14
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +12 -3
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +4 -1
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +4 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +22 -17
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +12 -11
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +6 -2
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +8 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-popover.js +10 -6
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +4 -9
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +3 -4
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +15 -6
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +4 -1
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +4 -1
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +15 -4
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +4 -1
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/content-lock/index.js +2 -0
- package/build-module/components/content-lock/index.js.map +1 -0
- package/build-module/components/content-lock/modify-content-lock-menu-item.js +57 -0
- package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +8 -12
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +7 -4
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +2 -2
- package/build-module/components/global-styles/color-panel.native.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +36 -39
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +4 -1
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +13 -7
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +17 -6
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/utils.js +4 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +3 -3
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/iframe/index.js +5 -5
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -4
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -3
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -4
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +3 -3
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +1 -4
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +8 -2
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +4 -1
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/menu.js +7 -24
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +4 -4
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +3 -7
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +4 -1
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +4 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/inspector-popover-header/index.js +8 -2
- package/build-module/components/inspector-popover-header/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +7 -4
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +19 -10
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +4 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +28 -7
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +8 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +19 -19
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js +12 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build-module/components/rich-text/index.js +39 -31
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js +5 -5
- package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +4 -1
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +4 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-input/button.js +12 -3
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +4 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +4 -6
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +2 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -1
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-event-redirect.js +60 -0
- package/build-module/components/writing-flow/use-event-redirect.js.map +1 -0
- package/build-module/components/writing-flow/use-input.js +31 -1
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +14 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +16 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +4 -4
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +26 -0
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/hooks/block-bindings.js +34 -31
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +10 -30
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/duotone.js +0 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +4 -1
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +3 -3
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/style.js +1 -5
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +19 -20
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +7 -7
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/layouts/constrained.js +43 -43
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +4 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/utils.js +1 -7
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +2 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/private-selectors.js +12 -15
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -7
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -46
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +46 -0
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/block-bindings.js +17 -12
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-module/utils/dom.js +99 -0
- package/build-module/utils/dom.js.map +1 -1
- package/build-module/utils/get-font-styles-and-weights.js +4 -4
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +120 -16
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +2 -11
- package/build-style/content.css +2 -11
- package/build-style/style-rtl.css +17 -38
- package/build-style/style.css +17 -38
- package/build-types/utils/dom.d.ts +25 -0
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +34 -32
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/index.js +4 -0
- package/src/components/block-breadcrumb/style.scss +1 -1
- package/src/components/block-canvas/index.js +9 -1
- package/src/components/block-compare/block-view.js +7 -1
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-draggable/index.js +4 -4
- package/src/components/block-draggable/style.scss +1 -1
- package/src/components/block-draggable/use-scroll-when-dragging.js +25 -25
- package/src/components/block-edit/multiple-usage-warning.js +4 -0
- package/src/components/block-inspector/index.js +22 -6
- package/src/components/block-list/block-invalid-warning.js +4 -2
- package/src/components/block-list/block.js +6 -2
- package/src/components/block-list/content.scss +2 -3
- package/src/components/block-list/use-block-props/index.js +3 -0
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -0
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +44 -0
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-lock/toolbar.js +3 -3
- package/src/components/block-mover/button.js +2 -0
- package/src/components/block-mover/index.js +2 -0
- package/src/components/block-mover/style.scss +1 -1
- package/src/components/block-navigation/dropdown.js +2 -0
- package/src/components/block-pattern-setup/index.js +3 -7
- package/src/components/block-pattern-setup/setup-toolbar.js +17 -4
- package/src/components/block-pattern-setup/style.scss +2 -2
- package/src/components/block-patterns-list/index.js +15 -13
- package/src/components/block-patterns-list/style.scss +2 -2
- package/src/components/block-patterns-paging/index.js +6 -0
- package/src/components/block-popover/index.js +7 -28
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +2 -0
- package/src/components/block-settings-menu-controls/index.js +7 -1
- package/src/components/block-switcher/index.js +26 -20
- package/src/components/block-switcher/pattern-transformations-menu.js +3 -7
- package/src/components/block-switcher/style.scss +5 -6
- package/src/components/block-toolbar/index.js +17 -8
- package/src/components/block-toolbar/shuffle.js +9 -7
- package/src/components/block-tools/block-selection-button.js +4 -0
- package/src/components/block-tools/block-toolbar-popover.js +10 -6
- package/src/components/block-tools/style.scss +3 -4
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -1
- package/src/components/block-tools/zoom-out-mode-inserters.js +2 -5
- package/src/components/block-tools/zoom-out-popover.js +3 -7
- package/src/components/block-tools/zoom-out-toolbar.js +20 -6
- package/src/components/block-variation-picker/README.md +2 -2
- package/src/components/block-variation-picker/index.js +6 -1
- package/src/components/block-variation-transforms/index.js +2 -0
- package/src/components/block-variation-transforms/style.scss +1 -1
- package/src/components/button-block-appender/content.scss +0 -1
- package/src/components/button-block-appender/index.js +14 -3
- package/src/components/color-palette/test/control.js +15 -2
- package/src/components/colors-gradients/dropdown.js +5 -1
- package/src/components/colors-gradients/style.scss +4 -4
- package/src/components/content-lock/index.js +1 -0
- package/src/components/content-lock/modify-content-lock-menu-item.js +58 -0
- package/src/components/default-block-appender/content.scss +0 -1
- package/src/components/editor-styles/index.js +4 -3
- package/src/components/global-styles/background-panel.js +6 -14
- package/src/components/global-styles/color-panel.js +8 -4
- package/src/components/global-styles/color-panel.native.js +2 -2
- package/src/components/global-styles/dimensions-panel.js +40 -40
- package/src/components/global-styles/filters-panel.js +5 -1
- package/src/components/global-styles/shadow-panel-components.js +12 -8
- package/src/components/global-styles/style.scss +3 -4
- package/src/components/global-styles/test/typography-utils.js +96 -5
- package/src/components/global-styles/test/utils.js +10 -0
- package/src/components/global-styles/typography-utils.js +22 -6
- package/src/components/global-styles/utils.js +4 -6
- package/src/components/grid/grid-item-movers.js +3 -3
- package/src/components/grid/style.scss +1 -1
- package/src/components/iframe/index.js +5 -5
- package/src/components/inner-blocks/index.js +2 -2
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -3
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -0
- package/src/components/inserter/block-patterns-tab/index.js +2 -0
- package/src/components/inserter/library.js +0 -2
- package/src/components/inserter/media-tab/hooks.js +3 -3
- package/src/components/inserter/media-tab/media-list.js +1 -4
- package/src/components/inserter/media-tab/media-preview.js +12 -2
- package/src/components/inserter/media-tab/media-tab.js +2 -0
- package/src/components/inserter/menu.js +15 -29
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/style.scss +6 -8
- package/src/components/inserter-list-item/index.js +4 -4
- package/src/components/inserter-list-item/style.scss +1 -3
- package/src/components/inserter-listbox/index.js +2 -8
- package/src/components/inserter-listbox/item.js +9 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +2 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -2
- package/src/components/inspector-popover-header/index.js +4 -0
- package/src/components/letter-spacing-control/README.md +8 -1
- package/src/components/letter-spacing-control/index.js +7 -4
- package/src/components/link-control/index.js +17 -8
- package/src/components/link-control/settings-drawer.js +2 -0
- package/src/components/link-control/style.scss +1 -3
- package/src/components/list-view/block-select-button.js +2 -0
- package/src/components/list-view/style.scss +14 -16
- package/src/components/media-placeholder/index.js +14 -0
- package/src/components/media-replace-flow/index.js +12 -1
- package/src/components/provider/use-block-sync.js +20 -20
- package/src/components/responsive-block-control/README.md +3 -27
- package/src/components/rich-text/content.scss +1 -1
- package/src/components/rich-text/event-listeners/paste-handler.js +6 -1
- package/src/components/rich-text/index.js +54 -41
- package/src/components/rich-text/style.scss +1 -1
- package/src/components/rich-text/use-mark-persistent.js +5 -5
- package/src/components/skip-to-selected-block/index.js +2 -0
- package/src/components/spacing-sizes-control/style.scss +1 -0
- package/src/components/tool-selector/index.js +2 -0
- package/src/components/url-input/button.js +6 -0
- package/src/components/url-input/index.js +2 -0
- package/src/components/url-popover/stories/index.story.js +7 -1
- package/src/components/use-block-drop-zone/index.js +4 -4
- package/src/components/warning/content.scss +3 -10
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +9 -2
- package/src/components/writing-flow/use-event-redirect.js +72 -0
- package/src/components/writing-flow/use-input.js +36 -1
- package/src/components/writing-flow/use-select-all.js +18 -1
- package/src/components/writing-flow/use-selection-observer.js +23 -3
- package/src/components/writing-flow/use-tab-nav.js +4 -4
- package/src/components/writing-flow/utils.js +30 -0
- package/src/hooks/block-bindings.js +42 -43
- package/src/hooks/block-bindings.scss +1 -9
- package/src/hooks/content-lock-ui.js +11 -36
- package/src/hooks/duotone.js +0 -4
- package/src/hooks/layout.js +2 -0
- package/src/hooks/layout.scss +3 -11
- package/src/hooks/spacing-visualizer.js +3 -3
- package/src/hooks/style.js +1 -4
- package/src/hooks/use-bindings-attributes.js +23 -24
- package/src/hooks/use-zoom-out.js +7 -7
- package/src/layouts/constrained.js +50 -47
- package/src/layouts/flex.js +2 -0
- package/src/layouts/test/grid.js +2 -2
- package/src/layouts/test/utils.js +6 -8
- package/src/layouts/utils.js +1 -9
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +4 -6
- package/src/store/private-actions.js +1 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +12 -11
- package/src/store/reducer.js +0 -5
- package/src/store/selectors.js +32 -51
- package/src/store/utils.js +50 -0
- package/src/utils/block-bindings.js +15 -16
- package/src/utils/dom.js +117 -0
- package/src/utils/get-font-styles-and-weights.js +12 -4
- package/src/utils/test/get-font-styles-and-weights.js +148 -0
- package/src/utils/test/transform-styles.js +259 -50
- package/src/utils/transform-styles/index.js +132 -21
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/utils/test/__snapshots__/transform-styles.js.snap +0 -109
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -811,21 +811,12 @@ _Parameters_
|
|
|
811
811
|
|
|
812
812
|
- _styles_ `EditorStyle[]`: CSS rules.
|
|
813
813
|
- _wrapperSelector_ `string`: Wrapper selector.
|
|
814
|
+
- _transformOptions_ `TransformOptions`: Additional options for style transformation.
|
|
814
815
|
|
|
815
816
|
_Returns_
|
|
816
817
|
|
|
817
818
|
- `Array`: converted rules.
|
|
818
819
|
|
|
819
|
-
_Type Definition_
|
|
820
|
-
|
|
821
|
-
- _EditorStyle_ `Object`
|
|
822
|
-
|
|
823
|
-
_Properties_
|
|
824
|
-
|
|
825
|
-
- _css_ `string`: the CSS block(s), as a single string.
|
|
826
|
-
- _baseURL_ `?string`: the base URL to be used as the reference when rewritting urls.
|
|
827
|
-
- _ignoredSelectors_ `?string[]`: the selectors not to wrap.
|
|
828
|
-
|
|
829
820
|
### Typewriter
|
|
830
821
|
|
|
831
822
|
Ensures that the text selection keeps the same vertical distance from the viewport during keyboard events within this component. The vertical distance can vary. It is the last clicked or scrolled to position.
|
|
@@ -20,7 +20,7 @@ function BlockAlignmentMatrixControl(props) {
|
|
|
20
20
|
value = 'center',
|
|
21
21
|
isDisabled
|
|
22
22
|
} = props;
|
|
23
|
-
const icon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
23
|
+
const icon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.AlignmentMatrixControl.Icon, {
|
|
24
24
|
value: value
|
|
25
25
|
});
|
|
26
26
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
|
|
@@ -48,7 +48,7 @@ function BlockAlignmentMatrixControl(props) {
|
|
|
48
48
|
disabled: isDisabled
|
|
49
49
|
});
|
|
50
50
|
},
|
|
51
|
-
renderContent: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
51
|
+
renderContent: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.AlignmentMatrixControl, {
|
|
52
52
|
hasFocusBorder: false,
|
|
53
53
|
onChange: onChange,
|
|
54
54
|
value: value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_keycodes","_components","_jsxRuntime","noop","BlockAlignmentMatrixControl","props","label","__","onChange","value","isDisabled","icon","jsx","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_keycodes","_components","_jsxRuntime","noop","BlockAlignmentMatrixControl","props","label","__","onChange","value","isDisabled","icon","jsx","AlignmentMatrixControl","Icon","Dropdown","popoverProps","placement","renderToggle","onToggle","isOpen","openOnArrowDown","event","keyCode","DOWN","preventDefault","ToolbarButton","onClick","onKeyDown","showTooltip","disabled","renderContent","hasFocusBorder","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/block-alignment-matrix-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport {\n\tToolbarButton,\n\tDropdown,\n\tAlignmentMatrixControl,\n} from '@wordpress/components';\n\nconst noop = () => {};\n\nfunction BlockAlignmentMatrixControl( props ) {\n\tconst {\n\t\tlabel = __( 'Change matrix alignment' ),\n\t\tonChange = noop,\n\t\tvalue = 'center',\n\t\tisDisabled,\n\t} = props;\n\n\tconst icon = <AlignmentMatrixControl.Icon value={ value } />;\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\trenderToggle={ ( { onToggle, isOpen } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<AlignmentMatrixControl\n\t\t\t\t\thasFocusBorder={ false }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default BlockAlignmentMatrixControl;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAI+B,IAAAG,WAAA,GAAAH,OAAA;AAT/B;AACA;AACA;;AASA,MAAMI,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,2BAA2BA,CAAEC,KAAK,EAAG;EAC7C,MAAM;IACLC,KAAK,GAAG,IAAAC,QAAE,EAAE,yBAA0B,CAAC;IACvCC,QAAQ,GAAGL,IAAI;IACfM,KAAK,GAAG,QAAQ;IAChBC;EACD,CAAC,GAAGL,KAAK;EAET,MAAMM,IAAI,gBAAG,IAAAT,WAAA,CAAAU,GAAA,EAACX,WAAA,CAAAY,sBAAsB,CAACC,IAAI;IAACL,KAAK,EAAGA;EAAO,CAAE,CAAC;EAE5D,oBACC,IAAAP,WAAA,CAAAU,GAAA,EAACX,WAAA,CAAAc,QAAQ;IACRC,YAAY,EAAG;MAAEC,SAAS,EAAE;IAAe,CAAG;IAC9CC,YAAY,EAAGA,CAAE;MAAEC,QAAQ;MAAEC;IAAO,CAAC,KAAM;MAC1C,MAAMC,eAAe,GAAKC,KAAK,IAAM;QACpC,IAAK,CAAEF,MAAM,IAAIE,KAAK,CAACC,OAAO,KAAKC,cAAI,EAAG;UACzCF,KAAK,CAACG,cAAc,CAAC,CAAC;UACtBN,QAAQ,CAAC,CAAC;QACX;MACD,CAAC;MAED,oBACC,IAAAjB,WAAA,CAAAU,GAAA,EAACX,WAAA,CAAAyB,aAAa;QACbC,OAAO,EAAGR,QAAU;QACpB,iBAAc,MAAM;QACpB,iBAAgBC,MAAQ;QACxBQ,SAAS,EAAGP,eAAiB;QAC7Bf,KAAK,EAAGA,KAAO;QACfK,IAAI,EAAGA,IAAM;QACbkB,WAAW;QACXC,QAAQ,EAAGpB;MAAY,CACvB,CAAC;IAEJ,CAAG;IACHqB,aAAa,EAAGA,CAAA,kBACf,IAAA7B,WAAA,CAAAU,GAAA,EAACX,WAAA,CAAAY,sBAAsB;MACtBmB,cAAc,EAAG,KAAO;MACxBxB,QAAQ,EAAGA,QAAU;MACrBC,KAAK,EAAGA;IAAO,CACf;EACC,CACH,CAAC;AAEJ;AAAC,IAAAwB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc/B,2BAA2B","ignoreList":[]}
|
|
@@ -73,7 +73,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
73
73
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
74
74
|
className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
|
|
75
75
|
"aria-current": !hasSelection ? 'true' : undefined,
|
|
76
|
-
children: [hasSelection && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
76
|
+
children: [hasSelection && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
77
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
78
|
+
, {
|
|
79
|
+
__next40pxDefaultSize: false,
|
|
77
80
|
className: "block-editor-block-breadcrumb__button",
|
|
78
81
|
variant: "tertiary",
|
|
79
82
|
onClick: () => {
|
|
@@ -88,7 +91,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
88
91
|
className: "block-editor-block-breadcrumb__separator"
|
|
89
92
|
})]
|
|
90
93
|
}), parents.map(parentClientId => /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
91
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
94
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
95
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
96
|
+
, {
|
|
97
|
+
__next40pxDefaultSize: false,
|
|
92
98
|
className: "block-editor-block-breadcrumb__button",
|
|
93
99
|
variant: "tertiary",
|
|
94
100
|
onClick: () => selectBlock(parentClientId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_data","_i18n","_icons","_element","_blockTitle","_interopRequireDefault","_store","_lockUnlock","_useBlockRefs","_getEditorRegion","_jsxRuntime","BlockBreadcrumb","rootLabelText","selectBlock","clearSelectedBlock","useDispatch","blockEditorStore","clientId","parents","hasSelection","useSelect","select","getSelectionStart","getSelectedBlockClientId","getEnabledBlockParents","unlock","selectedBlockClientId","rootLabel","__","blockRef","useRef","useBlockElementRef","jsxs","className","role","children","undefined","jsx","Button","variant","onClick","blockEditor","current","closest","getEditorRegion","focus","Icon","icon","chevronRightSmall","map","parentClientId","default","maximumLength","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-breadcrumb/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { chevronRightSmall, Icon } from '@wordpress/icons';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useBlockElementRef } from '../block-list/use-block-props/use-block-refs';\nimport getEditorRegion from '../../utils/get-editor-region';\n\n/**\n * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.\n *\n * @param {Object} props Component props.\n * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockBreadcrumb( { rootLabelText } ) {\n\tconst { selectBlock, clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { clientId, parents, hasSelection } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetEnabledBlockParents,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tparents: getEnabledBlockParents( selectedBlockClientId ),\n\t\t\tclientId: selectedBlockClientId,\n\t\t\thasSelection: !! getSelectionStart().clientId,\n\t\t};\n\t}, [] );\n\tconst rootLabel = rootLabelText || __( 'Document' );\n\n\t// We don't care about this specific ref, but this is a way\n\t// to get a ref within the editor canvas so we can focus it later.\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\treturn (\n\t\t<ul\n\t\t\tclassName=\"block-editor-block-breadcrumb\"\n\t\t\trole=\"list\"\n\t\t\taria-label={ __( 'Block breadcrumb' ) }\n\t\t>\n\t\t\t<li\n\t\t\t\tclassName={\n\t\t\t\t\t! hasSelection\n\t\t\t\t\t\t? 'block-editor-block-breadcrumb__current'\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\taria-current={ ! hasSelection ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ hasSelection && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Find the block editor wrapper for the selected block\n\t\t\t\t\t\t\tconst blockEditor = blockRef.current?.closest(\n\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tclearSelectedBlock();\n\n\t\t\t\t\t\t\tgetEditorRegion( blockEditor )?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ rootLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! hasSelection && rootLabel }\n\t\t\t\t{ !! clientId && (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</li>\n\n\t\t\t{ parents.map( ( parentClientId ) => (\n\t\t\t\t<li key={ parentClientId }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ parentClientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t\t{ !! clientId && (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__current\"\n\t\t\t\t\taria-current=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</li>\n\t\t\t) }\n\t\t</ul>\n\t\t/* eslint-enable jsx-a11y/no-redundant-roles */\n\t);\n}\n\nexport default Bl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AkB,EAAEd,QAAQ,EAAEY,QAAS,CAAC;;EAExC;AACD;AACA;AACA;EACC;EACA,oBACC,IAAAnB,WAAA,CAAAsB,IAAA;IACCC,SAAS,EAAC,+BAA+B;IACzCC,IAAI,EAAC,MAAM;IACX,cAAa,IAAAN,QAAE,EAAE,kBAAmB,CAAG;IAAAO,QAAA,gBAEvC,IAAAzB,WAAA,CAAAsB,IAAA;MACCC,SAAS,EACR,CAAEd,YAAY,GACX,wCAAwC,GACxCiB,SACH;MACD,gBAAe,CAAEjB,YAAY,GAAG,MAAM,GAAGiB,SAAW;MAAAD,QAAA,GAElDhB,YAAY,iBACb,IAAAT,WAAA,CAAA2B,GAAA,EAACvC,WAAA,CAAAwC,
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_i18n","_icons","_element","_blockTitle","_interopRequireDefault","_store","_lockUnlock","_useBlockRefs","_getEditorRegion","_jsxRuntime","BlockBreadcrumb","rootLabelText","selectBlock","clearSelectedBlock","useDispatch","blockEditorStore","clientId","parents","hasSelection","useSelect","select","getSelectionStart","getSelectedBlockClientId","getEnabledBlockParents","unlock","selectedBlockClientId","rootLabel","__","blockRef","useRef","useBlockElementRef","jsxs","className","role","children","undefined","jsx","Button","__next40pxDefaultSize","variant","onClick","blockEditor","current","closest","getEditorRegion","focus","Icon","icon","chevronRightSmall","map","parentClientId","default","maximumLength","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-breadcrumb/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { chevronRightSmall, Icon } from '@wordpress/icons';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useBlockElementRef } from '../block-list/use-block-props/use-block-refs';\nimport getEditorRegion from '../../utils/get-editor-region';\n\n/**\n * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.\n *\n * @param {Object} props Component props.\n * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockBreadcrumb( { rootLabelText } ) {\n\tconst { selectBlock, clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { clientId, parents, hasSelection } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetEnabledBlockParents,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tparents: getEnabledBlockParents( selectedBlockClientId ),\n\t\t\tclientId: selectedBlockClientId,\n\t\t\thasSelection: !! getSelectionStart().clientId,\n\t\t};\n\t}, [] );\n\tconst rootLabel = rootLabelText || __( 'Document' );\n\n\t// We don't care about this specific ref, but this is a way\n\t// to get a ref within the editor canvas so we can focus it later.\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\treturn (\n\t\t<ul\n\t\t\tclassName=\"block-editor-block-breadcrumb\"\n\t\t\trole=\"list\"\n\t\t\taria-label={ __( 'Block breadcrumb' ) }\n\t\t>\n\t\t\t<li\n\t\t\t\tclassName={\n\t\t\t\t\t! hasSelection\n\t\t\t\t\t\t? 'block-editor-block-breadcrumb__current'\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\taria-current={ ! hasSelection ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ hasSelection && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Find the block editor wrapper for the selected block\n\t\t\t\t\t\t\tconst blockEditor = blockRef.current?.closest(\n\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tclearSelectedBlock();\n\n\t\t\t\t\t\t\tgetEditorRegion( blockEditor )?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ rootLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! hasSelection && rootLabel }\n\t\t\t\t{ !! clientId && (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</li>\n\n\t\t\t{ parents.map( ( parentClientId ) => (\n\t\t\t\t<li key={ parentClientId }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ parentClientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t\t{ !! clientId && (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__current\"\n\t\t\t\t\taria-current=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</li>\n\t\t\t) }\n\t\t</ul>\n\t\t/* eslint-enable jsx-a11y/no-redundant-roles */\n\t);\n}\n\nexport default BlockBreadcrumb;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAJ,sBAAA,CAAAN,OAAA;AAA4D,IAAAW,WAAA,GAAAX,OAAA;AAhB5D;AACA;AACA;;AAOA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,SAASY,eAAeA,CAAE;EAAEC;AAAc,CAAC,EAAG;EAC7C,MAAM;IAAEC,WAAW;IAAEC;EAAmB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EAC3E,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAa,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACpE,MAAM;MACLC,iBAAiB;MACjBC,wBAAwB;MACxBC;IACD,CAAC,GAAG,IAAAC,kBAAM,EAAEJ,MAAM,CAAEL,YAAiB,CAAE,CAAC;IACxC,MAAMU,qBAAqB,GAAGH,wBAAwB,CAAC,CAAC;IACxD,OAAO;MACNL,OAAO,EAAEM,sBAAsB,CAAEE,qBAAsB,CAAC;MACxDT,QAAQ,EAAES,qBAAqB;MAC/BP,YAAY,EAAE,CAAC,CAAEG,iBAAiB,CAAC,CAAC,CAACL;IACtC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,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AA,gBACC,IAAAzB,WAAA,CAAA2B,GAAA,EAACvC,WAAA,CAAAwC;MACA;MAAA;QACAC,qBAAqB,EAAG,KAAO;QAC/BN,SAAS,EAAC,uCAAuC;QACjDO,OAAO,EAAC,UAAU;QAClBC,OAAO,EAAGA,CAAA,KAAM5B,WAAW,CAAEsC,cAAe,CAAG;QAAAhB,QAAA,eAE/C,IAAAzB,WAAA,CAAA2B,GAAA,EAACjC,WAAA,CAAAgD,OAAU;UACVnC,QAAQ,EAAGkC,cAAgB;UAC3BE,aAAa,EAAG;QAAI,CACpB;MAAC,CACK,CAAC,eACT,IAAA3C,WAAA,CAAA2B,GAAA,EAACnC,MAAA,CAAA6C,IAAI;QACJC,IAAI,EAAGC,wBAAmB;QAC1BhB,SAAS,EAAC;MAA0C,CACpD,CAAC;IAAA,GAhBOkB,cAiBN,CACH,CAAC,EACD,CAAC,CAAElC,QAAQ,iBACZ,IAAAP,WAAA,CAAA2B,GAAA;MACCJ,SAAS,EAAC,wCAAwC;MAClD,gBAAa,MAAM;MAAAE,QAAA,eAEnB,IAAAzB,WAAA,CAAA2B,GAAA,EAACjC,WAAA,CAAAgD,OAAU;QAACnC,QAAQ,EAAGA,QAAU;QAACoC,aAAa,EAAG;MAAI,CAAE;IAAC,CACtD,CACJ;EAAA,CACE;EACJ;AAEF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEczC,eAAe","ignoreList":[]}
|
|
@@ -25,6 +25,12 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
+
// EditorStyles is a memoized component, so avoid passing a new
|
|
29
|
+
// object reference on each render.
|
|
30
|
+
const EDITOR_STYLE_TRANSFORM_OPTIONS = {
|
|
31
|
+
// Don't transform selectors that already specify `.editor-styles-wrapper`.
|
|
32
|
+
ignoredSelectors: [/\.editor-styles-wrapper/gi]
|
|
33
|
+
};
|
|
28
34
|
function ExperimentalBlockCanvas({
|
|
29
35
|
shouldIframe = true,
|
|
30
36
|
height = '300px',
|
|
@@ -47,7 +53,8 @@ function ExperimentalBlockCanvas({
|
|
|
47
53
|
},
|
|
48
54
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_editorStyles.default, {
|
|
49
55
|
styles: styles,
|
|
50
|
-
scope: ".editor-styles-wrapper"
|
|
56
|
+
scope: ":where(.editor-styles-wrapper)",
|
|
57
|
+
transformOptions: EDITOR_STYLE_TRANSFORM_OPTIONS
|
|
51
58
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_writingFlow.default, {
|
|
52
59
|
ref: contentRef,
|
|
53
60
|
className: "editor-styles-wrapper",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_blockList","_interopRequireDefault","_blockTools","_editorStyles","_iframe","_writingFlow","_observeTyping","_blockSelectionClearer","_useBlockCommands","_jsxRuntime","ExperimentalBlockCanvas","shouldIframe","height","children","jsx","default","styles","contentRef","contentRefProp","iframeProps","useBlockCommands","resetTypingRef","useMouseMoveTypingReset","clearerRef","useBlockSelectionClearer","localRef","useRef","useMergeRefs","jsxs","__unstableContentRef","style","display","scope","ref","className","tabIndex","width","name","BlockCanvas","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-canvas/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport BlockTools from '../block-tools';\nimport EditorStyles from '../editor-styles';\nimport Iframe from '../iframe';\nimport WritingFlow from '../writing-flow';\nimport { useMouseMoveTypingReset } from '../observe-typing';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useBlockCommands } from '../use-block-commands';\n\nexport function ExperimentalBlockCanvas( {\n\tshouldIframe = true,\n\theight = '300px',\n\tchildren = <BlockList />,\n\tstyles,\n\tcontentRef: contentRefProp,\n\tiframeProps,\n} ) {\n\tuseBlockCommands();\n\tconst resetTypingRef = useMouseMoveTypingReset();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst localRef = useRef();\n\tconst contentRef = useMergeRefs( [ contentRefProp, clearerRef, localRef ] );\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<BlockTools\n\t\t\t\t__unstableContentRef={ localRef }\n\t\t\t\tstyle={ { height, display: 'flex' } }\n\t\t\t>\n\t\t\t\t<EditorStyles\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tscope=\".editor-styles-wrapper\"\n\t\t\t\t/>\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</BlockTools>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ localRef }\n\t\t\tstyle={ { height, display: 'flex' } }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\t{ ...iframeProps }\n\t\t\t\tref={ resetTypingRef }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t} }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</BlockTools>\n\t);\n}\n\n/**\n * BlockCanvas component is a component used to display the canvas of the block editor.\n * What we call the canvas is an iframe containing the block list that you can manipulate.\n * The component is also responsible of wiring up all the necessary hooks to enable\n * the keyboard navigation across blocks in the editor and inject content styles into the iframe.\n *\n * @example\n *\n * ```jsx\n * function MyBlockEditor() {\n * const [ blocks, updateBlocks ] = useState([]);\n * return (\n * <BlockEditorProvider\n * value={ blocks }\n * onInput={ updateBlocks }\n * onChange={ persistBlocks }\n * >\n * <BlockCanvas height=\"400px\" />\n * </BlockEditorProvider>\n * );\n * }\n * ```\n *\n * @param {Object} props Component props.\n * @param {string} props.height Canvas height, defaults to 300px.\n * @param {Array} props.styles Content styles to inject into the iframe.\n * @param {Element} props.children Content of the canvas, defaults to the BlockList component.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockCanvas( { children, height, styles } ) {\n\treturn (\n\t\t<ExperimentalBlockCanvas height={ height } styles={ styles }>\n\t\t\t{ children }\n\t\t</ExperimentalBlockCanvas>\n\t);\n}\n\nexport default BlockCanvas;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,aAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,OAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,YAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,cAAA,GAAAR,OAAA;AACA,IAAAS,sBAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AAAyD,IAAAW,WAAA,GAAAX,OAAA;AAhBzD;AACA;AACA;;AAIA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_blockList","_interopRequireDefault","_blockTools","_editorStyles","_iframe","_writingFlow","_observeTyping","_blockSelectionClearer","_useBlockCommands","_jsxRuntime","EDITOR_STYLE_TRANSFORM_OPTIONS","ignoredSelectors","ExperimentalBlockCanvas","shouldIframe","height","children","jsx","default","styles","contentRef","contentRefProp","iframeProps","useBlockCommands","resetTypingRef","useMouseMoveTypingReset","clearerRef","useBlockSelectionClearer","localRef","useRef","useMergeRefs","jsxs","__unstableContentRef","style","display","scope","transformOptions","ref","className","tabIndex","width","name","BlockCanvas","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-canvas/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport BlockTools from '../block-tools';\nimport EditorStyles from '../editor-styles';\nimport Iframe from '../iframe';\nimport WritingFlow from '../writing-flow';\nimport { useMouseMoveTypingReset } from '../observe-typing';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useBlockCommands } from '../use-block-commands';\n\n// EditorStyles is a memoized component, so avoid passing a new\n// object reference on each render.\nconst EDITOR_STYLE_TRANSFORM_OPTIONS = {\n\t// Don't transform selectors that already specify `.editor-styles-wrapper`.\n\tignoredSelectors: [ /\\.editor-styles-wrapper/gi ],\n};\n\nexport function ExperimentalBlockCanvas( {\n\tshouldIframe = true,\n\theight = '300px',\n\tchildren = <BlockList />,\n\tstyles,\n\tcontentRef: contentRefProp,\n\tiframeProps,\n} ) {\n\tuseBlockCommands();\n\tconst resetTypingRef = useMouseMoveTypingReset();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst localRef = useRef();\n\tconst contentRef = useMergeRefs( [ contentRefProp, clearerRef, localRef ] );\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<BlockTools\n\t\t\t\t__unstableContentRef={ localRef }\n\t\t\t\tstyle={ { height, display: 'flex' } }\n\t\t\t>\n\t\t\t\t<EditorStyles\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tscope=\":where(.editor-styles-wrapper)\"\n\t\t\t\t\ttransformOptions={ EDITOR_STYLE_TRANSFORM_OPTIONS }\n\t\t\t\t/>\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</BlockTools>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ localRef }\n\t\t\tstyle={ { height, display: 'flex' } }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\t{ ...iframeProps }\n\t\t\t\tref={ resetTypingRef }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t} }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</BlockTools>\n\t);\n}\n\n/**\n * BlockCanvas component is a component used to display the canvas of the block editor.\n * What we call the canvas is an iframe containing the block list that you can manipulate.\n * The component is also responsible of wiring up all the necessary hooks to enable\n * the keyboard navigation across blocks in the editor and inject content styles into the iframe.\n *\n * @example\n *\n * ```jsx\n * function MyBlockEditor() {\n * const [ blocks, updateBlocks ] = useState([]);\n * return (\n * <BlockEditorProvider\n * value={ blocks }\n * onInput={ updateBlocks }\n * onChange={ persistBlocks }\n * >\n * <BlockCanvas height=\"400px\" />\n * </BlockEditorProvider>\n * );\n * }\n * ```\n *\n * @param {Object} props Component props.\n * @param {string} props.height Canvas height, defaults to 300px.\n * @param {Array} props.styles Content styles to inject into the iframe.\n * @param {Element} props.children Content of the canvas, defaults to the BlockList component.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockCanvas( { children, height, styles } ) {\n\treturn (\n\t\t<ExperimentalBlockCanvas height={ height } styles={ styles }>\n\t\t\t{ children }\n\t\t</ExperimentalBlockCanvas>\n\t);\n}\n\nexport default BlockCanvas;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,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uB;IAACE,MAAM,EAAGA,MAAQ;IAACI,MAAM,EAAGA,MAAQ;IAAAH,QAAA,EACzDA;EAAQ,CACc,CAAC;AAE5B;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEcwB,WAAW","ignoreList":[]}
|
|
@@ -38,7 +38,10 @@ function BlockView({
|
|
|
38
38
|
})]
|
|
39
39
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
40
40
|
className: "block-editor-block-compare__action",
|
|
41
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
41
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
42
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
43
|
+
, {
|
|
44
|
+
__next40pxDefaultSize: false,
|
|
42
45
|
variant: "secondary",
|
|
43
46
|
tabIndex: "0",
|
|
44
47
|
onClick: action,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_dom","_jsxRuntime","BlockView","title","rawContent","renderedContent","action","actionText","className","jsxs","children","jsx","RawHTML","safeHTML","Button","variant","tabIndex","onClick"],"sources":["@wordpress/block-editor/src/components/block-compare/block-view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { RawHTML } from '@wordpress/element';\nimport { safeHTML } from '@wordpress/dom';\n\nexport default function BlockView( {\n\ttitle,\n\trawContent,\n\trenderedContent,\n\taction,\n\tactionText,\n\tclassName,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<div className=\"block-editor-block-compare__content\">\n\t\t\t\t<h2 className=\"block-editor-block-compare__heading\">\n\t\t\t\t\t{ title }\n\t\t\t\t</h2>\n\n\t\t\t\t<div className=\"block-editor-block-compare__html\">\n\t\t\t\t\t{ rawContent }\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"block-editor-block-compare__preview edit-post-visual-editor\">\n\t\t\t\t\t<RawHTML>{ safeHTML( renderedContent ) }</RawHTML>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"block-editor-block-compare__action\">\n\t\t\t\t<Button
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_dom","_jsxRuntime","BlockView","title","rawContent","renderedContent","action","actionText","className","jsxs","children","jsx","RawHTML","safeHTML","Button","__next40pxDefaultSize","variant","tabIndex","onClick"],"sources":["@wordpress/block-editor/src/components/block-compare/block-view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { RawHTML } from '@wordpress/element';\nimport { safeHTML } from '@wordpress/dom';\n\nexport default function BlockView( {\n\ttitle,\n\trawContent,\n\trenderedContent,\n\taction,\n\tactionText,\n\tclassName,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<div className=\"block-editor-block-compare__content\">\n\t\t\t\t<h2 className=\"block-editor-block-compare__heading\">\n\t\t\t\t\t{ title }\n\t\t\t\t</h2>\n\n\t\t\t\t<div className=\"block-editor-block-compare__html\">\n\t\t\t\t\t{ rawContent }\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"block-editor-block-compare__preview edit-post-visual-editor\">\n\t\t\t\t\t<RawHTML>{ safeHTML( renderedContent ) }</RawHTML>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div className=\"block-editor-block-compare__action\">\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\ttabIndex=\"0\"\n\t\t\t\t\tonClick={ action }\n\t\t\t\t>\n\t\t\t\t\t{ actionText }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAA0C,IAAAG,WAAA,GAAAH,OAAA;AAL1C;AACA;AACA;;AAKe,SAASI,SAASA,CAAE;EAClCC,KAAK;EACLC,UAAU;EACVC,eAAe;EACfC,MAAM;EACNC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,oBACC,IAAAP,WAAA,CAAAQ,IAAA;IAAKD,SAAS,EAAGA,SAAW;IAAAE,QAAA,gBAC3B,IAAAT,WAAA,CAAAQ,IAAA;MAAKD,SAAS,EAAC,qCAAqC;MAAAE,QAAA,gBACnD,IAAAT,WAAA,CAAAU,GAAA;QAAIH,SAAS,EAAC,qCAAqC;QAAAE,QAAA,EAChDP;MAAK,CACJ,CAAC,eAEL,IAAAF,WAAA,CAAAU,GAAA;QAAKH,SAAS,EAAC,kCAAkC;QAAAE,QAAA,EAC9CN;MAAU,CACR,CAAC,eAEN,IAAAH,WAAA,CAAAU,GAAA;QAAKH,SAAS,EAAC,6DAA6D;QAAAE,QAAA,eAC3E,IAAAT,WAAA,CAAAU,GAAA,EAACZ,QAAA,CAAAa,OAAO;UAAAF,QAAA,EAAG,IAAAG,aAAQ,EAAER,eAAgB;QAAC,CAAW;MAAC,CAC9C,CAAC;IAAA,CACF,CAAC,eAEN,IAAAJ,WAAA,CAAAU,GAAA;MAAKH,SAAS,EAAC,oCAAoC;MAAAE,QAAA,eAClD,IAAAT,WAAA,CAAAU,GAAA,EAACd,WAAA,CAAAiB;MACA;MAAA;QACAC,qBAAqB,EAAG,KAAO;QAC/BC,OAAO,EAAC,WAAW;QACnBC,QAAQ,EAAC,GAAG;QACZC,OAAO,EAAGZ,MAAQ;QAAAI,QAAA,EAEhBH;MAAU,CACL;IAAC,CACL,CAAC;EAAA,CACF,CAAC;AAER","ignoreList":[]}
|
|
@@ -64,7 +64,7 @@ const BlockDraggable = ({
|
|
|
64
64
|
getBlockType: _getBlockType
|
|
65
65
|
};
|
|
66
66
|
}, [clientIds]);
|
|
67
|
-
const
|
|
67
|
+
const isDraggingRef = (0, _element.useRef)(false);
|
|
68
68
|
const [startScrolling, scrollOnDragOver, stopScrolling] = (0, _useScrollWhenDragging.default)();
|
|
69
69
|
const {
|
|
70
70
|
getAllowedBlocks,
|
|
@@ -79,7 +79,7 @@ const BlockDraggable = ({
|
|
|
79
79
|
// Stop dragging blocks if the block draggable is unmounted.
|
|
80
80
|
(0, _element.useEffect)(() => {
|
|
81
81
|
return () => {
|
|
82
|
-
if (
|
|
82
|
+
if (isDraggingRef.current) {
|
|
83
83
|
stopDraggingBlocks();
|
|
84
84
|
}
|
|
85
85
|
};
|
|
@@ -159,7 +159,7 @@ const BlockDraggable = ({
|
|
|
159
159
|
// frame to enable dragging.
|
|
160
160
|
window.requestAnimationFrame(() => {
|
|
161
161
|
startDraggingBlocks(clientIds);
|
|
162
|
-
|
|
162
|
+
isDraggingRef.current = true;
|
|
163
163
|
startScrolling(event);
|
|
164
164
|
if (onDragStart) {
|
|
165
165
|
onDragStart();
|
|
@@ -169,7 +169,7 @@ const BlockDraggable = ({
|
|
|
169
169
|
onDragOver: scrollOnDragOver,
|
|
170
170
|
onDragEnd: () => {
|
|
171
171
|
stopDraggingBlocks();
|
|
172
|
-
|
|
172
|
+
isDraggingRef.current = false;
|
|
173
173
|
stopScrolling();
|
|
174
174
|
if (onDragEnd) {
|
|
175
175
|
onDragEnd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_components","_data","_element","_compose","_draggableChip","_interopRequireDefault","_useScrollWhenDragging","_store","_useBlockRefs","_useBlockDropZone","_jsxRuntime","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","useSelect","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","blockEditorStore","_getBlockType","getActiveBlockVariation","blocksStore","rootClientId","blockName","variation","isDragging","useRef","startScrolling","scrollOnDragOver","stopScrolling","useScrollWhenDragging","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","useDispatch","useEffect","current","blockEl","useBlockElement","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","isDropTargetValid","window","document","body","classList","add","remove","throttledOnDragOver","throttle","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","jsx","Draggable","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","default","count","onDraggableStart","onDraggableEnd","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockEl = useBlockElement( clientIds[ 0 ] );\n\tconst editorRoot = blockEl?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,cAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AAA2D,IAAAW,WAAA,GAAAX,OAAA;AAhB3D;AACA;AACA;;AAOA;AACA;AACA;;AAOA,MAAMY,cAAc,GAAGA,CAAE;EACxBC,qBAAqB;EACrBC,QAAQ;EACRC,SAAS;EACTC,cAAc;EACdC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC,gBAAgB,GAAG,KAAK;EACxBC;AACD,CAAC,KAAM;EACN,MAAM;IACLC,eAAe;IACfC,WAAW;IACXC,IAAI;IACJC,eAAe;IACfC;EACD,CAAC,GAAG,IAAAC,eAAS,EACVC,MAAM,IAAM;IACb,MAAM;MACLC,aAAa;MACbC,oBAAoB;MACpBC,YAAY;MACZC,kBAAkB;MAClBC;IACD,CAAC,GAAGL,MAAM,CAAEM,YAAiB,CAAC;IAC9B,MAAM;MAAER,YAAY,EAAES,aAAa;MAAEC;IAAwB,CAAC,G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KAAM;MACjB+B,kBAAkB,CAAC,CAAC;MACpBT,UAAU,CAACY,OAAO,GAAG,KAAK;MAE1BR,aAAa,CAAC,CAAC;MAEf,IAAK1B,SAAS,EAAG;QAChBA,SAAS,CAAC,CAAC;MACZ;IACD,CAAG;IACHuE,2BAA2B;IAC1B;IACA;IACArE,aAAa,KAAKsE,SAAS,GAC1BtE,aAAa,gBAEb,IAAAV,WAAA,CAAA2E,GAAA,EAACjF,cAAA,CAAAuF,OAAkB;MAClBC,KAAK,EAAG9E,SAAS,CAACoD,MAAQ;MAC1B3C,IAAI,EAAGA,IAAM;MACbJ,gBAAgB;IAAA,CAChB,CAEF;IACDH,SAAS,EAAGA,SAAW;IAAAH,QAAA,EAErBA,CAAE;MAAEgF,gBAAgB;MAAEC;IAAe,CAAC,KAAM;MAC7C,OAAOjF,QAAQ,CAAE;QAChBoE,SAAS,EAAE,IAAI;QACfhE,WAAW,EAAE4E,gBAAgB;QAC7B3E,SAAS,EAAE4E;MACZ,CAAE,CAAC;IACJ;EAAC,CACS,CAAC;AAEd,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEahF,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_components","_data","_element","_compose","_draggableChip","_interopRequireDefault","_useScrollWhenDragging","_store","_useBlockRefs","_useBlockDropZone","_jsxRuntime","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","useSelect","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","blockEditorStore","_getBlockType","getActiveBlockVariation","blocksStore","rootClientId","blockName","variation","isDraggingRef","useRef","startScrolling","scrollOnDragOver","stopScrolling","useScrollWhenDragging","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","useDispatch","useEffect","current","blockEl","useBlockElement","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","isDropTargetValid","window","document","body","classList","add","remove","throttledOnDragOver","throttle","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","jsx","Draggable","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","default","count","onDraggableStart","onDraggableEnd","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDraggingRef = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDraggingRef.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockEl = useBlockElement( clientIds[ 0 ] );\n\tconst editorRoot = blockEl?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDraggingRef.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDraggingRef.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,cAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AAA2D,IAAAW,WAAA,GAAAX,OAAA;AAhB3D;AACA;AACA;;AAOA;AACA;AACA;;AAOA,MAAMY,cAAc,GAAGA,CAAE;EACxBC,qBAAqB;EACrBC,QAAQ;EACRC,SAAS;EACTC,cAAc;EACdC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC,gBAAgB,GAAG,KAAK;EACxBC;AACD,CAAC,KAAM;EACN,MAAM;IACLC,eAAe;IACfC,WAAW;IACXC,IAAI;IACJC,eAAe;IACfC;EACD,CAAC,GAAG,IAAAC,eAAS,EACVC,MAAM,IAAM;IACb,MAAM;MACLC,aAAa;MACbC,oBAAoB;MACpBC,YAAY;MACZC,kBAAkB;MAClBC;IACD,CAAC,GAAGL,MAAM,CAAEM,YAAiB,CAAC;IAC9B,MAAM;MAAER,YAAY,EAAES,aAAa;MAAEC;IAAwB,CAAC,GAC7DR,MAAM,CAAES,aAAY,CAAC;IACtB,MAAMC,YAAY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CAACY,OAAO,GAAG,KAAK;MAE7BR,aAAa,CAAC,CAAC;MAEf,IAAK1B,SAAS,EAAG;QAChBA,SAAS,CAAC,CAAC;MACZ;IACD,CAAG;IACHuE,2BAA2B;IAC1B;IACA;IACArE,aAAa,KAAKsE,SAAS,GAC1BtE,aAAa,gBAEb,IAAAV,WAAA,CAAA2E,GAAA,EAACjF,cAAA,CAAAuF,OAAkB;MAClBC,KAAK,EAAG9E,SAAS,CAACoD,MAAQ;MAC1B3C,IAAI,EAAGA,IAAM;MACbJ,gBAAgB;IAAA,CAChB,CAEF;IACDH,SAAS,EAAGA,SAAW;IAAAH,QAAA,EAErBA,CAAE;MAAEgF,gBAAgB;MAAEC;IAAe,CAAC,KAAM;MAC7C,OAAOjF,QAAQ,CAAE;QAChBoE,SAAS,EAAE,IAAI;QACfhE,WAAW,EAAE4E,gBAAgB;QAC7B3E,SAAS,EAAE4E;MACZ,CAAE,CAAC;IACJ;EAAC,CACS,CAAC;AAEd,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEahF,cAAc","ignoreList":[]}
|
|
@@ -23,64 +23,64 @@ const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_
|
|
|
23
23
|
* and `onDragEnd` events respectively.
|
|
24
24
|
*/
|
|
25
25
|
function useScrollWhenDragging() {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
26
|
+
const dragStartYRef = (0, _element.useRef)(null);
|
|
27
|
+
const velocityYRef = (0, _element.useRef)(null);
|
|
28
|
+
const scrollParentYRef = (0, _element.useRef)(null);
|
|
29
|
+
const scrollEditorIntervalRef = (0, _element.useRef)(null);
|
|
30
30
|
|
|
31
31
|
// Clear interval when unmounting.
|
|
32
32
|
(0, _element.useEffect)(() => () => {
|
|
33
|
-
if (
|
|
34
|
-
clearInterval(
|
|
35
|
-
|
|
33
|
+
if (scrollEditorIntervalRef.current) {
|
|
34
|
+
clearInterval(scrollEditorIntervalRef.current);
|
|
35
|
+
scrollEditorIntervalRef.current = null;
|
|
36
36
|
}
|
|
37
37
|
}, []);
|
|
38
38
|
const startScrolling = (0, _element.useCallback)(event => {
|
|
39
|
-
|
|
39
|
+
dragStartYRef.current = event.clientY;
|
|
40
40
|
|
|
41
41
|
// Find nearest parent(s) to scroll.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
const newTop =
|
|
42
|
+
scrollParentYRef.current = (0, _dom.getScrollContainer)(event.target);
|
|
43
|
+
scrollEditorIntervalRef.current = setInterval(() => {
|
|
44
|
+
if (scrollParentYRef.current && velocityYRef.current) {
|
|
45
|
+
const newTop = scrollParentYRef.current.scrollTop + velocityYRef.current;
|
|
46
46
|
|
|
47
47
|
// Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
|
|
48
48
|
// Better to use a small scroll interval.
|
|
49
|
-
|
|
49
|
+
scrollParentYRef.current.scroll({
|
|
50
50
|
top: newTop
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}, SCROLL_INTERVAL_MS);
|
|
54
54
|
}, []);
|
|
55
55
|
const scrollOnDragOver = (0, _element.useCallback)(event => {
|
|
56
|
-
if (!
|
|
56
|
+
if (!scrollParentYRef.current) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
const scrollParentHeight =
|
|
60
|
-
const offsetDragStartPosition =
|
|
61
|
-
const offsetDragPosition = event.clientY -
|
|
59
|
+
const scrollParentHeight = scrollParentYRef.current.offsetHeight;
|
|
60
|
+
const offsetDragStartPosition = dragStartYRef.current - scrollParentYRef.current.offsetTop;
|
|
61
|
+
const offsetDragPosition = event.clientY - scrollParentYRef.current.offsetTop;
|
|
62
62
|
if (event.clientY > offsetDragStartPosition) {
|
|
63
63
|
// User is dragging downwards.
|
|
64
64
|
const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
|
|
65
65
|
const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
|
|
66
66
|
const distancePercentage = moveableDistance === 0 || dragDistance === 0 ? 0 : dragDistance / moveableDistance;
|
|
67
|
-
|
|
67
|
+
velocityYRef.current = VELOCITY_MULTIPLIER * distancePercentage;
|
|
68
68
|
} else if (event.clientY < offsetDragStartPosition) {
|
|
69
69
|
// User is dragging upwards.
|
|
70
70
|
const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
|
|
71
71
|
const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
|
|
72
72
|
const distancePercentage = moveableDistance === 0 || dragDistance === 0 ? 0 : dragDistance / moveableDistance;
|
|
73
|
-
|
|
73
|
+
velocityYRef.current = -VELOCITY_MULTIPLIER * distancePercentage;
|
|
74
74
|
} else {
|
|
75
|
-
|
|
75
|
+
velocityYRef.current = 0;
|
|
76
76
|
}
|
|
77
77
|
}, []);
|
|
78
78
|
const stopScrolling = () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
clearInterval(
|
|
83
|
-
|
|
79
|
+
dragStartYRef.current = null;
|
|
80
|
+
scrollParentYRef.current = null;
|
|
81
|
+
if (scrollEditorIntervalRef.current) {
|
|
82
|
+
clearInterval(scrollEditorIntervalRef.current);
|
|
83
|
+
scrollEditorIntervalRef.current = null;
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
return [startScrolling, scrollOnDragOver, stopScrolling];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dom","require","_element","SCROLL_INACTIVE_DISTANCE_PX","SCROLL_INTERVAL_MS","PIXELS_PER_SECOND_PER_PERCENTAGE","VELOCITY_MULTIPLIER","useScrollWhenDragging","
|
|
1
|
+
{"version":3,"names":["_dom","require","_element","SCROLL_INACTIVE_DISTANCE_PX","SCROLL_INTERVAL_MS","PIXELS_PER_SECOND_PER_PERCENTAGE","VELOCITY_MULTIPLIER","useScrollWhenDragging","dragStartYRef","useRef","velocityYRef","scrollParentYRef","scrollEditorIntervalRef","useEffect","current","clearInterval","startScrolling","useCallback","event","clientY","getScrollContainer","target","setInterval","newTop","scrollTop","scroll","top","scrollOnDragOver","scrollParentHeight","offsetHeight","offsetDragStartPosition","offsetTop","offsetDragPosition","moveableDistance","Math","max","dragDistance","distancePercentage","stopScrolling"],"sources":["@wordpress/block-editor/src/components/block-draggable/use-scroll-when-dragging.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\n\nconst SCROLL_INACTIVE_DISTANCE_PX = 50;\nconst SCROLL_INTERVAL_MS = 25;\nconst PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;\nconst VELOCITY_MULTIPLIER =\n\tPIXELS_PER_SECOND_PER_PERCENTAGE * ( SCROLL_INTERVAL_MS / 1000 );\n\n/**\n * React hook that scrolls the scroll container when a block is being dragged.\n *\n * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`\n * functions to be called in `onDragStart`, `onDragOver`\n * and `onDragEnd` events respectively.\n */\nexport default function useScrollWhenDragging() {\n\tconst dragStartYRef = useRef( null );\n\tconst velocityYRef = useRef( null );\n\tconst scrollParentYRef = useRef( null );\n\tconst scrollEditorIntervalRef = useRef( null );\n\n\t// Clear interval when unmounting.\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif ( scrollEditorIntervalRef.current ) {\n\t\t\t\tclearInterval( scrollEditorIntervalRef.current );\n\t\t\t\tscrollEditorIntervalRef.current = null;\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tconst startScrolling = useCallback( ( event ) => {\n\t\tdragStartYRef.current = event.clientY;\n\n\t\t// Find nearest parent(s) to scroll.\n\t\tscrollParentYRef.current = getScrollContainer( event.target );\n\n\t\tscrollEditorIntervalRef.current = setInterval( () => {\n\t\t\tif ( scrollParentYRef.current && velocityYRef.current ) {\n\t\t\t\tconst newTop =\n\t\t\t\t\tscrollParentYRef.current.scrollTop + velocityYRef.current;\n\n\t\t\t\t// Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.\n\t\t\t\t// Better to use a small scroll interval.\n\t\t\t\tscrollParentYRef.current.scroll( {\n\t\t\t\t\ttop: newTop,\n\t\t\t\t} );\n\t\t\t}\n\t\t}, SCROLL_INTERVAL_MS );\n\t}, [] );\n\n\tconst scrollOnDragOver = useCallback( ( event ) => {\n\t\tif ( ! scrollParentYRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst scrollParentHeight = scrollParentYRef.current.offsetHeight;\n\t\tconst offsetDragStartPosition =\n\t\t\tdragStartYRef.current - scrollParentYRef.current.offsetTop;\n\t\tconst offsetDragPosition =\n\t\t\tevent.clientY - scrollParentYRef.current.offsetTop;\n\n\t\tif ( event.clientY > offsetDragStartPosition ) {\n\t\t\t// User is dragging downwards.\n\t\t\tconst moveableDistance = Math.max(\n\t\t\t\tscrollParentHeight -\n\t\t\t\t\toffsetDragStartPosition -\n\t\t\t\t\tSCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst dragDistance = Math.max(\n\t\t\t\toffsetDragPosition -\n\t\t\t\t\toffsetDragStartPosition -\n\t\t\t\t\tSCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst distancePercentage =\n\t\t\t\tmoveableDistance === 0 || dragDistance === 0\n\t\t\t\t\t? 0\n\t\t\t\t\t: dragDistance / moveableDistance;\n\t\t\tvelocityYRef.current = VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else if ( event.clientY < offsetDragStartPosition ) {\n\t\t\t// User is dragging upwards.\n\t\t\tconst moveableDistance = Math.max(\n\t\t\t\toffsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst dragDistance = Math.max(\n\t\t\t\toffsetDragStartPosition -\n\t\t\t\t\toffsetDragPosition -\n\t\t\t\t\tSCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst distancePercentage =\n\t\t\t\tmoveableDistance === 0 || dragDistance === 0\n\t\t\t\t\t? 0\n\t\t\t\t\t: dragDistance / moveableDistance;\n\t\t\tvelocityYRef.current = -VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else {\n\t\t\tvelocityYRef.current = 0;\n\t\t}\n\t}, [] );\n\n\tconst stopScrolling = () => {\n\t\tdragStartYRef.current = null;\n\t\tscrollParentYRef.current = null;\n\n\t\tif ( scrollEditorIntervalRef.current ) {\n\t\t\tclearInterval( scrollEditorIntervalRef.current );\n\t\t\tscrollEditorIntervalRef.current = null;\n\t\t}\n\t};\n\n\treturn [ startScrolling, scrollOnDragOver, stopScrolling ];\n}\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,MAAME,2BAA2B,GAAG,EAAE;AACtC,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,gCAAgC,GAAG,IAAI;AAC7C,MAAMC,mBAAmB,GACxBD,gCAAgC,IAAKD,kBAAkB,GAAG,IAAI,CAAE;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,qBAAqBA,CAAA,EAAG;EAC/C,MAAMC,aAAa,GAAG,IAAAC,eAAM,EAAE,IAAK,CAAC;EACpC,MAAMC,YAAY,GAAG,IAAAD,eAAM,EAAE,IAAK,CAAC;EACnC,MAAME,gBAAgB,GAAG,IAAAF,eAAM,EAAE,IAAK,CAAC;EACvC,MAAMG,uBAAuB,GAAG,IAAAH,eAAM,EAAE,IAAK,CAAC;;EAE9C;EACA,IAAAI,kBAAS,EACR,MAAM,MAAM;IACX,IAAKD,uBAAuB,CAACE,OAAO,EAAG;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atch)(_store.store);
|
|
31
31
|
const blockType = (0, _blocks.getBlockType)(name);
|
|
32
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_warning.default, {
|
|
33
|
-
actions: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
33
|
+
actions: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
34
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
35
|
+
, {
|
|
36
|
+
__next40pxDefaultSize: false,
|
|
34
37
|
variant: "secondary",
|
|
35
38
|
onClick: () => selectBlock(originalBlockClientId),
|
|
36
39
|
children: (0, _i18n.__)('Find original')
|
|
37
|
-
}, "find-original"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
40
|
+
}, "find-original"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
41
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
42
|
+
, {
|
|
43
|
+
__next40pxDefaultSize: false,
|
|
38
44
|
variant: "secondary",
|
|
39
45
|
onClick: () => onReplace([]),
|
|
40
46
|
children: (0, _i18n.__)('Remove')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_components","_data","_i18n","_store","_warning","_interopRequireDefault","_jsxRuntime","MultipleUsageWarning","originalBlockClientId","name","onReplace","selectBlock","useDispatch","blockEditorStore","blockType","getBlockType","jsxs","default","actions","jsx","Button","variant","onClick","children","__","title"],"sources":["@wordpress/block-editor/src/components/block-edit/multiple-usage-warning.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { Button } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport Warning from '../warning';\n\nexport function MultipleUsageWarning( {\n\toriginalBlockClientId,\n\tname,\n\tonReplace,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst blockType = getBlockType( name );\n\n\treturn (\n\t\t<Warning\n\t\t\tactions={ [\n\t\t\t\t<Button\n\t\t\t\t\tkey=\"find-original\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => selectBlock( originalBlockClientId ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Find original' ) }\n\t\t\t\t</Button>,\n\t\t\t\t<Button\n\t\t\t\t\tkey=\"remove\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => onReplace( [] ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t</Button>,\n\t\t\t] }\n\t\t>\n\t\t\t<strong>{ blockType?.title }: </strong>\n\t\t\t{ __( 'This block can only be used once.' ) }\n\t\t</Warning>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAiC,IAAAO,WAAA,GAAAP,OAAA;AAZjC;AACA;AACA;;AAMA;AACA;AACA;;AAIO,SAASQ,oBAAoBA,CAAE;EACrCC,qBAAqB;EACrBC,IAAI;EACJC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC;EAAY,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAiB,CAAC;EACvD,MAAMC,SAAS,GAAG,IAAAC,oBAAY,EAAEN,IAAK,CAAC;EAEtC,oBACC,IAAAH,WAAA,CAAAU,IAAA,EAACZ,QAAA,CAAAa,OAAO;IACPC,OAAO,EAAG,cACT,IAAAZ,WAAA,CAAAa,GAAA,EAACnB,WAAA,CAAAoB,
|
|
1
|
+
{"version":3,"names":["_blocks","require","_components","_data","_i18n","_store","_warning","_interopRequireDefault","_jsxRuntime","MultipleUsageWarning","originalBlockClientId","name","onReplace","selectBlock","useDispatch","blockEditorStore","blockType","getBlockType","jsxs","default","actions","jsx","Button","__next40pxDefaultSize","variant","onClick","children","__","title"],"sources":["@wordpress/block-editor/src/components/block-edit/multiple-usage-warning.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { Button } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport Warning from '../warning';\n\nexport function MultipleUsageWarning( {\n\toriginalBlockClientId,\n\tname,\n\tonReplace,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst blockType = getBlockType( name );\n\n\treturn (\n\t\t<Warning\n\t\t\tactions={ [\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tkey=\"find-original\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => selectBlock( originalBlockClientId ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Find original' ) }\n\t\t\t\t</Button>,\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\tkey=\"remove\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => onReplace( [] ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t</Button>,\n\t\t\t] }\n\t\t>\n\t\t\t<strong>{ blockType?.title }: </strong>\n\t\t\t{ __( 'This block can only be used once.' ) }\n\t\t</Warning>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,G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ies
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
+
function BlockStylesPanel({
|
|
39
|
+
clientId
|
|
40
|
+
}) {
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
|
|
42
|
+
title: (0, _i18n.__)('Styles'),
|
|
43
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockStyles.default, {
|
|
44
|
+
clientId: clientId
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
38
48
|
function BlockInspectorLockedBlocks({
|
|
39
49
|
topLevelLockedBlock
|
|
40
50
|
}) {
|
|
@@ -46,6 +56,15 @@ function BlockInspectorLockedBlocks({
|
|
|
46
56
|
} = select(_store.store);
|
|
47
57
|
return getClientIdsOfDescendants(topLevelLockedBlock).filter(clientId => getBlockName(clientId) !== 'core/list-item' && getBlockEditingMode(clientId) === 'contentOnly');
|
|
48
58
|
}, [topLevelLockedBlock]);
|
|
59
|
+
const hasBlockStyles = (0, _data.useSelect)(select => {
|
|
60
|
+
const {
|
|
61
|
+
getBlockName
|
|
62
|
+
} = select(_store.store);
|
|
63
|
+
const {
|
|
64
|
+
getBlockStyles
|
|
65
|
+
} = select(_blocks.store);
|
|
66
|
+
return !!getBlockStyles(getBlockName(topLevelLockedBlock))?.length;
|
|
67
|
+
}, [topLevelLockedBlock]);
|
|
49
68
|
const blockInformation = (0, _useBlockDisplayInformation.default)(topLevelLockedBlock);
|
|
50
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
51
70
|
className: "block-editor-block-inspector",
|
|
@@ -54,7 +73,9 @@ function BlockInspectorLockedBlocks({
|
|
|
54
73
|
className: blockInformation.isSynced && 'is-synced'
|
|
55
74
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockVariationTransforms.default, {
|
|
56
75
|
blockClientId: topLevelLockedBlock
|
|
57
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockInfoSlotFill.default.Slot, {}),
|
|
76
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockInfoSlotFill.default.Slot, {}), hasBlockStyles && /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockStylesPanel, {
|
|
77
|
+
clientId: topLevelLockedBlock
|
|
78
|
+
}), contentClientIds.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
|
|
58
79
|
title: (0, _i18n.__)('Content'),
|
|
59
80
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockQuickNavigation.default, {
|
|
60
81
|
clientIds: contentClientIds
|
|
@@ -223,13 +244,8 @@ const BlockInspectorSingleBlock = ({
|
|
|
223
244
|
blockName: blockName,
|
|
224
245
|
tabs: availableTabs
|
|
225
246
|
}), !showTabs && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
226
|
-
children: [hasBlockStyles && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
227
|
-
|
|
228
|
-
title: (0, _i18n.__)('Styles'),
|
|
229
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockStyles.default, {
|
|
230
|
-
clientId: clientId
|
|
231
|
-
})
|
|
232
|
-
})
|
|
247
|
+
children: [hasBlockStyles && /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockStylesPanel, {
|
|
248
|
+
clientId: clientId
|
|
233
249
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default.Slot, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default.Slot, {
|
|
234
250
|
group: "list"
|
|
235
251
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default.Slot, {
|
|
@@ -250,7 +266,9 @@ const BlockInspectorSingleBlock = ({
|
|
|
250
266
|
label: borderPanelLabel
|
|
251
267
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default.Slot, {
|
|
252
268
|
group: "styles"
|
|
253
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_positionControlsPanel.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
269
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_positionControlsPanel.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorControls.default.Slot, {
|
|
270
|
+
group: "bindings"
|
|
271
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
254
272
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_advancedControlsPanel.default, {})
|
|
255
273
|
})]
|
|
256
274
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_skipToSelectedBlock.default, {}, "back")]
|