@wordpress/edit-widgets 5.18.1-next.5a1d1283.0 → 5.19.1

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/header/index.js +5 -2
  3. package/build/components/header/index.js.map +1 -1
  4. package/build/components/layout/interface.js +7 -2
  5. package/build/components/layout/interface.js.map +1 -1
  6. package/build/components/secondary-sidebar/index.js +6 -2
  7. package/build/components/secondary-sidebar/index.js.map +1 -1
  8. package/build/components/secondary-sidebar/list-view-sidebar.js +15 -10
  9. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  10. package/build/components/widget-areas-block-editor-content/index.js +2 -1
  11. package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
  12. package/build/components/widget-areas-block-editor-provider/index.js +3 -4
  13. package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
  14. package/build-module/components/header/index.js +5 -2
  15. package/build-module/components/header/index.js.map +1 -1
  16. package/build-module/components/layout/interface.js +8 -3
  17. package/build-module/components/layout/interface.js.map +1 -1
  18. package/build-module/components/secondary-sidebar/index.js +6 -2
  19. package/build-module/components/secondary-sidebar/index.js.map +1 -1
  20. package/build-module/components/secondary-sidebar/list-view-sidebar.js +17 -12
  21. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  22. package/build-module/components/widget-areas-block-editor-content/index.js +2 -1
  23. package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
  24. package/build-module/components/widget-areas-block-editor-provider/index.js +2 -3
  25. package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
  26. package/build-style/style-rtl.css +103 -4
  27. package/build-style/style.css +103 -4
  28. package/package.json +28 -28
  29. package/src/components/header/index.js +2 -1
  30. package/src/components/header/style.scss +2 -2
  31. package/src/components/layout/interface.js +14 -3
  32. package/src/components/secondary-sidebar/index.js +4 -2
  33. package/src/components/secondary-sidebar/list-view-sidebar.js +21 -25
  34. package/src/components/widget-areas-block-editor-content/index.js +4 -1
  35. package/src/components/widget-areas-block-editor-content/style.scss +99 -2
  36. package/src/components/widget-areas-block-editor-provider/index.js +13 -16
@@ -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( { listViewToggleElement } ) {
17
17
  const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
18
18
  const { isInserterOpened, isListViewOpened } =
19
19
  select( editWidgetsStore );
@@ -27,7 +27,9 @@ export default function SecondarySidebar() {
27
27
  return <InserterSidebar />;
28
28
  }
29
29
  if ( isListViewOpen ) {
30
- return <ListViewSidebar />;
30
+ return (
31
+ <ListViewSidebar listViewToggleElement={ listViewToggleElement } />
32
+ );
31
33
  }
32
34
  return null;
33
35
  }
@@ -3,13 +3,9 @@
3
3
  */
4
4
  import { __experimentalListView as ListView } from '@wordpress/block-editor';
5
5
  import { Button } from '@wordpress/components';
6
- import {
7
- useFocusOnMount,
8
- useFocusReturn,
9
- useMergeRefs,
10
- } from '@wordpress/compose';
6
+ import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
11
7
  import { useDispatch } from '@wordpress/data';
12
- import { useState } from '@wordpress/element';
8
+ import { useCallback, useState } from '@wordpress/element';
13
9
  import { __ } from '@wordpress/i18n';
14
10
  import { closeSmall } from '@wordpress/icons';
15
11
  import { ESCAPE } from '@wordpress/keycodes';
@@ -19,7 +15,7 @@ import { ESCAPE } from '@wordpress/keycodes';
19
15
  */
20
16
  import { store as editWidgetsStore } from '../../store';
21
17
 
22
- export default function ListViewSidebar() {
18
+ export default function ListViewSidebar( { listViewToggleElement } ) {
23
19
  const { setIsListViewOpened } = useDispatch( editWidgetsStore );
24
20
 
25
21
  // Use internal state instead of a ref to make sure that the component
@@ -27,15 +23,22 @@ export default function ListViewSidebar() {
27
23
  const [ dropZoneElement, setDropZoneElement ] = useState( null );
28
24
 
29
25
  const focusOnMountRef = useFocusOnMount( 'firstElement' );
30
- const headerFocusReturnRef = useFocusReturn();
31
- const contentFocusReturnRef = useFocusReturn();
32
26
 
33
- function closeOnEscape( event ) {
34
- if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
35
- event.preventDefault();
36
- setIsListViewOpened( false );
37
- }
38
- }
27
+ // When closing the list view, focus should return to the toggle button.
28
+ const closeListView = useCallback( () => {
29
+ setIsListViewOpened( false );
30
+ listViewToggleElement?.focus();
31
+ }, [ listViewToggleElement, setIsListViewOpened ] );
32
+
33
+ const closeOnEscape = useCallback(
34
+ ( event ) => {
35
+ if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
36
+ event.preventDefault();
37
+ closeListView();
38
+ }
39
+ },
40
+ [ closeListView ]
41
+ );
39
42
 
40
43
  return (
41
44
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
@@ -43,24 +46,17 @@ export default function ListViewSidebar() {
43
46
  className="edit-widgets-editor__list-view-panel"
44
47
  onKeyDown={ closeOnEscape }
45
48
  >
46
- <div
47
- className="edit-widgets-editor__list-view-panel-header"
48
- ref={ headerFocusReturnRef }
49
- >
49
+ <div className="edit-widgets-editor__list-view-panel-header">
50
50
  <strong>{ __( 'List View' ) }</strong>
51
51
  <Button
52
52
  icon={ closeSmall }
53
53
  label={ __( 'Close' ) }
54
- onClick={ () => setIsListViewOpened( false ) }
54
+ onClick={ closeListView }
55
55
  />
56
56
  </div>
57
57
  <div
58
58
  className="edit-widgets-editor__list-view-panel-content"
59
- ref={ useMergeRefs( [
60
- contentFocusReturnRef,
61
- focusOnMountRef,
62
- setDropZoneElement,
63
- ] ) }
59
+ ref={ useMergeRefs( [ focusOnMountRef, setDropZoneElement ] ) }
64
60
  >
65
61
  <ListView dropZoneElement={ dropZoneElement } />
66
62
  </div>
@@ -39,7 +39,10 @@ export default function WidgetAreasBlockEditorContent( {
39
39
  <Notices />
40
40
  <BlockTools>
41
41
  <KeyboardShortcuts />
42
- <EditorStyles styles={ styles } />
42
+ <EditorStyles
43
+ styles={ styles }
44
+ scope=".editor-styles-wrapper"
45
+ />
43
46
  <BlockSelectionClearer>
44
47
  <WritingFlow>
45
48
  <BlockList className="edit-widgets-main-block-list" />
@@ -11,8 +11,7 @@
11
11
  flex-grow: 1;
12
12
 
13
13
  > div:last-of-type,
14
- .block-editor-writing-flow,
15
- .block-editor-writing-flow > div {
14
+ .block-editor-writing-flow {
16
15
  display: flex;
17
16
  flex-direction: column;
18
17
  flex-grow: 1;
@@ -35,3 +34,101 @@
35
34
  }
36
35
  }
37
36
  }
37
+
38
+ // Fixed contextual toolbar
39
+ @include editor-left(".edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed");
40
+
41
+
42
+ .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
43
+ position: sticky;
44
+ top: 0;
45
+ z-index: z-index(".block-editor-block-popover");
46
+ display: block;
47
+ width: 100%;
48
+
49
+ // on desktop and tablet viewports the toolbar is fixed
50
+ // on top of interface header
51
+ $toolbar-margin: $grid-unit-80 * 3 - 2 * $grid-unit + $grid-unit-05;
52
+
53
+ @include break-medium() {
54
+ // leave room for block inserter, undo and redo, list view
55
+ margin-left: $toolbar-margin;
56
+ // position on top of interface header
57
+ position: fixed;
58
+ top: $admin-bar-height;
59
+ // Don't fill up when empty
60
+ min-height: initial;
61
+ // remove the border
62
+ border-bottom: none;
63
+ // has to be flex for collapse button to fit
64
+ display: flex;
65
+
66
+ // Mimic the height of the parent, vertically align center, and provide a max-height.
67
+ height: $header-height;
68
+ align-items: center;
69
+
70
+
71
+ // on tablet viewports the toolbar is fixed
72
+ // on top of interface header and covers the whole header
73
+ // except for the inserter on the left
74
+ width: calc(100% - #{$toolbar-margin});
75
+
76
+ &.is-collapsed {
77
+ width: initial;
78
+ }
79
+
80
+ &:empty {
81
+ width: initial;
82
+ }
83
+
84
+ .is-fullscreen-mode & {
85
+ // leave room for block inserter, undo and redo, list view
86
+ // and some margin left
87
+ margin-left: $grid-unit-80 * 4 - 2 * $grid-unit;
88
+
89
+ top: 0;
90
+
91
+ &.is-collapsed {
92
+ width: initial;
93
+ }
94
+
95
+ &:empty {
96
+ width: initial;
97
+ }
98
+ }
99
+
100
+ .show-icon-labels & {
101
+ margin-left: $grid-unit-80 + 2 * $grid-unit; // inserter and margin
102
+ width: calc(100% + 40px - #{$toolbar-margin}); //there are no undo, redo and list view buttons
103
+
104
+ .is-fullscreen-mode & {
105
+ margin-left: $grid-unit * 18; // site hub, inserter and margin
106
+ }
107
+ }
108
+
109
+ .blocks-widgets-container & {
110
+ margin-left: $grid-unit-80 * 2.4;
111
+
112
+ &.is-collapsed {
113
+ margin-left: $grid-unit-80 * 4.2;
114
+ }
115
+ }
116
+ }
117
+
118
+ // on desktop viewports the toolbar is fixed
119
+ // on top of interface header and leaves room
120
+ // for the block inserter the publish button
121
+ @include break-large() {
122
+ width: auto;
123
+ .show-icon-labels & {
124
+ width: auto; //there are no undo, redo and list view buttons
125
+ }
126
+
127
+ .is-fullscreen-mode & {
128
+ // in full screen mode we need to account for
129
+ // the combined with of the tools at the right of the header and the margin left
130
+ // of the toolbar which includes four buttons
131
+ width: calc(100% - 280px - #{4 * $grid-unit-80});
132
+ }
133
+ }
134
+ }
@@ -15,7 +15,6 @@ import {
15
15
  privateApis as blockEditorPrivateApis,
16
16
  } from '@wordpress/block-editor';
17
17
  import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
18
- import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
19
18
  import { store as preferencesStore } from '@wordpress/preferences';
20
19
 
21
20
  /**
@@ -98,21 +97,19 @@ export default function WidgetAreasBlockEditorProvider( {
98
97
  );
99
98
 
100
99
  return (
101
- <ShortcutProvider>
100
+ <SlotFillProvider>
102
101
  <KeyboardShortcuts.Register />
103
- <SlotFillProvider>
104
- <ExperimentalBlockEditorProvider
105
- value={ blocks }
106
- onInput={ onInput }
107
- onChange={ onChange }
108
- settings={ settings }
109
- useSubRegistry={ false }
110
- { ...props }
111
- >
112
- <CopyHandler>{ children }</CopyHandler>
113
- <PatternsMenuItems rootClientId={ widgetAreaId } />
114
- </ExperimentalBlockEditorProvider>
115
- </SlotFillProvider>
116
- </ShortcutProvider>
102
+ <ExperimentalBlockEditorProvider
103
+ value={ blocks }
104
+ onInput={ onInput }
105
+ onChange={ onChange }
106
+ settings={ settings }
107
+ useSubRegistry={ false }
108
+ { ...props }
109
+ >
110
+ <CopyHandler>{ children }</CopyHandler>
111
+ <PatternsMenuItems rootClientId={ widgetAreaId } />
112
+ </ExperimentalBlockEditorProvider>
113
+ </SlotFillProvider>
117
114
  );
118
115
  }