@wordpress/edit-widgets 5.21.1-next.f8d8eceb.0 → 5.23.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.
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","VisuallyHidden","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","PinnedItems","listView","plus","useCallback","useRef","useViewportMatch","SaveButton","UndoButton","RedoButton","MoreMenu","useLastSelectedWidgetArea","editWidgetsStore","unlock","useShouldContextualToolbarShow","Header","setListViewToggleElement","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","createElement","Fragment","className","as","shouldUseKeyboardFocusShortcut","ref","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","label","Slot","scope"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header( { setListViewToggleElement } ) {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\n\tconst { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {\n\t\tconst { isInserterOpened, isListViewOpened } =\n\t\t\tselect( editWidgetsStore );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t\tref={ setListViewToggleElement }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,W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eAAeK,MAAM"}
1
+ {"version":3,"names":["privateApis","blockEditorPrivateApis","useSelect","useRef","__","Popover","VisuallyHidden","PinnedItems","useViewportMatch","store","preferencesStore","DocumentTools","SaveButton","MoreMenu","unlock","BlockContextualToolbar","Header","setListViewToggleElement","isLargeViewport","blockToolbarRef","hasFixedToolbar","select","get","createElement","Fragment","className","as","isFixed","Slot","ref","name","scope"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Popover, VisuallyHidden } from '@wordpress/components';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport DocumentTools from './document-tools';\nimport SaveButton from '../save-button';\nimport MoreMenu from '../more-menu';\nimport { unlock } from '../../lock-unlock';\n\nconst { BlockContextualToolbar } = unlock( blockEditorPrivateApis );\n\nfunction Header( { setListViewToggleElement } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst blockToolbarRef = useRef();\n\tconst { hasFixedToolbar } = useSelect(\n\t\t( select ) => ( {\n\t\t\thasFixedToolbar: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isLargeViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<DocumentTools\n\t\t\t\t\t\tsetListViewToggleElement={ setListViewToggleElement }\n\t\t\t\t\t/>\n\t\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<div className=\"selected-block-tools-wrapper\">\n\t\t\t\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,cAAc,QAAQ,uBAAuB;AAC/D,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,UAAU,MAAM,gBAAgB;AACvC,O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,aAAA,CAAChB,WAAW,CAACqB,IAAI;IAACG,KAAK,EAAC;EAAmB,CAAE,CAAC,EAC9CR,aAAA,CAACV,QAAQ,MAAE,CACP,CACD,CACJ,CAAC;AAEL;AAEA,eAAeG,MAAM"}
@@ -645,11 +645,19 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
645
645
  overflow: visible;
646
646
  }
647
647
  }
648
+ .edit-widgets-header .selected-block-tools-wrapper {
649
+ overflow-x: hidden;
650
+ }
651
+ .edit-widgets-header .block-editor-block-contextual-toolbar.is-fixed {
652
+ border: none;
653
+ }
648
654
 
649
655
  .edit-widgets-header__navigable-toolbar-wrapper {
650
656
  display: flex;
651
657
  align-items: center;
652
658
  justify-content: center;
659
+ flex-shrink: 2;
660
+ overflow-x: hidden;
653
661
  padding-right: 16px;
654
662
  }
655
663
 
@@ -946,12 +954,6 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
946
954
  }
947
955
  }
948
956
 
949
- @media (min-width: 782px) {
950
- .blocks-widgets-container .interface-interface-skeleton__header:not(:focus-within) {
951
- z-index: 19;
952
- }
953
- }
954
-
955
957
  .edit-widgets-welcome-guide {
956
958
  width: 312px;
957
959
  }
@@ -1007,105 +1009,6 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
1007
1009
  padding: 6px;
1008
1010
  }
1009
1011
 
1010
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1011
- /* Set left position when auto-fold is not on the body element. */
1012
- right: 0;
1013
- }
1014
- @media (min-width: 783px) {
1015
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1016
- right: 160px;
1017
- }
1018
- }
1019
-
1020
- .auto-fold .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1021
- /* Auto fold is when on smaller breakpoints, nav menu auto collapses. */
1022
- }
1023
- @media (min-width: 783px) {
1024
- .auto-fold .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1025
- right: 36px;
1026
- }
1027
- }
1028
- @media (min-width: 961px) {
1029
- .auto-fold .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1030
- right: 160px;
1031
- }
1032
- }
1033
-
1034
- /* Sidebar manually collapsed. */
1035
- .folded .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1036
- right: 0;
1037
- }
1038
- @media (min-width: 783px) {
1039
- .folded .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1040
- right: 36px;
1041
- }
1042
- }
1043
-
1044
- body.is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1045
- right: 0 !important;
1046
- }
1047
-
1048
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1049
- position: sticky;
1050
- top: 0;
1051
- z-index: 31;
1052
- display: block;
1053
- width: 100%;
1054
- }
1055
- @media (min-width: 782px) {
1056
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1057
- margin-right: 180px;
1058
- position: fixed;
1059
- top: 32px;
1060
- min-height: initial;
1061
- border-bottom: none;
1062
- display: flex;
1063
- height: 60px;
1064
- align-items: center;
1065
- width: calc(100% - 180px);
1066
- }
1067
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed.is-collapsed {
1068
- width: initial;
1069
- }
1070
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed:empty {
1071
- width: initial;
1072
- }
1073
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1074
- margin-right: 240px;
1075
- top: 0;
1076
- }
1077
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed.is-collapsed {
1078
- width: initial;
1079
- }
1080
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed:empty {
1081
- width: initial;
1082
- }
1083
- .show-icon-labels .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1084
- margin-right: 80px;
1085
- width: calc(100% + 40px - 180px);
1086
- }
1087
- .is-fullscreen-mode .show-icon-labels .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1088
- margin-right: 144px;
1089
- }
1090
- .blocks-widgets-container .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1091
- margin-right: 153.6px;
1092
- }
1093
- .blocks-widgets-container .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed.is-collapsed {
1094
- margin-right: 268.8px;
1095
- }
1096
- }
1097
- @media (min-width: 960px) {
1098
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1099
- width: auto;
1100
- }
1101
- .show-icon-labels .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1102
- width: auto;
1103
- }
1104
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1105
- width: calc(100% - 280px - 256px);
1106
- }
1107
- }
1108
-
1109
1012
  .edit-widgets-editor__list-view-panel {
1110
1013
  height: 100%;
1111
1014
  display: flex;
@@ -645,11 +645,19 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
645
645
  overflow: visible;
646
646
  }
647
647
  }
648
+ .edit-widgets-header .selected-block-tools-wrapper {
649
+ overflow-x: hidden;
650
+ }
651
+ .edit-widgets-header .block-editor-block-contextual-toolbar.is-fixed {
652
+ border: none;
653
+ }
648
654
 
649
655
  .edit-widgets-header__navigable-toolbar-wrapper {
650
656
  display: flex;
651
657
  align-items: center;
652
658
  justify-content: center;
659
+ flex-shrink: 2;
660
+ overflow-x: hidden;
653
661
  padding-left: 16px;
654
662
  }
655
663
 
@@ -946,12 +954,6 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
946
954
  }
947
955
  }
948
956
 
949
- @media (min-width: 782px) {
950
- .blocks-widgets-container .interface-interface-skeleton__header:not(:focus-within) {
951
- z-index: 19;
952
- }
953
- }
954
-
955
957
  .edit-widgets-welcome-guide {
956
958
  width: 312px;
957
959
  }
@@ -1007,105 +1009,6 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
1007
1009
  padding: 6px;
1008
1010
  }
1009
1011
 
1010
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1011
- /* Set left position when auto-fold is not on the body element. */
1012
- left: 0;
1013
- }
1014
- @media (min-width: 783px) {
1015
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1016
- left: 160px;
1017
- }
1018
- }
1019
-
1020
- .auto-fold .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1021
- /* Auto fold is when on smaller breakpoints, nav menu auto collapses. */
1022
- }
1023
- @media (min-width: 783px) {
1024
- .auto-fold .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1025
- left: 36px;
1026
- }
1027
- }
1028
- @media (min-width: 961px) {
1029
- .auto-fold .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1030
- left: 160px;
1031
- }
1032
- }
1033
-
1034
- /* Sidebar manually collapsed. */
1035
- .folded .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1036
- left: 0;
1037
- }
1038
- @media (min-width: 783px) {
1039
- .folded .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1040
- left: 36px;
1041
- }
1042
- }
1043
-
1044
- body.is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1045
- left: 0 !important;
1046
- }
1047
-
1048
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1049
- position: sticky;
1050
- top: 0;
1051
- z-index: 31;
1052
- display: block;
1053
- width: 100%;
1054
- }
1055
- @media (min-width: 782px) {
1056
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1057
- margin-left: 180px;
1058
- position: fixed;
1059
- top: 32px;
1060
- min-height: initial;
1061
- border-bottom: none;
1062
- display: flex;
1063
- height: 60px;
1064
- align-items: center;
1065
- width: calc(100% - 180px);
1066
- }
1067
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed.is-collapsed {
1068
- width: initial;
1069
- }
1070
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed:empty {
1071
- width: initial;
1072
- }
1073
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1074
- margin-left: 240px;
1075
- top: 0;
1076
- }
1077
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed.is-collapsed {
1078
- width: initial;
1079
- }
1080
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed:empty {
1081
- width: initial;
1082
- }
1083
- .show-icon-labels .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1084
- margin-left: 80px;
1085
- width: calc(100% + 40px - 180px);
1086
- }
1087
- .is-fullscreen-mode .show-icon-labels .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1088
- margin-left: 144px;
1089
- }
1090
- .blocks-widgets-container .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1091
- margin-left: 153.6px;
1092
- }
1093
- .blocks-widgets-container .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed.is-collapsed {
1094
- margin-left: 268.8px;
1095
- }
1096
- }
1097
- @media (min-width: 960px) {
1098
- .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1099
- width: auto;
1100
- }
1101
- .show-icon-labels .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1102
- width: auto;
1103
- }
1104
- .is-fullscreen-mode .edit-widgets-block-editor .block-editor-block-contextual-toolbar.is-fixed {
1105
- width: calc(100% - 280px - 256px);
1106
- }
1107
- }
1108
-
1109
1012
  .edit-widgets-editor__list-view-panel {
1110
1013
  height: 100%;
1111
1014
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-widgets",
3
- "version": "5.21.1-next.f8d8eceb.0",
3
+ "version": "5.23.0",
4
4
  "description": "Widgets Page module for WordPress..",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,32 +27,32 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/api-fetch": "^6.41.1-next.f8d8eceb.0",
31
- "@wordpress/block-editor": "^12.12.2-next.f8d8eceb.0",
32
- "@wordpress/block-library": "^8.21.1-next.f8d8eceb.0",
33
- "@wordpress/blocks": "^12.21.1-next.f8d8eceb.0",
34
- "@wordpress/components": "^25.11.1-next.f8d8eceb.0",
35
- "@wordpress/compose": "^6.21.1-next.f8d8eceb.0",
36
- "@wordpress/core-data": "^6.21.1-next.f8d8eceb.0",
37
- "@wordpress/data": "^9.14.1-next.f8d8eceb.0",
38
- "@wordpress/deprecated": "^3.44.1-next.f8d8eceb.0",
39
- "@wordpress/dom": "^3.44.1-next.f8d8eceb.0",
40
- "@wordpress/element": "^5.21.1-next.f8d8eceb.0",
41
- "@wordpress/hooks": "^3.44.1-next.f8d8eceb.0",
42
- "@wordpress/i18n": "^4.44.1-next.f8d8eceb.0",
43
- "@wordpress/icons": "^9.35.1-next.f8d8eceb.0",
44
- "@wordpress/interface": "^5.21.1-next.f8d8eceb.0",
45
- "@wordpress/keyboard-shortcuts": "^4.21.1-next.f8d8eceb.0",
46
- "@wordpress/keycodes": "^3.44.1-next.f8d8eceb.0",
47
- "@wordpress/media-utils": "^4.35.1-next.f8d8eceb.0",
48
- "@wordpress/notices": "^4.12.1-next.f8d8eceb.0",
49
- "@wordpress/patterns": "^1.5.1-next.f8d8eceb.0",
50
- "@wordpress/plugins": "^6.12.1-next.f8d8eceb.0",
51
- "@wordpress/preferences": "^3.21.1-next.f8d8eceb.0",
52
- "@wordpress/private-apis": "^0.26.1-next.f8d8eceb.0",
53
- "@wordpress/reusable-blocks": "^4.21.1-next.f8d8eceb.0",
54
- "@wordpress/url": "^3.45.1-next.f8d8eceb.0",
55
- "@wordpress/widgets": "^3.21.1-next.f8d8eceb.0",
30
+ "@wordpress/api-fetch": "^6.43.0",
31
+ "@wordpress/block-editor": "^12.14.0",
32
+ "@wordpress/block-library": "^8.23.0",
33
+ "@wordpress/blocks": "^12.23.0",
34
+ "@wordpress/components": "^25.12.0",
35
+ "@wordpress/compose": "^6.23.0",
36
+ "@wordpress/core-data": "^6.23.0",
37
+ "@wordpress/data": "^9.16.0",
38
+ "@wordpress/deprecated": "^3.46.0",
39
+ "@wordpress/dom": "^3.46.0",
40
+ "@wordpress/element": "^5.23.0",
41
+ "@wordpress/hooks": "^3.46.0",
42
+ "@wordpress/i18n": "^4.46.0",
43
+ "@wordpress/icons": "^9.37.0",
44
+ "@wordpress/interface": "^5.23.0",
45
+ "@wordpress/keyboard-shortcuts": "^4.23.0",
46
+ "@wordpress/keycodes": "^3.46.0",
47
+ "@wordpress/media-utils": "^4.37.0",
48
+ "@wordpress/notices": "^4.14.0",
49
+ "@wordpress/patterns": "^1.7.0",
50
+ "@wordpress/plugins": "^6.14.0",
51
+ "@wordpress/preferences": "^3.23.0",
52
+ "@wordpress/private-apis": "^0.28.0",
53
+ "@wordpress/reusable-blocks": "^4.23.0",
54
+ "@wordpress/url": "^3.47.0",
55
+ "@wordpress/widgets": "^3.23.0",
56
56
  "classnames": "^2.3.1"
57
57
  },
58
58
  "peerDependencies": {
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "8d8fd197e202b8104ffb1cb83048efd0a6c3faf4"
65
+ "gitHead": "839018ff6029ba749780e288e08ff9cd898e50e8"
66
66
  }
@@ -0,0 +1,130 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+ import { __, _x } from '@wordpress/i18n';
6
+ import { Button, ToolbarItem } from '@wordpress/components';
7
+ import {
8
+ NavigableToolbar,
9
+ store as blockEditorStore,
10
+ privateApis as blockEditorPrivateApis,
11
+ } from '@wordpress/block-editor';
12
+ import { listView, plus } from '@wordpress/icons';
13
+ import { useCallback, useRef } from '@wordpress/element';
14
+ import { useViewportMatch } from '@wordpress/compose';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import UndoButton from '../undo-redo/undo';
20
+ import RedoButton from '../undo-redo/redo';
21
+ import useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area';
22
+ import { store as editWidgetsStore } from '../../../store';
23
+ import { unlock } from '../../../lock-unlock';
24
+
25
+ const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
26
+
27
+ function DocumentTools( { setListViewToggleElement } ) {
28
+ const isMediumViewport = useViewportMatch( 'medium' );
29
+ const inserterButton = useRef();
30
+ const widgetAreaClientId = useLastSelectedWidgetArea();
31
+ const isLastSelectedWidgetAreaOpen = useSelect(
32
+ ( select ) =>
33
+ select( editWidgetsStore ).getIsWidgetAreaOpen(
34
+ widgetAreaClientId
35
+ ),
36
+ [ widgetAreaClientId ]
37
+ );
38
+ const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
39
+ const { isInserterOpened, isListViewOpened } =
40
+ select( editWidgetsStore );
41
+ return {
42
+ isInserterOpen: isInserterOpened(),
43
+ isListViewOpen: isListViewOpened(),
44
+ };
45
+ }, [] );
46
+ const { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =
47
+ useDispatch( editWidgetsStore );
48
+ const { selectBlock } = useDispatch( blockEditorStore );
49
+ const handleClick = () => {
50
+ if ( isInserterOpen ) {
51
+ // Focusing the inserter button closes the inserter popover.
52
+ setIsInserterOpened( false );
53
+ } else {
54
+ if ( ! isLastSelectedWidgetAreaOpen ) {
55
+ // Select the last selected block if hasn't already.
56
+ selectBlock( widgetAreaClientId );
57
+ // Open the last selected widget area when opening the inserter.
58
+ setIsWidgetAreaOpen( widgetAreaClientId, true );
59
+ }
60
+ // The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the
61
+ // same tick and pretty much in a random order. The inserter is closed if any other part of the
62
+ // app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then
63
+ // the inserter is visible for a brief moment and then gets auto-closed due to focus moving to
64
+ // the selected block.
65
+ window.requestAnimationFrame( () => setIsInserterOpened( true ) );
66
+ }
67
+ };
68
+
69
+ const toggleListView = useCallback(
70
+ () => setIsListViewOpened( ! isListViewOpen ),
71
+ [ setIsListViewOpened, isListViewOpen ]
72
+ );
73
+
74
+ const {
75
+ shouldShowContextualToolbar,
76
+ canFocusHiddenToolbar,
77
+ fixedToolbarCanBeFocused,
78
+ } = useShouldContextualToolbarShow();
79
+ // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
80
+ // There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
81
+ const blockToolbarCanBeFocused =
82
+ shouldShowContextualToolbar ||
83
+ canFocusHiddenToolbar ||
84
+ fixedToolbarCanBeFocused;
85
+
86
+ return (
87
+ <NavigableToolbar
88
+ className="edit-widgets-header-toolbar"
89
+ aria-label={ __( 'Document tools' ) }
90
+ shouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }
91
+ >
92
+ <ToolbarItem
93
+ ref={ inserterButton }
94
+ as={ Button }
95
+ className="edit-widgets-header-toolbar__inserter-toggle"
96
+ variant="primary"
97
+ isPressed={ isInserterOpen }
98
+ onMouseDown={ ( event ) => {
99
+ event.preventDefault();
100
+ } }
101
+ onClick={ handleClick }
102
+ icon={ plus }
103
+ /* translators: button label text should, if possible, be under 16
104
+ characters. */
105
+ label={ _x(
106
+ 'Toggle block inserter',
107
+ 'Generic label for block inserter button'
108
+ ) }
109
+ />
110
+ { isMediumViewport && (
111
+ <>
112
+ <UndoButton />
113
+ <RedoButton />
114
+ <ToolbarItem
115
+ as={ Button }
116
+ className="edit-widgets-header-toolbar__list-view-toggle"
117
+ icon={ listView }
118
+ isPressed={ isListViewOpen }
119
+ /* translators: button label text should, if possible, be under 16 characters. */
120
+ label={ __( 'List View' ) }
121
+ onClick={ toggleListView }
122
+ ref={ setListViewToggleElement }
123
+ />
124
+ </>
125
+ ) }
126
+ </NavigableToolbar>
127
+ );
128
+ }
129
+
130
+ export default DocumentTools;