@wordpress/block-editor 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +5 -20
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +33 -12
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +7 -20
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +82 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -2
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/copy-handler/index.js +44 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -10
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +36 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +131 -6
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +4 -18
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +31 -12
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +6 -18
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +67 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -2
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/copy-handler/index.js +44 -9
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -9
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +63 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +19 -16
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +120 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-style/style-rtl.css +145 -272
- package/build-style/style.css +145 -272
- package/package.json +28 -28
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +3 -23
- package/src/components/block-lock/modal.js +37 -13
- package/src/components/block-lock/style.scss +1 -2
- package/src/components/block-lock/toolbar.js +4 -21
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/index.js +13 -1
- package/src/components/block-switcher/style.scss +4 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/copy-handler/index.js +52 -10
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +2 -10
- package/src/components/list-view/block.js +16 -7
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +19 -15
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +160 -5
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/store/utils.js +19 -0
- package/src/style.scss +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -33,32 +33,32 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.16.0",
|
|
35
35
|
"@react-spring/web": "^9.2.4",
|
|
36
|
-
"@wordpress/a11y": "^3.
|
|
37
|
-
"@wordpress/api-fetch": "^6.
|
|
38
|
-
"@wordpress/blob": "^3.
|
|
39
|
-
"@wordpress/blocks": "^11.
|
|
40
|
-
"@wordpress/components": "^19.
|
|
41
|
-
"@wordpress/compose": "^5.
|
|
42
|
-
"@wordpress/data": "^6.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^4.
|
|
47
|
-
"@wordpress/hooks": "^3.
|
|
48
|
-
"@wordpress/html-entities": "^3.
|
|
49
|
-
"@wordpress/i18n": "^4.
|
|
50
|
-
"@wordpress/icons": "^8.
|
|
51
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
52
|
-
"@wordpress/keyboard-shortcuts": "^3.
|
|
53
|
-
"@wordpress/keycodes": "^3.
|
|
54
|
-
"@wordpress/notices": "^3.
|
|
55
|
-
"@wordpress/rich-text": "^5.
|
|
56
|
-
"@wordpress/shortcode": "^3.
|
|
57
|
-
"@wordpress/style-engine": "^0.
|
|
58
|
-
"@wordpress/token-list": "^2.
|
|
59
|
-
"@wordpress/url": "^3.
|
|
60
|
-
"@wordpress/warning": "^2.
|
|
61
|
-
"@wordpress/wordcount": "^3.
|
|
36
|
+
"@wordpress/a11y": "^3.7.0",
|
|
37
|
+
"@wordpress/api-fetch": "^6.4.0",
|
|
38
|
+
"@wordpress/blob": "^3.7.0",
|
|
39
|
+
"@wordpress/blocks": "^11.6.0",
|
|
40
|
+
"@wordpress/components": "^19.9.0",
|
|
41
|
+
"@wordpress/compose": "^5.5.0",
|
|
42
|
+
"@wordpress/data": "^6.7.0",
|
|
43
|
+
"@wordpress/date": "^4.7.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.7.0",
|
|
45
|
+
"@wordpress/dom": "^3.7.0",
|
|
46
|
+
"@wordpress/element": "^4.5.0",
|
|
47
|
+
"@wordpress/hooks": "^3.7.0",
|
|
48
|
+
"@wordpress/html-entities": "^3.7.0",
|
|
49
|
+
"@wordpress/i18n": "^4.7.0",
|
|
50
|
+
"@wordpress/icons": "^8.3.0",
|
|
51
|
+
"@wordpress/is-shallow-equal": "^4.7.0",
|
|
52
|
+
"@wordpress/keyboard-shortcuts": "^3.5.0",
|
|
53
|
+
"@wordpress/keycodes": "^3.7.0",
|
|
54
|
+
"@wordpress/notices": "^3.7.0",
|
|
55
|
+
"@wordpress/rich-text": "^5.5.0",
|
|
56
|
+
"@wordpress/shortcode": "^3.7.0",
|
|
57
|
+
"@wordpress/style-engine": "^0.6.0",
|
|
58
|
+
"@wordpress/token-list": "^2.7.0",
|
|
59
|
+
"@wordpress/url": "^3.8.0",
|
|
60
|
+
"@wordpress/warning": "^2.7.0",
|
|
61
|
+
"@wordpress/wordcount": "^3.7.0",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"colord": "^2.7.0",
|
|
64
64
|
"diff": "^4.0.2",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "1ba52312b56db563df2d8d4fba5b00613fb46d8c"
|
|
81
81
|
}
|
|
@@ -6,7 +6,7 @@ import classNames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { __, _x } from '@wordpress/i18n';
|
|
10
10
|
import {
|
|
11
11
|
ToolbarDropdownMenu,
|
|
12
12
|
ToolbarGroup,
|
|
@@ -31,7 +31,7 @@ import useAvailableAlignments from './use-available-alignments';
|
|
|
31
31
|
const BLOCK_ALIGNMENTS_CONTROLS = {
|
|
32
32
|
none: {
|
|
33
33
|
icon: alignNone,
|
|
34
|
-
title:
|
|
34
|
+
title: _x( 'None', 'Alignment option' ),
|
|
35
35
|
},
|
|
36
36
|
left: {
|
|
37
37
|
icon: positionLeft,
|
|
@@ -25,6 +25,7 @@ export default function BlockContentOverlay( {
|
|
|
25
25
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
|
+
canEdit,
|
|
28
29
|
isParentSelected,
|
|
29
30
|
hasChildSelected,
|
|
30
31
|
isDraggingBlocks,
|
|
@@ -36,8 +37,10 @@ export default function BlockContentOverlay( {
|
|
|
36
37
|
hasSelectedInnerBlock,
|
|
37
38
|
isDraggingBlocks: _isDraggingBlocks,
|
|
38
39
|
isBlockHighlighted,
|
|
40
|
+
canEditBlock,
|
|
39
41
|
} = select( blockEditorStore );
|
|
40
42
|
return {
|
|
43
|
+
canEdit: canEditBlock( clientId ),
|
|
41
44
|
isParentSelected: isBlockSelected( clientId ),
|
|
42
45
|
hasChildSelected: hasSelectedInnerBlock( clientId, true ),
|
|
43
46
|
isDraggingBlocks: _isDraggingBlocks(),
|
|
@@ -59,6 +62,12 @@ export default function BlockContentOverlay( {
|
|
|
59
62
|
);
|
|
60
63
|
|
|
61
64
|
useEffect( () => {
|
|
65
|
+
// The overlay is always active when editing is locked.
|
|
66
|
+
if ( ! canEdit ) {
|
|
67
|
+
setIsOverlayActive( true );
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
// Reenable when blocks are not in use.
|
|
63
72
|
if ( ! isParentSelected && ! hasChildSelected && ! isOverlayActive ) {
|
|
64
73
|
setIsOverlayActive( true );
|
|
@@ -75,7 +84,13 @@ export default function BlockContentOverlay( {
|
|
|
75
84
|
if ( hasChildSelected && isOverlayActive ) {
|
|
76
85
|
setIsOverlayActive( false );
|
|
77
86
|
}
|
|
78
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
isParentSelected,
|
|
89
|
+
hasChildSelected,
|
|
90
|
+
isOverlayActive,
|
|
91
|
+
isHovered,
|
|
92
|
+
canEdit,
|
|
93
|
+
] );
|
|
79
94
|
|
|
80
95
|
// Disabled because the overlay div doesn't actually have a role or functionality
|
|
81
96
|
// as far as the a11y is concerned. We're just catching the first click so that
|
|
@@ -88,7 +103,9 @@ export default function BlockContentOverlay( {
|
|
|
88
103
|
onMouseEnter={ () => setIsHovered( true ) }
|
|
89
104
|
onMouseLeave={ () => setIsHovered( false ) }
|
|
90
105
|
onMouseUp={
|
|
91
|
-
isOverlayActive
|
|
106
|
+
isOverlayActive && canEdit
|
|
107
|
+
? () => setIsOverlayActive( false )
|
|
108
|
+
: undefined
|
|
92
109
|
}
|
|
93
110
|
>
|
|
94
111
|
{ wrapperProps?.children }
|
|
@@ -47,6 +47,7 @@ function BlockForType( {
|
|
|
47
47
|
onDeleteBlock,
|
|
48
48
|
onReplace,
|
|
49
49
|
parentWidth,
|
|
50
|
+
parentBlockAlignment,
|
|
50
51
|
wrapperProps,
|
|
51
52
|
blockWidth,
|
|
52
53
|
baseGlobalStyles,
|
|
@@ -95,6 +96,7 @@ function BlockForType( {
|
|
|
95
96
|
contentStyle={ contentStyle }
|
|
96
97
|
onDeleteBlock={ onDeleteBlock }
|
|
97
98
|
blockWidth={ blockWidth }
|
|
99
|
+
parentBlockAlignment={ parentBlockAlignment }
|
|
98
100
|
/>
|
|
99
101
|
<View onLayout={ getBlockWidth } />
|
|
100
102
|
</GlobalStylesContext.Provider>
|
|
@@ -4,43 +4,23 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useReducer } from '@wordpress/element';
|
|
6
6
|
import { MenuItem } from '@wordpress/components';
|
|
7
|
-
import { useSelect } from '@wordpress/data';
|
|
8
7
|
import { lock, unlock } from '@wordpress/icons';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
12
|
+
import useBlockLock from './use-block-lock';
|
|
13
13
|
import BlockLockModal from './modal';
|
|
14
|
-
import { store as blockEditorStore } from '../../store';
|
|
15
14
|
|
|
16
15
|
export default function BlockLockMenuItem( { clientId } ) {
|
|
17
|
-
const {
|
|
18
|
-
( select ) => {
|
|
19
|
-
const {
|
|
20
|
-
canMoveBlock,
|
|
21
|
-
canRemoveBlock,
|
|
22
|
-
canLockBlockType,
|
|
23
|
-
getBlockName,
|
|
24
|
-
getBlockRootClientId,
|
|
25
|
-
} = select( blockEditorStore );
|
|
26
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
canLockBlock: canLockBlockType( getBlockName( clientId ) ),
|
|
30
|
-
isLocked:
|
|
31
|
-
! canMoveBlock( clientId, rootClientId ) ||
|
|
32
|
-
! canRemoveBlock( clientId, rootClientId ),
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
[ clientId ]
|
|
36
|
-
);
|
|
16
|
+
const { canLock, isLocked } = useBlockLock( clientId );
|
|
37
17
|
|
|
38
18
|
const [ isModalOpen, toggleModal ] = useReducer(
|
|
39
19
|
( isActive ) => ! isActive,
|
|
40
20
|
false
|
|
41
21
|
);
|
|
42
22
|
|
|
43
|
-
if ( !
|
|
23
|
+
if ( ! canLock ) {
|
|
44
24
|
return null;
|
|
45
25
|
}
|
|
46
26
|
|
|
@@ -14,27 +14,25 @@ import {
|
|
|
14
14
|
import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';
|
|
15
15
|
import { useInstanceId } from '@wordpress/compose';
|
|
16
16
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
17
|
+
import { isReusableBlock, getBlockType } from '@wordpress/blocks';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
20
21
|
*/
|
|
22
|
+
import useBlockLock from './use-block-lock';
|
|
21
23
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
22
24
|
import { store as blockEditorStore } from '../../store';
|
|
23
25
|
|
|
24
26
|
export default function BlockLockModal( { clientId, onClose } ) {
|
|
25
27
|
const [ lock, setLock ] = useState( { move: false, remove: false } );
|
|
26
|
-
const { canMove, canRemove } =
|
|
28
|
+
const { canEdit, canMove, canRemove } = useBlockLock( clientId );
|
|
29
|
+
const { isReusable } = useSelect(
|
|
27
30
|
( select ) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
canRemoveBlock,
|
|
31
|
-
getBlockRootClientId,
|
|
32
|
-
} = select( blockEditorStore );
|
|
33
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
31
|
+
const { getBlockName } = select( blockEditorStore );
|
|
32
|
+
const blockName = getBlockName( clientId );
|
|
34
33
|
|
|
35
34
|
return {
|
|
36
|
-
|
|
37
|
-
canRemove: canRemoveBlock( clientId, rootClientId ),
|
|
35
|
+
isReusable: isReusableBlock( getBlockType( blockName ) ),
|
|
38
36
|
};
|
|
39
37
|
},
|
|
40
38
|
[ clientId ]
|
|
@@ -50,12 +48,12 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
50
48
|
setLock( {
|
|
51
49
|
move: ! canMove,
|
|
52
50
|
remove: ! canRemove,
|
|
51
|
+
...( isReusable ? { edit: ! canEdit } : {} ),
|
|
53
52
|
} );
|
|
54
|
-
}, [ canMove, canRemove ] );
|
|
53
|
+
}, [ canEdit, canMove, canRemove, isReusable ] );
|
|
55
54
|
|
|
56
55
|
const isAllChecked = Object.values( lock ).every( Boolean );
|
|
57
|
-
const
|
|
58
|
-
Object.values( lock ).some( Boolean ) && ! isAllChecked;
|
|
56
|
+
const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;
|
|
59
57
|
|
|
60
58
|
return (
|
|
61
59
|
<Modal
|
|
@@ -91,15 +89,41 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
91
89
|
<span id={ instanceId }>{ __( 'Lock all' ) }</span>
|
|
92
90
|
}
|
|
93
91
|
checked={ isAllChecked }
|
|
94
|
-
indeterminate={
|
|
92
|
+
indeterminate={ isMixed }
|
|
95
93
|
onChange={ ( newValue ) =>
|
|
96
94
|
setLock( {
|
|
97
95
|
move: newValue,
|
|
98
96
|
remove: newValue,
|
|
97
|
+
...( isReusable ? { edit: newValue } : {} ),
|
|
99
98
|
} )
|
|
100
99
|
}
|
|
101
100
|
/>
|
|
102
101
|
<ul className="block-editor-block-lock-modal__checklist">
|
|
102
|
+
{ isReusable && (
|
|
103
|
+
<li className="block-editor-block-lock-modal__checklist-item">
|
|
104
|
+
<CheckboxControl
|
|
105
|
+
label={
|
|
106
|
+
<>
|
|
107
|
+
{ __( 'Restrict editing' ) }
|
|
108
|
+
<Icon
|
|
109
|
+
icon={
|
|
110
|
+
lock.edit
|
|
111
|
+
? lockIcon
|
|
112
|
+
: unlockIcon
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
</>
|
|
116
|
+
}
|
|
117
|
+
checked={ !! lock.edit }
|
|
118
|
+
onChange={ ( edit ) =>
|
|
119
|
+
setLock( ( prevLock ) => ( {
|
|
120
|
+
...prevLock,
|
|
121
|
+
edit,
|
|
122
|
+
} ) )
|
|
123
|
+
}
|
|
124
|
+
/>
|
|
125
|
+
</li>
|
|
126
|
+
) }
|
|
103
127
|
<li className="block-editor-block-lock-modal__checklist-item">
|
|
104
128
|
<CheckboxControl
|
|
105
129
|
label={
|
|
@@ -5,45 +5,28 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
5
5
|
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
6
6
|
import { useReducer } from '@wordpress/element';
|
|
7
7
|
import { lock } from '@wordpress/icons';
|
|
8
|
-
import { useSelect } from '@wordpress/data';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
13
12
|
import BlockLockModal from './modal';
|
|
13
|
+
import useBlockLock from './use-block-lock';
|
|
14
14
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
15
|
-
import { store as blockEditorStore } from '../../store';
|
|
16
15
|
|
|
17
16
|
export default function BlockLockToolbar( { clientId } ) {
|
|
18
17
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
19
|
-
const { canMove, canRemove,
|
|
20
|
-
( select ) => {
|
|
21
|
-
const {
|
|
22
|
-
canMoveBlock,
|
|
23
|
-
canRemoveBlock,
|
|
24
|
-
canLockBlockType,
|
|
25
|
-
getBlockName,
|
|
26
|
-
} = select( blockEditorStore );
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
canMove: canMoveBlock( clientId ),
|
|
30
|
-
canRemove: canRemoveBlock( clientId ),
|
|
31
|
-
canLockBlock: canLockBlockType( getBlockName( clientId ) ),
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
[ clientId ]
|
|
35
|
-
);
|
|
18
|
+
const { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );
|
|
36
19
|
|
|
37
20
|
const [ isModalOpen, toggleModal ] = useReducer(
|
|
38
21
|
( isActive ) => ! isActive,
|
|
39
22
|
false
|
|
40
23
|
);
|
|
41
24
|
|
|
42
|
-
if ( !
|
|
25
|
+
if ( ! canLock ) {
|
|
43
26
|
return null;
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
if ( canMove && canRemove ) {
|
|
29
|
+
if ( canEdit && canMove && canRemove ) {
|
|
47
30
|
return null;
|
|
48
31
|
}
|
|
49
32
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Return details about the block lock status.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} clientId The block client Id.
|
|
15
|
+
*
|
|
16
|
+
* @return {Object} Block lock status
|
|
17
|
+
*/
|
|
18
|
+
export default function useBlockLock( clientId ) {
|
|
19
|
+
return useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const {
|
|
22
|
+
canEditBlock,
|
|
23
|
+
canMoveBlock,
|
|
24
|
+
canRemoveBlock,
|
|
25
|
+
canLockBlockType,
|
|
26
|
+
getBlockName,
|
|
27
|
+
getBlockRootClientId,
|
|
28
|
+
} = select( blockEditorStore );
|
|
29
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
30
|
+
|
|
31
|
+
const canEdit = canEditBlock( clientId );
|
|
32
|
+
const canMove = canMoveBlock( clientId, rootClientId );
|
|
33
|
+
const canRemove = canRemoveBlock( clientId, rootClientId );
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
canEdit,
|
|
37
|
+
canMove,
|
|
38
|
+
canRemove,
|
|
39
|
+
canLock: canLockBlockType( getBlockName( clientId ) ),
|
|
40
|
+
isLocked: ! canEdit || ! canMove || ! canRemove,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
[ clientId ]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -8,7 +8,7 @@ import { castArray, first, last } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { getBlockType } from '@wordpress/blocks';
|
|
11
|
-
import { Button } from '@wordpress/components';
|
|
11
|
+
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
12
12
|
import { useInstanceId } from '@wordpress/compose';
|
|
13
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
14
|
import { forwardRef } from '@wordpress/element';
|
|
@@ -139,12 +139,10 @@ const BlockMoverButton = forwardRef(
|
|
|
139
139
|
aria-describedby={ descriptionId }
|
|
140
140
|
{ ...props }
|
|
141
141
|
onClick={ isDisabled ? null : onClick }
|
|
142
|
-
|
|
142
|
+
disabled={ isDisabled }
|
|
143
|
+
__experimentalIsFocusable
|
|
143
144
|
/>
|
|
144
|
-
<
|
|
145
|
-
id={ descriptionId }
|
|
146
|
-
className="block-editor-block-mover-button__description"
|
|
147
|
-
>
|
|
145
|
+
<VisuallyHidden id={ descriptionId }>
|
|
148
146
|
{ getBlockMoverDescription(
|
|
149
147
|
blocksCount,
|
|
150
148
|
blockType && blockType.title,
|
|
@@ -154,7 +152,7 @@ const BlockMoverButton = forwardRef(
|
|
|
154
152
|
direction === 'up' ? -1 : 1,
|
|
155
153
|
orientation
|
|
156
154
|
) }
|
|
157
|
-
</
|
|
155
|
+
</VisuallyHidden>
|
|
158
156
|
</>
|
|
159
157
|
);
|
|
160
158
|
}
|
|
@@ -10,9 +10,7 @@ import classnames from 'classnames';
|
|
|
10
10
|
|
|
11
11
|
import { dragHandle } from '@wordpress/icons';
|
|
12
12
|
import { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';
|
|
13
|
-
import {
|
|
14
|
-
import { useState } from '@wordpress/element';
|
|
15
|
-
import { withSelect } from '@wordpress/data';
|
|
13
|
+
import { useSelect } from '@wordpress/data';
|
|
16
14
|
import { __ } from '@wordpress/i18n';
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -22,20 +20,35 @@ import BlockDraggable from '../block-draggable';
|
|
|
22
20
|
import { BlockMoverUpButton, BlockMoverDownButton } from './button';
|
|
23
21
|
import { store as blockEditorStore } from '../../store';
|
|
24
22
|
|
|
25
|
-
function BlockMover( {
|
|
26
|
-
isFirst,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} )
|
|
35
|
-
|
|
23
|
+
function BlockMover( { clientIds, hideDragHandle } ) {
|
|
24
|
+
const { canMove, rootClientId, isFirst, isLast, orientation } = useSelect(
|
|
25
|
+
( select ) => {
|
|
26
|
+
const {
|
|
27
|
+
getBlockIndex,
|
|
28
|
+
getBlockListSettings,
|
|
29
|
+
canMoveBlocks,
|
|
30
|
+
getBlockOrder,
|
|
31
|
+
getBlockRootClientId,
|
|
32
|
+
} = select( blockEditorStore );
|
|
33
|
+
const normalizedClientIds = castArray( clientIds );
|
|
34
|
+
const firstClientId = first( normalizedClientIds );
|
|
35
|
+
const _rootClientId = getBlockRootClientId(
|
|
36
|
+
first( normalizedClientIds )
|
|
37
|
+
);
|
|
38
|
+
const firstIndex = getBlockIndex( firstClientId );
|
|
39
|
+
const lastIndex = getBlockIndex( last( normalizedClientIds ) );
|
|
40
|
+
const blockOrder = getBlockOrder( _rootClientId );
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
return {
|
|
43
|
+
canMove: canMoveBlocks( clientIds, _rootClientId ),
|
|
44
|
+
rootClientId: _rootClientId,
|
|
45
|
+
isFirst: firstIndex === 0,
|
|
46
|
+
isLast: lastIndex === blockOrder.length - 1,
|
|
47
|
+
orientation: getBlockListSettings( _rootClientId )?.orientation,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
[ clientIds ]
|
|
51
|
+
);
|
|
39
52
|
|
|
40
53
|
if ( ! canMove || ( isFirst && isLast && ! rootClientId ) ) {
|
|
41
54
|
return null;
|
|
@@ -43,22 +56,14 @@ function BlockMover( {
|
|
|
43
56
|
|
|
44
57
|
const dragHandleLabel = __( 'Drag' );
|
|
45
58
|
|
|
46
|
-
// We emulate a disabled state because forcefully applying the `disabled`
|
|
47
|
-
// attribute on the buttons while it has focus causes the screen to change
|
|
48
|
-
// to an unfocused state (body as active element) without firing blur on,
|
|
49
|
-
// the rendering parent, leaving it unable to react to focus out.
|
|
50
59
|
return (
|
|
51
|
-
<
|
|
60
|
+
<ToolbarGroup
|
|
52
61
|
className={ classnames( 'block-editor-block-mover', {
|
|
53
|
-
'is-visible': isFocused || ! isHidden,
|
|
54
62
|
'is-horizontal': orientation === 'horizontal',
|
|
55
63
|
} ) }
|
|
56
64
|
>
|
|
57
65
|
{ ! hideDragHandle && (
|
|
58
|
-
<BlockDraggable
|
|
59
|
-
clientIds={ clientIds }
|
|
60
|
-
cloneClassname="block-editor-block-mover__drag-clone"
|
|
61
|
-
>
|
|
66
|
+
<BlockDraggable clientIds={ clientIds }>
|
|
62
67
|
{ ( draggableProps ) => (
|
|
63
68
|
<Button
|
|
64
69
|
icon={ dragHandle }
|
|
@@ -73,8 +78,8 @@ function BlockMover( {
|
|
|
73
78
|
) }
|
|
74
79
|
</BlockDraggable>
|
|
75
80
|
) }
|
|
76
|
-
<
|
|
77
|
-
<ToolbarItem
|
|
81
|
+
<div className="block-editor-block-mover__move-button-container">
|
|
82
|
+
<ToolbarItem>
|
|
78
83
|
{ ( itemProps ) => (
|
|
79
84
|
<BlockMoverUpButton
|
|
80
85
|
clientIds={ clientIds }
|
|
@@ -82,7 +87,7 @@ function BlockMover( {
|
|
|
82
87
|
/>
|
|
83
88
|
) }
|
|
84
89
|
</ToolbarItem>
|
|
85
|
-
<ToolbarItem
|
|
90
|
+
<ToolbarItem>
|
|
86
91
|
{ ( itemProps ) => (
|
|
87
92
|
<BlockMoverDownButton
|
|
88
93
|
clientIds={ clientIds }
|
|
@@ -90,40 +95,12 @@ function BlockMover( {
|
|
|
90
95
|
/>
|
|
91
96
|
) }
|
|
92
97
|
</ToolbarItem>
|
|
93
|
-
</
|
|
94
|
-
</
|
|
98
|
+
</div>
|
|
99
|
+
</ToolbarGroup>
|
|
95
100
|
);
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
/**
|
|
99
104
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md
|
|
100
105
|
*/
|
|
101
|
-
export default
|
|
102
|
-
const {
|
|
103
|
-
getBlock,
|
|
104
|
-
getBlockIndex,
|
|
105
|
-
getBlockListSettings,
|
|
106
|
-
canMoveBlocks,
|
|
107
|
-
getBlockOrder,
|
|
108
|
-
getBlockRootClientId,
|
|
109
|
-
} = select( blockEditorStore );
|
|
110
|
-
const normalizedClientIds = castArray( clientIds );
|
|
111
|
-
const firstClientId = first( normalizedClientIds );
|
|
112
|
-
const block = getBlock( firstClientId );
|
|
113
|
-
const rootClientId = getBlockRootClientId( first( normalizedClientIds ) );
|
|
114
|
-
const firstIndex = getBlockIndex( firstClientId );
|
|
115
|
-
const lastIndex = getBlockIndex( last( normalizedClientIds ) );
|
|
116
|
-
const blockOrder = getBlockOrder( rootClientId );
|
|
117
|
-
const isFirst = firstIndex === 0;
|
|
118
|
-
const isLast = lastIndex === blockOrder.length - 1;
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
blockType: block ? getBlockType( block.name ) : null,
|
|
122
|
-
canMove: canMoveBlocks( clientIds, rootClientId ),
|
|
123
|
-
rootClientId,
|
|
124
|
-
firstIndex,
|
|
125
|
-
isFirst,
|
|
126
|
-
isLast,
|
|
127
|
-
orientation: getBlockListSettings( rootClientId )?.orientation,
|
|
128
|
-
};
|
|
129
|
-
} )( BlockMover );
|
|
106
|
+
export default BlockMover;
|