@wordpress/block-editor 7.0.4 → 8.0.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 +11 -0
- package/README.md +31 -0
- package/build/components/alignment-control/ui.js +1 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +8 -47
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -2
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +27 -15
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +20 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -45
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +88 -35
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +19 -6
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +12 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +49 -23
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +92 -73
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +39 -16
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +1 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +8 -58
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +2 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/duotone.js +16 -5
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +37 -16
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +120 -28
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +303 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -35
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +12 -53
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +5 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +23 -15
- package/build-module/components/font-appearance-control/index.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/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -46
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +88 -36
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +19 -7
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +11 -3
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +49 -24
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +92 -73
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +41 -18
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +1 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +2 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +33 -16
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +124 -32
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +266 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +42 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +160 -57
- package/build-style/style.css +160 -57
- package/package.json +13 -14
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
- package/src/components/alignment-control/ui.js +1 -4
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-inspector/index.js +5 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
- package/src/components/colors-gradients/control.js +19 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
- package/src/components/colors-gradients/style.scss +3 -14
- package/src/components/colors-gradients/test/control.js +0 -16
- package/src/components/duotone-control/index.js +6 -0
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/font-appearance-control/index.js +22 -14
- package/src/components/iframe/index.js +1 -1
- package/src/components/index.js +3 -4
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/index.js +4 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -80
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/style.scss +64 -1
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +7 -0
- package/src/components/link-control/index.js +99 -34
- package/src/components/link-control/link-preview.js +21 -9
- package/src/components/link-control/search-input.js +9 -3
- package/src/components/link-control/style.scss +32 -16
- package/src/components/link-control/test/index.js +179 -4
- package/src/components/list-view/block.js +67 -23
- package/src/components/list-view/branch.js +113 -91
- package/src/components/list-view/index.js +58 -19
- package/src/components/list-view/leaf.js +1 -1
- package/src/components/list-view/style.scss +14 -3
- package/src/components/list-view/use-list-view-client-ids.js +7 -66
- package/src/components/rich-text/embed-handler-picker.native.js +1 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +3 -0
- package/src/components/url-input/index.js +14 -4
- package/src/components/use-setting/index.js +49 -11
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +1 -0
- package/src/hooks/duotone.js +21 -7
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +29 -13
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +3 -1
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +137 -41
- package/src/store/actions.js +223 -391
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +36 -18
- package/src/store/selectors.js +52 -47
- package/src/store/test/actions.js +395 -694
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +127 -167
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -42,12 +42,10 @@ var _store = require("../../store");
|
|
|
42
42
|
*/
|
|
43
43
|
function ListViewBlock({
|
|
44
44
|
block,
|
|
45
|
-
isSelected,
|
|
46
45
|
isDragged,
|
|
46
|
+
isSelected,
|
|
47
47
|
isBranchSelected,
|
|
48
|
-
|
|
49
|
-
onClick,
|
|
50
|
-
onToggleExpanded,
|
|
48
|
+
selectBlock,
|
|
51
49
|
position,
|
|
52
50
|
level,
|
|
53
51
|
rowCount,
|
|
@@ -64,16 +62,19 @@ function ListViewBlock({
|
|
|
64
62
|
const {
|
|
65
63
|
toggleBlockHighlight
|
|
66
64
|
} = (0, _data.useDispatch)(_store.store);
|
|
65
|
+
const {
|
|
66
|
+
__experimentalFeatures: withExperimentalFeatures,
|
|
67
|
+
__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
|
|
68
|
+
__experimentalHideContainerBlockActions: hideContainerBlockActions,
|
|
69
|
+
isTreeGridMounted,
|
|
70
|
+
expand,
|
|
71
|
+
collapse
|
|
72
|
+
} = (0, _context.useListViewContext)();
|
|
67
73
|
const hasSiblings = siblingBlockCount > 0;
|
|
68
74
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
69
75
|
const moverCellClassName = (0, _classnames.default)('block-editor-list-view-block__mover-cell', {
|
|
70
76
|
'is-visible': isHovered || isSelected
|
|
71
77
|
});
|
|
72
|
-
const {
|
|
73
|
-
__experimentalFeatures: withExperimentalFeatures,
|
|
74
|
-
__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
|
|
75
|
-
isTreeGridMounted
|
|
76
|
-
} = (0, _context.useListViewContext)();
|
|
77
78
|
const listViewBlockSettingsClassName = (0, _classnames.default)('block-editor-list-view-block__menu-cell', {
|
|
78
79
|
'is-visible': isHovered || isSelected
|
|
79
80
|
}); // If ListView has experimental features related to the Persistent List View,
|
|
@@ -86,22 +87,43 @@ function ListViewBlock({
|
|
|
86
87
|
}
|
|
87
88
|
}, []);
|
|
88
89
|
const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {};
|
|
89
|
-
|
|
90
|
-
const onMouseEnter = () => {
|
|
90
|
+
const onMouseEnter = (0, _element.useCallback)(() => {
|
|
91
91
|
setIsHovered(true);
|
|
92
92
|
highlightBlock(clientId, true);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const onMouseLeave = () => {
|
|
93
|
+
}, [clientId, setIsHovered, highlightBlock]);
|
|
94
|
+
const onMouseLeave = (0, _element.useCallback)(() => {
|
|
96
95
|
setIsHovered(false);
|
|
97
96
|
highlightBlock(clientId, false);
|
|
98
|
-
};
|
|
97
|
+
}, [clientId, setIsHovered, highlightBlock]);
|
|
98
|
+
const selectEditorBlock = (0, _element.useCallback)(event => {
|
|
99
|
+
event.stopPropagation();
|
|
100
|
+
selectBlock(clientId);
|
|
101
|
+
}, [clientId, selectBlock]);
|
|
102
|
+
const toggleExpanded = (0, _element.useCallback)(event => {
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
|
|
105
|
+
if (isExpanded === true) {
|
|
106
|
+
collapse(clientId);
|
|
107
|
+
} else if (isExpanded === false) {
|
|
108
|
+
expand(clientId);
|
|
109
|
+
}
|
|
110
|
+
}, [clientId, expand, collapse, isExpanded]);
|
|
111
|
+
const showBlockActions = withExperimentalFeatures && ( //hide actions for blocks like core/widget-areas
|
|
112
|
+
!hideContainerBlockActions || hideContainerBlockActions && level > 1);
|
|
113
|
+
const hideBlockActions = withExperimentalFeatures && !showBlockActions;
|
|
114
|
+
let colSpan;
|
|
115
|
+
|
|
116
|
+
if (hasRenderedMovers) {
|
|
117
|
+
colSpan = 2;
|
|
118
|
+
} else if (hideBlockActions) {
|
|
119
|
+
colSpan = 3;
|
|
120
|
+
}
|
|
99
121
|
|
|
100
122
|
const classes = (0, _classnames.default)({
|
|
101
123
|
'is-selected': isSelected,
|
|
102
124
|
'is-branch-selected': withExperimentalPersistentListViewFeatures && isBranchSelected,
|
|
103
|
-
'is-
|
|
104
|
-
'
|
|
125
|
+
'is-dragging': isDragged,
|
|
126
|
+
'has-single-cell': hideBlockActions
|
|
105
127
|
});
|
|
106
128
|
return (0, _element.createElement)(_leaf.default, {
|
|
107
129
|
className: classes,
|
|
@@ -118,7 +140,7 @@ function ListViewBlock({
|
|
|
118
140
|
isExpanded: isExpanded
|
|
119
141
|
}, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
120
142
|
className: "block-editor-list-view-block__contents-cell",
|
|
121
|
-
colSpan:
|
|
143
|
+
colSpan: colSpan,
|
|
122
144
|
ref: cellRef
|
|
123
145
|
}, ({
|
|
124
146
|
ref,
|
|
@@ -128,8 +150,8 @@ function ListViewBlock({
|
|
|
128
150
|
className: "block-editor-list-view-block__contents-container"
|
|
129
151
|
}, (0, _element.createElement)(_blockContents.default, {
|
|
130
152
|
block: block,
|
|
131
|
-
onClick:
|
|
132
|
-
onToggleExpanded:
|
|
153
|
+
onClick: selectEditorBlock,
|
|
154
|
+
onToggleExpanded: toggleExpanded,
|
|
133
155
|
isSelected: isSelected,
|
|
134
156
|
position: position,
|
|
135
157
|
siblingBlockCount: siblingBlockCount,
|
|
@@ -160,7 +182,7 @@ function ListViewBlock({
|
|
|
160
182
|
ref: ref,
|
|
161
183
|
tabIndex: tabIndex,
|
|
162
184
|
onFocus: onFocus
|
|
163
|
-
})))),
|
|
185
|
+
})))), showBlockActions && (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
164
186
|
className: listViewBlockSettingsClassName
|
|
165
187
|
}, ({
|
|
166
188
|
ref,
|
|
@@ -176,7 +198,11 @@ function ListViewBlock({
|
|
|
176
198
|
onFocus
|
|
177
199
|
},
|
|
178
200
|
disableOpenOnArrowDown: true,
|
|
179
|
-
__experimentalSelectBlock:
|
|
201
|
+
__experimentalSelectBlock: selectEditorBlock
|
|
180
202
|
})));
|
|
181
203
|
}
|
|
204
|
+
|
|
205
|
+
var _default = (0, _element.memo)(ListViewBlock);
|
|
206
|
+
|
|
207
|
+
exports.default = _default;
|
|
182
208
|
//# sourceMappingURL=block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["ListViewBlock","block","isSelected","isDragged","isBranchSelected","isLastOfSelectedBranch","onClick","onToggleExpanded","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","toggleBlockHighlight","blockEditorStore","hasSiblings","hasRenderedMovers","moverCellClassName","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","isTreeGridMounted","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","classes","undefined","ref","tabIndex","onFocus","moreVertical","className"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AAIA;;AAEA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AAC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ACbH,MAAAA,GADa;AAEbI,MAAAA,SAAS,EAAE,oCAFE;AAGbH,MAAAA,QAHa;AAIbC,MAAAA;AAJa,KAHf;AASC,IAAA,sBAAsB,MATvB;AAUC,IAAA,yBAAyB,EAAGjC;AAV7B,IAFF,CArEF,CADD;AAyFA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\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 { store as blockEditorStore } from '../../store';\n\nexport default function ListViewBlock( {\n\tblock,\n\tisSelected,\n\tisDragged,\n\tisBranchSelected,\n\tisLastOfSelectedBranch,\n\tonClick,\n\tonToggleExpanded,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\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\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\tisTreeGridMounted,\n\t} = useListViewContext();\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\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 (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t};\n\tconst onMouseLeave = () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t};\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-last-of-selected-branch':\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\tisLastOfSelectedBranch,\n\t\t'is-dragging': isDragged,\n\t} );\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={ isExpanded }\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={ hasRenderedMovers ? undefined : 2 }\n\t\t\t\tref={ cellRef }\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={ onClick }\n\t\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\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/>\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{ withExperimentalFeatures && (\n\t\t\t\t<TreeGridCell className={ listViewBlockSettingsClassName }>\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={ [ clientId ] }\n\t\t\t\t\t\t\ticon={ moreVertical }\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={ onClick }\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","toggleBlockHighlight","blockEditorStore","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","hideContainerBlockActions","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","selectEditorBlock","event","stopPropagation","toggleExpanded","showBlockActions","hideBlockActions","colSpan","classes","ref","tabIndex","onFocus","moreVertical","className"],"mappings":";;;;;;;;;AAaA;;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UC,IAAA,yBAAyB,EAAGV;AAV7B,IAFF,CArEF,CADD;AAyFA;;eAEc,mBAAMrC,aAAN,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\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 { store as blockEditorStore } from '../../store';\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} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions: hideContainerBlockActions,\n\t\tisTreeGridMounted,\n\t\texpand,\n\t\tcollapse,\n\t} = 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 || isSelected }\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 (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tevent.stopPropagation();\n\t\t\tselectBlock( clientId );\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\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\tconst showBlockActions =\n\t\twithExperimentalFeatures &&\n\t\t//hide actions for blocks like core/widget-areas\n\t\t( ! hideContainerBlockActions ||\n\t\t\t( hideContainerBlockActions && level > 1 ) );\n\n\tconst hideBlockActions = withExperimentalFeatures && ! showBlockActions;\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( hideBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': hideBlockActions,\n\t} );\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={ isExpanded }\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>\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={ selectEditorBlock }\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/>\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 className={ listViewBlockSettingsClassName }>\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={ [ clientId ] }\n\t\t\t\t\t\t\ticon={ moreVertical }\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={ selectEditorBlock }\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"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -15,12 +15,10 @@ var _data = require("@wordpress/data");
|
|
|
15
15
|
|
|
16
16
|
var _block = _interopRequireDefault(require("./block"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _context = require("./context");
|
|
19
19
|
|
|
20
20
|
var _utils = require("./utils");
|
|
21
21
|
|
|
22
|
-
var _context = require("./context");
|
|
23
|
-
|
|
24
22
|
/**
|
|
25
23
|
* External dependencies
|
|
26
24
|
*/
|
|
@@ -32,121 +30,142 @@ var _context = require("./context");
|
|
|
32
30
|
/**
|
|
33
31
|
* Internal dependencies
|
|
34
32
|
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Given a block, returns the total number of blocks in that subtree. This is used to help determine
|
|
36
|
+
* the list position of a block.
|
|
37
|
+
*
|
|
38
|
+
* When a block is collapsed, we do not count their children as part of that total. In the current drag
|
|
39
|
+
* implementation dragged blocks and their children are not counted.
|
|
40
|
+
*
|
|
41
|
+
* @param {Object} block block tree
|
|
42
|
+
* @param {Object} expandedState state that notes which branches are collapsed
|
|
43
|
+
* @param {Array} draggedClientIds a list of dragged client ids
|
|
44
|
+
* @return {number} block count
|
|
45
|
+
*/
|
|
46
|
+
function countBlocks(block, expandedState, draggedClientIds) {
|
|
47
|
+
var _expandedState$block$;
|
|
48
|
+
|
|
49
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
50
|
+
|
|
51
|
+
if (isDragged) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : true;
|
|
56
|
+
|
|
57
|
+
if (isExpanded) {
|
|
58
|
+
return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds), 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const countReducer = (expandedState, draggedClientIds) => (count, block) => {
|
|
65
|
+
var _expandedState$block$2;
|
|
66
|
+
|
|
67
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
68
|
+
|
|
69
|
+
if (isDragged) {
|
|
70
|
+
return count;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : true;
|
|
74
|
+
|
|
75
|
+
if (isExpanded && block.innerBlocks.length > 0) {
|
|
76
|
+
return count + countBlocks(block, expandedState, draggedClientIds);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return count + 1;
|
|
80
|
+
};
|
|
81
|
+
|
|
35
82
|
function ListViewBranch(props) {
|
|
36
83
|
const {
|
|
37
84
|
blocks,
|
|
38
85
|
selectBlock,
|
|
39
|
-
showAppender,
|
|
40
86
|
showBlockMovers,
|
|
41
87
|
showNestedBlocks,
|
|
42
|
-
|
|
88
|
+
selectedClientIds,
|
|
43
89
|
level = 1,
|
|
44
|
-
|
|
45
|
-
path = [],
|
|
90
|
+
path = '',
|
|
46
91
|
isBranchSelected = false,
|
|
47
|
-
|
|
92
|
+
listPosition = 0,
|
|
93
|
+
fixedListWindow
|
|
48
94
|
} = props;
|
|
49
95
|
const {
|
|
50
96
|
expandedState,
|
|
51
|
-
expand,
|
|
52
|
-
collapse,
|
|
53
97
|
draggedClientIds,
|
|
54
|
-
|
|
98
|
+
__experimentalPersistentListViewFeatures
|
|
55
99
|
} = (0, _context.useListViewContext)();
|
|
56
|
-
const isTreeRoot = !parentBlockClientId;
|
|
57
100
|
const filteredBlocks = (0, _lodash.compact)(blocks);
|
|
58
|
-
|
|
59
|
-
const itemHasAppender = parentClientId => showAppender && !isTreeRoot && (0, _utils.isClientIdSelected)(parentClientId, selectedClientIds);
|
|
60
|
-
|
|
61
|
-
const hasAppender = itemHasAppender(parentBlockClientId); // Add +1 to the rowCount to take the block appender into account.
|
|
62
|
-
|
|
63
101
|
const blockCount = filteredBlocks.length;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _lodash.map)(filteredBlocks, (block, index) => {
|
|
102
|
+
let nextPosition = listPosition;
|
|
103
|
+
return (0, _element.createElement)(_element.Fragment, null, filteredBlocks.map((block, index) => {
|
|
67
104
|
var _expandedState$client;
|
|
68
105
|
|
|
69
106
|
const {
|
|
70
107
|
clientId,
|
|
71
108
|
innerBlocks
|
|
72
109
|
} = block;
|
|
110
|
+
|
|
111
|
+
if (index > 0) {
|
|
112
|
+
nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const usesWindowing = __experimentalPersistentListViewFeatures;
|
|
116
|
+
const {
|
|
117
|
+
itemInView
|
|
118
|
+
} = fixedListWindow;
|
|
119
|
+
const blockInView = !usesWindowing || itemInView(nextPosition);
|
|
73
120
|
const position = index + 1;
|
|
74
|
-
const
|
|
75
|
-
const updatedTerminatedLevels = isLastRowAtLevel ? [...terminatedLevels, level] : terminatedLevels;
|
|
76
|
-
const updatedPath = [...path, position];
|
|
121
|
+
const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
|
|
77
122
|
const hasNestedBlocks = showNestedBlocks && !!innerBlocks && !!innerBlocks.length;
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const isSelectedBranch = isBranchSelected || isSelected && hasNestedBranch; // Logic needed to target the last item of a selected branch which might be deeply nested.
|
|
82
|
-
// This is currently only needed for styling purposes. See: `.is-last-of-selected-branch`.
|
|
83
|
-
|
|
84
|
-
const isLastBlock = index === blockCount - 1;
|
|
85
|
-
const isLast = isSelected || isLastOfBranch && isLastBlock;
|
|
86
|
-
const isLastOfSelectedBranch = isLastOfBranch && !hasNestedBranch && isLastBlock;
|
|
87
|
-
const isExpanded = hasNestedBranch ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : true : undefined;
|
|
88
|
-
|
|
89
|
-
const selectBlockWithClientId = event => {
|
|
90
|
-
event.stopPropagation();
|
|
91
|
-
selectBlock(clientId);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const toggleExpanded = event => {
|
|
95
|
-
event.stopPropagation();
|
|
96
|
-
|
|
97
|
-
if (isExpanded === true) {
|
|
98
|
-
collapse(clientId);
|
|
99
|
-
} else if (isExpanded === false) {
|
|
100
|
-
expand(clientId);
|
|
101
|
-
}
|
|
102
|
-
}; // Make updates to the selected or dragged blocks synchronous,
|
|
123
|
+
const isExpanded = hasNestedBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : true : undefined;
|
|
124
|
+
const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
|
|
125
|
+
const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
|
|
103
126
|
// but asynchronous for any other block.
|
|
104
127
|
|
|
105
|
-
|
|
106
|
-
const
|
|
128
|
+
const isSelected = (0, _utils.isClientIdSelected)(clientId, selectedClientIds);
|
|
129
|
+
const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
|
|
107
130
|
return (0, _element.createElement)(_data.AsyncModeProvider, {
|
|
108
131
|
key: clientId,
|
|
109
132
|
value: !isSelected
|
|
110
|
-
}, (0, _element.createElement)(_block.default, {
|
|
133
|
+
}, showBlock && (0, _element.createElement)(_block.default, {
|
|
111
134
|
block: block,
|
|
112
|
-
|
|
113
|
-
onToggleExpanded: toggleExpanded,
|
|
114
|
-
isDragged: isDragged,
|
|
135
|
+
selectBlock: selectBlock,
|
|
115
136
|
isSelected: isSelected,
|
|
116
137
|
isBranchSelected: isSelectedBranch,
|
|
117
|
-
|
|
138
|
+
isDragged: isDragged,
|
|
118
139
|
level: level,
|
|
119
140
|
position: position,
|
|
120
|
-
rowCount:
|
|
141
|
+
rowCount: blockCount,
|
|
121
142
|
siblingBlockCount: blockCount,
|
|
122
143
|
showBlockMovers: showBlockMovers,
|
|
123
|
-
terminatedLevels: terminatedLevels,
|
|
124
144
|
path: updatedPath,
|
|
125
|
-
isExpanded: isExpanded
|
|
126
|
-
|
|
145
|
+
isExpanded: isExpanded,
|
|
146
|
+
listPosition: nextPosition
|
|
147
|
+
}), !showBlock && (0, _element.createElement)("tr", null, (0, _element.createElement)("td", {
|
|
148
|
+
className: "block-editor-list-view-placeholder"
|
|
149
|
+
})), hasNestedBlocks && isExpanded && !isDragged && (0, _element.createElement)(ListViewBranch, {
|
|
127
150
|
blocks: innerBlocks,
|
|
128
151
|
selectBlock: selectBlock,
|
|
129
|
-
isBranchSelected: isSelectedBranch,
|
|
130
|
-
isLastOfBranch: isLast,
|
|
131
|
-
showAppender: showAppender,
|
|
132
152
|
showBlockMovers: showBlockMovers,
|
|
133
153
|
showNestedBlocks: showNestedBlocks,
|
|
134
|
-
parentBlockClientId: clientId,
|
|
135
154
|
level: level + 1,
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
path: updatedPath,
|
|
156
|
+
listPosition: nextPosition + 1,
|
|
157
|
+
fixedListWindow: fixedListWindow,
|
|
158
|
+
isBranchSelected: isSelectedBranch,
|
|
159
|
+
selectedClientIds: selectedClientIds
|
|
138
160
|
}));
|
|
139
|
-
}), hasAppender && (0, _element.createElement)(_appender.default, {
|
|
140
|
-
parentBlockClientId: parentBlockClientId,
|
|
141
|
-
position: rowCount,
|
|
142
|
-
rowCount: appenderPosition,
|
|
143
|
-
level: level,
|
|
144
|
-
terminatedLevels: terminatedLevels,
|
|
145
|
-
path: [...path, appenderPosition]
|
|
146
161
|
}));
|
|
147
162
|
}
|
|
148
163
|
|
|
149
164
|
ListViewBranch.defaultProps = {
|
|
150
165
|
selectBlock: () => {}
|
|
151
166
|
};
|
|
167
|
+
|
|
168
|
+
var _default = (0, _element.memo)(ListViewBranch);
|
|
169
|
+
|
|
170
|
+
exports.default = _default;
|
|
152
171
|
//# sourceMappingURL=branch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/branch.js"],"names":["countBlocks","block","expandedState","draggedClientIds","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","ListViewBranch","props","blocks","selectBlock","showBlockMovers","showNestedBlocks","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","__experimentalPersistentListViewFeatures","filteredBlocks","blockCount","nextPosition","map","index","usesWindowing","itemInView","blockInView","position","updatedPath","hasNestedBlocks","undefined","showBlock","isSelected","isSelectedBranch","defaultProps"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAAsBC,KAAtB,EAA6BC,aAA7B,EAA4CC,gBAA5C,EAA+D;AAAA;;AAC9D,QAAMC,SAAS,GAAGD,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEE,QAAlB,CAA4BJ,KAAK,CAACK,QAAlC,CAAlB;;AACA,MAAKF,SAAL,EAAiB;AAChB,WA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CAAE;AADQ,CAA9B;;eAIe,mBAAMH,cAAN,C","sourcesContent":["/**\n * External dependencies\n */\nimport { compact } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\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 * @return {number} block count\n */\nfunction countBlocks( block, expandedState, draggedClientIds ) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? true;\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer( expandedState, draggedClientIds ),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer = ( expandedState, draggedClientIds ) => (\n\tcount,\n\tblock\n) => {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn count;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? true;\n\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\treturn count + countBlocks( block, expandedState, draggedClientIds );\n\t}\n\treturn count + 1;\n};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock,\n\t\tshowBlockMovers,\n\t\tshowNestedBlocks,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t} = props;\n\n\tconst {\n\t\texpandedState,\n\t\tdraggedClientIds,\n\t\t__experimentalPersistentListViewFeatures,\n\t} = useListViewContext();\n\n\tconst filteredBlocks = compact( blocks );\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);\n\t\t\t\t}\n\n\t\t\t\tconst usesWindowing = __experimentalPersistentListViewFeatures;\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\n\t\t\t\tconst blockInView =\n\t\t\t\t\t! usesWindowing || 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 =\n\t\t\t\t\tshowNestedBlocks && !! innerBlocks && !! innerBlocks.length;\n\n\t\t\t\tconst isExpanded = hasNestedBlocks\n\t\t\t\t\t? expandedState[ clientId ] ?? true\n\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={ isExpanded }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\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 && isExpanded && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\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\tshowNestedBlocks={ showNestedBlocks }\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/>\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"]}
|
|
@@ -69,29 +69,44 @@ const expanded = (state, action) => {
|
|
|
69
69
|
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
70
70
|
* @param {Function} props.onSelect Block selection callback.
|
|
71
71
|
* @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
|
|
72
|
-
* @param {boolean} props.
|
|
72
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
73
73
|
* @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
|
|
74
74
|
* @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
|
|
75
|
+
* @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
|
|
75
76
|
* @param {Object} ref Forwarded ref
|
|
76
77
|
*/
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
function ListView({
|
|
80
81
|
blocks,
|
|
81
|
-
showOnlyCurrentHierarchy,
|
|
82
82
|
onSelect = noop,
|
|
83
83
|
__experimentalFeatures,
|
|
84
84
|
__experimentalPersistentListViewFeatures,
|
|
85
|
+
__experimentalHideContainerBlockActions,
|
|
86
|
+
showNestedBlocks,
|
|
87
|
+
showBlockMovers,
|
|
85
88
|
...props
|
|
86
89
|
}, ref) {
|
|
87
90
|
const {
|
|
88
91
|
clientIdsTree,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} = (0, _useListViewClientIds.default)(blocks
|
|
92
|
+
draggedClientIds,
|
|
93
|
+
selectedClientIds
|
|
94
|
+
} = (0, _useListViewClientIds.default)(blocks);
|
|
92
95
|
const {
|
|
93
96
|
selectBlock
|
|
94
97
|
} = (0, _data.useDispatch)(_store.store);
|
|
98
|
+
const {
|
|
99
|
+
visibleBlockCount
|
|
100
|
+
} = (0, _data.useSelect)(select => {
|
|
101
|
+
const {
|
|
102
|
+
getGlobalBlockCount,
|
|
103
|
+
getClientIdsOfDescendants
|
|
104
|
+
} = select(_store.store);
|
|
105
|
+
const draggedBlockCount = (draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.length) > 0 ? getClientIdsOfDescendants(draggedClientIds).length + 1 : 0;
|
|
106
|
+
return {
|
|
107
|
+
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount
|
|
108
|
+
};
|
|
109
|
+
}, [draggedClientIds]);
|
|
95
110
|
const selectEditorBlock = (0, _element.useCallback)(clientId => {
|
|
96
111
|
selectBlock(clientId);
|
|
97
112
|
onSelect(clientId);
|
|
@@ -106,7 +121,14 @@ function ListView({
|
|
|
106
121
|
const isMounted = (0, _element.useRef)(false);
|
|
107
122
|
(0, _element.useEffect)(() => {
|
|
108
123
|
isMounted.current = true;
|
|
109
|
-
}, []);
|
|
124
|
+
}, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
125
|
+
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
126
|
+
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
127
|
+
|
|
128
|
+
const [fixedListWindow] = (0, _compose.__experimentalUseFixedWindowList)(elementRef, 36, visibleBlockCount, {
|
|
129
|
+
useWindowing: __experimentalPersistentListViewFeatures,
|
|
130
|
+
windowOverscan: 40
|
|
131
|
+
});
|
|
110
132
|
const expand = (0, _element.useCallback)(clientId => {
|
|
111
133
|
if (!clientId) {
|
|
112
134
|
return;
|
|
@@ -127,29 +149,26 @@ function ListView({
|
|
|
127
149
|
clientId
|
|
128
150
|
});
|
|
129
151
|
}, [setExpandedState]);
|
|
130
|
-
|
|
131
|
-
const expandRow = row => {
|
|
152
|
+
const expandRow = (0, _element.useCallback)(row => {
|
|
132
153
|
var _row$dataset;
|
|
133
154
|
|
|
134
155
|
expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const collapseRow = row => {
|
|
156
|
+
}, [expand]);
|
|
157
|
+
const collapseRow = (0, _element.useCallback)(row => {
|
|
138
158
|
var _row$dataset2;
|
|
139
159
|
|
|
140
160
|
collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
|
|
141
|
-
};
|
|
142
|
-
|
|
161
|
+
}, [collapse]);
|
|
143
162
|
const contextValue = (0, _element.useMemo)(() => ({
|
|
144
163
|
__experimentalFeatures,
|
|
145
164
|
__experimentalPersistentListViewFeatures,
|
|
165
|
+
__experimentalHideContainerBlockActions,
|
|
146
166
|
isTreeGridMounted: isMounted.current,
|
|
147
167
|
draggedClientIds,
|
|
148
|
-
selectedClientIds,
|
|
149
168
|
expandedState,
|
|
150
169
|
expand,
|
|
151
170
|
collapse
|
|
152
|
-
}), [__experimentalFeatures, __experimentalPersistentListViewFeatures, isMounted.current, draggedClientIds,
|
|
171
|
+
}), [__experimentalFeatures, __experimentalPersistentListViewFeatures, __experimentalHideContainerBlockActions, isMounted.current, draggedClientIds, expandedState, expand, collapse]);
|
|
153
172
|
return (0, _element.createElement)(_data.AsyncModeProvider, {
|
|
154
173
|
value: true
|
|
155
174
|
}, (0, _element.createElement)(_dropIndicator.default, {
|
|
@@ -165,7 +184,11 @@ function ListView({
|
|
|
165
184
|
value: contextValue
|
|
166
185
|
}, (0, _element.createElement)(_branch.default, (0, _extends2.default)({
|
|
167
186
|
blocks: clientIdsTree,
|
|
168
|
-
selectBlock: selectEditorBlock
|
|
187
|
+
selectBlock: selectEditorBlock,
|
|
188
|
+
showNestedBlocks: showNestedBlocks,
|
|
189
|
+
showBlockMovers: showBlockMovers,
|
|
190
|
+
fixedListWindow: fixedListWindow,
|
|
191
|
+
selectedClientIds: selectedClientIds
|
|
169
192
|
}, props)))));
|
|
170
193
|
}
|
|
171
194
|
|