@wordpress/block-editor 10.4.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 +7 -0
- package/README.md +0 -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-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.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/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.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 +7 -5
- package/build/components/font-sizes/with-font-sizes.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 +5 -3
- package/build/components/inner-blocks/index.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/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/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/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/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 +44 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- 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 +4 -2
- 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/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -2
- package/build/store/selectors.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-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.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/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.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 +8 -6
- package/build-module/components/font-sizes/with-font-sizes.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 +5 -3
- package/build-module/components/inner-blocks/index.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/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/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/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/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 +39 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- 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 +4 -2
- 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/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.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 +13 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +39 -26
- package/build-style/style.css +39 -26
- package/package.json +28 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- 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-list/style.scss +10 -5
- 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/style.scss +0 -1
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- 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 +14 -11
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +7 -4
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- 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/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/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/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 +76 -16
- package/src/hooks/layout.js +2 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +16 -9
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +19 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
.block-editor-list-view-tree {
|
|
2
|
+
width: 100%;
|
|
3
|
+
border-collapse: collapse;
|
|
4
|
+
padding: 0;
|
|
5
|
+
margin: 0;
|
|
6
|
+
|
|
7
|
+
// Move upwards when in modal.
|
|
8
|
+
.components-modal__content & {
|
|
9
|
+
margin: (-$grid-unit-15) (-$grid-unit-15 * 0.5) 0;
|
|
10
|
+
width: calc(100% + #{ $grid-unit-15 });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.block-editor-list-view-leaf {
|
|
15
|
+
// Use position relative for row animation.
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
// The background has to be applied to the td, not tr, or border-radius won't work.
|
|
19
|
+
&.is-selected td {
|
|
20
|
+
background: var(--wp-admin-theme-color);
|
|
21
|
+
}
|
|
22
|
+
&.is-selected .block-editor-list-view-block-contents,
|
|
23
|
+
&.is-selected .components-button.has-icon {
|
|
24
|
+
color: $white;
|
|
25
|
+
}
|
|
26
|
+
&.is-selected .block-editor-list-view-block-contents {
|
|
27
|
+
// Hide selection styles while a user is dragging blocks/files etc.
|
|
28
|
+
.is-dragging-components-draggable & {
|
|
29
|
+
background: none;
|
|
30
|
+
color: $gray-900;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
&.is-selected .block-editor-list-view-block-contents:focus {
|
|
34
|
+
&::after {
|
|
35
|
+
box-shadow:
|
|
36
|
+
inset 0 0 0 1px $white,
|
|
37
|
+
0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
&.is-selected .block-editor-list-view-block__menu:focus {
|
|
41
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.is-dragging {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Border radius for corners of the selected item.
|
|
49
|
+
&.is-first-selected td:first-child {
|
|
50
|
+
border-top-left-radius: $radius-block-ui;
|
|
51
|
+
}
|
|
52
|
+
&.is-first-selected td:last-child {
|
|
53
|
+
border-top-right-radius: $radius-block-ui;
|
|
54
|
+
}
|
|
55
|
+
&.is-last-selected td:first-child {
|
|
56
|
+
border-bottom-left-radius: $radius-block-ui;
|
|
57
|
+
}
|
|
58
|
+
&.is-last-selected td:last-child {
|
|
59
|
+
border-bottom-right-radius: $radius-block-ui;
|
|
60
|
+
}
|
|
61
|
+
&.is-branch-selected:not(.is-selected) {
|
|
62
|
+
// Lighten a CSS variable without introducing a new SASS variable
|
|
63
|
+
background:
|
|
64
|
+
linear-gradient(transparentize($white, 0.1), transparentize($white, 0.1)),
|
|
65
|
+
linear-gradient(var(--wp-admin-theme-color), var(--wp-admin-theme-color));
|
|
66
|
+
}
|
|
67
|
+
&.is-branch-selected.is-first-selected td:first-child {
|
|
68
|
+
border-top-left-radius: $radius-block-ui;
|
|
69
|
+
}
|
|
70
|
+
&.is-branch-selected.is-first-selected td:last-child {
|
|
71
|
+
border-top-right-radius: $radius-block-ui;
|
|
72
|
+
}
|
|
73
|
+
&[aria-expanded="false"] {
|
|
74
|
+
&.is-branch-selected.is-first-selected td:first-child {
|
|
75
|
+
border-top-left-radius: $radius-block-ui;
|
|
76
|
+
}
|
|
77
|
+
&.is-branch-selected.is-first-selected td:last-child {
|
|
78
|
+
border-top-right-radius: $radius-block-ui;
|
|
79
|
+
}
|
|
80
|
+
&.is-branch-selected.is-last-selected td:first-child {
|
|
81
|
+
border-bottom-left-radius: $radius-block-ui;
|
|
82
|
+
}
|
|
83
|
+
&.is-branch-selected.is-last-selected td:last-child {
|
|
84
|
+
border-bottom-right-radius: $radius-block-ui;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
&.is-branch-selected:not(.is-selected) td {
|
|
88
|
+
border-radius: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// List View renders a fixed number of items and relies on each item having a fixed height of 36px.
|
|
93
|
+
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
94
|
+
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
95
|
+
.block-editor-list-view-block-contents {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: auto;
|
|
100
|
+
padding: ($grid-unit-15 * 0.5) $grid-unit-05 ($grid-unit-15 * 0.5) 0;
|
|
101
|
+
text-align: left;
|
|
102
|
+
color: $gray-900;
|
|
103
|
+
border-radius: $radius-block-ui;
|
|
104
|
+
position: relative;
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
|
|
107
|
+
&.is-dropping-before::before {
|
|
108
|
+
content: "";
|
|
109
|
+
position: absolute;
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
transition: border-color 0.1s linear, border-style 0.1s linear, box-shadow 0.1s linear;
|
|
112
|
+
top: -2px;
|
|
113
|
+
right: 0;
|
|
114
|
+
left: 0;
|
|
115
|
+
border-top: 4px solid var(--wp-admin-theme-color);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.components-modal__content & {
|
|
119
|
+
padding-left: 0;
|
|
120
|
+
padding-right: 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.block-editor-list-view-block-contents:focus {
|
|
125
|
+
box-shadow: none;
|
|
126
|
+
|
|
127
|
+
&::after {
|
|
128
|
+
content: "";
|
|
129
|
+
position: absolute;
|
|
130
|
+
top: 0;
|
|
131
|
+
right: -(24px + 5px); // Icon size + padding.
|
|
132
|
+
bottom: 0;
|
|
133
|
+
left: 0;
|
|
134
|
+
border-radius: inherit;
|
|
135
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
136
|
+
z-index: 2;
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
|
|
139
|
+
// Hide focus styles while a user is dragging blocks/files etc.
|
|
140
|
+
.is-dragging-components-draggable & {
|
|
141
|
+
box-shadow: none;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Fix focus styling width when one row has fewer cells.
|
|
146
|
+
&.has-single-cell .block-editor-list-view-block-contents:focus::after {
|
|
147
|
+
right: 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.block-editor-list-view-block__menu:focus {
|
|
151
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
152
|
+
z-index: 1;
|
|
153
|
+
|
|
154
|
+
// Hide focus styles while a user is dragging blocks/files etc.
|
|
155
|
+
.is-dragging-components-draggable & {
|
|
156
|
+
box-shadow: none;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&.is-visible .block-editor-list-view-block-contents {
|
|
161
|
+
opacity: 1;
|
|
162
|
+
@include edit-post__fade-in-animation;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.block-editor-block-icon {
|
|
166
|
+
align-self: flex-start;
|
|
167
|
+
margin-right: $grid-unit-10;
|
|
168
|
+
width: $icon-size;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.block-editor-list-view-block__menu-cell,
|
|
172
|
+
.block-editor-list-view-block__mover-cell,
|
|
173
|
+
.block-editor-list-view-block__contents-cell {
|
|
174
|
+
padding-top: 0;
|
|
175
|
+
padding-bottom: 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.block-editor-list-view-block__menu-cell,
|
|
179
|
+
.block-editor-list-view-block__mover-cell {
|
|
180
|
+
line-height: 0;
|
|
181
|
+
width: $button-size;
|
|
182
|
+
vertical-align: middle;
|
|
183
|
+
@include reduce-motion("transition");
|
|
184
|
+
|
|
185
|
+
> * {
|
|
186
|
+
opacity: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Show on hover, visible, and show above to keep the hit area size.
|
|
190
|
+
&:hover,
|
|
191
|
+
&.is-visible {
|
|
192
|
+
position: relative;
|
|
193
|
+
z-index: 1;
|
|
194
|
+
|
|
195
|
+
> * {
|
|
196
|
+
opacity: 1;
|
|
197
|
+
@include edit-post__fade-in-animation;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&,
|
|
202
|
+
.components-button.has-icon {
|
|
203
|
+
width: 24px;
|
|
204
|
+
min-width: 24px;
|
|
205
|
+
padding: 0;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.block-editor-list-view-block__menu-cell {
|
|
210
|
+
padding-right: $grid-unit-05;
|
|
211
|
+
|
|
212
|
+
.components-button.has-icon {
|
|
213
|
+
height: 24px;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.block-editor-list-view-block__mover-cell-alignment-wrapper {
|
|
218
|
+
display: flex;
|
|
219
|
+
height: 100%;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
align-items: center;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Keep the tap target large but the focus target small.
|
|
225
|
+
.block-editor-block-mover-button {
|
|
226
|
+
position: relative;
|
|
227
|
+
width: $button-size;
|
|
228
|
+
height: $button-size-small;
|
|
229
|
+
|
|
230
|
+
// Position the icon.
|
|
231
|
+
svg {
|
|
232
|
+
position: relative;
|
|
233
|
+
height: $button-size-small;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
&.is-up-button {
|
|
237
|
+
margin-top: -$grid-unit-15 * 0.5;
|
|
238
|
+
align-items: flex-end;
|
|
239
|
+
svg {
|
|
240
|
+
bottom: -$grid-unit-05;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
&.is-down-button {
|
|
245
|
+
margin-bottom: -$grid-unit-15 * 0.5;
|
|
246
|
+
align-items: flex-start;
|
|
247
|
+
svg {
|
|
248
|
+
top: -$grid-unit-05;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Tweak size and position of focus ring.
|
|
253
|
+
&::before {
|
|
254
|
+
height: 16px;
|
|
255
|
+
min-width: 100%;
|
|
256
|
+
left: 0;
|
|
257
|
+
right: 0;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.block-editor-inserter__toggle {
|
|
262
|
+
background: $gray-900;
|
|
263
|
+
color: $white;
|
|
264
|
+
height: $grid-unit-30;
|
|
265
|
+
margin: 6px 6px 6px 1px;
|
|
266
|
+
min-width: $grid-unit-30;
|
|
267
|
+
|
|
268
|
+
&:active {
|
|
269
|
+
color: $white;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.block-editor-list-view-block-select-button__label-wrapper {
|
|
274
|
+
min-width: 120px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.block-editor-list-view-block-select-button__title {
|
|
278
|
+
flex: 1;
|
|
279
|
+
position: relative;
|
|
280
|
+
|
|
281
|
+
.components-truncate {
|
|
282
|
+
position: absolute;
|
|
283
|
+
width: 100%;
|
|
284
|
+
transform: translateY(-50%);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.block-editor-list-view-block-select-button__anchor-wrapper {
|
|
289
|
+
position: relative;
|
|
290
|
+
max-width: min(110px, 40%);
|
|
291
|
+
width: 100%;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.block-editor-list-view-block-select-button__anchor {
|
|
295
|
+
position: absolute;
|
|
296
|
+
right: 0;
|
|
297
|
+
transform: translateY(-50%);
|
|
298
|
+
background: rgba($black, 0.1);
|
|
299
|
+
border-radius: $radius-block-ui;
|
|
300
|
+
padding: 2px 6px;
|
|
301
|
+
max-width: 100%;
|
|
302
|
+
box-sizing: border-box;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
&.is-selected .block-editor-list-view-block-select-button__anchor {
|
|
306
|
+
background: rgba($black, 0.3);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.block-editor-list-view-block-select-button__lock {
|
|
310
|
+
line-height: 0;
|
|
311
|
+
width: 24px;
|
|
312
|
+
min-width: 24px;
|
|
313
|
+
margin-left: auto;
|
|
314
|
+
padding: 0;
|
|
315
|
+
vertical-align: middle;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.block-editor-list-view-block-select-button__description,
|
|
320
|
+
.block-editor-list-view-appender__description {
|
|
321
|
+
display: none;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.block-editor-list-view-block__contents-cell,
|
|
325
|
+
.block-editor-list-view-appender__cell {
|
|
326
|
+
.block-editor-list-view-block__contents-container,
|
|
327
|
+
.block-editor-list-view-appender__container {
|
|
328
|
+
display: flex;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Chevron container metrics.
|
|
333
|
+
.block-editor-list-view__expander {
|
|
334
|
+
height: $icon-size;
|
|
335
|
+
margin-left: $grid-unit-05;
|
|
336
|
+
width: $icon-size;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// First level of indentation is aria-level 2, max indent is 8.
|
|
340
|
+
// Indent is a full icon size, plus 4px which optically aligns child icons to the text label above.
|
|
341
|
+
$block-navigation-max-indent: 8;
|
|
342
|
+
.block-editor-list-view-leaf[aria-level] .block-editor-list-view__expander {
|
|
343
|
+
margin-left: ( $icon-size ) * $block-navigation-max-indent + 4 * ( $block-navigation-max-indent - 1 );
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.block-editor-list-view-leaf:not([aria-level="1"]) {
|
|
347
|
+
.block-editor-list-view__expander {
|
|
348
|
+
margin-right: 4px;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
@for $i from 0 to $block-navigation-max-indent {
|
|
353
|
+
.block-editor-list-view-leaf[aria-level="#{ $i + 1 }"] .block-editor-list-view__expander {
|
|
354
|
+
@if $i - 1 >= 0 {
|
|
355
|
+
margin-left: ( $icon-size * $i ) + 4 * ($i - 1);
|
|
356
|
+
}
|
|
357
|
+
@else {
|
|
358
|
+
margin-left: ( $icon-size * $i );
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.block-editor-list-view-leaf .block-editor-list-view__expander {
|
|
364
|
+
visibility: hidden;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Point downwards when open.
|
|
368
|
+
.block-editor-list-view-leaf[aria-expanded="true"] .block-editor-list-view__expander svg {
|
|
369
|
+
visibility: visible;
|
|
370
|
+
transition: transform 0.2s ease;
|
|
371
|
+
transform: rotate(90deg);
|
|
372
|
+
@include reduce-motion("transition");
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Point rightwards when closed
|
|
376
|
+
.block-editor-list-view-leaf[aria-expanded="false"] .block-editor-list-view__expander svg {
|
|
377
|
+
visibility: visible;
|
|
378
|
+
transform: rotate(0deg);
|
|
379
|
+
transition: transform 0.2s ease;
|
|
380
|
+
@include reduce-motion("transition");
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.block-editor-list-view-drop-indicator {
|
|
384
|
+
pointer-events: none;
|
|
385
|
+
|
|
386
|
+
.block-editor-list-view-drop-indicator__line {
|
|
387
|
+
background: var(--wp-admin-theme-color);
|
|
388
|
+
height: $border-width;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.block-editor-list-view-placeholder {
|
|
393
|
+
padding: 0;
|
|
394
|
+
margin: 0;
|
|
395
|
+
height: 36px;
|
|
396
|
+
}
|
|
397
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getCommonDepthClientIds } from '../utils';
|
|
5
|
+
|
|
6
|
+
describe( 'getCommonDepthClientIds', () => {
|
|
7
|
+
it( 'should return start and end when no depth is provided', () => {
|
|
8
|
+
const result = getCommonDepthClientIds(
|
|
9
|
+
'start-id',
|
|
10
|
+
'clicked-id',
|
|
11
|
+
[],
|
|
12
|
+
[]
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
expect( result ).toEqual( { start: 'start-id', end: 'clicked-id' } );
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
it( 'should return deepest start and end when depths match', () => {
|
|
19
|
+
const result = getCommonDepthClientIds(
|
|
20
|
+
'start-id',
|
|
21
|
+
'clicked-id',
|
|
22
|
+
[ 'start-1', 'start-2', 'start-3' ],
|
|
23
|
+
[ 'end-1', 'end-2', 'end-3' ]
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect( result ).toEqual( { start: 'start-id', end: 'clicked-id' } );
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
it( 'should return shallower ids when start is shallower', () => {
|
|
30
|
+
const result = getCommonDepthClientIds(
|
|
31
|
+
'start-id',
|
|
32
|
+
'clicked-id',
|
|
33
|
+
[ 'start-1' ],
|
|
34
|
+
[ 'end-1', 'end-2', 'end-3' ]
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
expect( result ).toEqual( { start: 'start-id', end: 'end-2' } );
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
it( 'should return shallower ids when end is shallower', () => {
|
|
41
|
+
const result = getCommonDepthClientIds(
|
|
42
|
+
'start-id',
|
|
43
|
+
'clicked-id',
|
|
44
|
+
[ 'start-1', 'start-2', 'start-3' ],
|
|
45
|
+
[ 'end-1', 'end-2' ]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect( result ).toEqual( { start: 'start-3', end: 'clicked-id' } );
|
|
49
|
+
} );
|
|
50
|
+
} );
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { speak } from '@wordpress/a11y';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
+
import { useCallback } from '@wordpress/element';
|
|
8
|
+
import { UP, DOWN, HOME, END } from '@wordpress/keycodes';
|
|
9
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { store as blockEditorStore } from '../../store';
|
|
15
|
+
import { getCommonDepthClientIds } from './utils';
|
|
16
|
+
|
|
17
|
+
export default function useBlockSelection() {
|
|
18
|
+
const { clearSelectedBlock, multiSelect, selectBlock } =
|
|
19
|
+
useDispatch( blockEditorStore );
|
|
20
|
+
const {
|
|
21
|
+
getBlockName,
|
|
22
|
+
getBlockParents,
|
|
23
|
+
getBlockSelectionStart,
|
|
24
|
+
getBlockSelectionEnd,
|
|
25
|
+
getSelectedBlockClientIds,
|
|
26
|
+
hasMultiSelection,
|
|
27
|
+
hasSelectedBlock,
|
|
28
|
+
} = useSelect( blockEditorStore );
|
|
29
|
+
|
|
30
|
+
const { getBlockType } = useSelect( blocksStore );
|
|
31
|
+
|
|
32
|
+
const updateBlockSelection = useCallback(
|
|
33
|
+
async ( event, clientId, destinationClientId ) => {
|
|
34
|
+
if ( ! event?.shiftKey ) {
|
|
35
|
+
selectBlock( clientId );
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// To handle multiple block selection via the `SHIFT` key, prevent
|
|
40
|
+
// the browser default behavior of opening the link in a new window.
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
|
|
43
|
+
const isKeyPress =
|
|
44
|
+
event.type === 'keydown' &&
|
|
45
|
+
( event.keyCode === UP ||
|
|
46
|
+
event.keyCode === DOWN ||
|
|
47
|
+
event.keyCode === HOME ||
|
|
48
|
+
event.keyCode === END );
|
|
49
|
+
|
|
50
|
+
// Handle clicking on a block when no blocks are selected, and return early.
|
|
51
|
+
if (
|
|
52
|
+
! isKeyPress &&
|
|
53
|
+
! hasSelectedBlock() &&
|
|
54
|
+
! hasMultiSelection()
|
|
55
|
+
) {
|
|
56
|
+
selectBlock( clientId, null );
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const selectedBlocks = getSelectedBlockClientIds();
|
|
61
|
+
const clientIdWithParents = [
|
|
62
|
+
...getBlockParents( clientId ),
|
|
63
|
+
clientId,
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
if (
|
|
67
|
+
isKeyPress &&
|
|
68
|
+
! selectedBlocks.some( ( blockId ) =>
|
|
69
|
+
clientIdWithParents.includes( blockId )
|
|
70
|
+
)
|
|
71
|
+
) {
|
|
72
|
+
// Ensure that shift-selecting blocks via the keyboard only
|
|
73
|
+
// expands the current selection if focusing over already
|
|
74
|
+
// selected blocks. Otherwise, clear the selection so that
|
|
75
|
+
// a user can create a new selection entirely by keyboard.
|
|
76
|
+
await clearSelectedBlock();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let startTarget = getBlockSelectionStart();
|
|
80
|
+
let endTarget = clientId;
|
|
81
|
+
|
|
82
|
+
// Handle keyboard behavior for selecting multiple blocks.
|
|
83
|
+
if ( isKeyPress ) {
|
|
84
|
+
if ( ! hasSelectedBlock() && ! hasMultiSelection() ) {
|
|
85
|
+
// Set the starting point of the selection to the currently
|
|
86
|
+
// focused block, if there are no blocks currently selected.
|
|
87
|
+
// This ensures that as the selection is expanded or contracted,
|
|
88
|
+
// the starting point of the selection is anchored to that block.
|
|
89
|
+
startTarget = clientId;
|
|
90
|
+
}
|
|
91
|
+
if ( destinationClientId ) {
|
|
92
|
+
// If the user presses UP or DOWN, we want to ensure that the block they're
|
|
93
|
+
// moving to is the target for selection, and not the currently focused one.
|
|
94
|
+
endTarget = destinationClientId;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const startParents = getBlockParents( startTarget );
|
|
99
|
+
const endParents = getBlockParents( endTarget );
|
|
100
|
+
|
|
101
|
+
const { start, end } = getCommonDepthClientIds(
|
|
102
|
+
startTarget,
|
|
103
|
+
endTarget,
|
|
104
|
+
startParents,
|
|
105
|
+
endParents
|
|
106
|
+
);
|
|
107
|
+
await multiSelect( start, end, null );
|
|
108
|
+
|
|
109
|
+
// Announce deselected block, or number of deselected blocks if
|
|
110
|
+
// the total number of blocks deselected is greater than one.
|
|
111
|
+
const updatedSelectedBlocks = getSelectedBlockClientIds();
|
|
112
|
+
|
|
113
|
+
// If the selection is greater than 1 and the Home or End keys
|
|
114
|
+
// were used to generate the selection, then skip announcing the
|
|
115
|
+
// deselected blocks.
|
|
116
|
+
if (
|
|
117
|
+
( event.keyCode === HOME || event.keyCode === END ) &&
|
|
118
|
+
updatedSelectedBlocks.length > 1
|
|
119
|
+
) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const selectionDiff = selectedBlocks.filter(
|
|
124
|
+
( blockId ) => ! updatedSelectedBlocks.includes( blockId )
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
let label;
|
|
128
|
+
if ( selectionDiff.length === 1 ) {
|
|
129
|
+
const title = getBlockType(
|
|
130
|
+
getBlockName( selectionDiff[ 0 ] )
|
|
131
|
+
)?.title;
|
|
132
|
+
if ( title ) {
|
|
133
|
+
label = sprintf(
|
|
134
|
+
/* translators: %s: block name */
|
|
135
|
+
__( '%s deselected.' ),
|
|
136
|
+
title
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
} else if ( selectionDiff.length > 1 ) {
|
|
140
|
+
label = sprintf(
|
|
141
|
+
/* translators: %s: number of deselected blocks */
|
|
142
|
+
__( '%s blocks deselected.' ),
|
|
143
|
+
selectionDiff.length
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if ( label ) {
|
|
148
|
+
speak( label );
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[
|
|
152
|
+
clearSelectedBlock,
|
|
153
|
+
getBlockName,
|
|
154
|
+
getBlockType,
|
|
155
|
+
getBlockParents,
|
|
156
|
+
getBlockSelectionStart,
|
|
157
|
+
getBlockSelectionEnd,
|
|
158
|
+
getSelectedBlockClientIds,
|
|
159
|
+
hasMultiSelection,
|
|
160
|
+
hasSelectedBlock,
|
|
161
|
+
multiSelect,
|
|
162
|
+
selectBlock,
|
|
163
|
+
]
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
updateBlockSelection,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
|
|
12
|
+
export default function useListViewClientIds( blocks ) {
|
|
13
|
+
return useSelect(
|
|
14
|
+
( select ) => {
|
|
15
|
+
const {
|
|
16
|
+
getDraggedBlockClientIds,
|
|
17
|
+
getSelectedBlockClientIds,
|
|
18
|
+
__unstableGetClientIdsTree,
|
|
19
|
+
} = select( blockEditorStore );
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
selectedClientIds: getSelectedBlockClientIds(),
|
|
23
|
+
draggedClientIds: getDraggedBlockClientIds(),
|
|
24
|
+
clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree(),
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
[ blocks ]
|
|
28
|
+
);
|
|
29
|
+
}
|