@wordpress/edit-widgets 5.24.1 → 5.25.1-next.79a6196f.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/LICENSE.md +1 -1
- package/build/blocks/widget-area/index.js +1 -0
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/header/document-tools/index.js +19 -18
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +4 -12
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +8 -3
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +8 -3
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/layout/interface.js +2 -7
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +2 -6
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.js +5 -1
- package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +4 -2
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/store/index.js +3 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +10 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +14 -0
- package/build/store/reducer.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +1 -0
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +19 -18
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -13
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +7 -3
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +7 -3
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/layout/interface.js +3 -8
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +2 -6
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +8 -6
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +6 -2
- package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +4 -2
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/store/index.js +3 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +13 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +25 -5
- package/build-style/style.css +25 -5
- package/package.json +30 -29
- package/src/blocks/widget-area/block.json +1 -0
- package/src/components/header/document-tools/index.js +19 -23
- package/src/components/header/index.js +4 -9
- package/src/components/header/style.scss +25 -5
- package/src/components/header/undo-redo/redo.js +8 -3
- package/src/components/header/undo-redo/undo.js +8 -3
- package/src/components/layout/interface.js +3 -14
- package/src/components/secondary-sidebar/index.js +2 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +6 -4
- package/src/components/widget-areas-block-editor-content/index.js +4 -0
- package/src/components/widget-areas-block-editor-provider/index.js +4 -1
- package/src/store/index.js +4 -0
- package/src/store/private-selectors.js +3 -0
- package/src/store/reducer.js +11 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { BlockToolbar } from '@wordpress/block-editor';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { useRef } from '@wordpress/element';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
@@ -16,11 +16,8 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
16
16
|
import DocumentTools from './document-tools';
|
|
17
17
|
import SaveButton from '../save-button';
|
|
18
18
|
import MoreMenu from '../more-menu';
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function Header( { setListViewToggleElement } ) {
|
|
20
|
+
function Header() {
|
|
24
21
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
25
22
|
const blockToolbarRef = useRef();
|
|
26
23
|
const { hasFixedToolbar } = useSelect(
|
|
@@ -50,13 +47,11 @@ function Header( { setListViewToggleElement } ) {
|
|
|
50
47
|
{ __( 'Widgets' ) }
|
|
51
48
|
</VisuallyHidden>
|
|
52
49
|
) }
|
|
53
|
-
<DocumentTools
|
|
54
|
-
setListViewToggleElement={ setListViewToggleElement }
|
|
55
|
-
/>
|
|
50
|
+
<DocumentTools />
|
|
56
51
|
{ hasFixedToolbar && isLargeViewport && (
|
|
57
52
|
<>
|
|
58
53
|
<div className="selected-block-tools-wrapper">
|
|
59
|
-
<
|
|
54
|
+
<BlockToolbar hideDragHandle />
|
|
60
55
|
</div>
|
|
61
56
|
<Popover.Slot
|
|
62
57
|
ref={ blockToolbarRef }
|
|
@@ -12,10 +12,31 @@
|
|
|
12
12
|
|
|
13
13
|
.selected-block-tools-wrapper {
|
|
14
14
|
overflow-x: hidden;
|
|
15
|
-
}
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
.block-editor-block-contextual-toolbar {
|
|
17
|
+
border-bottom: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Modified group borders
|
|
21
|
+
.components-toolbar-group,
|
|
22
|
+
.components-toolbar {
|
|
23
|
+
border-right: none;
|
|
24
|
+
|
|
25
|
+
&::after {
|
|
26
|
+
content: "";
|
|
27
|
+
width: $border-width;
|
|
28
|
+
margin-top: $grid-unit + $grid-unit-05;
|
|
29
|
+
margin-bottom: $grid-unit + $grid-unit-05;
|
|
30
|
+
background-color: $gray-300;
|
|
31
|
+
margin-left: $grid-unit;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
& .components-toolbar-group.components-toolbar-group {
|
|
35
|
+
&::after {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
19
40
|
}
|
|
20
41
|
}
|
|
21
42
|
|
|
@@ -24,7 +45,6 @@
|
|
|
24
45
|
align-items: center;
|
|
25
46
|
justify-content: center;
|
|
26
47
|
flex-shrink: 2;
|
|
27
|
-
overflow-x: hidden;
|
|
28
48
|
padding-left: $grid-unit-20;
|
|
29
49
|
}
|
|
30
50
|
|
|
@@ -46,7 +66,7 @@
|
|
|
46
66
|
}
|
|
47
67
|
|
|
48
68
|
.edit-widgets-header-toolbar {
|
|
49
|
-
|
|
69
|
+
gap: $grid-unit-10;
|
|
50
70
|
|
|
51
71
|
// The Toolbar component adds different styles to buttons, so we reset them
|
|
52
72
|
// here to the original button styles
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';
|
|
8
8
|
import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
function RedoButton( props, ref ) {
|
|
12
13
|
const shortcut = isAppleOS()
|
|
13
14
|
? displayShortcut.primaryShift( 'z' )
|
|
14
15
|
: displayShortcut.primary( 'y' );
|
|
@@ -19,7 +20,9 @@ export default function RedoButton() {
|
|
|
19
20
|
);
|
|
20
21
|
const { redo } = useDispatch( coreStore );
|
|
21
22
|
return (
|
|
22
|
-
<
|
|
23
|
+
<Button
|
|
24
|
+
{ ...props }
|
|
25
|
+
ref={ ref }
|
|
23
26
|
icon={ ! isRTL() ? redoIcon : undoIcon }
|
|
24
27
|
label={ __( 'Redo' ) }
|
|
25
28
|
shortcut={ shortcut }
|
|
@@ -31,3 +34,5 @@ export default function RedoButton() {
|
|
|
31
34
|
/>
|
|
32
35
|
);
|
|
33
36
|
}
|
|
37
|
+
|
|
38
|
+
export default forwardRef( RedoButton );
|
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';
|
|
8
8
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
function UndoButton( props, ref ) {
|
|
12
13
|
const hasUndo = useSelect(
|
|
13
14
|
( select ) => select( coreStore ).hasUndo(),
|
|
14
15
|
[]
|
|
15
16
|
);
|
|
16
17
|
const { undo } = useDispatch( coreStore );
|
|
17
18
|
return (
|
|
18
|
-
<
|
|
19
|
+
<Button
|
|
20
|
+
{ ...props }
|
|
21
|
+
ref={ ref }
|
|
19
22
|
icon={ ! isRTL() ? undoIcon : redoIcon }
|
|
20
23
|
label={ __( 'Undo' ) }
|
|
21
24
|
shortcut={ displayShortcut.primary( 'z' ) }
|
|
@@ -27,3 +30,5 @@ export default function UndoButton() {
|
|
|
27
30
|
/>
|
|
28
31
|
);
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
export default forwardRef( UndoButton );
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useViewportMatch } from '@wordpress/compose';
|
|
5
5
|
import { BlockBreadcrumb } from '@wordpress/block-editor';
|
|
6
|
-
import { useEffect
|
|
6
|
+
import { useEffect } from '@wordpress/element';
|
|
7
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import {
|
|
9
9
|
InterfaceSkeleton,
|
|
@@ -68,9 +68,6 @@ function Interface( { blockEditorSettings } ) {
|
|
|
68
68
|
[]
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
const [ listViewToggleElement, setListViewToggleElement ] =
|
|
72
|
-
useState( null );
|
|
73
|
-
|
|
74
71
|
// Inserter and Sidebars are mutually exclusive
|
|
75
72
|
useEffect( () => {
|
|
76
73
|
if ( hasSidebarEnabled && ! isHugeViewport ) {
|
|
@@ -97,16 +94,8 @@ function Interface( { blockEditorSettings } ) {
|
|
|
97
94
|
...interfaceLabels,
|
|
98
95
|
secondarySidebar: secondarySidebarLabel,
|
|
99
96
|
} }
|
|
100
|
-
header={
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
secondarySidebar={
|
|
104
|
-
hasSecondarySidebar && (
|
|
105
|
-
<SecondarySidebar
|
|
106
|
-
listViewToggleElement={ listViewToggleElement }
|
|
107
|
-
/>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
97
|
+
header={ <Header /> }
|
|
98
|
+
secondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }
|
|
110
99
|
sidebar={
|
|
111
100
|
hasSidebarEnabled && (
|
|
112
101
|
<ComplementaryArea.Slot scope="core/edit-widgets" />
|
|
@@ -13,7 +13,7 @@ import { store as editWidgetsStore } from '../../store';
|
|
|
13
13
|
import InserterSidebar from './inserter-sidebar';
|
|
14
14
|
import ListViewSidebar from './list-view-sidebar';
|
|
15
15
|
|
|
16
|
-
export default function SecondarySidebar(
|
|
16
|
+
export default function SecondarySidebar() {
|
|
17
17
|
const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
|
|
18
18
|
const { isInserterOpened, isListViewOpened } =
|
|
19
19
|
select( editWidgetsStore );
|
|
@@ -27,9 +27,7 @@ export default function SecondarySidebar( { listViewToggleElement } ) {
|
|
|
27
27
|
return <InserterSidebar />;
|
|
28
28
|
}
|
|
29
29
|
if ( isListViewOpen ) {
|
|
30
|
-
return
|
|
31
|
-
<ListViewSidebar listViewToggleElement={ listViewToggleElement } />
|
|
32
|
-
);
|
|
30
|
+
return <ListViewSidebar />;
|
|
33
31
|
}
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import { useCallback, useState } from '@wordpress/element';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { closeSmall } from '@wordpress/icons';
|
|
@@ -14,9 +14,11 @@ import { ESCAPE } from '@wordpress/keycodes';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import { store as editWidgetsStore } from '../../store';
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
17
18
|
|
|
18
|
-
export default function ListViewSidebar(
|
|
19
|
+
export default function ListViewSidebar() {
|
|
19
20
|
const { setIsListViewOpened } = useDispatch( editWidgetsStore );
|
|
21
|
+
const { getListViewToggleRef } = unlock( useSelect( editWidgetsStore ) );
|
|
20
22
|
|
|
21
23
|
// Use internal state instead of a ref to make sure that the component
|
|
22
24
|
// re-renders when the dropZoneElement updates.
|
|
@@ -27,8 +29,8 @@ export default function ListViewSidebar( { listViewToggleElement } ) {
|
|
|
27
29
|
// When closing the list view, focus should return to the toggle button.
|
|
28
30
|
const closeListView = useCallback( () => {
|
|
29
31
|
setIsListViewOpened( false );
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
+
getListViewToggleRef().current?.focus();
|
|
33
|
+
}, [ getListViewToggleRef, setIsListViewOpened ] );
|
|
32
34
|
|
|
33
35
|
const closeOnEscape = useCallback(
|
|
34
36
|
( event ) => {
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
BlockList,
|
|
6
|
+
BlockToolbar,
|
|
6
7
|
BlockTools,
|
|
7
8
|
BlockSelectionClearer,
|
|
8
9
|
WritingFlow,
|
|
9
10
|
__unstableEditorStyles as EditorStyles,
|
|
10
11
|
} from '@wordpress/block-editor';
|
|
12
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
11
13
|
import { useSelect } from '@wordpress/data';
|
|
12
14
|
import { useMemo } from '@wordpress/element';
|
|
13
15
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -29,6 +31,7 @@ export default function WidgetAreasBlockEditorContent( {
|
|
|
29
31
|
),
|
|
30
32
|
[]
|
|
31
33
|
);
|
|
34
|
+
const isLargeViewport = useViewportMatch( 'medium' );
|
|
32
35
|
|
|
33
36
|
const styles = useMemo( () => {
|
|
34
37
|
return hasThemeStyles ? blockEditorSettings.styles : [];
|
|
@@ -37,6 +40,7 @@ export default function WidgetAreasBlockEditorContent( {
|
|
|
37
40
|
return (
|
|
38
41
|
<div className="edit-widgets-block-editor">
|
|
39
42
|
<Notices />
|
|
43
|
+
{ ! isLargeViewport && <BlockToolbar hideDragHandle /> }
|
|
40
44
|
<BlockTools>
|
|
41
45
|
<KeyboardShortcuts />
|
|
42
46
|
<EditorStyles
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { SlotFillProvider } from '@wordpress/components';
|
|
5
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
5
6
|
import { uploadMedia } from '@wordpress/media-utils';
|
|
6
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
8
|
import {
|
|
@@ -32,6 +33,7 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
32
33
|
...props
|
|
33
34
|
} ) {
|
|
34
35
|
const mediaPermissions = useResourcePermissions( 'media' );
|
|
36
|
+
const isLargeViewport = useViewportMatch( 'medium' );
|
|
35
37
|
const {
|
|
36
38
|
reusableBlocks,
|
|
37
39
|
isFixedToolbarActive,
|
|
@@ -78,7 +80,7 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
78
80
|
return {
|
|
79
81
|
...blockEditorSettings,
|
|
80
82
|
__experimentalReusableBlocks: reusableBlocks,
|
|
81
|
-
hasFixedToolbar: isFixedToolbarActive,
|
|
83
|
+
hasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,
|
|
82
84
|
keepCaretInsideBlock,
|
|
83
85
|
mediaUpload: mediaUploadBlockEditor,
|
|
84
86
|
templateLock: 'all',
|
|
@@ -89,6 +91,7 @@ export default function WidgetAreasBlockEditorProvider( {
|
|
|
89
91
|
}, [
|
|
90
92
|
blockEditorSettings,
|
|
91
93
|
isFixedToolbarActive,
|
|
94
|
+
isLargeViewport,
|
|
92
95
|
keepCaretInsideBlock,
|
|
93
96
|
mediaPermissions.canCreate,
|
|
94
97
|
reusableBlocks,
|
package/src/store/index.js
CHANGED
|
@@ -11,7 +11,9 @@ import reducer from './reducer';
|
|
|
11
11
|
import * as resolvers from './resolvers';
|
|
12
12
|
import * as selectors from './selectors';
|
|
13
13
|
import * as actions from './actions';
|
|
14
|
+
import * as privateSelectors from './private-selectors';
|
|
14
15
|
import { STORE_NAME } from './constants';
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Block editor data store configuration.
|
|
@@ -47,3 +49,5 @@ apiFetch.use( function ( options, next ) {
|
|
|
47
49
|
|
|
48
50
|
return next( options );
|
|
49
51
|
} );
|
|
52
|
+
|
|
53
|
+
unlock( store ).registerPrivateSelectors( privateSelectors );
|
package/src/store/reducer.js
CHANGED
|
@@ -68,6 +68,17 @@ export function listViewPanel( state = false, action ) {
|
|
|
68
68
|
return state;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* This reducer does nothing aside initializing a ref to the list view toggle.
|
|
73
|
+
* We will have a unique ref per "editor" instance.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} state
|
|
76
|
+
* @return {Object} Reference to the list view toggle button.
|
|
77
|
+
*/
|
|
78
|
+
export function listViewToggleRef( state = { current: null } ) {
|
|
79
|
+
return state;
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
export default combineReducers( {
|
|
72
83
|
blockInserterPanel,
|
|
73
84
|
listViewPanel,
|