@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
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
align-items: flex-start;
|
|
12
12
|
|
|
13
13
|
> .components-unit-control-wrapper {
|
|
14
|
-
width:
|
|
14
|
+
width: 110px;
|
|
15
15
|
margin-bottom: 0;
|
|
16
|
+
margin-right: #{ $grid-unit-10 };
|
|
17
|
+
flex-shrink: 0;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
.components-range-control {
|
|
19
|
-
|
|
21
|
+
flex: 1;
|
|
20
22
|
margin-bottom: 0;
|
|
21
23
|
|
|
22
24
|
.components-base-control__field {
|
|
@@ -49,6 +51,7 @@
|
|
|
49
51
|
.component-border-radius-control__linked-button.has-icon {
|
|
50
52
|
display: flex;
|
|
51
53
|
justify-content: center;
|
|
54
|
+
margin-left: 2px;
|
|
52
55
|
|
|
53
56
|
svg {
|
|
54
57
|
margin-right: 0;
|
|
@@ -78,10 +78,18 @@ export function useClipboardHandler() {
|
|
|
78
78
|
getSelectedBlockClientIds,
|
|
79
79
|
hasMultiSelection,
|
|
80
80
|
getSettings,
|
|
81
|
+
__unstableIsFullySelected,
|
|
82
|
+
__unstableIsSelectionCollapsed,
|
|
83
|
+
__unstableIsSelectionMergeable,
|
|
84
|
+
__unstableGetSelectedBlocksWithPartialSelection,
|
|
81
85
|
} = useSelect( blockEditorStore );
|
|
82
|
-
const {
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
const {
|
|
87
|
+
flashBlock,
|
|
88
|
+
removeBlocks,
|
|
89
|
+
replaceBlocks,
|
|
90
|
+
__unstableDeleteSelection,
|
|
91
|
+
__unstableExpandSelection,
|
|
92
|
+
} = useDispatch( blockEditorStore );
|
|
85
93
|
const notifyCopy = useNotifyCopy();
|
|
86
94
|
|
|
87
95
|
return useRefEffect( ( node ) => {
|
|
@@ -116,20 +124,54 @@ export function useClipboardHandler() {
|
|
|
116
124
|
const eventDefaultPrevented = event.defaultPrevented;
|
|
117
125
|
event.preventDefault();
|
|
118
126
|
|
|
127
|
+
const isSelectionMergeable = __unstableIsSelectionMergeable();
|
|
128
|
+
const shouldHandleWholeBlocks =
|
|
129
|
+
__unstableIsSelectionCollapsed() || __unstableIsFullySelected();
|
|
130
|
+
const expandSelectionIsNeeded =
|
|
131
|
+
! shouldHandleWholeBlocks && ! isSelectionMergeable;
|
|
119
132
|
if ( event.type === 'copy' || event.type === 'cut' ) {
|
|
120
133
|
if ( selectedBlockClientIds.length === 1 ) {
|
|
121
134
|
flashBlock( selectedBlockClientIds[ 0 ] );
|
|
122
135
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
// If we have a partial selection that is not mergeable, just
|
|
137
|
+
// expand the selection to the whole blocks.
|
|
138
|
+
if ( expandSelectionIsNeeded ) {
|
|
139
|
+
__unstableExpandSelection();
|
|
140
|
+
} else {
|
|
141
|
+
notifyCopy( event.type, selectedBlockClientIds );
|
|
142
|
+
let blocks;
|
|
143
|
+
// Check if we have partial selection.
|
|
144
|
+
if ( shouldHandleWholeBlocks ) {
|
|
145
|
+
blocks = getBlocksByClientId( selectedBlockClientIds );
|
|
146
|
+
} else {
|
|
147
|
+
const [
|
|
148
|
+
head,
|
|
149
|
+
tail,
|
|
150
|
+
] = __unstableGetSelectedBlocksWithPartialSelection();
|
|
151
|
+
const inBetweenBlocks = getBlocksByClientId(
|
|
152
|
+
selectedBlockClientIds.slice(
|
|
153
|
+
1,
|
|
154
|
+
selectedBlockClientIds.length - 1
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
blocks = [ head, ...inBetweenBlocks, tail ];
|
|
158
|
+
}
|
|
159
|
+
const serialized = serialize( blocks );
|
|
160
|
+
|
|
161
|
+
event.clipboardData.setData( 'text/plain', serialized );
|
|
162
|
+
event.clipboardData.setData( 'text/html', serialized );
|
|
163
|
+
}
|
|
129
164
|
}
|
|
130
165
|
|
|
131
166
|
if ( event.type === 'cut' ) {
|
|
132
|
-
|
|
167
|
+
// We need to also check if at the start we needed to
|
|
168
|
+
// expand the selection, as in this point we might have
|
|
169
|
+
// programmatically fully selected the blocks above.
|
|
170
|
+
if ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {
|
|
171
|
+
removeBlocks( selectedBlockClientIds );
|
|
172
|
+
} else {
|
|
173
|
+
__unstableDeleteSelection();
|
|
174
|
+
}
|
|
133
175
|
} else if ( event.type === 'paste' ) {
|
|
134
176
|
if ( eventDefaultPrevented ) {
|
|
135
177
|
// This was likely already handled in rich-text/use-paste-handler.js.
|
|
@@ -34,8 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
// The black plus that shows up on the right side of an empty paragraph block, or the initial appender
|
|
36
36
|
// that exists only on empty documents.
|
|
37
|
-
.block-editor-default-block-appender .block-editor-inserter
|
|
38
|
-
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter { // This needs specificity to override inherited popover styles.
|
|
37
|
+
.block-editor-default-block-appender .block-editor-inserter {
|
|
39
38
|
position: absolute;
|
|
40
39
|
top: 0;
|
|
41
40
|
right: 0;
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { DOWN } from '@wordpress/keycodes';
|
|
13
|
+
import { Icon, filter } from '@wordpress/icons';
|
|
13
14
|
|
|
14
15
|
function DuotoneControl( {
|
|
15
16
|
colorPalette,
|
|
@@ -41,7 +42,13 @@ function DuotoneControl( {
|
|
|
41
42
|
aria-expanded={ isOpen }
|
|
42
43
|
onKeyDown={ openOnArrowDown }
|
|
43
44
|
label={ __( 'Apply duotone filter' ) }
|
|
44
|
-
icon={
|
|
45
|
+
icon={
|
|
46
|
+
value ? (
|
|
47
|
+
<DuotoneSwatch values={ value } />
|
|
48
|
+
) : (
|
|
49
|
+
<Icon icon={ filter } />
|
|
50
|
+
)
|
|
51
|
+
}
|
|
45
52
|
/>
|
|
46
53
|
);
|
|
47
54
|
} }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Gradients
|
|
2
|
+
|
|
3
|
+
The `Gradients` component exposes tools for working with gradients
|
|
4
|
+
|
|
5
|
+
<a name="getGradientSlugByValue" href="#getGradientSlugByValue">#</a> **getGradientSlugByValue**
|
|
6
|
+
|
|
7
|
+
Retrieves the gradient slug per slug.
|
|
8
|
+
|
|
9
|
+
_Parameters_
|
|
10
|
+
|
|
11
|
+
- _gradients_ `Array`: Gradient Palette
|
|
12
|
+
- _value_ `string`: Gradient value
|
|
13
|
+
|
|
14
|
+
_Returns_
|
|
15
|
+
|
|
16
|
+
- `string`: Gradient slug.
|
|
17
|
+
|
|
18
|
+
<a name="getGradientValueBySlug" href="#getGradientValueBySlug">#</a> **getGradientValueBySlug**
|
|
19
|
+
|
|
20
|
+
Retrieves the gradient value per slug.
|
|
21
|
+
|
|
22
|
+
_Parameters_
|
|
23
|
+
|
|
24
|
+
- _gradients_ `Array`: Gradient Palette
|
|
25
|
+
- _slug_ `string`: Gradient slug
|
|
26
|
+
|
|
27
|
+
_Returns_
|
|
28
|
+
|
|
29
|
+
- `string`: Gradient value.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { AccessibilityInfo, Platform } from 'react-native';
|
|
4
|
+
import { AccessibilityInfo, Platform, Text } from 'react-native';
|
|
5
5
|
import { delay } from 'lodash';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -15,6 +15,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
|
15
15
|
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
16
16
|
import {
|
|
17
17
|
Icon,
|
|
18
|
+
plus,
|
|
18
19
|
plusCircle,
|
|
19
20
|
plusCircleFilled,
|
|
20
21
|
insertAfter,
|
|
@@ -32,27 +33,51 @@ import { store as blockEditorStore } from '../../store';
|
|
|
32
33
|
|
|
33
34
|
const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
34
35
|
|
|
35
|
-
const defaultRenderToggle = ( {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
const defaultRenderToggle = ( {
|
|
37
|
+
onToggle,
|
|
38
|
+
disabled,
|
|
39
|
+
style,
|
|
40
|
+
containerStyle,
|
|
41
|
+
onLongPress,
|
|
42
|
+
useExpandedMode,
|
|
43
|
+
} ) => {
|
|
44
|
+
// The "expanded mode" refers to the editor's appearance when no blocks
|
|
45
|
+
// are currently selected. The "add block" button has a separate style
|
|
46
|
+
// for the "expanded mode", which are added via the below "expandedModeViewProps"
|
|
47
|
+
// and "expandedModeViewText" variables.
|
|
48
|
+
const expandedModeViewProps = useExpandedMode && {
|
|
49
|
+
icon: <Icon icon={ plus } style={ style } />,
|
|
50
|
+
customContainerStyles: containerStyle,
|
|
51
|
+
fixedRatio: false,
|
|
52
|
+
};
|
|
53
|
+
const expandedModeViewText = (
|
|
54
|
+
<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>
|
|
55
|
+
{ __( 'Add Blocks' ) }
|
|
56
|
+
</Text>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<ToolbarButton
|
|
61
|
+
title={ _x(
|
|
62
|
+
'Add block',
|
|
63
|
+
'Generic label for block inserter button'
|
|
64
|
+
) }
|
|
65
|
+
icon={ <Icon icon={ plusCircleFilled } style={ style } /> }
|
|
66
|
+
onClick={ onToggle }
|
|
67
|
+
extraProps={ {
|
|
68
|
+
hint: __( 'Double tap to add a block' ),
|
|
69
|
+
// testID is present to disambiguate this element for native UI tests. It's not
|
|
70
|
+
// usually required for components. See: https://git.io/JeQ7G.
|
|
71
|
+
testID: 'add-block-button',
|
|
72
|
+
onLongPress,
|
|
73
|
+
} }
|
|
74
|
+
isDisabled={ disabled }
|
|
75
|
+
{ ...expandedModeViewProps }
|
|
76
|
+
>
|
|
77
|
+
{ useExpandedMode && expandedModeViewText }
|
|
78
|
+
</ToolbarButton>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
56
81
|
|
|
57
82
|
export class Inserter extends Component {
|
|
58
83
|
constructor() {
|
|
@@ -219,13 +244,21 @@ export class Inserter extends Component {
|
|
|
219
244
|
renderToggle = defaultRenderToggle,
|
|
220
245
|
getStylesFromColorScheme,
|
|
221
246
|
showSeparator,
|
|
247
|
+
useExpandedMode,
|
|
222
248
|
} = this.props;
|
|
223
249
|
if ( showSeparator && isOpen ) {
|
|
224
250
|
return <BlockInsertionPoint />;
|
|
225
251
|
}
|
|
226
|
-
const style =
|
|
227
|
-
styles
|
|
228
|
-
|
|
252
|
+
const style = useExpandedMode
|
|
253
|
+
? styles[ 'inserter-menu__add-block-button-icon--expanded' ]
|
|
254
|
+
: getStylesFromColorScheme(
|
|
255
|
+
styles[ 'inserter-menu__add-block-button-icon' ],
|
|
256
|
+
styles[ 'inserter-menu__add-block-button-icon--dark' ]
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
const containerStyle = getStylesFromColorScheme(
|
|
260
|
+
styles[ 'inserter-menu__add-block-button' ],
|
|
261
|
+
styles[ 'inserter-menu__add-block-button--dark' ]
|
|
229
262
|
);
|
|
230
263
|
|
|
231
264
|
const onPress = () => {
|
|
@@ -265,7 +298,9 @@ export class Inserter extends Component {
|
|
|
265
298
|
isOpen,
|
|
266
299
|
disabled,
|
|
267
300
|
style,
|
|
301
|
+
containerStyle,
|
|
268
302
|
onLongPress,
|
|
303
|
+
useExpandedMode,
|
|
269
304
|
} ) }
|
|
270
305
|
<Picker
|
|
271
306
|
ref={ ( instance ) => ( this.picker = instance ) }
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
|
|
3
|
-
.
|
|
4
|
-
color: $blue-
|
|
3
|
+
.inserter-menu__add-block-button-icon {
|
|
4
|
+
color: $blue-50;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.
|
|
7
|
+
.inserter-menu__add-block-button-icon--dark {
|
|
8
8
|
color: $blue-30;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
.inserter-menu__add-block-button-icon--expanded {
|
|
12
|
+
color: $white;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.inserter-menu__add-block-button {
|
|
16
|
+
border-radius: 22px;
|
|
17
|
+
background-color: $blue-50;
|
|
18
|
+
margin: 8px;
|
|
19
|
+
padding: 6px 16px 6px 12px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.inserter-menu__add-block-button--dark {
|
|
23
|
+
background-color: $blue-30;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.inserter-menu__add-block-button-text {
|
|
27
|
+
color: $white;
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
align-self: center;
|
|
30
|
+
}
|
|
31
|
+
|
|
11
32
|
.inserter-menu__list-wrapper {
|
|
12
33
|
flex: 1;
|
|
13
34
|
}
|
|
@@ -148,6 +148,10 @@ function LinkControl( {
|
|
|
148
148
|
|
|
149
149
|
const currentInputIsEmpty = ! currentInputValue?.trim()?.length;
|
|
150
150
|
|
|
151
|
+
const { createPage, isCreatingPage, errorMessage } = useCreatePage(
|
|
152
|
+
createSuggestion
|
|
153
|
+
);
|
|
154
|
+
|
|
151
155
|
useEffect( () => {
|
|
152
156
|
if (
|
|
153
157
|
forceIsEditingLink !== undefined &&
|
|
@@ -185,7 +189,7 @@ function LinkControl( {
|
|
|
185
189
|
nextFocusTarget.focus();
|
|
186
190
|
|
|
187
191
|
isEndingEditWithFocus.current = false;
|
|
188
|
-
}, [ isEditingLink ] );
|
|
192
|
+
}, [ isEditingLink, isCreatingPage ] );
|
|
189
193
|
|
|
190
194
|
useEffect( () => {
|
|
191
195
|
/**
|
|
@@ -217,10 +221,6 @@ function LinkControl( {
|
|
|
217
221
|
setIsEditingLink( false );
|
|
218
222
|
}
|
|
219
223
|
|
|
220
|
-
const { createPage, isCreatingPage, errorMessage } = useCreatePage(
|
|
221
|
-
createSuggestion
|
|
222
|
-
);
|
|
223
|
-
|
|
224
224
|
const handleSelectSuggestion = ( updatedValue ) => {
|
|
225
225
|
onChange( {
|
|
226
226
|
...updatedValue,
|
|
@@ -8,7 +8,6 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { Button } from '@wordpress/components';
|
|
10
10
|
import { forwardRef } from '@wordpress/element';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
12
11
|
import { Icon, lock } from '@wordpress/icons';
|
|
13
12
|
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
14
13
|
|
|
@@ -19,7 +18,7 @@ import BlockIcon from '../block-icon';
|
|
|
19
18
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
20
19
|
import BlockTitle from '../block-title';
|
|
21
20
|
import ListViewExpander from './expander';
|
|
22
|
-
import {
|
|
21
|
+
import { useBlockLock } from '../block-lock';
|
|
23
22
|
|
|
24
23
|
function ListViewBlockSelectButton(
|
|
25
24
|
{
|
|
@@ -36,14 +35,7 @@ function ListViewBlockSelectButton(
|
|
|
36
35
|
ref
|
|
37
36
|
) {
|
|
38
37
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
39
|
-
const isLocked =
|
|
40
|
-
( select ) => {
|
|
41
|
-
const { canMoveBlock, canRemoveBlock } = select( blockEditorStore );
|
|
42
|
-
|
|
43
|
-
return ! canMoveBlock( clientId ) || ! canRemoveBlock( clientId );
|
|
44
|
-
},
|
|
45
|
-
[ clientId ]
|
|
46
|
-
);
|
|
38
|
+
const { isLocked } = useBlockLock( clientId );
|
|
47
39
|
|
|
48
40
|
// The `href` attribute triggers the browser's native HTML drag operations.
|
|
49
41
|
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
@@ -36,6 +36,7 @@ import { useListViewContext } from './context';
|
|
|
36
36
|
import { getBlockPositionDescription } from './utils';
|
|
37
37
|
import { store as blockEditorStore } from '../../store';
|
|
38
38
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
39
|
+
import { useBlockLock } from '../block-lock';
|
|
39
40
|
|
|
40
41
|
function ListViewBlock( {
|
|
41
42
|
block,
|
|
@@ -65,6 +66,7 @@ function ListViewBlock( {
|
|
|
65
66
|
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
66
67
|
|
|
67
68
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
69
|
+
const { isLocked } = useBlockLock( clientId );
|
|
68
70
|
const instanceId = useInstanceId( ListViewBlock );
|
|
69
71
|
const descriptionId = `list-view-block-select-button__${ instanceId }`;
|
|
70
72
|
const blockPositionDescription = getBlockPositionDescription(
|
|
@@ -73,13 +75,20 @@ function ListViewBlock( {
|
|
|
73
75
|
level
|
|
74
76
|
);
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
let blockAriaLabel = __( 'Link' );
|
|
79
|
+
if ( blockInformation ) {
|
|
80
|
+
blockAriaLabel = isLocked
|
|
81
|
+
? sprintf(
|
|
82
|
+
// translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
83
|
+
__( '%s link (locked)' ),
|
|
84
|
+
blockInformation.title
|
|
85
|
+
)
|
|
86
|
+
: sprintf(
|
|
87
|
+
// translators: %s: The title of the block. This string indicates a link to select the block.
|
|
88
|
+
__( '%s link' ),
|
|
89
|
+
blockInformation.title
|
|
90
|
+
);
|
|
91
|
+
}
|
|
83
92
|
|
|
84
93
|
const settingsAriaLabel = blockInformation
|
|
85
94
|
? sprintf(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# NavigableToolbar
|
|
2
|
+
|
|
3
|
+
A toolbar that can be navigated with a keyboard
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
The component accepts the following props. Props not included in this set will be applied to the element wrapping NavigableMenu content.
|
|
8
|
+
|
|
9
|
+
## `focusOnMount`
|
|
10
|
+
|
|
11
|
+
Whether to immediately focus when the component mounts.
|
|
12
|
+
|
|
13
|
+
- Type: `Boolean`
|
|
14
|
+
- Required: No
|
|
15
|
+
- Default: false
|
|
16
|
+
|
|
@@ -36,7 +36,6 @@ import { useBlockEditContext } from '../block-edit';
|
|
|
36
36
|
import FormatToolbarContainer from './format-toolbar-container';
|
|
37
37
|
import { store as blockEditorStore } from '../../store';
|
|
38
38
|
import { useUndoAutomaticChange } from './use-undo-automatic-change';
|
|
39
|
-
import { useCaretInFormat } from './use-caret-in-format';
|
|
40
39
|
import { useMarkPersistent } from './use-mark-persistent';
|
|
41
40
|
import { usePasteHandler } from './use-paste-handler';
|
|
42
41
|
import { useInputRules } from './use-input-rules';
|
|
@@ -268,7 +267,6 @@ function RichTextWrapper(
|
|
|
268
267
|
onChange,
|
|
269
268
|
} );
|
|
270
269
|
|
|
271
|
-
useCaretInFormat( { value } );
|
|
272
270
|
useMarkPersistent( { html: adjustedValue, value } );
|
|
273
271
|
|
|
274
272
|
const keyboardShortcuts = useRef( new Set() );
|
|
@@ -125,7 +125,6 @@ function RichTextWrapper(
|
|
|
125
125
|
const embedHandlerPickerRef = useRef();
|
|
126
126
|
const selector = ( select ) => {
|
|
127
127
|
const {
|
|
128
|
-
isCaretWithinFormattedText,
|
|
129
128
|
getSelectionStart,
|
|
130
129
|
getSelectionEnd,
|
|
131
130
|
getSettings,
|
|
@@ -163,7 +162,6 @@ function RichTextWrapper(
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
return {
|
|
166
|
-
isCaretWithinFormattedText: isCaretWithinFormattedText(),
|
|
167
165
|
selectionStart: isSelected ? selectionStart.offset : undefined,
|
|
168
166
|
selectionEnd: isSelected ? selectionEnd.offset : undefined,
|
|
169
167
|
isSelected,
|
|
@@ -177,7 +175,6 @@ function RichTextWrapper(
|
|
|
177
175
|
// retrieved from the store on merge.
|
|
178
176
|
// To do: fix this somehow.
|
|
179
177
|
const {
|
|
180
|
-
isCaretWithinFormattedText,
|
|
181
178
|
selectionStart,
|
|
182
179
|
selectionEnd,
|
|
183
180
|
isSelected,
|
|
@@ -600,7 +597,6 @@ function RichTextWrapper(
|
|
|
600
597
|
__unstableIsSelected={ isSelected }
|
|
601
598
|
__unstableInputRule={ inputRule }
|
|
602
599
|
__unstableMultilineTag={ multilineTag }
|
|
603
|
-
__unstableIsCaretWithinFormattedText={ isCaretWithinFormattedText }
|
|
604
600
|
__unstableOnEnterFormattedText={ enterFormattedText }
|
|
605
601
|
__unstableOnExitFormattedText={ exitFormattedText }
|
|
606
602
|
__unstableOnCreateUndoLevel={ __unstableMarkLastChangeAsPersistent }
|
|
@@ -19,6 +19,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
19
19
|
* @property {string} title Human-readable block type label.
|
|
20
20
|
* @property {WPIcon} icon Block type icon.
|
|
21
21
|
* @property {string} description A detailed block type description.
|
|
22
|
+
* @property {string} anchor HTML anchor.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -63,6 +64,7 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
63
64
|
title: match.title || blockType.title,
|
|
64
65
|
icon: match.icon || blockType.icon,
|
|
65
66
|
description: match.description || blockType.description,
|
|
67
|
+
anchor: attributes?.anchor,
|
|
66
68
|
};
|
|
67
69
|
},
|
|
68
70
|
[ clientId ]
|