@wordpress/block-editor 11.8.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +15 -3
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -4
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +83 -9
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +11 -28
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -32
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +12 -12
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +6 -6
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +1 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +78 -14
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -9
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +87 -77
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/index.js +7 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/list-view/block-select-button.js +7 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +12 -21
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +10 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/hooks/duotone.js +29 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/utils.js +15 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +7 -0
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +5 -5
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +68 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -4
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +10 -27
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +2 -32
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +13 -13
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -7
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +2 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +78 -16
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +10 -10
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +87 -77
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +14 -22
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +11 -5
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/hooks/duotone.js +28 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/utils.js +16 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +7 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +4 -4
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -6
- package/build-style/content.css +9 -6
- package/build-style/style-rtl.css +223 -46
- package/build-style/style.css +223 -46
- package/package.json +32 -32
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-list/block.native.js +2 -3
- package/src/components/block-list/content.scss +16 -15
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +94 -11
- package/src/components/block-tools/selected-block-popover.js +11 -44
- package/src/components/block-tools/style.scss +157 -3
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/border-panel.js +1 -30
- package/src/components/global-styles/color-panel.js +13 -13
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +17 -7
- package/src/components/global-styles/effects-panel.js +2 -2
- package/src/components/global-styles/filters-panel.js +90 -17
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +126 -4
- package/src/components/global-styles/typography-panel.js +37 -11
- package/src/components/global-styles/use-global-styles-output.js +64 -64
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/list-view/block-select-button.js +6 -1
- package/src/components/list-view/block.js +23 -31
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +8 -1
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +15 -3
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/duotone.js +46 -25
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-typography-props.js +2 -2
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/utils.js +20 -3
- package/src/private-apis.js +6 -0
- package/src/store/actions.js +7 -0
- package/src/utils/object.js +4 -4
- package/src/utils/test/object.js +21 -21
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +75 -0
- package/tsconfig.json +1 -0
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getBlock,
|
|
9
9
|
within,
|
|
10
10
|
getEditorHtml,
|
|
11
|
-
|
|
11
|
+
typeInRichText,
|
|
12
12
|
} from 'test/helpers';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -71,7 +71,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
71
71
|
within( paragraphBlock ).getByPlaceholderText(
|
|
72
72
|
'Start writing…'
|
|
73
73
|
);
|
|
74
|
-
|
|
74
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
75
75
|
|
|
76
76
|
// Add Spacer block
|
|
77
77
|
await addBlock( screen, 'Spacer' );
|
|
@@ -132,7 +132,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
132
132
|
within( paragraphBlock ).getByPlaceholderText(
|
|
133
133
|
'Start writing…'
|
|
134
134
|
);
|
|
135
|
-
|
|
135
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
136
136
|
|
|
137
137
|
// Add Spacer block
|
|
138
138
|
await addBlock( screen, 'Spacer' );
|
|
@@ -179,7 +179,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
179
179
|
within( paragraphBlock ).getByPlaceholderText(
|
|
180
180
|
'Start writing…'
|
|
181
181
|
);
|
|
182
|
-
|
|
182
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
183
183
|
|
|
184
184
|
// Add Spacer block
|
|
185
185
|
await addBlock( screen, 'Spacer' );
|
|
@@ -228,7 +228,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
228
228
|
within( paragraphBlock ).getByPlaceholderText(
|
|
229
229
|
'Start writing…'
|
|
230
230
|
);
|
|
231
|
-
|
|
231
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
232
232
|
|
|
233
233
|
// Add Spacer block
|
|
234
234
|
await addBlock( screen, 'Spacer' );
|
|
@@ -275,7 +275,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
275
275
|
within( paragraphBlock ).getByPlaceholderText(
|
|
276
276
|
'Start writing…'
|
|
277
277
|
);
|
|
278
|
-
|
|
278
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
279
279
|
|
|
280
280
|
// Add Spacer block
|
|
281
281
|
await addBlock( screen, 'Spacer' );
|
|
@@ -322,7 +322,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
322
322
|
within( paragraphBlock ).getByPlaceholderText(
|
|
323
323
|
'Start writing…'
|
|
324
324
|
);
|
|
325
|
-
|
|
325
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
326
326
|
|
|
327
327
|
// Add Spacer block
|
|
328
328
|
await addBlock( screen, 'Spacer' );
|
|
@@ -368,7 +368,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
368
368
|
within( paragraphBlock ).getByPlaceholderText(
|
|
369
369
|
'Start writing…'
|
|
370
370
|
);
|
|
371
|
-
|
|
371
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
372
372
|
|
|
373
373
|
// Add Spacer block
|
|
374
374
|
await addBlock( screen, 'Spacer' );
|
|
@@ -405,7 +405,7 @@ describe( 'Block Actions Menu', () => {
|
|
|
405
405
|
within( paragraphBlock ).getByPlaceholderText(
|
|
406
406
|
'Start writing…'
|
|
407
407
|
);
|
|
408
|
-
|
|
408
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
409
409
|
|
|
410
410
|
// Add Spacer block
|
|
411
411
|
await addBlock( screen, 'Spacer' );
|
|
@@ -35,11 +35,14 @@
|
|
|
35
35
|
> * {
|
|
36
36
|
width: $block-toolbar-height * 0.5;
|
|
37
37
|
min-width: 0 !important; // overrides default button width.
|
|
38
|
-
padding-left: 0 !important;
|
|
39
|
-
padding-right: 0 !important;
|
|
40
38
|
overflow: hidden;
|
|
41
39
|
}
|
|
42
40
|
|
|
41
|
+
.block-editor-block-mover-button {
|
|
42
|
+
padding-left: 0;
|
|
43
|
+
padding-right: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
43
46
|
.block-editor-block-mover-button.is-up-button svg {
|
|
44
47
|
left: 5px;
|
|
45
48
|
}
|
|
@@ -55,9 +58,12 @@
|
|
|
55
58
|
@include break-small() {
|
|
56
59
|
width: $block-toolbar-height * 0.5;
|
|
57
60
|
min-width: 0 !important; // overrides default button width.
|
|
58
|
-
padding-left: 0 !important;
|
|
59
|
-
padding-right: 0 !important;
|
|
60
61
|
overflow: hidden;
|
|
62
|
+
|
|
63
|
+
.block-editor-block-mover &.has-icon.has-icon {
|
|
64
|
+
padding-left: 0;
|
|
65
|
+
padding-right: 0;
|
|
66
|
+
}
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
within,
|
|
10
10
|
getEditorHtml,
|
|
11
11
|
render,
|
|
12
|
-
|
|
12
|
+
typeInRichText,
|
|
13
13
|
} from 'test/helpers';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -89,7 +89,7 @@ describe( 'Block Mover Picker', () => {
|
|
|
89
89
|
within( paragraphBlock ).getByPlaceholderText(
|
|
90
90
|
'Start writing…'
|
|
91
91
|
);
|
|
92
|
-
|
|
92
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
93
93
|
|
|
94
94
|
// Add Spacer block
|
|
95
95
|
await addBlock( screen, 'Spacer' );
|
|
@@ -138,7 +138,7 @@ describe( 'Block Mover Picker', () => {
|
|
|
138
138
|
within( paragraphBlock ).getByPlaceholderText(
|
|
139
139
|
'Start writing…'
|
|
140
140
|
);
|
|
141
|
-
|
|
141
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
142
142
|
|
|
143
143
|
// Add Spacer block
|
|
144
144
|
await addBlock( screen, 'Spacer' );
|
|
@@ -176,7 +176,7 @@ describe( 'Block Mover Picker', () => {
|
|
|
176
176
|
within( paragraphBlock ).getByPlaceholderText(
|
|
177
177
|
'Start writing…'
|
|
178
178
|
);
|
|
179
|
-
|
|
179
|
+
typeInRichText( paragraphField, 'Hello!' );
|
|
180
180
|
|
|
181
181
|
// Add Spacer block
|
|
182
182
|
await addBlock( screen, 'Spacer' );
|
|
@@ -99,6 +99,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
99
99
|
// header area and not contextually to the block.
|
|
100
100
|
const displayHeaderToolbar =
|
|
101
101
|
useViewportMatch( 'medium', '<' ) || hasFixedToolbar;
|
|
102
|
+
const isLargeViewport = ! useViewportMatch( 'medium', '<' );
|
|
102
103
|
|
|
103
104
|
if ( blockType ) {
|
|
104
105
|
if ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {
|
|
@@ -124,9 +125,9 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
124
125
|
|
|
125
126
|
return (
|
|
126
127
|
<div className={ classes }>
|
|
127
|
-
{ ! isMultiToolbar &&
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
{ ! isMultiToolbar && isLargeViewport && ! isContentLocked && (
|
|
129
|
+
<BlockParentSelector />
|
|
130
|
+
) }
|
|
130
131
|
<div ref={ nodeRef } { ...showMoversGestures }>
|
|
131
132
|
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
|
|
132
133
|
! isContentLocked && (
|
|
@@ -56,26 +56,46 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
// on desktop browsers the fixed toolbar has tweaked borders
|
|
60
|
+
@include break-medium() {
|
|
61
|
+
.block-editor-block-contextual-toolbar.is-fixed {
|
|
62
|
+
.block-editor-block-toolbar {
|
|
63
|
+
.components-toolbar-group,
|
|
64
|
+
.components-toolbar {
|
|
65
|
+
border-right: none;
|
|
66
|
+
|
|
67
|
+
&::after {
|
|
68
|
+
content: "";
|
|
69
|
+
width: $border-width;
|
|
70
|
+
margin-top: $grid-unit + $grid-unit-05;
|
|
71
|
+
margin-bottom: $grid-unit + $grid-unit-05;
|
|
72
|
+
background-color: $gray-300;
|
|
73
|
+
margin-left: $grid-unit;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
& .components-toolbar-group.components-toolbar-group {
|
|
77
|
+
&::after {
|
|
78
|
+
display: none;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
> :last-child,
|
|
84
|
+
> :last-child .components-toolbar-group,
|
|
85
|
+
> :last-child .components-toolbar {
|
|
86
|
+
&::after {
|
|
87
|
+
display: none;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
64
91
|
}
|
|
65
92
|
}
|
|
66
93
|
|
|
67
|
-
.block-editor-block-parent-
|
|
68
|
-
|
|
69
|
-
top: -$border-width;
|
|
70
|
-
left: calc(-#{$grid-unit-60} - #{$grid-unit-10} - #{$border-width});
|
|
94
|
+
.block-editor-block-contextual-toolbar.has-parent:not(.is-fixed) {
|
|
95
|
+
margin-left: calc(#{$grid-unit-60} + #{$grid-unit-10});
|
|
71
96
|
|
|
72
97
|
.show-icon-labels & {
|
|
73
|
-
|
|
74
|
-
left: auto;
|
|
75
|
-
top: auto;
|
|
76
|
-
margin-top: -$border-width;
|
|
77
|
-
margin-left: -$border-width;
|
|
78
|
-
margin-bottom: -$border-width;
|
|
98
|
+
margin-left: 0;
|
|
79
99
|
}
|
|
80
100
|
}
|
|
81
101
|
|
|
@@ -152,21 +172,38 @@
|
|
|
152
172
|
.block-editor-block-icon {
|
|
153
173
|
width: 0 !important;
|
|
154
174
|
height: 0 !important;
|
|
175
|
+
min-width: 0 !important;
|
|
155
176
|
}
|
|
156
177
|
}
|
|
157
178
|
|
|
158
179
|
// Parent selector overrides
|
|
159
180
|
|
|
160
181
|
.block-editor-block-parent-selector__button {
|
|
182
|
+
border-top-right-radius: 0;
|
|
183
|
+
border-bottom-right-radius: 0;
|
|
184
|
+
|
|
161
185
|
.block-editor-block-icon {
|
|
162
186
|
width: 0;
|
|
163
187
|
}
|
|
164
188
|
}
|
|
165
189
|
|
|
166
|
-
.block-editor-block-mover
|
|
190
|
+
.block-editor-block-mover .block-editor-block-mover__move-button-container {
|
|
167
191
|
width: auto;
|
|
168
192
|
}
|
|
169
193
|
|
|
194
|
+
.block-editor-block-mover.is-horizontal {
|
|
195
|
+
.block-editor-block-mover__move-button-container,
|
|
196
|
+
.block-editor-block-mover-button {
|
|
197
|
+
padding-left: 6px;
|
|
198
|
+
padding-right: 6px;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.block-editor-block-mover:not(.is-horizontal) .block-editor-block-mover-button {
|
|
203
|
+
padding-left: $grid-unit;
|
|
204
|
+
padding-right: $grid-unit;
|
|
205
|
+
}
|
|
206
|
+
|
|
170
207
|
// Mover overrides.
|
|
171
208
|
.block-editor-block-toolbar__block-controls .block-editor-block-mover {
|
|
172
209
|
border-left: 1px solid $gray-900;
|
|
@@ -179,15 +216,9 @@
|
|
|
179
216
|
border-left-color: $gray-200;
|
|
180
217
|
}
|
|
181
218
|
|
|
182
|
-
.block-editor-block-mover-
|
|
183
|
-
|
|
184
|
-
padding-
|
|
185
|
-
padding-right: $grid-unit !important;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.block-editor-block-mover__drag-handle.has-icon {
|
|
189
|
-
padding-left: 12px !important;
|
|
190
|
-
padding-right: 12px !important;
|
|
219
|
+
.block-editor-block-mover .block-editor-block-mover__drag-handle.has-icon {
|
|
220
|
+
padding-left: $grid-unit-15;
|
|
221
|
+
padding-right: $grid-unit-15;
|
|
191
222
|
}
|
|
192
223
|
|
|
193
224
|
.block-editor-block-contextual-toolbar.is-fixed .block-editor-block-mover__move-button-container {
|
|
@@ -204,18 +235,10 @@
|
|
|
204
235
|
|
|
205
236
|
.block-editor-block-mover__move-button-container {
|
|
206
237
|
border-left: 1px solid $gray-900;
|
|
207
|
-
|
|
208
|
-
&::before {
|
|
209
|
-
content: "";
|
|
210
|
-
display: block;
|
|
211
|
-
height: 1px;
|
|
212
|
-
background: $gray-900;
|
|
213
|
-
order: 2;
|
|
214
|
-
}
|
|
215
238
|
}
|
|
216
239
|
|
|
217
240
|
.is-down-button.is-down-button.is-down-button {
|
|
218
|
-
order:
|
|
241
|
+
order: 2;
|
|
219
242
|
}
|
|
220
243
|
|
|
221
244
|
.block-editor-block-contextual-toolbar.is-fixed .block-editor-block-mover__move-button-container::before {
|
|
@@ -7,8 +7,16 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { forwardRef, useEffect, useRef, useState } from '@wordpress/element';
|
|
10
11
|
import { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';
|
|
11
12
|
import { useSelect } from '@wordpress/data';
|
|
13
|
+
import {
|
|
14
|
+
ToolbarItem,
|
|
15
|
+
ToolbarButton,
|
|
16
|
+
ToolbarGroup,
|
|
17
|
+
} from '@wordpress/components';
|
|
18
|
+
import { levelUp } from '@wordpress/icons';
|
|
19
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
22
|
* Internal dependencies
|
|
@@ -16,10 +24,57 @@ import { useSelect } from '@wordpress/data';
|
|
|
16
24
|
import NavigableToolbar from '../navigable-toolbar';
|
|
17
25
|
import BlockToolbar from '../block-toolbar';
|
|
18
26
|
import { store as blockEditorStore } from '../../store';
|
|
27
|
+
import BlockIcon from '../block-icon';
|
|
28
|
+
|
|
29
|
+
const CollapseFixedToolbarButton = forwardRef( ( { onClick }, ref ) => {
|
|
30
|
+
return (
|
|
31
|
+
<ToolbarItem
|
|
32
|
+
as={ ToolbarButton }
|
|
33
|
+
className="block-editor-block-toolbar__collapse-fixed-toolbar"
|
|
34
|
+
icon={ levelUp }
|
|
35
|
+
onClick={ onClick }
|
|
36
|
+
ref={ ref }
|
|
37
|
+
label={ __( 'Show document tools' ) }
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
const ExpandFixedToolbarButton = forwardRef( ( { onClick, icon }, ref ) => {
|
|
43
|
+
return (
|
|
44
|
+
<ToolbarItem
|
|
45
|
+
as={ ToolbarButton }
|
|
46
|
+
className="block-editor-block-toolbar__expand-fixed-toolbar"
|
|
47
|
+
icon={ <BlockIcon icon={ icon } /> }
|
|
48
|
+
onClick={ onClick }
|
|
49
|
+
ref={ ref }
|
|
50
|
+
label={ __( 'Show block tools' ) }
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
} );
|
|
19
54
|
|
|
20
55
|
function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
21
|
-
|
|
22
|
-
|
|
56
|
+
// When the toolbar is fixed it can be collapsed
|
|
57
|
+
const [ isCollapsed, setIsCollapsed ] = useState( false );
|
|
58
|
+
const expandFixedToolbarButtonRef = useRef();
|
|
59
|
+
const collapseFixedToolbarButtonRef = useRef();
|
|
60
|
+
|
|
61
|
+
// Don't focus the block toolbar just because it mounts
|
|
62
|
+
const initialRender = useRef( true );
|
|
63
|
+
useEffect( () => {
|
|
64
|
+
if ( initialRender.current ) {
|
|
65
|
+
initialRender.current = false;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if ( isCollapsed && expandFixedToolbarButtonRef.current ) {
|
|
69
|
+
expandFixedToolbarButtonRef.current.focus();
|
|
70
|
+
}
|
|
71
|
+
if ( ! isCollapsed && collapseFixedToolbarButtonRef.current ) {
|
|
72
|
+
collapseFixedToolbarButtonRef.current.focus();
|
|
73
|
+
}
|
|
74
|
+
}, [ isCollapsed ] );
|
|
75
|
+
|
|
76
|
+
const { blockType, hasParents, showParentSelector, selectedBlockClientId } =
|
|
77
|
+
useSelect( ( select ) => {
|
|
23
78
|
const {
|
|
24
79
|
getBlockName,
|
|
25
80
|
getBlockParents,
|
|
@@ -28,16 +83,17 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
28
83
|
} = select( blockEditorStore );
|
|
29
84
|
const { getBlockType } = select( blocksStore );
|
|
30
85
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
31
|
-
const
|
|
32
|
-
const parents = getBlockParents(
|
|
86
|
+
const _selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
87
|
+
const parents = getBlockParents( _selectedBlockClientId );
|
|
33
88
|
const firstParentClientId = parents[ parents.length - 1 ];
|
|
34
89
|
const parentBlockName = getBlockName( firstParentClientId );
|
|
35
90
|
const parentBlockType = getBlockType( parentBlockName );
|
|
36
91
|
|
|
37
92
|
return {
|
|
93
|
+
selectedBlockClientId: _selectedBlockClientId,
|
|
38
94
|
blockType:
|
|
39
|
-
|
|
40
|
-
getBlockType( getBlockName(
|
|
95
|
+
_selectedBlockClientId &&
|
|
96
|
+
getBlockType( getBlockName( _selectedBlockClientId ) ),
|
|
41
97
|
hasParents: parents.length,
|
|
42
98
|
showParentSelector:
|
|
43
99
|
parentBlockType &&
|
|
@@ -48,12 +104,16 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
48
104
|
) &&
|
|
49
105
|
selectedBlockClientIds.length <= 1 &&
|
|
50
106
|
! __unstableGetContentLockingParent(
|
|
51
|
-
|
|
107
|
+
_selectedBlockClientId
|
|
52
108
|
),
|
|
53
109
|
};
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
)
|
|
110
|
+
}, [] );
|
|
111
|
+
|
|
112
|
+
useEffect( () => {
|
|
113
|
+
setIsCollapsed( false );
|
|
114
|
+
}, [ selectedBlockClientId ] );
|
|
115
|
+
|
|
116
|
+
const isLargeViewport = useViewportMatch( 'medium' );
|
|
57
117
|
|
|
58
118
|
if ( blockType ) {
|
|
59
119
|
if ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {
|
|
@@ -65,6 +125,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
65
125
|
const classes = classnames( 'block-editor-block-contextual-toolbar', {
|
|
66
126
|
'has-parent': hasParents && showParentSelector,
|
|
67
127
|
'is-fixed': isFixed,
|
|
128
|
+
'is-collapsed': isCollapsed,
|
|
68
129
|
} );
|
|
69
130
|
|
|
70
131
|
return (
|
|
@@ -75,7 +136,29 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
75
136
|
aria-label={ __( 'Block tools' ) }
|
|
76
137
|
{ ...props }
|
|
77
138
|
>
|
|
78
|
-
|
|
139
|
+
{ isFixed && isLargeViewport && blockType && (
|
|
140
|
+
<ToolbarGroup
|
|
141
|
+
className={
|
|
142
|
+
isCollapsed
|
|
143
|
+
? 'block-editor-block-toolbar__group-expand-fixed-toolbar'
|
|
144
|
+
: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
{ isCollapsed ? (
|
|
148
|
+
<ExpandFixedToolbarButton
|
|
149
|
+
onClick={ () => setIsCollapsed( false ) }
|
|
150
|
+
icon={ blockType.icon }
|
|
151
|
+
ref={ expandFixedToolbarButtonRef }
|
|
152
|
+
/>
|
|
153
|
+
) : (
|
|
154
|
+
<CollapseFixedToolbarButton
|
|
155
|
+
onClick={ () => setIsCollapsed( true ) }
|
|
156
|
+
ref={ collapseFixedToolbarButtonRef }
|
|
157
|
+
/>
|
|
158
|
+
) }
|
|
159
|
+
</ToolbarGroup>
|
|
160
|
+
) }
|
|
161
|
+
{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }
|
|
79
162
|
</NavigableToolbar>
|
|
80
163
|
);
|
|
81
164
|
}
|
|
@@ -10,7 +10,6 @@ import { useRef, useEffect } from '@wordpress/element';
|
|
|
10
10
|
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
13
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Internal dependencies
|
|
@@ -22,26 +21,20 @@ import BlockPopover from '../block-popover';
|
|
|
22
21
|
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
23
22
|
import Inserter from '../inserter';
|
|
24
23
|
import { unlock } from '../../lock-unlock';
|
|
24
|
+
import { privateApis } from '../../private-apis';
|
|
25
25
|
|
|
26
26
|
function selector( select ) {
|
|
27
27
|
const {
|
|
28
28
|
__unstableGetEditorMode,
|
|
29
|
-
isMultiSelecting,
|
|
30
29
|
hasMultiSelection,
|
|
31
30
|
isTyping,
|
|
32
|
-
isBlockInterfaceHidden,
|
|
33
|
-
getSettings,
|
|
34
31
|
getLastMultiSelectedBlockClientId,
|
|
35
32
|
} = unlock( select( blockEditorStore ) );
|
|
36
33
|
|
|
37
34
|
return {
|
|
38
35
|
editorMode: __unstableGetEditorMode(),
|
|
39
36
|
hasMultiSelection: hasMultiSelection(),
|
|
40
|
-
isMultiSelecting: isMultiSelecting(),
|
|
41
37
|
isTyping: isTyping(),
|
|
42
|
-
isBlockInterfaceHidden: isBlockInterfaceHidden(),
|
|
43
|
-
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
44
|
-
isDistractionFree: getSettings().isDistractionFree,
|
|
45
38
|
lastClientId: hasMultiSelection()
|
|
46
39
|
? getLastMultiSelectedBlockClientId()
|
|
47
40
|
: null,
|
|
@@ -52,21 +45,16 @@ function SelectedBlockPopover( {
|
|
|
52
45
|
clientId,
|
|
53
46
|
rootClientId,
|
|
54
47
|
isEmptyDefaultBlock,
|
|
55
|
-
showContents, // we may need to mount an empty popover because we reuse
|
|
56
48
|
capturingClientId,
|
|
57
49
|
__unstablePopoverSlot,
|
|
58
50
|
__unstableContentRef,
|
|
59
51
|
} ) {
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
hasFixedToolbar,
|
|
67
|
-
isDistractionFree,
|
|
68
|
-
lastClientId,
|
|
69
|
-
} = useSelect( selector, [] );
|
|
52
|
+
const { editorMode, hasMultiSelection, isTyping, lastClientId } = useSelect(
|
|
53
|
+
selector,
|
|
54
|
+
[]
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const { useShouldContextualToolbarShow } = unlock( privateApis );
|
|
70
58
|
const isInsertionPointVisible = useSelect(
|
|
71
59
|
( select ) => {
|
|
72
60
|
const {
|
|
@@ -85,8 +73,10 @@ function SelectedBlockPopover( {
|
|
|
85
73
|
},
|
|
86
74
|
[ clientId ]
|
|
87
75
|
);
|
|
88
|
-
const isLargeViewport = useViewportMatch( 'medium' );
|
|
89
76
|
const isToolbarForced = useRef( false );
|
|
77
|
+
const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
|
|
78
|
+
useShouldContextualToolbarShow( clientId );
|
|
79
|
+
|
|
90
80
|
const { stopTyping } = useDispatch( blockEditorStore );
|
|
91
81
|
|
|
92
82
|
const showEmptyBlockSideInserter =
|
|
@@ -94,20 +84,6 @@ function SelectedBlockPopover( {
|
|
|
94
84
|
const shouldShowBreadcrumb =
|
|
95
85
|
! hasMultiSelection &&
|
|
96
86
|
( editorMode === 'navigation' || editorMode === 'zoom-out' );
|
|
97
|
-
const shouldShowContextualToolbar =
|
|
98
|
-
editorMode === 'edit' &&
|
|
99
|
-
! hasFixedToolbar &&
|
|
100
|
-
isLargeViewport &&
|
|
101
|
-
! isMultiSelecting &&
|
|
102
|
-
! showEmptyBlockSideInserter &&
|
|
103
|
-
! isTyping &&
|
|
104
|
-
! isBlockInterfaceHidden;
|
|
105
|
-
const canFocusHiddenToolbar =
|
|
106
|
-
editorMode === 'edit' &&
|
|
107
|
-
! shouldShowContextualToolbar &&
|
|
108
|
-
! hasFixedToolbar &&
|
|
109
|
-
! isDistractionFree &&
|
|
110
|
-
! isEmptyDefaultBlock;
|
|
111
87
|
|
|
112
88
|
useShortcut(
|
|
113
89
|
'core/block-editor/focus-toolbar',
|
|
@@ -179,7 +155,7 @@ function SelectedBlockPopover( {
|
|
|
179
155
|
resize={ false }
|
|
180
156
|
{ ...popoverProps }
|
|
181
157
|
>
|
|
182
|
-
{ shouldShowContextualToolbar &&
|
|
158
|
+
{ shouldShowContextualToolbar && (
|
|
183
159
|
<BlockContextualToolbar
|
|
184
160
|
// If the toolbar is being shown because of being forced
|
|
185
161
|
// it should focus the toolbar right after the mount.
|
|
@@ -215,8 +191,6 @@ function wrapperSelector( select ) {
|
|
|
215
191
|
getBlockRootClientId,
|
|
216
192
|
getBlock,
|
|
217
193
|
getBlockParents,
|
|
218
|
-
getSettings,
|
|
219
|
-
isNavigationMode: _isNavigationMode,
|
|
220
194
|
__experimentalGetBlockListSettingsForBlocks,
|
|
221
195
|
} = select( blockEditorStore );
|
|
222
196
|
|
|
@@ -242,14 +216,10 @@ function wrapperSelector( select ) {
|
|
|
242
216
|
?.__experimentalCaptureToolbars
|
|
243
217
|
);
|
|
244
218
|
|
|
245
|
-
const settings = getSettings();
|
|
246
|
-
|
|
247
219
|
return {
|
|
248
220
|
clientId,
|
|
249
221
|
rootClientId: getBlockRootClientId( clientId ),
|
|
250
222
|
name,
|
|
251
|
-
isDistractionFree: settings.isDistractionFree,
|
|
252
|
-
isNavigationMode: _isNavigationMode(),
|
|
253
223
|
isEmptyDefaultBlock:
|
|
254
224
|
name && isUnmodifiedDefaultBlock( { name, attributes } ),
|
|
255
225
|
capturingClientId,
|
|
@@ -272,8 +242,6 @@ export default function WrappedBlockPopover( {
|
|
|
272
242
|
name,
|
|
273
243
|
isEmptyDefaultBlock,
|
|
274
244
|
capturingClientId,
|
|
275
|
-
isDistractionFree,
|
|
276
|
-
isNavigationMode,
|
|
277
245
|
} = selected;
|
|
278
246
|
|
|
279
247
|
if ( ! name ) {
|
|
@@ -285,7 +253,6 @@ export default function WrappedBlockPopover( {
|
|
|
285
253
|
clientId={ clientId }
|
|
286
254
|
rootClientId={ rootClientId }
|
|
287
255
|
isEmptyDefaultBlock={ isEmptyDefaultBlock }
|
|
288
|
-
showContents={ ! isDistractionFree || isNavigationMode }
|
|
289
256
|
capturingClientId={ capturingClientId }
|
|
290
257
|
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
291
258
|
__unstableContentRef={ __unstableContentRef }
|