@wordpress/block-editor 10.3.0 → 10.5.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 +13 -0
- package/README.md +0 -1
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-list/block.js +3 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -4
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +21 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +12 -2
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +8 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +10 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +72 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +1 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +5 -4
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +26 -18
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +22 -13
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +7 -6
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +23 -22
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +30 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +62 -31
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.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-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-list/block.js +3 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -3
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +21 -11
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +12 -2
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +9 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +10 -4
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +67 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +1 -0
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +6 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +27 -19
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +23 -14
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +7 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +24 -23
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +26 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +59 -31
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -88
- package/build-style/style.css +84 -84
- package/package.json +29 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/style.scss +11 -6
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +1 -0
- package/src/components/block-popover/style.scss +1 -5
- package/src/components/block-preview/index.js +8 -3
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +21 -11
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
- package/src/components/color-palette/test/control.js +1 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +15 -13
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +11 -4
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-list-item/style.scss +2 -0
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
- package/src/components/spacing-sizes-control/style.scss +1 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/border.js +1 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +106 -19
- package/src/hooks/font-size.js +1 -0
- package/src/hooks/layout.js +8 -11
- package/src/hooks/margin.js +23 -17
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +23 -19
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/hooks/utils.js +5 -6
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +44 -39
- package/src/store/actions.js +26 -0
- package/src/store/array.js +1 -6
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +43 -29
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +20 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _blocks = require("@wordpress/blocks");
|
|
15
|
+
|
|
16
|
+
var _components = require("@wordpress/components");
|
|
17
|
+
|
|
18
|
+
var _compose = require("@wordpress/compose");
|
|
19
|
+
|
|
20
|
+
var _icons = require("@wordpress/icons");
|
|
21
|
+
|
|
22
|
+
var _data = require("@wordpress/data");
|
|
23
|
+
|
|
24
|
+
var _i18n = require("@wordpress/i18n");
|
|
25
|
+
|
|
26
|
+
var _leaf = _interopRequireDefault(require("./leaf"));
|
|
27
|
+
|
|
28
|
+
var _button = require("../block-mover/button");
|
|
29
|
+
|
|
30
|
+
var _blockContents = _interopRequireDefault(require("./block-contents"));
|
|
31
|
+
|
|
32
|
+
var _blockSettingsDropdown = _interopRequireDefault(require("../block-settings-menu/block-settings-dropdown"));
|
|
33
|
+
|
|
34
|
+
var _context = require("./context");
|
|
35
|
+
|
|
36
|
+
var _utils = require("./utils");
|
|
37
|
+
|
|
38
|
+
var _store = require("../../store");
|
|
39
|
+
|
|
40
|
+
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
41
|
+
|
|
42
|
+
var _blockLock = require("../block-lock");
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* External dependencies
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* WordPress dependencies
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Internal dependencies
|
|
54
|
+
*/
|
|
55
|
+
function ListViewBlock(_ref) {
|
|
56
|
+
let {
|
|
57
|
+
block,
|
|
58
|
+
isDragged,
|
|
59
|
+
isSelected,
|
|
60
|
+
isBranchSelected,
|
|
61
|
+
selectBlock,
|
|
62
|
+
position,
|
|
63
|
+
level,
|
|
64
|
+
rowCount,
|
|
65
|
+
siblingBlockCount,
|
|
66
|
+
showBlockMovers,
|
|
67
|
+
path,
|
|
68
|
+
isExpanded,
|
|
69
|
+
selectedClientIds,
|
|
70
|
+
preventAnnouncement,
|
|
71
|
+
selectBlockInCanvas
|
|
72
|
+
} = _ref;
|
|
73
|
+
const cellRef = (0, _element.useRef)(null);
|
|
74
|
+
const [isHovered, setIsHovered] = (0, _element.useState)(false);
|
|
75
|
+
const {
|
|
76
|
+
clientId
|
|
77
|
+
} = block;
|
|
78
|
+
const {
|
|
79
|
+
isLocked,
|
|
80
|
+
isContentLocked
|
|
81
|
+
} = (0, _blockLock.useBlockLock)(clientId);
|
|
82
|
+
const forceSelectionContentLock = (0, _data.useSelect)(select => {
|
|
83
|
+
if (isSelected) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!isContentLocked) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return select(_store.store).hasSelectedInnerBlock(clientId, true);
|
|
92
|
+
}, [isContentLocked, clientId, isSelected]);
|
|
93
|
+
const isFirstSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[0] === clientId;
|
|
94
|
+
const isLastSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
|
|
95
|
+
const {
|
|
96
|
+
toggleBlockHighlight
|
|
97
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
98
|
+
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
99
|
+
const blockName = (0, _data.useSelect)(select => select(_store.store).getBlockName(clientId), [clientId]); // When a block hides its toolbar it also hides the block settings menu,
|
|
100
|
+
// since that menu is part of the toolbar in the editor canvas.
|
|
101
|
+
// List View respects this by also hiding the block settings menu.
|
|
102
|
+
|
|
103
|
+
const showBlockActions = (0, _blocks.hasBlockSupport)(blockName, '__experimentalToolbar', true);
|
|
104
|
+
const instanceId = (0, _compose.useInstanceId)(ListViewBlock);
|
|
105
|
+
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
106
|
+
const blockPositionDescription = (0, _utils.getBlockPositionDescription)(position, siblingBlockCount, level);
|
|
107
|
+
let blockAriaLabel = (0, _i18n.__)('Link');
|
|
108
|
+
|
|
109
|
+
if (blockInformation) {
|
|
110
|
+
blockAriaLabel = isLocked ? (0, _i18n.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
111
|
+
(0, _i18n.__)('%s link (locked)'), blockInformation.title) : (0, _i18n.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the block.
|
|
112
|
+
(0, _i18n.__)('%s link'), blockInformation.title);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const settingsAriaLabel = blockInformation ? (0, _i18n.sprintf)( // translators: %s: The title of the block.
|
|
116
|
+
(0, _i18n.__)('Options for %s block'), blockInformation.title) : (0, _i18n.__)('Options');
|
|
117
|
+
const {
|
|
118
|
+
isTreeGridMounted,
|
|
119
|
+
expand,
|
|
120
|
+
collapse
|
|
121
|
+
} = (0, _context.useListViewContext)();
|
|
122
|
+
const hasSiblings = siblingBlockCount > 0;
|
|
123
|
+
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
124
|
+
const moverCellClassName = (0, _classnames.default)('block-editor-list-view-block__mover-cell', {
|
|
125
|
+
'is-visible': isHovered || isSelected
|
|
126
|
+
});
|
|
127
|
+
const listViewBlockSettingsClassName = (0, _classnames.default)('block-editor-list-view-block__menu-cell', {
|
|
128
|
+
'is-visible': isHovered || isFirstSelectedBlock
|
|
129
|
+
}); // If ListView has experimental features related to the Persistent List View,
|
|
130
|
+
// only focus the selected list item on mount; otherwise the list would always
|
|
131
|
+
// try to steal the focus from the editor canvas.
|
|
132
|
+
|
|
133
|
+
(0, _element.useEffect)(() => {
|
|
134
|
+
if (!isTreeGridMounted && isSelected) {
|
|
135
|
+
cellRef.current.focus();
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
const onMouseEnter = (0, _element.useCallback)(() => {
|
|
139
|
+
setIsHovered(true);
|
|
140
|
+
toggleBlockHighlight(clientId, true);
|
|
141
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
142
|
+
const onMouseLeave = (0, _element.useCallback)(() => {
|
|
143
|
+
setIsHovered(false);
|
|
144
|
+
toggleBlockHighlight(clientId, false);
|
|
145
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
146
|
+
const selectEditorBlock = (0, _element.useCallback)(event => {
|
|
147
|
+
selectBlock(event, clientId);
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
}, [clientId, selectBlock]);
|
|
150
|
+
const updateSelection = (0, _element.useCallback)(newClientId => {
|
|
151
|
+
selectBlock(undefined, newClientId);
|
|
152
|
+
}, [selectBlock]);
|
|
153
|
+
const toggleExpanded = (0, _element.useCallback)(event => {
|
|
154
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
event.stopPropagation();
|
|
157
|
+
|
|
158
|
+
if (isExpanded === true) {
|
|
159
|
+
collapse(clientId);
|
|
160
|
+
} else if (isExpanded === false) {
|
|
161
|
+
expand(clientId);
|
|
162
|
+
}
|
|
163
|
+
}, [clientId, expand, collapse, isExpanded]);
|
|
164
|
+
let colSpan;
|
|
165
|
+
|
|
166
|
+
if (hasRenderedMovers) {
|
|
167
|
+
colSpan = 2;
|
|
168
|
+
} else if (!showBlockActions) {
|
|
169
|
+
colSpan = 3;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const classes = (0, _classnames.default)({
|
|
173
|
+
'is-selected': isSelected || forceSelectionContentLock,
|
|
174
|
+
'is-first-selected': isFirstSelectedBlock,
|
|
175
|
+
'is-last-selected': isLastSelectedBlock,
|
|
176
|
+
'is-branch-selected': isBranchSelected,
|
|
177
|
+
'is-dragging': isDragged,
|
|
178
|
+
'has-single-cell': !showBlockActions
|
|
179
|
+
}); // Only include all selected blocks if the currently clicked on block
|
|
180
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
181
|
+
// to alter a block that isn't part of the selection, they're still able
|
|
182
|
+
// to do so.
|
|
183
|
+
|
|
184
|
+
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
185
|
+
return (0, _element.createElement)(_leaf.default, {
|
|
186
|
+
className: classes,
|
|
187
|
+
onMouseEnter: onMouseEnter,
|
|
188
|
+
onMouseLeave: onMouseLeave,
|
|
189
|
+
onFocus: onMouseEnter,
|
|
190
|
+
onBlur: onMouseLeave,
|
|
191
|
+
level: level,
|
|
192
|
+
position: position,
|
|
193
|
+
rowCount: rowCount,
|
|
194
|
+
path: path,
|
|
195
|
+
id: `list-view-block-${clientId}`,
|
|
196
|
+
"data-block": clientId,
|
|
197
|
+
isExpanded: isContentLocked ? undefined : isExpanded,
|
|
198
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
199
|
+
}, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
200
|
+
className: "block-editor-list-view-block__contents-cell",
|
|
201
|
+
colSpan: colSpan,
|
|
202
|
+
ref: cellRef,
|
|
203
|
+
"aria-label": blockAriaLabel,
|
|
204
|
+
"aria-selected": !!isSelected || forceSelectionContentLock,
|
|
205
|
+
"aria-expanded": isContentLocked ? undefined : isExpanded,
|
|
206
|
+
"aria-describedby": descriptionId
|
|
207
|
+
}, _ref2 => {
|
|
208
|
+
let {
|
|
209
|
+
ref,
|
|
210
|
+
tabIndex,
|
|
211
|
+
onFocus
|
|
212
|
+
} = _ref2;
|
|
213
|
+
return (0, _element.createElement)("div", {
|
|
214
|
+
className: "block-editor-list-view-block__contents-container"
|
|
215
|
+
}, (0, _element.createElement)(_blockContents.default, {
|
|
216
|
+
block: block,
|
|
217
|
+
onClick: selectBlockInCanvas ? selectEditorBlock : event => {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
},
|
|
220
|
+
onToggleExpanded: toggleExpanded,
|
|
221
|
+
isSelected: isSelected,
|
|
222
|
+
position: position,
|
|
223
|
+
siblingBlockCount: siblingBlockCount,
|
|
224
|
+
level: level,
|
|
225
|
+
ref: ref,
|
|
226
|
+
tabIndex: tabIndex,
|
|
227
|
+
onFocus: onFocus,
|
|
228
|
+
isExpanded: isExpanded,
|
|
229
|
+
selectedClientIds: selectedClientIds,
|
|
230
|
+
preventAnnouncement: preventAnnouncement
|
|
231
|
+
}), (0, _element.createElement)("div", {
|
|
232
|
+
className: "block-editor-list-view-block-select-button__description",
|
|
233
|
+
id: descriptionId
|
|
234
|
+
}, blockPositionDescription));
|
|
235
|
+
}), hasRenderedMovers && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
236
|
+
className: moverCellClassName,
|
|
237
|
+
withoutGridItem: true
|
|
238
|
+
}, (0, _element.createElement)(_components.__experimentalTreeGridItem, null, _ref3 => {
|
|
239
|
+
let {
|
|
240
|
+
ref,
|
|
241
|
+
tabIndex,
|
|
242
|
+
onFocus
|
|
243
|
+
} = _ref3;
|
|
244
|
+
return (0, _element.createElement)(_button.BlockMoverUpButton, {
|
|
245
|
+
orientation: "vertical",
|
|
246
|
+
clientIds: [clientId],
|
|
247
|
+
ref: ref,
|
|
248
|
+
tabIndex: tabIndex,
|
|
249
|
+
onFocus: onFocus
|
|
250
|
+
});
|
|
251
|
+
}), (0, _element.createElement)(_components.__experimentalTreeGridItem, null, _ref4 => {
|
|
252
|
+
let {
|
|
253
|
+
ref,
|
|
254
|
+
tabIndex,
|
|
255
|
+
onFocus
|
|
256
|
+
} = _ref4;
|
|
257
|
+
return (0, _element.createElement)(_button.BlockMoverDownButton, {
|
|
258
|
+
orientation: "vertical",
|
|
259
|
+
clientIds: [clientId],
|
|
260
|
+
ref: ref,
|
|
261
|
+
tabIndex: tabIndex,
|
|
262
|
+
onFocus: onFocus
|
|
263
|
+
});
|
|
264
|
+
}))), showBlockActions && (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
265
|
+
className: listViewBlockSettingsClassName,
|
|
266
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
267
|
+
}, _ref5 => {
|
|
268
|
+
let {
|
|
269
|
+
ref,
|
|
270
|
+
tabIndex,
|
|
271
|
+
onFocus
|
|
272
|
+
} = _ref5;
|
|
273
|
+
return (0, _element.createElement)(_blockSettingsDropdown.default, {
|
|
274
|
+
clientIds: dropdownClientIds,
|
|
275
|
+
icon: _icons.moreVertical,
|
|
276
|
+
label: settingsAriaLabel,
|
|
277
|
+
toggleProps: {
|
|
278
|
+
ref,
|
|
279
|
+
className: 'block-editor-list-view-block__menu',
|
|
280
|
+
tabIndex,
|
|
281
|
+
onFocus
|
|
282
|
+
},
|
|
283
|
+
disableOpenOnArrowDown: true,
|
|
284
|
+
__experimentalSelectBlock: updateSelection
|
|
285
|
+
});
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var _default = (0, _element.memo)(ListViewBlock);
|
|
290
|
+
|
|
291
|
+
exports.default = _default;
|
|
292
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block.js"],"names":["ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","selectBlockInCanvas","cellRef","isHovered","setIsHovered","clientId","isLocked","isContentLocked","forceSelectionContentLock","select","blockEditorStore","hasSelectedInnerBlock","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","blockName","getBlockName","showBlockActions","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","title","settingsAriaLabel","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","onMouseEnter","onMouseLeave","selectEditorBlock","event","preventDefault","updateSelection","newClientId","undefined","toggleExpanded","stopPropagation","colSpan","classes","dropdownClientIds","includes","ref","tabIndex","onFocus","moreVertical","className"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AAIA;;AACA;;AAQA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvCA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAcA,SAASA,aAAT,OAgBI;AAAA,MAhBoB;AACvBC,IAAAA,KADuB;AAEvBC,IAAAA,SAFuB;AAGvBC,IAAAA,UAHuB;AAIvBC,IAAAA,gBAJuB;AAKvBC,IAAAA,WALuB;AAMvBC,IAAAA,QANuB;AAOvBC,IAAAA,KAPuB;AAQvBC,IAAAA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A,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,4BAAC,4BAAD;AACC,MAAA,WAAW,EAAC,UADb;AAEC,MAAA,SAAS,EAAG,CAAE9C,QAAF,CAFb;AAGC,MAAA,GAAG,EAAG4C,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAfD,CADD,CAzDF,EAwFGhC,gBAAgB,IACjB,4BAAC,sCAAD;AACC,IAAA,SAAS,EAAGa,8BADb;AAEC,qBAAgB,CAAC,CAAE3C,UAAH,IAAiBmB;AAFlC,KAIG;AAAA,QAAE;AAAEyC,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,4BAAC,8BAAD;AACC,MAAA,SAAS,EAAGJ,iBADb;AAEC,MAAA,IAAI,EAAGK,mBAFR;AAGC,MAAA,KAAK,EAAG3B,iBAHT;AAIC,MAAA,WAAW,EAAG;AACbwB,QAAAA,GADa;AAEbI,QAAAA,SAAS,EAAE,oCAFE;AAGbH,QAAAA,QAHa;AAIbC,QAAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGX;AAX7B,MADC;AAAA,GAJH,CAzFF,CADD;AAiHA;;eAEc,mBAAMtD,aAAN,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlock( {\n\tblock,\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tpreventAnnouncement,\n\tselectBlockInCanvas,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { isLocked, isContentLocked } = useBlockLock( clientId );\n\tconst forceSelectionContentLock = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isSelected ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif ( ! isContentLocked ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn select( blockEditorStore ).hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\t\t},\n\t\t[ isContentLocked, clientId, isSelected ]\n\t);\n\n\tconst isFirstSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected && selectedClientIds[ 0 ] === clientId );\n\tconst isLastSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected &&\n\t\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId );\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockName = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockName( clientId ),\n\t\t[ clientId ]\n\t);\n\n\t// When a block hides its toolbar it also hides the block settings menu,\n\t// since that menu is part of the toolbar in the editor canvas.\n\t// List View respects this by also hiding the block settings menu.\n\tconst showBlockActions = hasBlockSupport(\n\t\tblockName,\n\t\t'__experimentalToolbar',\n\t\ttrue\n\t);\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tlet blockAriaLabel = __( 'Link' );\n\tif ( blockInformation ) {\n\t\tblockAriaLabel = isLocked\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the locked block.\n\t\t\t\t\t__( '%s link (locked)' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the block.\n\t\t\t\t\t__( '%s link' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t );\n\t}\n\n\tconst settingsAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Options for %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Options' );\n\n\tconst { isTreeGridMounted, expand, collapse } = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif ( ! isTreeGridMounted && isSelected ) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\ttoggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\ttoggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateSelection = useCallback(\n\t\t( newClientId ) => {\n\t\t\tselectBlock( undefined, newClientId );\n\t\t},\n\t\t[ selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected || forceSelectionContentLock,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isContentLocked ? undefined : isExpanded }\n\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-label={ blockAriaLabel }\n\t\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t\t\taria-expanded={ isContentLocked ? undefined : isExpanded }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\tselectBlockInCanvas\n\t\t\t\t\t\t\t\t\t? selectEditorBlock\n\t\t\t\t\t\t\t\t\t: ( event ) => {\n\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tpreventAnnouncement={ preventAnnouncement }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ updateSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
var _block = _interopRequireDefault(require("./block"));
|
|
15
|
+
|
|
16
|
+
var _context = require("./context");
|
|
17
|
+
|
|
18
|
+
var _utils = require("./utils");
|
|
19
|
+
|
|
20
|
+
var _store = require("../../store");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Given a block, returns the total number of blocks in that subtree. This is used to help determine
|
|
32
|
+
* the list position of a block.
|
|
33
|
+
*
|
|
34
|
+
* When a block is collapsed, we do not count their children as part of that total. In the current drag
|
|
35
|
+
* implementation dragged blocks and their children are not counted.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} block block tree
|
|
38
|
+
* @param {Object} expandedState state that notes which branches are collapsed
|
|
39
|
+
* @param {Array} draggedClientIds a list of dragged client ids
|
|
40
|
+
* @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
|
|
41
|
+
* @return {number} block count
|
|
42
|
+
*/
|
|
43
|
+
function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
|
|
44
|
+
var _expandedState$block$;
|
|
45
|
+
|
|
46
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
47
|
+
|
|
48
|
+
if (isDragged) {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
|
|
53
|
+
|
|
54
|
+
if (isExpanded) {
|
|
55
|
+
return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
|
|
62
|
+
var _expandedState$block$2;
|
|
63
|
+
|
|
64
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
65
|
+
|
|
66
|
+
if (isDragged) {
|
|
67
|
+
return count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
|
|
71
|
+
|
|
72
|
+
if (isExpanded && block.innerBlocks.length > 0) {
|
|
73
|
+
return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return count + 1;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function ListViewBranch(props) {
|
|
80
|
+
const {
|
|
81
|
+
blocks,
|
|
82
|
+
selectBlock,
|
|
83
|
+
showBlockMovers,
|
|
84
|
+
selectedClientIds,
|
|
85
|
+
level = 1,
|
|
86
|
+
path = '',
|
|
87
|
+
isBranchSelected = false,
|
|
88
|
+
listPosition = 0,
|
|
89
|
+
fixedListWindow,
|
|
90
|
+
isExpanded,
|
|
91
|
+
parentId,
|
|
92
|
+
shouldShowInnerBlocks = true,
|
|
93
|
+
selectBlockInCanvas
|
|
94
|
+
} = props;
|
|
95
|
+
const isContentLocked = (0, _data.useSelect)(select => {
|
|
96
|
+
return !!(parentId && select(_store.store).getTemplateLock(parentId) === 'contentOnly');
|
|
97
|
+
}, [parentId]);
|
|
98
|
+
const {
|
|
99
|
+
expandedState,
|
|
100
|
+
draggedClientIds
|
|
101
|
+
} = (0, _context.useListViewContext)();
|
|
102
|
+
|
|
103
|
+
if (isContentLocked) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const filteredBlocks = blocks.filter(Boolean);
|
|
108
|
+
const blockCount = filteredBlocks.length;
|
|
109
|
+
let nextPosition = listPosition;
|
|
110
|
+
return (0, _element.createElement)(_element.Fragment, null, filteredBlocks.map((block, index) => {
|
|
111
|
+
var _expandedState$client;
|
|
112
|
+
|
|
113
|
+
const {
|
|
114
|
+
clientId,
|
|
115
|
+
innerBlocks
|
|
116
|
+
} = block;
|
|
117
|
+
|
|
118
|
+
if (index > 0) {
|
|
119
|
+
nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const {
|
|
123
|
+
itemInView
|
|
124
|
+
} = fixedListWindow;
|
|
125
|
+
const blockInView = itemInView(nextPosition);
|
|
126
|
+
const position = index + 1;
|
|
127
|
+
const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
|
|
128
|
+
const hasNestedBlocks = !!(innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length);
|
|
129
|
+
const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
|
|
130
|
+
const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
|
|
131
|
+
const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
|
|
132
|
+
// but asynchronous for any other block.
|
|
133
|
+
|
|
134
|
+
const isSelected = (0, _utils.isClientIdSelected)(clientId, selectedClientIds);
|
|
135
|
+
const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
|
|
136
|
+
return (0, _element.createElement)(_data.AsyncModeProvider, {
|
|
137
|
+
key: clientId,
|
|
138
|
+
value: !isSelected
|
|
139
|
+
}, showBlock && (0, _element.createElement)(_block.default, {
|
|
140
|
+
block: block,
|
|
141
|
+
selectBlock: selectBlock,
|
|
142
|
+
isSelected: isSelected,
|
|
143
|
+
isBranchSelected: isSelectedBranch,
|
|
144
|
+
isDragged: isDragged,
|
|
145
|
+
level: level,
|
|
146
|
+
position: position,
|
|
147
|
+
rowCount: blockCount,
|
|
148
|
+
siblingBlockCount: blockCount,
|
|
149
|
+
showBlockMovers: showBlockMovers,
|
|
150
|
+
path: updatedPath,
|
|
151
|
+
isExpanded: shouldExpand,
|
|
152
|
+
listPosition: nextPosition,
|
|
153
|
+
selectedClientIds: selectedClientIds,
|
|
154
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
155
|
+
}), !showBlock && (0, _element.createElement)("tr", null, (0, _element.createElement)("td", {
|
|
156
|
+
className: "block-editor-list-view-placeholder"
|
|
157
|
+
})), hasNestedBlocks && shouldExpand && !isDragged && (0, _element.createElement)(ListViewBranch, {
|
|
158
|
+
parentId: clientId,
|
|
159
|
+
blocks: innerBlocks,
|
|
160
|
+
selectBlock: selectBlock,
|
|
161
|
+
showBlockMovers: showBlockMovers,
|
|
162
|
+
level: level + 1,
|
|
163
|
+
path: updatedPath,
|
|
164
|
+
listPosition: nextPosition + 1,
|
|
165
|
+
fixedListWindow: fixedListWindow,
|
|
166
|
+
isBranchSelected: isSelectedBranch,
|
|
167
|
+
selectedClientIds: selectedClientIds,
|
|
168
|
+
isExpanded: isExpanded,
|
|
169
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
170
|
+
}));
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
ListViewBranch.defaultProps = {
|
|
175
|
+
selectBlock: () => {}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
var _default = (0, _element.memo)(ListViewBranch);
|
|
179
|
+
|
|
180
|
+
exports.default = _default;
|
|
181
|
+
//# sourceMappingURL=branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/branch.js"],"names":["countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","parentId","shouldShowInnerBlocks","selectBlockInCanvas","isContentLocked","select","blockEditorStore","getTemplateLock","filteredBlocks","filter","Boolean","blockCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","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GA,UATrB;AAUC,MAAA,eAAe,EAAGjB,eAVnB;AAWC,MAAA,IAAI,EAAGwB,WAXR;AAYC,MAAA,UAAU,EAAGE,YAZd;AAaC,MAAA,YAAY,EAAGR,YAbhB;AAcC,MAAA,iBAAiB,EAAGjB,iBAdrB;AAeC,MAAA,mBAAmB,EAAGQ;AAfvB,MAFF,EAoBG,CAAEmB,SAAF,IACD,wCACC;AAAI,MAAA,SAAS,EAAC;AAAd,MADD,CArBF,EAyBGH,eAAe,IAAIC,YAAnB,IAAmC,CAAEvC,SAArC,IACD,4BAAC,cAAD;AACC,MAAA,QAAQ,EAAGE,QADZ;AAEC,MAAA,MAAM,EAAGE,WAFV;AAGC,MAAA,WAAW,EAAGQ,WAHf;AAIC,MAAA,eAAe,EAAGC,eAJnB;AAKC,MAAA,KAAK,EAAGE,KAAK,GAAG,CALjB;AAMC,MAAA,IAAI,EAAGsB,WANR;AAOC,MAAA,YAAY,EAAGN,YAAY,GAAG,CAP/B;AAQC,MAAA,eAAe,EAAGZ,eARnB;AASC,MAAA,gBAAgB,EAAGwB,gBATpB;AAUC,MAAA,iBAAiB,EAAG7B,iBAVrB;AAWC,MAAA,UAAU,EAAGX,UAXd;AAYC,MAAA,mBAAmB,EAAGmB;AAZvB,MA1BF,CADD;AA4CA,GAnFC,CADH,CADD;AAwFA;;AAEDb,cAAc,CAACmC,YAAf,GAA8B;AAC7BhC,EAAAA,WAAW,EAAE,MAAM,CAAE;AADQ,CAA9B;;eAIe,mBAAMH,cAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer =\n\t( expandedState, draggedClientIds, isExpandedByDefault ) =>\n\t( count, block ) => {\n\t\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\t\tif ( isDragged ) {\n\t\t\treturn count;\n\t\t}\n\t\tconst isExpanded =\n\t\t\texpandedState[ block.clientId ] ?? isExpandedByDefault;\n\t\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\t\treturn (\n\t\t\t\tcount +\n\t\t\t\tcountBlocks(\n\t\t\t\t\tblock,\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn count + 1;\n\t};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tshouldShowInnerBlocks = true,\n\t\tselectBlockInCanvas,\n\t} = props;\n\n\tconst isContentLocked = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! (\n\t\t\t\tparentId &&\n\t\t\t\tselect( blockEditorStore ).getTemplateLock( parentId ) ===\n\t\t\t\t\t'contentOnly'\n\t\t\t);\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tif ( isContentLocked ) {\n\t\treturn null;\n\t}\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand =\n\t\t\t\t\thasNestedBlocks && shouldShowInnerBlocks\n\t\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tselectBlockInCanvas={ selectBlockInCanvas }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tselectBlockInCanvas={ selectBlockInCanvas }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nListViewBranch.defaultProps = {\n\tselectBlock: () => {},\n};\n\nexport default memo( ListViewBranch );\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useListViewContext = exports.ListViewContext = void 0;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
13
|
+
const ListViewContext = (0, _element.createContext)({});
|
|
14
|
+
exports.ListViewContext = ListViewContext;
|
|
15
|
+
|
|
16
|
+
const useListViewContext = () => (0, _element.useContext)(ListViewContext);
|
|
17
|
+
|
|
18
|
+
exports.useListViewContext = useListViewContext;
|
|
19
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/context.js"],"names":["ListViewContext","useListViewContext"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,eAAe,GAAG,4BAAe,EAAf,CAAxB;;;AAEA,MAAMC,kBAAkB,GAAG,MAAM,yBAAYD,eAAZ,CAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const ListViewContext = createContext( {} );\n\nexport const useListViewContext = () => useContext( ListViewContext );\n"]}
|