@wordpress/block-editor 15.7.1-next.2f1c7c01b.0 → 15.8.1-next.16d95556a.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-card/index.js +76 -34
- package/build/components/block-card/index.js.map +2 -2
- package/build/components/block-inspector/edit-contents.js +72 -0
- package/build/components/block-inspector/edit-contents.js.map +7 -0
- package/build/components/block-inspector/index.js +32 -9
- package/build/components/block-inspector/index.js.map +3 -3
- package/build/components/block-list/index.js +9 -9
- package/build/components/block-list/index.js.map +2 -2
- package/build/components/block-switcher/index.js +24 -123
- package/build/components/block-switcher/index.js.map +3 -3
- package/build/components/block-toolbar/block-toolbar-icon.js +175 -0
- package/build/components/block-toolbar/block-toolbar-icon.js.map +7 -0
- package/build/components/block-toolbar/index.js +51 -53
- package/build/components/block-toolbar/index.js.map +3 -3
- package/build/components/block-toolbar/pattern-overrides-dropdown.js +93 -0
- package/build/components/block-toolbar/pattern-overrides-dropdown.js.map +7 -0
- package/build/components/block-tools/index.js +10 -3
- package/build/components/block-tools/index.js.map +2 -2
- package/build/components/border-radius-control/utils.js +7 -3
- package/build/components/border-radius-control/utils.js.map +2 -2
- package/build/components/content-lock/modify-content-lock-menu-item.js +3 -3
- package/build/components/content-lock/modify-content-lock-menu-item.js.map +2 -2
- package/build/components/global-styles/border-panel.js +11 -7
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +35 -27
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +19 -12
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/inserter/media-tab/media-tab.js +2 -1
- package/build/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build/components/inspector-controls-tabs/index.js +2 -1
- package/build/components/inspector-controls-tabs/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.js +55 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build/components/keyboard-shortcuts/index.js +8 -0
- package/build/components/keyboard-shortcuts/index.js.map +2 -2
- package/build/components/rich-text/format-edit.js +9 -1
- package/build/components/rich-text/format-edit.js.map +2 -2
- package/build/components/rich-text/index.js +1 -0
- package/build/components/rich-text/index.js.map +2 -2
- package/build/hooks/border.js +10 -5
- package/build/hooks/border.js.map +3 -3
- package/build/hooks/color.js +31 -9
- package/build/hooks/color.js.map +3 -3
- package/build/hooks/content-lock-ui.js +4 -5
- package/build/hooks/content-lock-ui.js.map +2 -2
- package/build/hooks/dimensions.js +9 -4
- package/build/hooks/dimensions.js.map +2 -2
- package/build/hooks/fit-text.js +19 -75
- package/build/hooks/fit-text.js.map +3 -3
- package/build/hooks/font-size.js +5 -2
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/layout.js +4 -1
- package/build/hooks/layout.js.map +2 -2
- package/build/hooks/spacing-visualizer.js +5 -0
- package/build/hooks/spacing-visualizer.js.map +2 -2
- package/build/hooks/typography.js +23 -14
- package/build/hooks/typography.js.map +3 -3
- package/build/store/private-selectors.js +21 -1
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +4 -0
- package/build/store/reducer.js.map +2 -2
- package/build/store/selectors.js +12 -3
- package/build/store/selectors.js.map +2 -2
- package/build/utils/fit-text-frontend.js +1 -0
- package/build/utils/fit-text-frontend.js.map +2 -2
- package/build/utils/fit-text-utils.js +1 -1
- package/build/utils/fit-text-utils.js.map +1 -1
- package/build-module/components/block-card/index.js +82 -32
- package/build-module/components/block-card/index.js.map +2 -2
- package/build-module/components/block-inspector/edit-contents.js +51 -0
- package/build-module/components/block-inspector/edit-contents.js.map +7 -0
- package/build-module/components/block-inspector/index.js +32 -9
- package/build-module/components/block-inspector/index.js.map +2 -2
- package/build-module/components/block-list/index.js +11 -11
- package/build-module/components/block-list/index.js.map +2 -2
- package/build-module/components/block-switcher/index.js +24 -124
- package/build-module/components/block-switcher/index.js.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.js +144 -0
- package/build-module/components/block-toolbar/block-toolbar-icon.js.map +7 -0
- package/build-module/components/block-toolbar/index.js +51 -53
- package/build-module/components/block-toolbar/index.js.map +2 -2
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.js +76 -0
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.js.map +7 -0
- package/build-module/components/block-tools/index.js +10 -3
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/border-radius-control/utils.js +7 -3
- package/build-module/components/border-radius-control/utils.js.map +2 -2
- package/build-module/components/content-lock/modify-content-lock-menu-item.js +3 -3
- package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +11 -7
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +34 -27
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +21 -13
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +2 -1
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.js +2 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.js +55 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.js +8 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +2 -2
- package/build-module/components/rich-text/format-edit.js +9 -1
- package/build-module/components/rich-text/format-edit.js.map +2 -2
- package/build-module/components/rich-text/index.js +1 -0
- package/build-module/components/rich-text/index.js.map +2 -2
- package/build-module/hooks/border.js +10 -5
- package/build-module/hooks/border.js.map +3 -3
- package/build-module/hooks/color.js +31 -9
- package/build-module/hooks/color.js.map +3 -3
- package/build-module/hooks/content-lock-ui.js +4 -5
- package/build-module/hooks/content-lock-ui.js.map +2 -2
- package/build-module/hooks/dimensions.js +9 -4
- package/build-module/hooks/dimensions.js.map +2 -2
- package/build-module/hooks/fit-text.js +18 -66
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +5 -2
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/layout.js +4 -1
- package/build-module/hooks/layout.js.map +2 -2
- package/build-module/hooks/spacing-visualizer.js +5 -0
- package/build-module/hooks/spacing-visualizer.js.map +2 -2
- package/build-module/hooks/typography.js +23 -14
- package/build-module/hooks/typography.js.map +3 -3
- package/build-module/store/private-selectors.js +20 -1
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +4 -0
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/store/selectors.js +12 -3
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/utils/fit-text-frontend.js +1 -0
- package/build-module/utils/fit-text-frontend.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +1 -1
- package/build-module/utils/fit-text-utils.js.map +1 -1
- package/build-style/style-rtl.css +31 -71
- package/build-style/style.css +31 -71
- package/package.json +37 -37
- package/src/components/block-card/index.js +95 -38
- package/src/components/block-card/style.scss +17 -1
- package/src/components/block-inspector/edit-contents.js +64 -0
- package/src/components/block-inspector/index.js +35 -13
- package/src/components/block-inspector/style.scss +6 -3
- package/src/components/block-list/index.js +11 -9
- package/src/components/block-switcher/block-transformations-menu.native.js +0 -1
- package/src/components/block-switcher/index.js +51 -180
- package/src/components/block-switcher/style.scss +0 -70
- package/src/components/block-switcher/test/index.js +17 -18
- package/src/components/block-toolbar/block-toolbar-icon.js +173 -0
- package/src/components/block-toolbar/index.js +50 -52
- package/src/components/block-toolbar/pattern-overrides-dropdown.js +99 -0
- package/src/components/block-toolbar/style.scss +21 -21
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +6 -4
- package/src/components/block-toolbar/test/block-toolbar-icon.js +182 -0
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +2 -2
- package/src/components/block-tools/index.js +11 -1
- package/src/components/border-radius-control/test/utils.js +90 -0
- package/src/components/border-radius-control/utils.js +7 -3
- package/src/components/content-lock/modify-content-lock-menu-item.js +9 -3
- package/src/components/global-styles/border-panel.js +11 -7
- package/src/components/global-styles/color-panel.js +32 -26
- package/src/components/global-styles/typography-panel.js +14 -1
- package/src/components/inserter/media-tab/media-tab.js +7 -1
- package/src/components/inspector-controls-tabs/index.js +1 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +58 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -1
- package/src/components/keyboard-shortcuts/index.js +9 -0
- package/src/components/rich-text/format-edit.js +9 -1
- package/src/components/rich-text/index.js +1 -0
- package/src/hooks/border.js +12 -6
- package/src/hooks/color.js +40 -13
- package/src/hooks/content-lock-ui.js +9 -6
- package/src/hooks/dimensions.js +25 -17
- package/src/hooks/fit-text.js +23 -84
- package/src/hooks/font-size.js +7 -2
- package/src/hooks/layout.js +11 -7
- package/src/hooks/spacing-visualizer.js +9 -1
- package/src/hooks/typography.js +24 -18
- package/src/store/private-selectors.js +26 -1
- package/src/store/reducer.js +6 -0
- package/src/store/selectors.js +24 -3
- package/src/utils/fit-text-frontend.js +1 -0
- package/src/utils/fit-text-utils.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-inspector/edit-contents-button.js +0 -61
- package/build/components/block-inspector/edit-contents-button.js.map +0 -7
- package/build-module/components/block-inspector/edit-contents-button.js +0 -40
- package/build-module/components/block-inspector/edit-contents-button.js.map +0 -7
- package/src/components/block-inspector/edit-contents-button.js +0 -46
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
color: $gray-900;
|
|
7
7
|
display: flex;
|
|
8
8
|
padding: $grid-unit-20;
|
|
9
|
+
|
|
10
|
+
&.is-parent {
|
|
11
|
+
padding-bottom: $grid-unit-05;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.is-child {
|
|
15
|
+
padding-top: $grid-unit-05;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.block-editor-block-card__parent-select-button {
|
|
20
|
+
padding: 0;
|
|
21
|
+
align-items: start;
|
|
22
|
+
text-align: start;
|
|
23
|
+
height: auto !important;
|
|
9
24
|
}
|
|
10
25
|
|
|
11
26
|
.block-editor-block-card__title {
|
|
@@ -26,7 +41,8 @@
|
|
|
26
41
|
padding: 3px 0; // This makes the title as high as the icon.
|
|
27
42
|
}
|
|
28
43
|
|
|
29
|
-
.block-editor-block-card .block-editor-block-icon
|
|
44
|
+
.block-editor-block-card .block-editor-block-icon,
|
|
45
|
+
.block-editor-block-card__child-indicator-icon {
|
|
30
46
|
flex: 0 0 $button-size-small;
|
|
31
47
|
margin-left: 0;
|
|
32
48
|
margin-right: $grid-unit-15;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button, __experimentalVStack as VStack } from '@wordpress/components';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
|
|
14
|
+
export default function EditContents( { clientId } ) {
|
|
15
|
+
const { editContentOnlySection, stopEditingContentOnlySection } = unlock(
|
|
16
|
+
useDispatch( blockEditorStore )
|
|
17
|
+
);
|
|
18
|
+
const { isWithinSection, isWithinEditedSection, editedContentOnlySection } =
|
|
19
|
+
useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const {
|
|
22
|
+
isSectionBlock,
|
|
23
|
+
getParentSectionBlock,
|
|
24
|
+
getEditedContentOnlySection,
|
|
25
|
+
isWithinEditedContentOnlySection,
|
|
26
|
+
} = unlock( select( blockEditorStore ) );
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
isWithinSection:
|
|
30
|
+
isSectionBlock( clientId ) ||
|
|
31
|
+
!! getParentSectionBlock( clientId ),
|
|
32
|
+
isWithinEditedSection:
|
|
33
|
+
isWithinEditedContentOnlySection( clientId ),
|
|
34
|
+
editedContentOnlySection: getEditedContentOnlySection(),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
[ clientId ]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if ( ! isWithinSection && ! isWithinEditedSection ) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<VStack className="block-editor-block-inspector-edit-contents" expanded>
|
|
46
|
+
<Button
|
|
47
|
+
className="block-editor-block-inspector-edit-contents__button"
|
|
48
|
+
__next40pxDefaultSize
|
|
49
|
+
variant="secondary"
|
|
50
|
+
onClick={ () => {
|
|
51
|
+
if ( ! editedContentOnlySection ) {
|
|
52
|
+
editContentOnlySection( clientId );
|
|
53
|
+
} else {
|
|
54
|
+
stopEditingContentOnlySection();
|
|
55
|
+
}
|
|
56
|
+
} }
|
|
57
|
+
>
|
|
58
|
+
{ editedContentOnlySection
|
|
59
|
+
? __( 'Exit pattern' )
|
|
60
|
+
: __( 'Edit pattern' ) }
|
|
61
|
+
</Button>
|
|
62
|
+
</VStack>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -13,7 +13,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
16
|
+
import EditContents from './edit-contents';
|
|
17
17
|
import SkipToSelectedBlock from '../skip-to-selected-block';
|
|
18
18
|
import BlockCard from '../block-card';
|
|
19
19
|
import MultiSelectionInspector from '../multi-selection-inspector';
|
|
@@ -93,6 +93,7 @@ function BlockInspector() {
|
|
|
93
93
|
isSectionBlock,
|
|
94
94
|
isSectionBlockInSelection,
|
|
95
95
|
hasBlockStyles,
|
|
96
|
+
editedContentOnlySection,
|
|
96
97
|
} = useSelect( ( select ) => {
|
|
97
98
|
const {
|
|
98
99
|
getSelectedBlockClientId,
|
|
@@ -101,12 +102,18 @@ function BlockInspector() {
|
|
|
101
102
|
getBlockName,
|
|
102
103
|
getParentSectionBlock,
|
|
103
104
|
isSectionBlock: _isSectionBlock,
|
|
105
|
+
getEditedContentOnlySection,
|
|
106
|
+
isWithinEditedContentOnlySection,
|
|
104
107
|
} = unlock( select( blockEditorStore ) );
|
|
105
108
|
const { getBlockStyles } = select( blocksStore );
|
|
106
109
|
const _selectedBlockClientId = getSelectedBlockClientId();
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
const isWithinEditedSection = isWithinEditedContentOnlySection(
|
|
111
|
+
_selectedBlockClientId
|
|
112
|
+
);
|
|
113
|
+
const renderedBlockClientId = isWithinEditedSection
|
|
114
|
+
? _selectedBlockClientId
|
|
115
|
+
: getParentSectionBlock( _selectedBlockClientId ) ||
|
|
116
|
+
_selectedBlockClientId;
|
|
110
117
|
const _selectedBlockName =
|
|
111
118
|
renderedBlockClientId && getBlockName( renderedBlockClientId );
|
|
112
119
|
const _blockType =
|
|
@@ -115,7 +122,6 @@ function BlockInspector() {
|
|
|
115
122
|
const _isSectionBlockInSelection = selectedBlockClientIds.some(
|
|
116
123
|
( id ) => _isSectionBlock( id )
|
|
117
124
|
);
|
|
118
|
-
|
|
119
125
|
const blockStyles =
|
|
120
126
|
_selectedBlockName && getBlockStyles( _selectedBlockName );
|
|
121
127
|
const _hasBlockStyles = blockStyles && blockStyles.length > 0;
|
|
@@ -128,6 +134,7 @@ function BlockInspector() {
|
|
|
128
134
|
isSectionBlockInSelection: _isSectionBlockInSelection,
|
|
129
135
|
isSectionBlock: _isSectionBlock( renderedBlockClientId ),
|
|
130
136
|
hasBlockStyles: _hasBlockStyles,
|
|
137
|
+
editedContentOnlySection: getEditedContentOnlySection(),
|
|
131
138
|
};
|
|
132
139
|
}, [] );
|
|
133
140
|
|
|
@@ -263,6 +270,7 @@ function BlockInspector() {
|
|
|
263
270
|
availableTabs={ availableTabs }
|
|
264
271
|
contentClientIds={ contentClientIds }
|
|
265
272
|
hasBlockStyles={ hasBlockStyles }
|
|
273
|
+
editedContentOnlySection={ editedContentOnlySection }
|
|
266
274
|
/>
|
|
267
275
|
</BlockInspectorSingleBlockWrapper>
|
|
268
276
|
);
|
|
@@ -311,25 +319,39 @@ const BlockInspectorSingleBlock = ( {
|
|
|
311
319
|
availableTabs,
|
|
312
320
|
contentClientIds,
|
|
313
321
|
hasBlockStyles,
|
|
322
|
+
editedContentOnlySection,
|
|
314
323
|
} ) => {
|
|
315
324
|
const hasMultipleTabs = availableTabs?.length > 1;
|
|
316
|
-
|
|
325
|
+
const hasParentChildBlockCards =
|
|
326
|
+
window?.__experimentalContentOnlyPatternInsertion &&
|
|
327
|
+
editedContentOnlySection &&
|
|
328
|
+
editedContentOnlySection !== clientId;
|
|
329
|
+
const parentBlockInformation = useBlockDisplayInformation(
|
|
330
|
+
editedContentOnlySection
|
|
331
|
+
);
|
|
317
332
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
318
333
|
const isBlockSynced = blockInformation.isSynced;
|
|
319
|
-
|
|
320
334
|
const shouldShowTabs = ! isBlockSynced && hasMultipleTabs;
|
|
321
335
|
|
|
322
336
|
return (
|
|
323
337
|
<div className="block-editor-block-inspector">
|
|
338
|
+
{ hasParentChildBlockCards && (
|
|
339
|
+
<BlockCard
|
|
340
|
+
{ ...parentBlockInformation }
|
|
341
|
+
className={ parentBlockInformation.isSynced && 'is-synced' }
|
|
342
|
+
parentClientId={ editedContentOnlySection }
|
|
343
|
+
/>
|
|
344
|
+
) }
|
|
324
345
|
<BlockCard
|
|
325
346
|
{ ...blockInformation }
|
|
326
|
-
className={ isBlockSynced && 'is-synced' }
|
|
327
347
|
allowParentNavigation
|
|
328
|
-
|
|
329
|
-
{
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
348
|
+
className={ isBlockSynced && 'is-synced' }
|
|
349
|
+
isChild={ hasParentChildBlockCards }
|
|
350
|
+
clientId={ clientId }
|
|
351
|
+
/>
|
|
352
|
+
{ window?.__experimentalContentOnlyPatternInsertion && (
|
|
353
|
+
<EditContents clientId={ clientId } />
|
|
354
|
+
) }
|
|
333
355
|
<BlockVariationTransforms blockClientId={ clientId } />
|
|
334
356
|
{ shouldShowTabs && (
|
|
335
357
|
<InspectorControlsTabs
|
|
@@ -55,7 +55,10 @@
|
|
|
55
55
|
border-top: $border-width solid $gray-300;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.block-editor-block-inspector-edit-contents
|
|
59
|
-
margin
|
|
60
|
-
|
|
58
|
+
.block-editor-block-inspector-edit-contents {
|
|
59
|
+
margin: 0 $grid-unit-20 $grid-unit-20 $grid-unit-20;
|
|
60
|
+
|
|
61
|
+
.block-editor-block-inspector-edit-contents__button {
|
|
62
|
+
justify-content: center;
|
|
63
|
+
}
|
|
61
64
|
}
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
import { useMergeRefs, useDebounce } from '@wordpress/compose';
|
|
16
16
|
import {
|
|
17
17
|
createContext,
|
|
18
|
+
useEffect,
|
|
18
19
|
useMemo,
|
|
19
20
|
useCallback,
|
|
20
|
-
useEffect,
|
|
21
21
|
} from '@wordpress/element';
|
|
22
22
|
import { getDefaultBlockName } from '@wordpress/blocks';
|
|
23
23
|
|
|
@@ -52,9 +52,9 @@ function Root( { className, ...settings } ) {
|
|
|
52
52
|
( select ) => {
|
|
53
53
|
const {
|
|
54
54
|
getSettings,
|
|
55
|
-
getEditedContentOnlySection,
|
|
56
55
|
isTyping,
|
|
57
56
|
hasBlockSpotlight,
|
|
57
|
+
getEditedContentOnlySection,
|
|
58
58
|
} = unlock( select( blockEditorStore ) );
|
|
59
59
|
const { outlineMode, focusMode } = getSettings();
|
|
60
60
|
return {
|
|
@@ -133,24 +133,26 @@ function StopEditingContentOnlySectionOnOutsideSelect( { clientId } ) {
|
|
|
133
133
|
);
|
|
134
134
|
const isBlockOrDescendantSelected = useSelect(
|
|
135
135
|
( select ) => {
|
|
136
|
-
const {
|
|
137
|
-
|
|
136
|
+
const {
|
|
137
|
+
isBlockSelected,
|
|
138
|
+
hasSelectedInnerBlock,
|
|
139
|
+
getBlockSelectionStart,
|
|
140
|
+
} = select( blockEditorStore );
|
|
138
141
|
return (
|
|
142
|
+
! getBlockSelectionStart() ||
|
|
139
143
|
isBlockSelected( clientId ) ||
|
|
140
144
|
hasSelectedInnerBlock( clientId, true )
|
|
141
145
|
);
|
|
142
146
|
},
|
|
143
147
|
[ clientId ]
|
|
144
148
|
);
|
|
149
|
+
|
|
145
150
|
useEffect( () => {
|
|
146
151
|
if ( ! isBlockOrDescendantSelected ) {
|
|
147
152
|
stopEditingContentOnlySection();
|
|
148
153
|
}
|
|
149
|
-
}, [
|
|
150
|
-
|
|
151
|
-
clientId,
|
|
152
|
-
stopEditingContentOnlySection,
|
|
153
|
-
] );
|
|
154
|
+
}, [ isBlockOrDescendantSelected, stopEditingContentOnlySection ] );
|
|
155
|
+
|
|
154
156
|
return null;
|
|
155
157
|
}
|
|
156
158
|
|
|
@@ -33,7 +33,6 @@ const BlockTransformationsMenu = ( {
|
|
|
33
33
|
const blocksThatSplitWhenTransformed = {
|
|
34
34
|
'core/list': [ 'core/paragraph', 'core/heading' ],
|
|
35
35
|
'core/quote': [ 'core/paragraph' ],
|
|
36
|
-
'core/pullquote': [ 'core/paragraph' ],
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
return possibleTransformations.map( ( item ) => {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { __, _n, sprintf, _x } from '@wordpress/i18n';
|
|
5
5
|
import {
|
|
6
6
|
DropdownMenu,
|
|
7
|
-
ToolbarButton,
|
|
8
7
|
ToolbarGroup,
|
|
9
8
|
ToolbarItem,
|
|
10
9
|
__experimentalText as Text,
|
|
@@ -17,60 +16,64 @@ import {
|
|
|
17
16
|
isTemplatePart,
|
|
18
17
|
} from '@wordpress/blocks';
|
|
19
18
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
20
|
-
import { copy } from '@wordpress/icons';
|
|
21
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
22
19
|
|
|
23
20
|
/**
|
|
24
21
|
* Internal dependencies
|
|
25
22
|
*/
|
|
26
23
|
import { store as blockEditorStore } from '../../store';
|
|
27
|
-
import BlockIcon from '../block-icon';
|
|
28
24
|
import BlockTransformationsMenu from './block-transformations-menu';
|
|
29
25
|
import { useBlockVariationTransforms } from './block-variation-transformations';
|
|
30
26
|
import BlockStylesMenu from './block-styles-menu';
|
|
31
27
|
import PatternTransformationsMenu from './pattern-transformations-menu';
|
|
32
|
-
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
33
|
-
import { unlock } from '../../lock-unlock';
|
|
34
28
|
|
|
35
|
-
function BlockSwitcherDropdownMenuContents( {
|
|
36
|
-
onClose,
|
|
37
|
-
clientIds,
|
|
38
|
-
hasBlockStyles,
|
|
39
|
-
canRemove,
|
|
40
|
-
} ) {
|
|
29
|
+
function BlockSwitcherDropdownMenuContents( { onClose, clientIds } ) {
|
|
41
30
|
const { replaceBlocks, multiSelect, updateBlockAttributes } =
|
|
42
31
|
useDispatch( blockEditorStore );
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
32
|
+
const {
|
|
33
|
+
possibleBlockTransformations,
|
|
34
|
+
patterns,
|
|
35
|
+
blocks,
|
|
36
|
+
isUsingBindings,
|
|
37
|
+
canRemove,
|
|
38
|
+
hasBlockStyles,
|
|
39
|
+
} = useSelect(
|
|
40
|
+
( select ) => {
|
|
41
|
+
const {
|
|
42
|
+
getBlockAttributes,
|
|
43
|
+
getBlocksByClientId,
|
|
44
|
+
getBlockRootClientId,
|
|
45
|
+
getBlockTransformItems,
|
|
46
|
+
__experimentalGetPatternTransformItems,
|
|
47
|
+
canRemoveBlocks,
|
|
48
|
+
getBlockName,
|
|
49
|
+
} = select( blockEditorStore );
|
|
50
|
+
const { getBlockStyles } = select( blocksStore );
|
|
51
|
+
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
|
|
52
|
+
const _blocks = getBlocksByClientId( clientIds );
|
|
53
|
+
const _isSingleBlock = clientIds.length === 1;
|
|
54
|
+
const _blockName = _isSingleBlock && getBlockName( clientIds[ 0 ] );
|
|
55
|
+
const _hasBlockStyles =
|
|
56
|
+
_isSingleBlock && !! getBlockStyles( _blockName )?.length;
|
|
57
|
+
return {
|
|
58
|
+
blocks: _blocks,
|
|
59
|
+
possibleBlockTransformations: getBlockTransformItems(
|
|
60
|
+
_blocks,
|
|
61
|
+
rootClientId
|
|
62
|
+
),
|
|
63
|
+
patterns: __experimentalGetPatternTransformItems(
|
|
64
|
+
_blocks,
|
|
65
|
+
rootClientId
|
|
66
|
+
),
|
|
67
|
+
isUsingBindings: clientIds.every(
|
|
68
|
+
( clientId ) =>
|
|
69
|
+
!! getBlockAttributes( clientId )?.metadata?.bindings
|
|
70
|
+
),
|
|
71
|
+
canRemove: canRemoveBlocks( clientIds ),
|
|
72
|
+
hasBlockStyles: _hasBlockStyles,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
[ clientIds ]
|
|
76
|
+
);
|
|
74
77
|
const blockVariationTransformations = useBlockVariationTransforms( {
|
|
75
78
|
clientIds,
|
|
76
79
|
blocks,
|
|
@@ -101,6 +104,7 @@ function BlockSwitcherDropdownMenuContents( {
|
|
|
101
104
|
replaceBlocks( clientIds, transformedBlocks );
|
|
102
105
|
selectForMultipleBlocks( transformedBlocks );
|
|
103
106
|
}
|
|
107
|
+
|
|
104
108
|
/**
|
|
105
109
|
* The `isSynced` check is a stopgap solution here.
|
|
106
110
|
* Ideally, the Transforms API should handle this
|
|
@@ -189,133 +193,8 @@ function BlockSwitcherDropdownMenuContents( {
|
|
|
189
193
|
);
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
export const BlockSwitcher = ( { clientIds } ) => {
|
|
193
|
-
const {
|
|
194
|
-
hasContentOnlyLocking,
|
|
195
|
-
canRemove,
|
|
196
|
-
hasBlockStyles,
|
|
197
|
-
icon,
|
|
198
|
-
invalidBlocks,
|
|
199
|
-
isReusable,
|
|
200
|
-
isTemplate,
|
|
201
|
-
isDisabled,
|
|
202
|
-
isSectionInSelection,
|
|
203
|
-
} = useSelect(
|
|
204
|
-
( select ) => {
|
|
205
|
-
const {
|
|
206
|
-
getTemplateLock,
|
|
207
|
-
getBlocksByClientId,
|
|
208
|
-
getBlockAttributes,
|
|
209
|
-
canRemoveBlocks,
|
|
210
|
-
getBlockEditingMode,
|
|
211
|
-
isSectionBlock,
|
|
212
|
-
} = unlock( select( blockEditorStore ) );
|
|
213
|
-
const { getBlockStyles, getBlockType, getActiveBlockVariation } =
|
|
214
|
-
select( blocksStore );
|
|
215
|
-
const _blocks = getBlocksByClientId( clientIds );
|
|
216
|
-
if ( ! _blocks.length || _blocks.some( ( block ) => ! block ) ) {
|
|
217
|
-
return { invalidBlocks: true };
|
|
218
|
-
}
|
|
219
|
-
const [ { name: firstBlockName } ] = _blocks;
|
|
220
|
-
const _isSingleBlockSelected = _blocks.length === 1;
|
|
221
|
-
const blockType = getBlockType( firstBlockName );
|
|
222
|
-
const editingMode = getBlockEditingMode( clientIds[ 0 ] );
|
|
223
|
-
|
|
224
|
-
let _icon;
|
|
225
|
-
let _hasTemplateLock;
|
|
226
|
-
if ( _isSingleBlockSelected ) {
|
|
227
|
-
const match = getActiveBlockVariation(
|
|
228
|
-
firstBlockName,
|
|
229
|
-
getBlockAttributes( clientIds[ 0 ] )
|
|
230
|
-
);
|
|
231
|
-
// Take into account active block variations.
|
|
232
|
-
_icon = match?.icon || blockType.icon;
|
|
233
|
-
_hasTemplateLock =
|
|
234
|
-
getTemplateLock( clientIds[ 0 ] ) === 'contentOnly';
|
|
235
|
-
} else {
|
|
236
|
-
const isSelectionOfSameType =
|
|
237
|
-
new Set( _blocks.map( ( { name } ) => name ) ).size === 1;
|
|
238
|
-
_hasTemplateLock = clientIds.some(
|
|
239
|
-
( id ) => getTemplateLock( id ) === 'contentOnly'
|
|
240
|
-
);
|
|
241
|
-
// When selection consists of blocks of multiple types, display an
|
|
242
|
-
// appropriate icon to communicate the non-uniformity.
|
|
243
|
-
_icon = isSelectionOfSameType ? blockType.icon : copy;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const _isSectionInSelection = clientIds.some( ( id ) =>
|
|
247
|
-
isSectionBlock( id )
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
return {
|
|
251
|
-
canRemove: canRemoveBlocks( clientIds ),
|
|
252
|
-
hasBlockStyles:
|
|
253
|
-
_isSingleBlockSelected &&
|
|
254
|
-
!! getBlockStyles( firstBlockName )?.length,
|
|
255
|
-
icon: _icon,
|
|
256
|
-
isReusable:
|
|
257
|
-
_isSingleBlockSelected && isReusableBlock( _blocks[ 0 ] ),
|
|
258
|
-
isTemplate:
|
|
259
|
-
_isSingleBlockSelected && isTemplatePart( _blocks[ 0 ] ),
|
|
260
|
-
hasContentOnlyLocking: _hasTemplateLock,
|
|
261
|
-
isDisabled: editingMode !== 'default',
|
|
262
|
-
isSectionInSelection: _isSectionInSelection,
|
|
263
|
-
};
|
|
264
|
-
},
|
|
265
|
-
[ clientIds ]
|
|
266
|
-
);
|
|
267
|
-
const blockTitle = useBlockDisplayTitle( {
|
|
268
|
-
clientId: clientIds?.[ 0 ],
|
|
269
|
-
maximumLength: 35,
|
|
270
|
-
} );
|
|
271
|
-
const showIconLabels = useSelect(
|
|
272
|
-
( select ) =>
|
|
273
|
-
select( preferencesStore ).get( 'core', 'showIconLabels' ),
|
|
274
|
-
[]
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
if ( invalidBlocks ) {
|
|
278
|
-
return null;
|
|
279
|
-
}
|
|
280
|
-
|
|
196
|
+
export const BlockSwitcher = ( { children, clientIds, label, text } ) => {
|
|
281
197
|
const isSingleBlock = clientIds.length === 1;
|
|
282
|
-
const blockSwitcherLabel = isSingleBlock
|
|
283
|
-
? blockTitle
|
|
284
|
-
: __( 'Multiple blocks selected' );
|
|
285
|
-
|
|
286
|
-
const blockIndicatorText =
|
|
287
|
-
( isReusable || isTemplate ) && ! showIconLabels && blockTitle
|
|
288
|
-
? blockTitle
|
|
289
|
-
: undefined;
|
|
290
|
-
|
|
291
|
-
const hideTransformsForSections =
|
|
292
|
-
window?.__experimentalContentOnlyPatternInsertion &&
|
|
293
|
-
isSectionInSelection;
|
|
294
|
-
const hideDropdown =
|
|
295
|
-
hideTransformsForSections ||
|
|
296
|
-
isDisabled ||
|
|
297
|
-
( ! hasBlockStyles && ! canRemove ) ||
|
|
298
|
-
hasContentOnlyLocking;
|
|
299
|
-
|
|
300
|
-
if ( hideDropdown ) {
|
|
301
|
-
return (
|
|
302
|
-
<ToolbarGroup>
|
|
303
|
-
<ToolbarButton
|
|
304
|
-
disabled
|
|
305
|
-
className="block-editor-block-switcher__no-switcher-icon"
|
|
306
|
-
title={ blockSwitcherLabel }
|
|
307
|
-
icon={
|
|
308
|
-
<BlockIcon
|
|
309
|
-
className="block-editor-block-switcher__toggle"
|
|
310
|
-
icon={ icon }
|
|
311
|
-
showColors
|
|
312
|
-
/>
|
|
313
|
-
}
|
|
314
|
-
text={ blockIndicatorText }
|
|
315
|
-
/>
|
|
316
|
-
</ToolbarGroup>
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
198
|
|
|
320
199
|
const blockSwitcherDescription = isSingleBlock
|
|
321
200
|
? __( 'Change block type or style' )
|
|
@@ -334,19 +213,13 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
334
213
|
{ ( toggleProps ) => (
|
|
335
214
|
<DropdownMenu
|
|
336
215
|
className="block-editor-block-switcher"
|
|
337
|
-
label={
|
|
216
|
+
label={ label }
|
|
338
217
|
popoverProps={ {
|
|
339
218
|
placement: 'bottom-start',
|
|
340
219
|
className: 'block-editor-block-switcher__popover',
|
|
341
220
|
} }
|
|
342
|
-
icon={
|
|
343
|
-
|
|
344
|
-
className="block-editor-block-switcher__toggle"
|
|
345
|
-
icon={ icon }
|
|
346
|
-
showColors
|
|
347
|
-
/>
|
|
348
|
-
}
|
|
349
|
-
text={ blockIndicatorText }
|
|
221
|
+
icon={ children }
|
|
222
|
+
text={ text }
|
|
350
223
|
toggleProps={ {
|
|
351
224
|
description: blockSwitcherDescription,
|
|
352
225
|
...toggleProps,
|
|
@@ -357,8 +230,6 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
357
230
|
<BlockSwitcherDropdownMenuContents
|
|
358
231
|
onClose={ onClose }
|
|
359
232
|
clientIds={ clientIds }
|
|
360
|
-
hasBlockStyles={ hasBlockStyles }
|
|
361
|
-
canRemove={ canRemove }
|
|
362
233
|
/>
|
|
363
234
|
) }
|
|
364
235
|
</DropdownMenu>
|
|
@@ -1,54 +1,6 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables" as *;
|
|
2
2
|
@use "@wordpress/base-styles/colors" as *;
|
|
3
3
|
|
|
4
|
-
.block-editor-block-switcher {
|
|
5
|
-
position: relative;
|
|
6
|
-
|
|
7
|
-
// @todo override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
8
|
-
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
9
|
-
// It needs specificity due to style inherited from .components-accessible-toolbar .components-button.has-icon.has-icon.
|
|
10
|
-
.components-button.components-dropdown-menu__toggle.has-icon.has-icon {
|
|
11
|
-
min-width: $button-size;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Show an indicator triangle.
|
|
16
|
-
.block-editor-block-switcher__no-switcher-icon,
|
|
17
|
-
.block-editor-block-switcher__toggle {
|
|
18
|
-
position: relative;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.components-button.block-editor-block-switcher__toggle,
|
|
22
|
-
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
23
|
-
margin: 0;
|
|
24
|
-
display: block;
|
|
25
|
-
height: $grid-unit-60;
|
|
26
|
-
|
|
27
|
-
.block-editor-block-icon {
|
|
28
|
-
margin: auto;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
33
|
-
display: flex;
|
|
34
|
-
|
|
35
|
-
.block-editor-block-icon {
|
|
36
|
-
margin-right: auto;
|
|
37
|
-
margin-left: auto;
|
|
38
|
-
min-width: $icon-size !important;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Even when the block switcher does not have any transformations, it still serves as a block indicator.
|
|
43
|
-
.components-button.block-editor-block-switcher__no-switcher-icon[aria-disabled="true"] {
|
|
44
|
-
color: $gray-900;
|
|
45
|
-
|
|
46
|
-
// Since it's not clickable, though, don't show a hover state.
|
|
47
|
-
&:hover {
|
|
48
|
-
color: $gray-900;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
4
|
.components-popover.block-editor-block-switcher__popover .components-popover__content {
|
|
53
5
|
min-width: 300px;
|
|
54
6
|
}
|
|
@@ -97,28 +49,6 @@
|
|
|
97
49
|
font-weight: $font-weight-medium;
|
|
98
50
|
}
|
|
99
51
|
|
|
100
|
-
// The block switcher in the contextual toolbar should be bigger.
|
|
101
|
-
.block-editor-block-contextual-toolbar {
|
|
102
|
-
.components-button.block-editor-block-switcher__no-switcher-icon {
|
|
103
|
-
min-width: $button-size;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.components-button.block-editor-block-switcher__no-switcher-icon,
|
|
107
|
-
.components-button.block-editor-block-switcher__toggle {
|
|
108
|
-
height: $grid-unit-60;
|
|
109
|
-
|
|
110
|
-
.block-editor-block-icon,
|
|
111
|
-
.block-editor-block-switcher__transform {
|
|
112
|
-
width: $block-toolbar-height;
|
|
113
|
-
height: $block-toolbar-height;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.block-editor-block-switcher__transform {
|
|
117
|
-
padding: $grid-unit-15;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
52
|
.block-editor-block-switcher__preview-patterns-container {
|
|
123
53
|
padding-bottom: $grid-unit-20;
|
|
124
54
|
|