@wordpress/block-editor 12.19.3 → 12.19.4
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/build/components/block-edit/context.js +2 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +8 -3
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-preview/index.js +4 -0
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +21 -8
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/index.js +6 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +80 -23
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/link-preview.js +4 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/rich-text/index.js +45 -25
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +3 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/hooks/block-hooks.js +8 -6
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/border.js +6 -4
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +2 -4
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +0 -10
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -8
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -16
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -4
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -5
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -0
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +22 -10
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +82 -24
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/rich-text/index.js +45 -26
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +3 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/hooks/block-hooks.js +8 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/border.js +7 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +3 -5
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +0 -9
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +47 -14
- package/build-style/style.css +47 -14
- package/package.json +7 -7
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +5 -1
- package/src/components/block-inspector/index.js +7 -5
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-toolbar/style.scss +11 -6
- package/src/components/global-styles/border-panel.js +33 -22
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/shadow-panel-components.js +92 -23
- package/src/components/global-styles/style.scss +33 -10
- package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/src/components/link-control/link-preview.js +9 -2
- package/src/components/link-control/style.scss +9 -0
- package/src/components/rich-text/index.js +74 -51
- package/src/components/rich-text/use-enter.js +4 -0
- package/src/components/url-popover/style.scss +1 -0
- package/src/hooks/block-hooks.js +10 -5
- package/src/hooks/block-hooks.scss +6 -0
- package/src/hooks/border.js +16 -4
- package/src/hooks/use-bindings-attributes.js +5 -7
- package/src/private-apis.js +2 -0
- package/src/store/private-actions.js +0 -10
- package/src/store/private-selectors.js +0 -8
- package/src/store/reducer.js +0 -15
|
@@ -2,10 +2,24 @@
|
|
|
2
2
|
fill: currentColor;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
// @todo: Ideally, popover, swatch size, and gap values should be CSS variables
|
|
6
|
+
// to apply precise grid layouts.
|
|
7
|
+
// https://github.com/WordPress/gutenberg/blob/954ecae571abbddc113d3a4bd8e1a72230180554/packages/block-editor/src/components/duotone-control/style.scss#L3-L9
|
|
5
8
|
.block-editor-global-styles__shadow-popover-container {
|
|
6
9
|
width: 230px;
|
|
7
10
|
}
|
|
8
11
|
|
|
12
|
+
.block-editor-global-styles__shadow__list {
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 12px;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
padding-bottom: $grid-unit-10;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.block-editor-global-styles__clear-shadow {
|
|
20
|
+
text-align: right;
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
.block-editor-global-styles-filters-panel__dropdown,
|
|
10
24
|
.block-editor-global-styles__shadow-dropdown {
|
|
11
25
|
display: block;
|
|
@@ -21,14 +35,6 @@
|
|
|
21
35
|
}
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
// wrapper to clip the shadow beyond 6px
|
|
25
|
-
.block-editor-global-styles__shadow-indicator-wrapper {
|
|
26
|
-
padding: $grid-unit-15 * 0.5;
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
38
|
// These styles are similar to the color palette.
|
|
33
39
|
.block-editor-global-styles__shadow-indicator {
|
|
34
40
|
color: $gray-800;
|
|
@@ -37,8 +43,25 @@
|
|
|
37
43
|
cursor: pointer;
|
|
38
44
|
padding: 0;
|
|
39
45
|
|
|
40
|
-
height: $button-size-small;
|
|
41
|
-
width: $button-size-small;
|
|
46
|
+
height: $button-size-small + 2 * $border-width;
|
|
47
|
+
width: $button-size-small + 2 * $border-width;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
|
|
50
|
+
transform: scale(1);
|
|
51
|
+
transition: transform 0.1s ease;
|
|
52
|
+
will-change: transform;
|
|
53
|
+
|
|
54
|
+
&:focus {
|
|
55
|
+
border: #{ $border-width * 2 } solid $gray-700;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:hover {
|
|
59
|
+
transform: scale(1.2);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&.unset {
|
|
63
|
+
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
64
|
+
}
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
.block-editor-global-styles-advanced-panel__custom-css-input textarea {
|
|
@@ -11,10 +11,10 @@ import { __ } from '@wordpress/i18n';
|
|
|
11
11
|
import BlockStyles from '../block-styles';
|
|
12
12
|
import DefaultStylePicker from '../default-style-picker';
|
|
13
13
|
import InspectorControls from '../inspector-controls';
|
|
14
|
-
import {
|
|
14
|
+
import { useBorderPanelLabel } from '../../hooks/border';
|
|
15
15
|
|
|
16
16
|
const StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {
|
|
17
|
-
const borderPanelLabel =
|
|
17
|
+
const borderPanelLabel = useBorderPanelLabel( { blockName } );
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<>
|
|
@@ -16,8 +16,9 @@ import { useCopyToClipboard } from '@wordpress/compose';
|
|
|
16
16
|
import { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';
|
|
17
17
|
import { Icon, globe, info, linkOff, edit, copySmall } from '@wordpress/icons';
|
|
18
18
|
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
19
|
-
import { useDispatch } from '@wordpress/data';
|
|
19
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
20
20
|
import { store as noticesStore } from '@wordpress/notices';
|
|
21
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Internal dependencies
|
|
@@ -33,6 +34,12 @@ export default function LinkPreview( {
|
|
|
33
34
|
hasUnlinkControl = false,
|
|
34
35
|
onRemove,
|
|
35
36
|
} ) {
|
|
37
|
+
const showIconLabels = useSelect(
|
|
38
|
+
( select ) =>
|
|
39
|
+
select( preferencesStore ).get( 'core', 'showIconLabels' ),
|
|
40
|
+
[]
|
|
41
|
+
);
|
|
42
|
+
|
|
36
43
|
// Avoid fetching if rich previews are not desired.
|
|
37
44
|
const showRichPreviews = hasRichPreviews ? value?.url : null;
|
|
38
45
|
|
|
@@ -139,7 +146,7 @@ export default function LinkPreview( {
|
|
|
139
146
|
label={ sprintf(
|
|
140
147
|
// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).
|
|
141
148
|
__( 'Copy link%s' ), // Ends up looking like "Copy link: https://example.com".
|
|
142
|
-
isEmptyURL ? '' : ': ' + value.url
|
|
149
|
+
isEmptyURL || showIconLabels ? '' : ': ' + value.url
|
|
143
150
|
) }
|
|
144
151
|
ref={ ref }
|
|
145
152
|
disabled={ isEmptyURL }
|
|
@@ -34,6 +34,15 @@ $block-editor-link-control-number-of-actions: 1;
|
|
|
34
34
|
content: attr(aria-label);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
.block-editor-link-control__search-item-top {
|
|
39
|
+
gap: $grid-unit-10;
|
|
40
|
+
|
|
41
|
+
.components-button.has-icon {
|
|
42
|
+
min-width: inherit;
|
|
43
|
+
width: min-content;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
48
|
|
|
@@ -19,13 +19,14 @@ import {
|
|
|
19
19
|
removeFormat,
|
|
20
20
|
} from '@wordpress/rich-text';
|
|
21
21
|
import { Popover } from '@wordpress/components';
|
|
22
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
22
|
+
import { getBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
27
|
import { useBlockEditorAutocompleteProps } from '../autocomplete';
|
|
28
28
|
import { useBlockEditContext } from '../block-edit';
|
|
29
|
+
import { blockBindingsKey } from '../block-edit/context';
|
|
29
30
|
import FormatToolbarContainer from './format-toolbar-container';
|
|
30
31
|
import { store as blockEditorStore } from '../../store';
|
|
31
32
|
import { useUndoAutomaticChange } from './use-undo-automatic-change';
|
|
@@ -109,6 +110,7 @@ export function RichTextWrapper(
|
|
|
109
110
|
__unstableDisableFormats: disableFormats,
|
|
110
111
|
disableLineBreaks,
|
|
111
112
|
__unstableAllowPrefixTransformations,
|
|
113
|
+
disableEditing,
|
|
112
114
|
...props
|
|
113
115
|
},
|
|
114
116
|
forwardedRef
|
|
@@ -116,11 +118,9 @@ export function RichTextWrapper(
|
|
|
116
118
|
props = removeNativeProps( props );
|
|
117
119
|
|
|
118
120
|
const anchorRef = useRef();
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
name: blockName,
|
|
123
|
-
} = useBlockEditContext();
|
|
121
|
+
const context = useBlockEditContext();
|
|
122
|
+
const { clientId, isSelected: isBlockSelected, name: blockName } = context;
|
|
123
|
+
const blockBindings = context[ blockBindingsKey ];
|
|
124
124
|
const selector = ( select ) => {
|
|
125
125
|
// Avoid subscribing to the block editor store if the block is not
|
|
126
126
|
// selected.
|
|
@@ -128,12 +128,10 @@ export function RichTextWrapper(
|
|
|
128
128
|
return { isSelected: false };
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
const { getSelectionStart, getSelectionEnd
|
|
131
|
+
const { getSelectionStart, getSelectionEnd } =
|
|
132
132
|
select( blockEditorStore );
|
|
133
133
|
const selectionStart = getSelectionStart();
|
|
134
134
|
const selectionEnd = getSelectionEnd();
|
|
135
|
-
const blockBindings =
|
|
136
|
-
getBlockAttributes( clientId )?.metadata?.bindings;
|
|
137
135
|
|
|
138
136
|
let isSelected;
|
|
139
137
|
|
|
@@ -146,50 +144,60 @@ export function RichTextWrapper(
|
|
|
146
144
|
isSelected = selectionStart.clientId === clientId;
|
|
147
145
|
}
|
|
148
146
|
|
|
149
|
-
// Disable Rich Text editing if block bindings specify that.
|
|
150
|
-
let shouldDisableEditing = false;
|
|
151
|
-
if ( blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS ) {
|
|
152
|
-
const blockTypeAttributes = getBlockType( blockName ).attributes;
|
|
153
|
-
const { getBlockBindingsSource } = unlock(
|
|
154
|
-
select( blockEditorStore )
|
|
155
|
-
);
|
|
156
|
-
for ( const [ attribute, args ] of Object.entries(
|
|
157
|
-
blockBindings
|
|
158
|
-
) ) {
|
|
159
|
-
if (
|
|
160
|
-
blockTypeAttributes?.[ attribute ]?.source !== 'rich-text'
|
|
161
|
-
) {
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
|
|
166
|
-
const blockBindingsSource = getBlockBindingsSource(
|
|
167
|
-
args.source
|
|
168
|
-
);
|
|
169
|
-
if (
|
|
170
|
-
! blockBindingsSource ||
|
|
171
|
-
blockBindingsSource.lockAttributesEditing
|
|
172
|
-
) {
|
|
173
|
-
shouldDisableEditing = true;
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
147
|
return {
|
|
180
148
|
selectionStart: isSelected ? selectionStart.offset : undefined,
|
|
181
149
|
selectionEnd: isSelected ? selectionEnd.offset : undefined,
|
|
182
150
|
isSelected,
|
|
183
|
-
shouldDisableEditing,
|
|
184
151
|
};
|
|
185
152
|
};
|
|
186
|
-
const { selectionStart, selectionEnd, isSelected
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
153
|
+
const { selectionStart, selectionEnd, isSelected } = useSelect( selector, [
|
|
154
|
+
clientId,
|
|
155
|
+
identifier,
|
|
156
|
+
originalIsSelected,
|
|
157
|
+
isBlockSelected,
|
|
158
|
+
] );
|
|
159
|
+
|
|
160
|
+
const disableBoundBlocks = useSelect(
|
|
161
|
+
( select ) => {
|
|
162
|
+
// Disable Rich Text editing if block bindings specify that.
|
|
163
|
+
let _disableBoundBlocks = false;
|
|
164
|
+
if ( blockBindings && blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS ) {
|
|
165
|
+
const blockTypeAttributes =
|
|
166
|
+
getBlockType( blockName ).attributes;
|
|
167
|
+
const { getBlockBindingsSource } = unlock(
|
|
168
|
+
select( blocksStore )
|
|
169
|
+
);
|
|
170
|
+
for ( const [ attribute, args ] of Object.entries(
|
|
171
|
+
blockBindings
|
|
172
|
+
) ) {
|
|
173
|
+
if (
|
|
174
|
+
blockTypeAttributes?.[ attribute ]?.source !==
|
|
175
|
+
'rich-text'
|
|
176
|
+
) {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
|
|
181
|
+
const blockBindingsSource = getBlockBindingsSource(
|
|
182
|
+
args.source
|
|
183
|
+
);
|
|
184
|
+
if (
|
|
185
|
+
! blockBindingsSource ||
|
|
186
|
+
blockBindingsSource.lockAttributesEditing
|
|
187
|
+
) {
|
|
188
|
+
_disableBoundBlocks = true;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return _disableBoundBlocks;
|
|
195
|
+
},
|
|
196
|
+
[ blockBindings, blockName ]
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const shouldDisableEditing = disableEditing || disableBoundBlocks;
|
|
200
|
+
|
|
193
201
|
const { getSelectionStart, getSelectionEnd, getBlockRootClientId } =
|
|
194
202
|
useSelect( blockEditorStore );
|
|
195
203
|
const { selectionChange } = useDispatch( blockEditorStore );
|
|
@@ -442,19 +450,34 @@ export function RichTextWrapper(
|
|
|
442
450
|
);
|
|
443
451
|
}
|
|
444
452
|
|
|
445
|
-
|
|
453
|
+
// This is the private API for the RichText component.
|
|
454
|
+
// It allows access to all props, not just the public ones.
|
|
455
|
+
export const PrivateRichText = withDeprecations(
|
|
446
456
|
forwardRef( RichTextWrapper )
|
|
447
457
|
);
|
|
448
458
|
|
|
449
|
-
|
|
450
|
-
|
|
459
|
+
PrivateRichText.Content = Content;
|
|
460
|
+
PrivateRichText.isEmpty = ( value ) => {
|
|
451
461
|
return ! value || value.length === 0;
|
|
452
462
|
};
|
|
453
463
|
|
|
464
|
+
// This is the public API for the RichText component.
|
|
465
|
+
// We wrap the PrivateRichText component to hide some props from the public API.
|
|
454
466
|
/**
|
|
455
467
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
|
|
456
468
|
*/
|
|
457
|
-
|
|
469
|
+
const PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {
|
|
470
|
+
return (
|
|
471
|
+
<PrivateRichText ref={ ref } { ...props } disableEditing={ false } />
|
|
472
|
+
);
|
|
473
|
+
} );
|
|
474
|
+
|
|
475
|
+
PublicForwardedRichTextContainer.Content = Content;
|
|
476
|
+
PublicForwardedRichTextContainer.isEmpty = ( value ) => {
|
|
477
|
+
return ! value || value.length === 0;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
export default PublicForwardedRichTextContainer;
|
|
458
481
|
export { RichTextShortcut } from './shortcut';
|
|
459
482
|
export { RichTextToolbarButton } from './toolbar-button';
|
|
460
483
|
export { __unstableRichTextInputEvent } from './input-event';
|
|
@@ -21,6 +21,10 @@ export function useEnter( props ) {
|
|
|
21
21
|
propsRef.current = props;
|
|
22
22
|
return useRefEffect( ( element ) => {
|
|
23
23
|
function onKeyDown( event ) {
|
|
24
|
+
if ( event.target.contentEditable !== 'true' ) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
if ( event.defaultPrevented ) {
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
text-overflow: ellipsis;
|
|
59
59
|
white-space: nowrap;
|
|
60
60
|
margin-right: $grid-unit-10;
|
|
61
|
+
min-width: 150px;
|
|
61
62
|
// Avoids the popover from growing too wide when the URL is long.
|
|
62
63
|
// See https://github.com/WordPress/gutenberg/issues/58599
|
|
63
64
|
max-width: $modal-min-width;
|
package/src/hooks/block-hooks.js
CHANGED
|
@@ -35,12 +35,12 @@ function BlockHooksControlPure( { name, clientId } ) {
|
|
|
35
35
|
|
|
36
36
|
const { blockIndex, rootClientId, innerBlocksLength } = useSelect(
|
|
37
37
|
( select ) => {
|
|
38
|
-
const {
|
|
38
|
+
const { getBlocks, getBlockIndex, getBlockRootClientId } =
|
|
39
39
|
select( blockEditorStore );
|
|
40
40
|
|
|
41
41
|
return {
|
|
42
42
|
blockIndex: getBlockIndex( clientId ),
|
|
43
|
-
innerBlocksLength:
|
|
43
|
+
innerBlocksLength: getBlocks( clientId )?.length,
|
|
44
44
|
rootClientId: getBlockRootClientId( clientId ),
|
|
45
45
|
};
|
|
46
46
|
},
|
|
@@ -49,7 +49,7 @@ function BlockHooksControlPure( { name, clientId } ) {
|
|
|
49
49
|
|
|
50
50
|
const hookedBlockClientIds = useSelect(
|
|
51
51
|
( select ) => {
|
|
52
|
-
const {
|
|
52
|
+
const { getBlocks, getGlobalBlockCount } =
|
|
53
53
|
select( blockEditorStore );
|
|
54
54
|
|
|
55
55
|
const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(
|
|
@@ -69,7 +69,7 @@ function BlockHooksControlPure( { name, clientId } ) {
|
|
|
69
69
|
// Any of the current block's siblings (with the right block type) qualifies
|
|
70
70
|
// as a hooked block (inserted `before` or `after` the current one), as the block
|
|
71
71
|
// might've been automatically inserted and then moved around a bit by the user.
|
|
72
|
-
candidates =
|
|
72
|
+
candidates = getBlocks( rootClientId );
|
|
73
73
|
break;
|
|
74
74
|
|
|
75
75
|
case 'first_child':
|
|
@@ -77,7 +77,7 @@ function BlockHooksControlPure( { name, clientId } ) {
|
|
|
77
77
|
// Any of the current block's child blocks (with the right block type) qualifies
|
|
78
78
|
// as a hooked first or last child block, as the block might've been automatically
|
|
79
79
|
// inserted and then moved around a bit by the user.
|
|
80
|
-
candidates =
|
|
80
|
+
candidates = getBlocks( clientId );
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -161,6 +161,11 @@ function BlockHooksControlPure( { name, clientId } ) {
|
|
|
161
161
|
title={ __( 'Plugins' ) }
|
|
162
162
|
initialOpen={ true }
|
|
163
163
|
>
|
|
164
|
+
<p className="block-editor-hooks__block-hooks-helptext">
|
|
165
|
+
{ __(
|
|
166
|
+
'Manage the inclusion of blocks added automatically by plugins.'
|
|
167
|
+
) }
|
|
168
|
+
</p>
|
|
164
169
|
{ Object.keys( groupedHookedBlocks ).map( ( vendor ) => {
|
|
165
170
|
return (
|
|
166
171
|
<Fragment key={ vendor }>
|
package/src/hooks/border.js
CHANGED
|
@@ -18,9 +18,14 @@ import { useSelect } from '@wordpress/data';
|
|
|
18
18
|
import { getColorClassName } from '../components/colors';
|
|
19
19
|
import InspectorControls from '../components/inspector-controls';
|
|
20
20
|
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
cleanEmptyObject,
|
|
23
|
+
shouldSkipSerialization,
|
|
24
|
+
useBlockSettings,
|
|
25
|
+
} from './utils';
|
|
22
26
|
import {
|
|
23
27
|
useHasBorderPanel,
|
|
28
|
+
useHasBorderPanelControls,
|
|
24
29
|
BorderPanel as StylesBorderPanel,
|
|
25
30
|
} from '../components/global-styles';
|
|
26
31
|
import { store as blockEditorStore } from '../store';
|
|
@@ -220,14 +225,21 @@ export function hasShadowSupport( blockName ) {
|
|
|
220
225
|
return hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );
|
|
221
226
|
}
|
|
222
227
|
|
|
223
|
-
export function
|
|
228
|
+
export function useBorderPanelLabel( {
|
|
224
229
|
blockName,
|
|
225
230
|
hasBorderControl,
|
|
226
231
|
hasShadowControl,
|
|
227
232
|
} = {} ) {
|
|
233
|
+
const settings = useBlockSettings( blockName );
|
|
234
|
+
const controls = useHasBorderPanelControls( settings );
|
|
235
|
+
|
|
228
236
|
if ( ! hasBorderControl && ! hasShadowControl && blockName ) {
|
|
229
|
-
hasBorderControl =
|
|
230
|
-
|
|
237
|
+
hasBorderControl =
|
|
238
|
+
controls?.hasBorderColor ||
|
|
239
|
+
controls?.hasBorderStyle ||
|
|
240
|
+
controls?.hasBorderWidth ||
|
|
241
|
+
controls?.hasBorderRadius;
|
|
242
|
+
hasShadowControl = controls?.hasShadow;
|
|
231
243
|
}
|
|
232
244
|
|
|
233
245
|
if ( hasBorderControl && hasShadowControl ) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
4
|
+
import { getBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import { addFilter } from '@wordpress/hooks';
|
|
@@ -33,18 +33,16 @@ const createEditFunctionWithBindingsAttribute = () =>
|
|
|
33
33
|
createHigherOrderComponent(
|
|
34
34
|
( BlockEdit ) => ( props ) => {
|
|
35
35
|
const { clientId, name: blockName } = useBlockEditContext();
|
|
36
|
-
const
|
|
37
|
-
useSelect(
|
|
38
|
-
);
|
|
36
|
+
const blockBindingsSources = unlock(
|
|
37
|
+
useSelect( blocksStore )
|
|
38
|
+
).getAllBlockBindingsSources();
|
|
39
39
|
const { getBlockAttributes } = useSelect( blockEditorStore );
|
|
40
40
|
|
|
41
41
|
const updatedAttributes = getBlockAttributes( clientId );
|
|
42
42
|
if ( updatedAttributes?.metadata?.bindings ) {
|
|
43
43
|
Object.entries( updatedAttributes.metadata.bindings ).forEach(
|
|
44
44
|
( [ attributeName, settings ] ) => {
|
|
45
|
-
const source =
|
|
46
|
-
settings.source
|
|
47
|
-
);
|
|
45
|
+
const source = blockBindingsSources[ settings.source ];
|
|
48
46
|
|
|
49
47
|
if ( source && source.useSource ) {
|
|
50
48
|
// Second argument (`updateMetaValue`) will be used to update the value in the future.
|
package/src/private-apis.js
CHANGED
|
@@ -27,6 +27,7 @@ import { ExperimentalBlockCanvas } from './components/block-canvas';
|
|
|
27
27
|
import { getDuotoneFilter } from './components/duotone/utils';
|
|
28
28
|
import { useFlashEditableBlocks } from './components/use-flash-editable-blocks';
|
|
29
29
|
import { selectBlockPatternsKey } from './store/private-keys';
|
|
30
|
+
import { PrivateRichText } from './components/rich-text/';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Private @wordpress/block-editor APIs.
|
|
@@ -58,4 +59,5 @@ lock( privateApis, {
|
|
|
58
59
|
usesContextKey,
|
|
59
60
|
useFlashEditableBlocks,
|
|
60
61
|
selectBlockPatternsKey,
|
|
62
|
+
PrivateRichText,
|
|
61
63
|
} );
|
|
@@ -390,16 +390,6 @@ export function stopEditingAsBlocks( clientId ) {
|
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
export function registerBlockBindingsSource( source ) {
|
|
394
|
-
return {
|
|
395
|
-
type: 'REGISTER_BLOCK_BINDINGS_SOURCE',
|
|
396
|
-
sourceName: source.name,
|
|
397
|
-
sourceLabel: source.label,
|
|
398
|
-
useSource: source.useSource,
|
|
399
|
-
lockAttributesEditing: source.lockAttributesEditing,
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
|
|
403
393
|
/**
|
|
404
394
|
* Returns an action object used in signalling that the user has begun to drag.
|
|
405
395
|
*
|
|
@@ -341,14 +341,6 @@ export function getLastFocus( state ) {
|
|
|
341
341
|
return state.lastFocus;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
export function getAllBlockBindingsSources( state ) {
|
|
345
|
-
return state.blockBindingsSources;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
export function getBlockBindingsSource( state, sourceName ) {
|
|
349
|
-
return state.blockBindingsSources[ sourceName ];
|
|
350
|
-
}
|
|
351
|
-
|
|
352
344
|
/**
|
|
353
345
|
* Returns true if the user is dragging anything, or false otherwise. It is possible for a
|
|
354
346
|
* user to be dragging data from outside of the editor, so this selector is separate from
|
package/src/store/reducer.js
CHANGED
|
@@ -2050,20 +2050,6 @@ export function lastFocus( state = false, action ) {
|
|
|
2050
2050
|
return state;
|
|
2051
2051
|
}
|
|
2052
2052
|
|
|
2053
|
-
function blockBindingsSources( state = {}, action ) {
|
|
2054
|
-
if ( action.type === 'REGISTER_BLOCK_BINDINGS_SOURCE' ) {
|
|
2055
|
-
return {
|
|
2056
|
-
...state,
|
|
2057
|
-
[ action.sourceName ]: {
|
|
2058
|
-
label: action.sourceLabel,
|
|
2059
|
-
useSource: action.useSource,
|
|
2060
|
-
lockAttributesEditing: action.lockAttributesEditing ?? true,
|
|
2061
|
-
},
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
return state;
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
2053
|
const combinedReducers = combineReducers( {
|
|
2068
2054
|
blocks,
|
|
2069
2055
|
isDragging,
|
|
@@ -2095,7 +2081,6 @@ const combinedReducers = combineReducers( {
|
|
|
2095
2081
|
blockRemovalRules,
|
|
2096
2082
|
openedBlockSettingsMenu,
|
|
2097
2083
|
registeredInserterMediaCategories,
|
|
2098
|
-
blockBindingsSources,
|
|
2099
2084
|
} );
|
|
2100
2085
|
|
|
2101
2086
|
function withAutomaticChangeReset( reducer ) {
|