@wordpress/block-editor 12.8.1 → 12.9.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 +6 -0
- package/README.md +5 -12
- package/build/components/block-list/block-outline.native.js +4 -3
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/index.js +4 -3
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -5
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +3 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/color-style-selector/index.js +1 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +7 -4
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +10 -8
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/link-control/index.js +1 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +48 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +3 -3
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +14 -8
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-images.js +5 -4
- package/build/components/list-view/use-list-view-images.js.map +1 -1
- package/build/components/preview-options/index.js +3 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +74 -63
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/warning/index.js +1 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/auto-inserting-blocks.js +174 -0
- package/build/hooks/auto-inserting-blocks.js.map +1 -0
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +4 -3
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/index.js +4 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -5
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +3 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +1 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +8 -4
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +11 -8
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +48 -7
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +3 -3
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +14 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-images.js +5 -4
- package/build-module/components/list-view/use-list-view-images.js.map +1 -1
- package/build-module/components/preview-options/index.js +3 -1
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +74 -63
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/warning/index.js +2 -2
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/auto-inserting-blocks.js +167 -0
- package/build-module/hooks/auto-inserting-blocks.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-style/content-rtl.css +8 -7
- package/build-style/content.css +8 -7
- package/package.json +32 -32
- package/src/components/block-list/block-outline.native.js +5 -2
- package/src/components/block-list/content.scss +2 -3
- package/src/components/block-list/index.js +4 -3
- package/src/components/block-popover/inbetween.js +4 -3
- package/src/components/block-popover/index.js +3 -2
- package/src/components/button-block-appender/content.scss +8 -0
- package/src/components/color-style-selector/index.js +1 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +7 -2
- package/src/components/inserter/search-results.native.js +13 -9
- package/src/components/link-control/index.js +1 -5
- package/src/components/link-control/test/index.js +1 -0
- package/src/components/list-view/block-select-button.js +67 -15
- package/src/components/list-view/drop-indicator.js +4 -5
- package/src/components/list-view/index.js +19 -13
- package/src/components/list-view/use-list-view-images.js +8 -4
- package/src/components/observe-typing/README.md +2 -2
- package/src/components/preview-options/index.js +2 -0
- package/src/components/provider/index.js +8 -1
- package/src/components/use-block-commands/index.js +92 -88
- package/src/components/warning/index.js +2 -2
- package/src/hooks/auto-inserting-blocks.js +232 -0
- package/src/hooks/index.js +1 -0
- package/build/utils/pre-parse-patterns.js +0 -68
- package/build/utils/pre-parse-patterns.js.map +0 -1
- package/build-module/utils/pre-parse-patterns.js +0 -61
- package/build-module/utils/pre-parse-patterns.js.map +0 -1
- package/src/components/url-popover/test/__snapshots__/index.js.snap +0 -133
- package/src/components/url-popover/test/index.js +0 -75
- package/src/utils/pre-parse-patterns.js +0 -69
|
@@ -181,12 +181,12 @@
|
|
|
181
181
|
box-shadow: none;
|
|
182
182
|
}
|
|
183
183
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted,
|
|
184
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
184
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
185
185
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus {
|
|
186
186
|
outline: none;
|
|
187
187
|
}
|
|
188
188
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
189
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
189
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
190
190
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
191
191
|
content: "";
|
|
192
192
|
position: absolute;
|
|
@@ -201,14 +201,10 @@
|
|
|
201
201
|
outline: 2px solid transparent;
|
|
202
202
|
}
|
|
203
203
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
204
|
-
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
204
|
+
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
205
205
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
206
206
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) #fff;
|
|
207
207
|
}
|
|
208
|
-
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected {
|
|
209
|
-
box-shadow: none;
|
|
210
|
-
outline: none;
|
|
211
|
-
}
|
|
212
208
|
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected::after {
|
|
213
209
|
content: "";
|
|
214
210
|
position: absolute;
|
|
@@ -220,6 +216,8 @@
|
|
|
220
216
|
top: -14px;
|
|
221
217
|
border-radius: 2px;
|
|
222
218
|
border-top: 4px solid #ccc;
|
|
219
|
+
bottom: auto;
|
|
220
|
+
box-shadow: none;
|
|
223
221
|
}
|
|
224
222
|
.block-editor-block-list__layout .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected::after {
|
|
225
223
|
border-color: var(--wp-admin-theme-color);
|
|
@@ -675,6 +673,9 @@
|
|
|
675
673
|
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .block-list-appender:only-child.is-drag-over .block-editor-inserter, .is-layout-flow.block-editor-block-list__block:not(.is-selected) > .block-list-appender:only-child.is-drag-over .block-editor-inserter, .is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .wp-block-group__inner-container > .block-list-appender:only-child.is-drag-over .block-editor-inserter, .is-layout-flow.block-editor-block-list__block:not(.is-selected) > .wp-block-group__inner-container > .block-list-appender:only-child.is-drag-over .block-editor-inserter {
|
|
676
674
|
visibility: visible;
|
|
677
675
|
}
|
|
676
|
+
.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__block > .block-list-appender:only-child::after {
|
|
677
|
+
border: none;
|
|
678
|
+
}
|
|
678
679
|
.block-list-appender:only-child.is-drag-over .block-editor-button-block-appender {
|
|
679
680
|
background-color: var(--wp-admin-theme-color);
|
|
680
681
|
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
|
package/build-style/content.css
CHANGED
|
@@ -181,12 +181,12 @@
|
|
|
181
181
|
box-shadow: none;
|
|
182
182
|
}
|
|
183
183
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted,
|
|
184
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
184
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
185
185
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus {
|
|
186
186
|
outline: none;
|
|
187
187
|
}
|
|
188
188
|
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
189
|
-
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
189
|
+
.block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
190
190
|
.block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
191
191
|
content: "";
|
|
192
192
|
position: absolute;
|
|
@@ -201,14 +201,10 @@
|
|
|
201
201
|
outline: 2px solid transparent;
|
|
202
202
|
}
|
|
203
203
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
|
|
204
|
-
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
204
|
+
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
205
205
|
.is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
|
|
206
206
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) #fff;
|
|
207
207
|
}
|
|
208
|
-
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected {
|
|
209
|
-
box-shadow: none;
|
|
210
|
-
outline: none;
|
|
211
|
-
}
|
|
212
208
|
.block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected::after {
|
|
213
209
|
content: "";
|
|
214
210
|
position: absolute;
|
|
@@ -220,6 +216,8 @@
|
|
|
220
216
|
top: -14px;
|
|
221
217
|
border-radius: 2px;
|
|
222
218
|
border-top: 4px solid #ccc;
|
|
219
|
+
bottom: auto;
|
|
220
|
+
box-shadow: none;
|
|
223
221
|
}
|
|
224
222
|
.block-editor-block-list__layout .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected::after {
|
|
225
223
|
border-color: var(--wp-admin-theme-color);
|
|
@@ -675,6 +673,9 @@
|
|
|
675
673
|
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .block-list-appender:only-child.is-drag-over .block-editor-inserter, .is-layout-flow.block-editor-block-list__block:not(.is-selected) > .block-list-appender:only-child.is-drag-over .block-editor-inserter, .is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .wp-block-group__inner-container > .block-list-appender:only-child.is-drag-over .block-editor-inserter, .is-layout-flow.block-editor-block-list__block:not(.is-selected) > .wp-block-group__inner-container > .block-list-appender:only-child.is-drag-over .block-editor-inserter {
|
|
676
674
|
visibility: visible;
|
|
677
675
|
}
|
|
676
|
+
.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__block > .block-list-appender:only-child::after {
|
|
677
|
+
border: none;
|
|
678
|
+
}
|
|
678
679
|
.block-list-appender:only-child.is-drag-over .block-editor-button-block-appender {
|
|
679
680
|
background-color: var(--wp-admin-theme-color);
|
|
680
681
|
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,36 +35,36 @@
|
|
|
35
35
|
"@emotion/react": "^11.7.1",
|
|
36
36
|
"@emotion/styled": "^11.6.0",
|
|
37
37
|
"@react-spring/web": "^9.4.5",
|
|
38
|
-
"@wordpress/a11y": "^3.
|
|
39
|
-
"@wordpress/api-fetch": "^6.
|
|
40
|
-
"@wordpress/blob": "^3.
|
|
41
|
-
"@wordpress/blocks": "^12.
|
|
42
|
-
"@wordpress/commands": "^0.
|
|
43
|
-
"@wordpress/components": "^25.
|
|
44
|
-
"@wordpress/compose": "^6.
|
|
45
|
-
"@wordpress/data": "^9.
|
|
46
|
-
"@wordpress/date": "^4.
|
|
47
|
-
"@wordpress/deprecated": "^3.
|
|
48
|
-
"@wordpress/dom": "^3.
|
|
49
|
-
"@wordpress/element": "^5.
|
|
50
|
-
"@wordpress/escape-html": "^2.
|
|
51
|
-
"@wordpress/hooks": "^3.
|
|
52
|
-
"@wordpress/html-entities": "^3.
|
|
53
|
-
"@wordpress/i18n": "^4.
|
|
54
|
-
"@wordpress/icons": "^9.
|
|
55
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
56
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
57
|
-
"@wordpress/keycodes": "^3.
|
|
58
|
-
"@wordpress/notices": "^4.
|
|
59
|
-
"@wordpress/preferences": "^3.
|
|
60
|
-
"@wordpress/private-apis": "^0.
|
|
61
|
-
"@wordpress/rich-text": "^6.
|
|
62
|
-
"@wordpress/shortcode": "^3.
|
|
63
|
-
"@wordpress/style-engine": "^1.
|
|
64
|
-
"@wordpress/token-list": "^2.
|
|
65
|
-
"@wordpress/url": "^3.
|
|
66
|
-
"@wordpress/warning": "^2.
|
|
67
|
-
"@wordpress/wordcount": "^3.
|
|
38
|
+
"@wordpress/a11y": "^3.41.0",
|
|
39
|
+
"@wordpress/api-fetch": "^6.38.0",
|
|
40
|
+
"@wordpress/blob": "^3.41.0",
|
|
41
|
+
"@wordpress/blocks": "^12.18.0",
|
|
42
|
+
"@wordpress/commands": "^0.12.0",
|
|
43
|
+
"@wordpress/components": "^25.7.0",
|
|
44
|
+
"@wordpress/compose": "^6.18.0",
|
|
45
|
+
"@wordpress/data": "^9.11.0",
|
|
46
|
+
"@wordpress/date": "^4.41.0",
|
|
47
|
+
"@wordpress/deprecated": "^3.41.0",
|
|
48
|
+
"@wordpress/dom": "^3.41.0",
|
|
49
|
+
"@wordpress/element": "^5.18.0",
|
|
50
|
+
"@wordpress/escape-html": "^2.41.0",
|
|
51
|
+
"@wordpress/hooks": "^3.41.0",
|
|
52
|
+
"@wordpress/html-entities": "^3.41.0",
|
|
53
|
+
"@wordpress/i18n": "^4.41.0",
|
|
54
|
+
"@wordpress/icons": "^9.32.0",
|
|
55
|
+
"@wordpress/is-shallow-equal": "^4.41.0",
|
|
56
|
+
"@wordpress/keyboard-shortcuts": "^4.18.0",
|
|
57
|
+
"@wordpress/keycodes": "^3.41.0",
|
|
58
|
+
"@wordpress/notices": "^4.9.0",
|
|
59
|
+
"@wordpress/preferences": "^3.18.0",
|
|
60
|
+
"@wordpress/private-apis": "^0.23.0",
|
|
61
|
+
"@wordpress/rich-text": "^6.18.0",
|
|
62
|
+
"@wordpress/shortcode": "^3.41.0",
|
|
63
|
+
"@wordpress/style-engine": "^1.24.0",
|
|
64
|
+
"@wordpress/token-list": "^2.41.0",
|
|
65
|
+
"@wordpress/url": "^3.42.0",
|
|
66
|
+
"@wordpress/warning": "^2.41.0",
|
|
67
|
+
"@wordpress/wordcount": "^3.41.0",
|
|
68
68
|
"change-case": "^4.1.2",
|
|
69
69
|
"classnames": "^2.3.1",
|
|
70
70
|
"colord": "^2.7.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "5eac1734bcdca2301fdd37ec8cfe2a45e722a2c4"
|
|
90
90
|
}
|
|
@@ -13,7 +13,7 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
|
13
13
|
*/
|
|
14
14
|
import styles from './block.scss';
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const TEXT_BLOCKS_WITH_OUTLINE = [ 'core/missing' ];
|
|
17
17
|
|
|
18
18
|
function BlockOutline( {
|
|
19
19
|
blockCategory,
|
|
@@ -22,7 +22,9 @@ function BlockOutline( {
|
|
|
22
22
|
isSelected,
|
|
23
23
|
name,
|
|
24
24
|
} ) {
|
|
25
|
-
const textBlockWithOutline =
|
|
25
|
+
const textBlockWithOutline = TEXT_BLOCKS_WITH_OUTLINE.includes( name );
|
|
26
|
+
const socialBlockWithOutline = name.includes( 'core/social-link' );
|
|
27
|
+
|
|
26
28
|
const hasBlockTextCategory =
|
|
27
29
|
blockCategory === 'text' && ! textBlockWithOutline;
|
|
28
30
|
const hasBlockMediaCategory =
|
|
@@ -47,6 +49,7 @@ function BlockOutline( {
|
|
|
47
49
|
( ( hasBlockTextCategory && hasInnerBlocks ) ||
|
|
48
50
|
( ! hasBlockTextCategory && hasInnerBlocks ) ||
|
|
49
51
|
( ! hasBlockTextCategory && isRootList ) ||
|
|
52
|
+
socialBlockWithOutline ||
|
|
50
53
|
textBlockWithOutline );
|
|
51
54
|
|
|
52
55
|
return (
|
|
@@ -85,7 +85,6 @@
|
|
|
85
85
|
.block-editor-block-list__block.is-highlighted,
|
|
86
86
|
.block-editor-block-list__block.is-highlighted ~ .is-multi-selected,
|
|
87
87
|
&.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
88
|
-
& .is-block-moving-mode.block-editor-block-list__block.has-child-selected,
|
|
89
88
|
.block-editor-block-list__block:not([contenteditable]):focus {
|
|
90
89
|
outline: none;
|
|
91
90
|
|
|
@@ -113,8 +112,6 @@
|
|
|
113
112
|
|
|
114
113
|
// Moving blocks using keyboard (Ellipsis > Move).
|
|
115
114
|
& .is-block-moving-mode.block-editor-block-list__block.is-selected {
|
|
116
|
-
box-shadow: none;
|
|
117
|
-
outline: none;
|
|
118
115
|
|
|
119
116
|
&::after {
|
|
120
117
|
content: "";
|
|
@@ -130,6 +127,8 @@
|
|
|
130
127
|
top: -$default-block-margin * 0.5;
|
|
131
128
|
border-radius: $radius-block-ui;
|
|
132
129
|
border-top: 4px solid $gray-400;
|
|
130
|
+
bottom: auto;
|
|
131
|
+
box-shadow: none;
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
|
|
@@ -31,7 +31,6 @@ import BlockListBlock from './block';
|
|
|
31
31
|
import BlockListAppender from '../block-list-appender';
|
|
32
32
|
import { useInBetweenInserter } from './use-in-between-inserter';
|
|
33
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
|
-
import { usePreParsePatterns } from '../../utils/pre-parse-patterns';
|
|
35
34
|
import { LayoutProvider, defaultLayout } from './layout';
|
|
36
35
|
import { useBlockSelectionClearer } from '../block-selection-clearer';
|
|
37
36
|
import { useInnerBlocksProps } from '../inner-blocks';
|
|
@@ -39,6 +38,7 @@ import {
|
|
|
39
38
|
BlockEditContextProvider,
|
|
40
39
|
DEFAULT_BLOCK_EDIT_CONTEXT,
|
|
41
40
|
} from '../block-edit/context';
|
|
41
|
+
import { useTypingObserver } from '../observe-typing';
|
|
42
42
|
|
|
43
43
|
const elementContext = createContext();
|
|
44
44
|
|
|
@@ -104,7 +104,7 @@ function Root( { className, ...settings } ) {
|
|
|
104
104
|
ref: useMergeRefs( [
|
|
105
105
|
useBlockSelectionClearer(),
|
|
106
106
|
useInBetweenInserter(),
|
|
107
|
-
|
|
107
|
+
useTypingObserver(),
|
|
108
108
|
] ),
|
|
109
109
|
className: classnames( 'is-root-container', className, {
|
|
110
110
|
'is-outline-mode': isOutlineMode,
|
|
@@ -118,13 +118,14 @@ function Root( { className, ...settings } ) {
|
|
|
118
118
|
<elementContext.Provider value={ element }>
|
|
119
119
|
<IntersectionObserver.Provider value={ intersectionObserver }>
|
|
120
120
|
<div { ...innerBlocksProps } />
|
|
121
|
+
{ /* Ensure element and layout styles are always at the end of the document */ }
|
|
122
|
+
<div ref={ setElement } />
|
|
121
123
|
</IntersectionObserver.Provider>
|
|
122
124
|
</elementContext.Provider>
|
|
123
125
|
);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
export default function BlockList( settings ) {
|
|
127
|
-
usePreParsePatterns();
|
|
128
129
|
return (
|
|
129
130
|
<BlockEditContextProvider value={ DEFAULT_BLOCK_EDIT_CONTEXT }>
|
|
130
131
|
<Root { ...settings } />
|
|
@@ -81,10 +81,10 @@ function BlockPopoverInbetween( {
|
|
|
81
81
|
return undefined;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
const
|
|
84
|
+
const contextElement = previousElement || nextElement;
|
|
85
85
|
|
|
86
86
|
return {
|
|
87
|
-
|
|
87
|
+
contextElement,
|
|
88
88
|
getBoundingClientRect() {
|
|
89
89
|
const previousRect = previousElement
|
|
90
90
|
? previousElement.getBoundingClientRect()
|
|
@@ -215,7 +215,8 @@ function BlockPopoverInbetween( {
|
|
|
215
215
|
focusOnMount={ false }
|
|
216
216
|
// Render in the old slot if needed for backward compatibility,
|
|
217
217
|
// otherwise render in place (not in the default popover slot).
|
|
218
|
-
__unstableSlotName={ __unstablePopoverSlot
|
|
218
|
+
__unstableSlotName={ __unstablePopoverSlot }
|
|
219
|
+
inline={ ! __unstablePopoverSlot }
|
|
219
220
|
// Forces a remount of the popover when its position changes
|
|
220
221
|
// This makes sure the popover doesn't animate from its previous position.
|
|
221
222
|
key={ nextClientId + '--' + rootClientId }
|
|
@@ -142,7 +142,7 @@ function BlockPopover(
|
|
|
142
142
|
|
|
143
143
|
return new window.DOMRect( left, top, width, height );
|
|
144
144
|
},
|
|
145
|
-
|
|
145
|
+
contextElement: selectedElement,
|
|
146
146
|
};
|
|
147
147
|
}, [
|
|
148
148
|
bottomClientId,
|
|
@@ -163,7 +163,8 @@ function BlockPopover(
|
|
|
163
163
|
anchor={ popoverAnchor }
|
|
164
164
|
// Render in the old slot if needed for backward compatibility,
|
|
165
165
|
// otherwise render in place (not in the default popover slot).
|
|
166
|
-
__unstableSlotName={ __unstablePopoverSlot
|
|
166
|
+
__unstableSlotName={ __unstablePopoverSlot }
|
|
167
|
+
inline={ ! __unstablePopoverSlot }
|
|
167
168
|
placement="top-start"
|
|
168
169
|
resize={ false }
|
|
169
170
|
flip={ false }
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
// When the appender shows up in empty container blocks, such as Group and Columns, add an extra click state.
|
|
37
37
|
.block-list-appender:only-child {
|
|
38
|
+
// One level of nesting
|
|
38
39
|
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
|
|
39
40
|
.is-layout-flow.block-editor-block-list__block:not(.is-selected) > &,
|
|
40
41
|
// Legacy groups have an inner container so need to be targeted separately
|
|
@@ -69,6 +70,13 @@
|
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
// Hide the dashed outline in 2-level nested cases, so for example the dashed
|
|
74
|
+
// empty column is only shown when the columns block is selected.
|
|
75
|
+
.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__block > &::after {
|
|
76
|
+
border: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Drop zone.
|
|
72
80
|
&.is-drag-over .block-editor-button-block-appender {
|
|
73
81
|
background-color: var(--wp-admin-theme-color);
|
|
74
82
|
box-shadow: inset 0 0 0 $border-width $light-gray-placeholder;
|
|
@@ -13,7 +13,7 @@ import { DOWN } from '@wordpress/keycodes';
|
|
|
13
13
|
import deprecated from '@wordpress/deprecated';
|
|
14
14
|
|
|
15
15
|
const ColorSelectorSVGIcon = () => (
|
|
16
|
-
<SVG xmlns="
|
|
16
|
+
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
|
17
17
|
<Path d="M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z" />
|
|
18
18
|
</SVG>
|
|
19
19
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { useMemo } from '@wordpress/element';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -12,18 +13,22 @@ import { store as blockEditorStore } from '../../store';
|
|
|
12
13
|
import { createInserterSection, filterInserterItems } from './utils';
|
|
13
14
|
|
|
14
15
|
function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
|
|
15
|
-
const {
|
|
16
|
+
const { inserterItems } = useSelect(
|
|
16
17
|
( select ) => {
|
|
17
18
|
const { getInserterItems } = select( blockEditorStore );
|
|
18
19
|
const allItems = getInserterItems( rootClientId );
|
|
19
20
|
|
|
20
21
|
return {
|
|
21
|
-
|
|
22
|
+
inserterItems: allItems,
|
|
22
23
|
};
|
|
23
24
|
},
|
|
24
25
|
[ rootClientId ]
|
|
25
26
|
);
|
|
26
27
|
|
|
28
|
+
const items = useMemo( () => {
|
|
29
|
+
return filterInserterItems( inserterItems, { onlyReusable: true } );
|
|
30
|
+
}, [ inserterItems ] );
|
|
31
|
+
|
|
27
32
|
const sections = [ createInserterSection( { key: 'reuseable', items } ) ];
|
|
28
33
|
|
|
29
34
|
return (
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { useMemo } from '@wordpress/element';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -21,21 +22,24 @@ function InserterSearchResults( {
|
|
|
21
22
|
rootClientId,
|
|
22
23
|
isFullScreen,
|
|
23
24
|
} ) {
|
|
24
|
-
const {
|
|
25
|
+
const { inserterItems } = useSelect(
|
|
25
26
|
( select ) => {
|
|
26
|
-
const
|
|
27
|
+
const items =
|
|
27
28
|
select( blockEditorStore ).getInserterItems( rootClientId );
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
allowReusable: true,
|
|
31
|
-
} );
|
|
32
|
-
const filteredItems = searchItems( availableItems, filterValue );
|
|
33
|
-
|
|
34
|
-
return { blockTypes: filteredItems };
|
|
30
|
+
return { inserterItems: items };
|
|
35
31
|
},
|
|
36
|
-
[ rootClientId
|
|
32
|
+
[ rootClientId ]
|
|
37
33
|
);
|
|
38
34
|
|
|
35
|
+
const blockTypes = useMemo( () => {
|
|
36
|
+
const availableItems = filterInserterItems( inserterItems, {
|
|
37
|
+
allowReusable: true,
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
return searchItems( availableItems, filterValue );
|
|
41
|
+
}, [ inserterItems, filterValue ] );
|
|
42
|
+
|
|
39
43
|
const { items, trackBlockTypeSelected } =
|
|
40
44
|
useBlockTypeImpressions( blockTypes );
|
|
41
45
|
|
|
@@ -422,11 +422,7 @@ function LinkControl( {
|
|
|
422
422
|
settings={ settings?.filter(
|
|
423
423
|
( { id } ) => id === 'opensInNewTab'
|
|
424
424
|
) }
|
|
425
|
-
onChange={
|
|
426
|
-
onChange( {
|
|
427
|
-
opensInNewTab,
|
|
428
|
-
} );
|
|
429
|
-
} }
|
|
425
|
+
onChange={ onChange }
|
|
430
426
|
/>
|
|
431
427
|
);
|
|
432
428
|
}
|
|
@@ -6,6 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
10
|
import {
|
|
10
11
|
Button,
|
|
11
12
|
__experimentalHStack as HStack,
|
|
@@ -55,13 +56,15 @@ function ListViewBlockSelectButton(
|
|
|
55
56
|
} );
|
|
56
57
|
const { isLocked } = useBlockLock( clientId );
|
|
57
58
|
const {
|
|
59
|
+
canInsertBlockType,
|
|
58
60
|
getSelectedBlockClientIds,
|
|
59
61
|
getPreviousBlockClientId,
|
|
60
62
|
getBlockRootClientId,
|
|
61
63
|
getBlockOrder,
|
|
64
|
+
getBlocksByClientId,
|
|
62
65
|
canRemoveBlocks,
|
|
63
66
|
} = useSelect( blockEditorStore );
|
|
64
|
-
const { removeBlocks } = useDispatch( blockEditorStore );
|
|
67
|
+
const { duplicateBlocks, removeBlocks } = useDispatch( blockEditorStore );
|
|
65
68
|
const isMatch = useShortcutEventMatch();
|
|
66
69
|
const isSticky = blockInformation?.positionType === 'sticky';
|
|
67
70
|
const images = useListViewImages( { clientId, isExpanded } );
|
|
@@ -83,10 +86,35 @@ function ListViewBlockSelectButton(
|
|
|
83
86
|
onDragStart?.( event );
|
|
84
87
|
};
|
|
85
88
|
|
|
89
|
+
// Determine which blocks to update:
|
|
90
|
+
// If the current (focused) block is part of the block selection, use the whole selection.
|
|
91
|
+
// If the focused block is not part of the block selection, only update the focused block.
|
|
92
|
+
function getBlocksToUpdate() {
|
|
93
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
94
|
+
const isUpdatingSelectedBlocks =
|
|
95
|
+
selectedBlockClientIds.includes( clientId );
|
|
96
|
+
const firstBlockClientId = isUpdatingSelectedBlocks
|
|
97
|
+
? selectedBlockClientIds[ 0 ]
|
|
98
|
+
: clientId;
|
|
99
|
+
const firstBlockRootClientId =
|
|
100
|
+
getBlockRootClientId( firstBlockClientId );
|
|
101
|
+
|
|
102
|
+
const blocksToUpdate = isUpdatingSelectedBlocks
|
|
103
|
+
? selectedBlockClientIds
|
|
104
|
+
: [ clientId ];
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
blocksToUpdate,
|
|
108
|
+
firstBlockClientId,
|
|
109
|
+
firstBlockRootClientId,
|
|
110
|
+
selectedBlockClientIds,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
86
114
|
/**
|
|
87
115
|
* @param {KeyboardEvent} event
|
|
88
116
|
*/
|
|
89
|
-
function onKeyDownHandler( event ) {
|
|
117
|
+
async function onKeyDownHandler( event ) {
|
|
90
118
|
if ( event.keyCode === ENTER || event.keyCode === SPACE ) {
|
|
91
119
|
onClick( event );
|
|
92
120
|
} else if (
|
|
@@ -94,18 +122,12 @@ function ListViewBlockSelectButton(
|
|
|
94
122
|
event.keyCode === DELETE ||
|
|
95
123
|
isMatch( 'core/block-editor/remove', event )
|
|
96
124
|
) {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const firstBlockRootClientId =
|
|
104
|
-
getBlockRootClientId( firstBlockClientId );
|
|
105
|
-
|
|
106
|
-
const blocksToDelete = isDeletingSelectedBlocks
|
|
107
|
-
? selectedBlockClientIds
|
|
108
|
-
: [ clientId ];
|
|
125
|
+
const {
|
|
126
|
+
blocksToUpdate: blocksToDelete,
|
|
127
|
+
firstBlockClientId,
|
|
128
|
+
firstBlockRootClientId,
|
|
129
|
+
selectedBlockClientIds,
|
|
130
|
+
} = getBlocksToUpdate();
|
|
109
131
|
|
|
110
132
|
// Don't update the selection if the blocks cannot be deleted.
|
|
111
133
|
if ( ! canRemoveBlocks( blocksToDelete, firstBlockRootClientId ) ) {
|
|
@@ -131,6 +153,36 @@ function ListViewBlockSelectButton(
|
|
|
131
153
|
}
|
|
132
154
|
|
|
133
155
|
updateFocusAndSelection( blockToFocus, shouldUpdateSelection );
|
|
156
|
+
} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {
|
|
157
|
+
if ( event.defaultPrevented ) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
|
|
162
|
+
const { blocksToUpdate, firstBlockRootClientId } =
|
|
163
|
+
getBlocksToUpdate();
|
|
164
|
+
|
|
165
|
+
const canDuplicate = getBlocksByClientId( blocksToUpdate ).every(
|
|
166
|
+
( block ) => {
|
|
167
|
+
return (
|
|
168
|
+
!! block &&
|
|
169
|
+
hasBlockSupport( block.name, 'multiple', true ) &&
|
|
170
|
+
canInsertBlockType( block.name, firstBlockRootClientId )
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
if ( canDuplicate ) {
|
|
176
|
+
const updatedBlocks = await duplicateBlocks(
|
|
177
|
+
blocksToUpdate,
|
|
178
|
+
false
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if ( updatedBlocks?.length ) {
|
|
182
|
+
// If blocks have been duplicated, focus the first duplicated block.
|
|
183
|
+
updateFocusAndSelection( updatedBlocks[ 0 ], false );
|
|
184
|
+
}
|
|
185
|
+
}
|
|
134
186
|
}
|
|
135
187
|
}
|
|
136
188
|
|
|
@@ -194,7 +246,7 @@ function ListViewBlockSelectButton(
|
|
|
194
246
|
{ images.map( ( image, index ) => (
|
|
195
247
|
<span
|
|
196
248
|
className="block-editor-list-view-block-select-button__image"
|
|
197
|
-
key={
|
|
249
|
+
key={ image.clientId }
|
|
198
250
|
style={ {
|
|
199
251
|
backgroundImage: `url(${ image.url })`,
|
|
200
252
|
zIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.
|
|
@@ -159,10 +159,8 @@ export default function ListViewDropIndicator( {
|
|
|
159
159
|
return undefined;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const ownerDocument = targetElement.ownerDocument;
|
|
163
|
-
|
|
164
162
|
return {
|
|
165
|
-
|
|
163
|
+
contextElement: targetElement,
|
|
166
164
|
getBoundingClientRect() {
|
|
167
165
|
const rect = targetElement.getBoundingClientRect();
|
|
168
166
|
const indent = getDropIndicatorIndent( rect );
|
|
@@ -189,9 +187,10 @@ export default function ListViewDropIndicator( {
|
|
|
189
187
|
'horizontal'
|
|
190
188
|
);
|
|
191
189
|
|
|
190
|
+
const doc = targetElement.ownerDocument;
|
|
192
191
|
const windowScroll =
|
|
193
|
-
scrollContainer ===
|
|
194
|
-
scrollContainer ===
|
|
192
|
+
scrollContainer === doc.body ||
|
|
193
|
+
scrollContainer === doc.documentElement;
|
|
195
194
|
|
|
196
195
|
// If the scroll container is not the window, offset the left position, if need be.
|
|
197
196
|
if ( scrollContainer && ! windowScroll ) {
|
|
@@ -159,19 +159,6 @@ function ListViewComponent(
|
|
|
159
159
|
isMounted.current = true;
|
|
160
160
|
}, [] );
|
|
161
161
|
|
|
162
|
-
// List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
163
|
-
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
164
|
-
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
165
|
-
const [ fixedListWindow ] = useFixedWindowList(
|
|
166
|
-
elementRef,
|
|
167
|
-
BLOCK_LIST_ITEM_HEIGHT,
|
|
168
|
-
visibleBlockCount,
|
|
169
|
-
{
|
|
170
|
-
useWindowing: true,
|
|
171
|
-
windowOverscan: 40,
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
|
|
175
162
|
const expand = useCallback(
|
|
176
163
|
( clientId ) => {
|
|
177
164
|
if ( ! clientId ) {
|
|
@@ -242,6 +229,25 @@ function ListViewComponent(
|
|
|
242
229
|
]
|
|
243
230
|
);
|
|
244
231
|
|
|
232
|
+
// List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
233
|
+
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
234
|
+
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
235
|
+
const [ fixedListWindow ] = useFixedWindowList(
|
|
236
|
+
elementRef,
|
|
237
|
+
BLOCK_LIST_ITEM_HEIGHT,
|
|
238
|
+
visibleBlockCount,
|
|
239
|
+
{
|
|
240
|
+
// Ensure that the windowing logic is recalculated when the expanded state changes.
|
|
241
|
+
// This is necessary because expanding a collapsed block in a short list view can
|
|
242
|
+
// switch the list view to a tall list view with a scrollbar, and vice versa.
|
|
243
|
+
// When this happens, the windowing logic needs to be recalculated to ensure that
|
|
244
|
+
// the correct number of blocks are rendered, by rechecking for a scroll container.
|
|
245
|
+
expandedState,
|
|
246
|
+
useWindowing: true,
|
|
247
|
+
windowOverscan: 40,
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
|
|
245
251
|
// If there are no blocks to show and we're not showing the appender, do not render the list view.
|
|
246
252
|
if ( ! clientIdsTree.length && ! showAppender ) {
|
|
247
253
|
return null;
|