@wordpress/edit-widgets 5.25.1-next.79a6196f.0 → 5.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/header/document-tools/index.js +2 -7
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +3 -8
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +3 -8
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +2 -7
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +3 -7
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +3 -7
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-style/style-rtl.css +2 -1
- package/build-style/style.css +2 -1
- package/package.json +28 -28
- package/src/components/header/document-tools/index.js +2 -3
- package/src/components/header/style.scss +2 -1
- package/src/components/header/undo-redo/redo.js +3 -8
- package/src/components/header/undo-redo/undo.js +3 -8
package/CHANGELOG.md
CHANGED
|
@@ -84,8 +84,7 @@ function DocumentTools() {
|
|
|
84
84
|
return (0, _react.createElement)(_blockEditor.NavigableToolbar, {
|
|
85
85
|
className: "edit-widgets-header-toolbar",
|
|
86
86
|
"aria-label": (0, _i18n.__)('Document tools'),
|
|
87
|
-
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
|
|
88
|
-
variant: "unstyled"
|
|
87
|
+
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
|
|
89
88
|
}, (0, _react.createElement)(_components.ToolbarItem, {
|
|
90
89
|
ref: inserterButton,
|
|
91
90
|
as: _components.Button,
|
|
@@ -100,11 +99,7 @@ function DocumentTools() {
|
|
|
100
99
|
/* translators: button label text should, if possible, be under 16
|
|
101
100
|
characters. */,
|
|
102
101
|
label: (0, _i18n._x)('Toggle block inserter', 'Generic label for block inserter button')
|
|
103
|
-
}), isMediumViewport && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.ToolbarItem, {
|
|
104
|
-
as: _undo.default
|
|
105
|
-
}), (0, _react.createElement)(_components.ToolbarItem, {
|
|
106
|
-
as: _redo.default
|
|
107
|
-
}), (0, _react.createElement)(_components.ToolbarItem, {
|
|
102
|
+
}), isMediumViewport && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_undo.default, null), (0, _react.createElement)(_redo.default, null), (0, _react.createElement)(_components.ToolbarItem, {
|
|
108
103
|
as: _components.Button,
|
|
109
104
|
className: "edit-widgets-header-toolbar__list-view-toggle",
|
|
110
105
|
icon: _icons.listView,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_i18n","_components","_blockEditor","_icons","_element","_compose","_undo","_interopRequireDefault","_redo","_useLastSelectedWidgetArea","_store","_lockUnlock","useCanBlockToolbarBeFocused","unlock","blockEditorPrivateApis","DocumentTools","isMediumViewport","useViewportMatch","inserterButton","useRef","widgetAreaClientId","useLastSelectedWidgetArea","isLastSelectedWidgetAreaOpen","useSelect","select","editWidgetsStore","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","listViewToggleRef","isInserterOpened","isListViewOpened","getListViewToggleRef","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","useDispatch","selectBlock","blockEditorStore","handleClick","window","requestAnimationFrame","toggleListView","useCallback","blockToolbarCanBeFocused","_react","createElement","NavigableToolbar","className","__","shouldUseKeyboardFocusShortcut","
|
|
1
|
+
{"version":3,"names":["_data","require","_i18n","_components","_blockEditor","_icons","_element","_compose","_undo","_interopRequireDefault","_redo","_useLastSelectedWidgetArea","_store","_lockUnlock","useCanBlockToolbarBeFocused","unlock","blockEditorPrivateApis","DocumentTools","isMediumViewport","useViewportMatch","inserterButton","useRef","widgetAreaClientId","useLastSelectedWidgetArea","isLastSelectedWidgetAreaOpen","useSelect","select","editWidgetsStore","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","listViewToggleRef","isInserterOpened","isListViewOpened","getListViewToggleRef","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","useDispatch","selectBlock","blockEditorStore","handleClick","window","requestAnimationFrame","toggleListView","useCallback","blockToolbarCanBeFocused","_react","createElement","NavigableToolbar","className","__","shouldUseKeyboardFocusShortcut","ToolbarItem","ref","as","Button","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","plus","label","_x","Fragment","default","listView","_default","exports"],"sources":["@wordpress/edit-widgets/src/components/header/document-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis );\n\nfunction DocumentTools() {\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, listViewToggleRef } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isInserterOpened, isListViewOpened, getListViewToggleRef } =\n\t\t\t\tunlock( select( editWidgetsStore ) );\n\t\t\treturn {\n\t\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\t};\n\t\t},\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\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\tconst blockToolbarCanBeFocused = useCanBlockToolbarBeFocused();\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterButton }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ handleClick }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<UndoButton />\n\t\t\t\t\t<RedoButton />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,KAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,KAAA,GAAAD,sBAAA,CAAAR,OAAA;AACA,IAAAU,0BAAA,GAAAF,sB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tC,KAAA,CAAA0D,OAAU,MAAE,CAAC,EACd,IAAArB,MAAA,CAAAC,aAAA,EAAC7C,WAAA,CAAAkD,WAAW;IACXE,EAAE,EAAGC,kBAAQ;IACbN,SAAS,EAAC,+CAA+C;IACzDa,IAAI,EAAGM,eAAU;IACjBX,SAAS,EAAG5B;IACZ;IACAmC,KAAK,EAAG,IAAAd,QAAE,EAAE,WAAY,CAAG;IAC3BW,OAAO,EAAGlB,cAAgB;IAC1BU,GAAG,EAAGvB;EAAmB,CACzB,CACA,CAEc,CAAC;AAErB;AAAC,IAAAuC,QAAA,GAEcrD,aAAa;AAAAsD,OAAA,CAAAH,OAAA,GAAAE,QAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = RedoButton;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
9
|
var _components = require("@wordpress/components");
|
|
@@ -11,20 +11,17 @@ var _data = require("@wordpress/data");
|
|
|
11
11
|
var _icons = require("@wordpress/icons");
|
|
12
12
|
var _keycodes = require("@wordpress/keycodes");
|
|
13
13
|
var _coreData = require("@wordpress/core-data");
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
14
|
/**
|
|
16
15
|
* WordPress dependencies
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
|
-
function RedoButton(
|
|
18
|
+
function RedoButton() {
|
|
20
19
|
const shortcut = (0, _keycodes.isAppleOS)() ? _keycodes.displayShortcut.primaryShift('z') : _keycodes.displayShortcut.primary('y');
|
|
21
20
|
const hasRedo = (0, _data.useSelect)(select => select(_coreData.store).hasRedo(), []);
|
|
22
21
|
const {
|
|
23
22
|
redo
|
|
24
23
|
} = (0, _data.useDispatch)(_coreData.store);
|
|
25
|
-
return (0, _react.createElement)(_components.
|
|
26
|
-
...props,
|
|
27
|
-
ref: ref,
|
|
24
|
+
return (0, _react.createElement)(_components.ToolbarButton, {
|
|
28
25
|
icon: !(0, _i18n.isRTL)() ? _icons.redo : _icons.undo,
|
|
29
26
|
label: (0, _i18n.__)('Redo'),
|
|
30
27
|
shortcut: shortcut
|
|
@@ -36,6 +33,4 @@ function RedoButton(props, ref) {
|
|
|
36
33
|
onClick: hasRedo ? redo : undefined
|
|
37
34
|
});
|
|
38
35
|
}
|
|
39
|
-
var _default = (0, _element.forwardRef)(RedoButton);
|
|
40
|
-
exports.default = _default;
|
|
41
36
|
//# sourceMappingURL=redo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_data","_icons","_keycodes","_coreData","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_icons","_keycodes","_coreData","RedoButton","shortcut","isAppleOS","displayShortcut","primaryShift","primary","hasRedo","useSelect","select","coreStore","redo","useDispatch","_react","createElement","ToolbarButton","icon","isRTL","redoIcon","undoIcon","label","__","onClick","undefined"],"sources":["@wordpress/edit-widgets/src/components/header/undo-redo/redo.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\n\nexport default function RedoButton() {\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tconst hasRedo = useSelect(\n\t\t( select ) => select( coreStore ).hasRedo(),\n\t\t[]\n\t);\n\tconst { redo } = useDispatch( coreStore );\n\treturn (\n\t\t<ToolbarButton\n\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\tlabel={ __( 'Redo' ) }\n\t\t\tshortcut={ shortcut }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasRedo }\n\t\t\tonClick={ hasRedo ? redo : undefined }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQe,SAASM,UAAUA,CAAA,EAAG;EACpC,MAAMC,QAAQ,GAAG,IAAAC,mBAAS,EAAC,CAAC,GACzBC,yBAAe,CAACC,YAAY,CAAE,GAAI,CAAC,GACnCD,yBAAe,CAACE,OAAO,CAAE,GAAI,CAAC;EAEjC,MAAMC,OAAO,GAAG,IAAAC,eAAS,EACtBC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACH,OAAO,CAAC,CAAC,EAC3C,EACD,CAAC;EACD,MAAM;IAAEI;EAAK,CAAC,GAAG,IAAAC,iBAAW,EAAEF,eAAU,CAAC;EACzC,OACC,IAAAG,MAAA,CAAAC,aAAA,EAAClB,WAAA,CAAAmB,aAAa;IACbC,IAAI,EAAG,CAAE,IAAAC,WAAK,EAAC,CAAC,GAAGC,WAAQ,GAAGC,WAAU;IACxCC,KAAK,EAAG,IAAAC,QAAE,EAAE,MAAO,CAAG;IACtBnB,QAAQ,EAAGA;IACX;IACA;IACA;IAAA;IACA,iBAAgB,CAAEK,OAAS;IAC3Be,OAAO,EAAGf,OAAO,GAAGI,IAAI,GAAGY;EAAW,CACtC,CAAC;AAEJ"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = UndoButton;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
9
|
var _components = require("@wordpress/components");
|
|
@@ -11,19 +11,16 @@ var _data = require("@wordpress/data");
|
|
|
11
11
|
var _icons = require("@wordpress/icons");
|
|
12
12
|
var _keycodes = require("@wordpress/keycodes");
|
|
13
13
|
var _coreData = require("@wordpress/core-data");
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
14
|
/**
|
|
16
15
|
* WordPress dependencies
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
|
-
function UndoButton(
|
|
18
|
+
function UndoButton() {
|
|
20
19
|
const hasUndo = (0, _data.useSelect)(select => select(_coreData.store).hasUndo(), []);
|
|
21
20
|
const {
|
|
22
21
|
undo
|
|
23
22
|
} = (0, _data.useDispatch)(_coreData.store);
|
|
24
|
-
return (0, _react.createElement)(_components.
|
|
25
|
-
...props,
|
|
26
|
-
ref: ref,
|
|
23
|
+
return (0, _react.createElement)(_components.ToolbarButton, {
|
|
27
24
|
icon: !(0, _i18n.isRTL)() ? _icons.undo : _icons.redo,
|
|
28
25
|
label: (0, _i18n.__)('Undo'),
|
|
29
26
|
shortcut: _keycodes.displayShortcut.primary('z')
|
|
@@ -35,6 +32,4 @@ function UndoButton(props, ref) {
|
|
|
35
32
|
onClick: hasUndo ? undo : undefined
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
|
-
var _default = (0, _element.forwardRef)(UndoButton);
|
|
39
|
-
exports.default = _default;
|
|
40
35
|
//# sourceMappingURL=undo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_data","_icons","_keycodes","_coreData","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_icons","_keycodes","_coreData","UndoButton","hasUndo","useSelect","select","coreStore","undo","useDispatch","_react","createElement","ToolbarButton","icon","isRTL","undoIcon","redoIcon","label","__","shortcut","displayShortcut","primary","onClick","undefined"],"sources":["@wordpress/edit-widgets/src/components/header/undo-redo/undo.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\n\nexport default function UndoButton() {\n\tconst hasUndo = useSelect(\n\t\t( select ) => select( coreStore ).hasUndo(),\n\t\t[]\n\t);\n\tconst { undo } = useDispatch( coreStore );\n\treturn (\n\t\t<ToolbarButton\n\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\tlabel={ __( 'Undo' ) }\n\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasUndo }\n\t\t\tonClick={ hasUndo ? undo : undefined }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQe,SAASM,UAAUA,CAAA,EAAG;EACpC,MAAMC,OAAO,GAAG,IAAAC,eAAS,EACtBC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACH,OAAO,CAAC,CAAC,EAC3C,EACD,CAAC;EACD,MAAM;IAAEI;EAAK,CAAC,GAAG,IAAAC,iBAAW,EAAEF,eAAU,CAAC;EACzC,OACC,IAAAG,MAAA,CAAAC,aAAA,EAACb,WAAA,CAAAc,aAAa;IACbC,IAAI,EAAG,CAAE,IAAAC,WAAK,EAAC,CAAC,GAAGC,WAAQ,GAAGC,WAAU;IACxCC,KAAK,EAAG,IAAAC,QAAE,EAAE,MAAO,CAAG;IACtBC,QAAQ,EAAGC,yBAAe,CAACC,OAAO,CAAE,GAAI;IACxC;IACA;IACA;IAAA;IACA,iBAAgB,CAAEjB,OAAS;IAC3BkB,OAAO,EAAGlB,OAAO,GAAGI,IAAI,GAAGe;EAAW,CACtC,CAAC;AAEJ"}
|
|
@@ -76,8 +76,7 @@ function DocumentTools() {
|
|
|
76
76
|
return createElement(NavigableToolbar, {
|
|
77
77
|
className: "edit-widgets-header-toolbar",
|
|
78
78
|
"aria-label": __('Document tools'),
|
|
79
|
-
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
|
|
80
|
-
variant: "unstyled"
|
|
79
|
+
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
|
|
81
80
|
}, createElement(ToolbarItem, {
|
|
82
81
|
ref: inserterButton,
|
|
83
82
|
as: Button,
|
|
@@ -92,11 +91,7 @@ function DocumentTools() {
|
|
|
92
91
|
/* translators: button label text should, if possible, be under 16
|
|
93
92
|
characters. */,
|
|
94
93
|
label: _x('Toggle block inserter', 'Generic label for block inserter button')
|
|
95
|
-
}), isMediumViewport && createElement(Fragment, null, createElement(ToolbarItem, {
|
|
96
|
-
as: UndoButton
|
|
97
|
-
}), createElement(ToolbarItem, {
|
|
98
|
-
as: RedoButton
|
|
99
|
-
}), createElement(ToolbarItem, {
|
|
94
|
+
}), isMediumViewport && createElement(Fragment, null, createElement(UndoButton, null), createElement(RedoButton, null), createElement(ToolbarItem, {
|
|
100
95
|
as: Button,
|
|
101
96
|
className: "edit-widgets-header-toolbar__list-view-toggle",
|
|
102
97
|
icon: listView,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","listView","plus","useCallback","useRef","useViewportMatch","UndoButton","RedoButton","useLastSelectedWidgetArea","editWidgetsStore","unlock","useCanBlockToolbarBeFocused","DocumentTools","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","listViewToggleRef","isInserterOpened","isListViewOpened","getListViewToggleRef","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","blockToolbarCanBeFocused","createElement","className","shouldUseKeyboardFocusShortcut","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","listView","plus","useCallback","useRef","useViewportMatch","UndoButton","RedoButton","useLastSelectedWidgetArea","editWidgetsStore","unlock","useCanBlockToolbarBeFocused","DocumentTools","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","listViewToggleRef","isInserterOpened","isListViewOpened","getListViewToggleRef","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","blockToolbarCanBeFocused","createElement","className","shouldUseKeyboardFocusShortcut","ref","as","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","label","Fragment"],"sources":["@wordpress/edit-widgets/src/components/header/document-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport useLastSelectedWidgetArea from '../../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis );\n\nfunction DocumentTools() {\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, listViewToggleRef } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isInserterOpened, isListViewOpened, getListViewToggleRef } =\n\t\t\t\tunlock( select( editWidgetsStore ) );\n\t\t\treturn {\n\t\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\t};\n\t\t},\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\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\tconst blockToolbarCanBeFocused = useCanBlockToolbarBeFocused();\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterButton }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ handleClick }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<UndoButton />\n\t\t\t\t\t<RedoButton />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleList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EAAC,8CAA8C;IACxDI,OAAO,EAAC,SAAS;IACjBC,SAAS,EAAGrB,cAAgB;IAC5BsB,WAAW,EAAKC,KAAK,IAAM;MAC1BA,KAAK,CAACC,cAAc,CAAC,CAAC;IACvB,CAAG;IACHC,OAAO,EAAGf,WAAa;IACvBgB,IAAI,EAAG3C;IACP;AACJ,mBADI;IAEA4C,KAAK,EAAGrD,EAAE,CACT,uBAAuB,EACvB,yCACD;EAAG,CACH,CAAC,EACAoB,gBAAgB,IACjBqB,aAAA,CAAAa,QAAA,QACCb,aAAA,CAAC5B,UAAU,MAAE,CAAC,EACd4B,aAAA,CAAC3B,UAAU,MAAE,CAAC,EACd2B,aAAA,CAACvC,WAAW;IACX2C,EAAE,EAAG5C,MAAQ;IACbyC,SAAS,EAAC,+CAA+C;IACzDU,IAAI,EAAG5C,QAAU;IACjBuC,SAAS,EAAGpB;IACZ;IACA0B,KAAK,EAAGtD,EAAE,CAAE,WAAY,CAAG;IAC3BoD,OAAO,EAAGZ,cAAgB;IAC1BK,GAAG,EAAGhB;EAAmB,CACzB,CACA,CAEc,CAAC;AAErB;AAEA,eAAeT,aAAa"}
|
|
@@ -3,21 +3,18 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
6
|
+
import { ToolbarButton } from '@wordpress/components';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
8
|
import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';
|
|
9
9
|
import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
-
|
|
12
|
-
function RedoButton(props, ref) {
|
|
11
|
+
export default function RedoButton() {
|
|
13
12
|
const shortcut = isAppleOS() ? displayShortcut.primaryShift('z') : displayShortcut.primary('y');
|
|
14
13
|
const hasRedo = useSelect(select => select(coreStore).hasRedo(), []);
|
|
15
14
|
const {
|
|
16
15
|
redo
|
|
17
16
|
} = useDispatch(coreStore);
|
|
18
|
-
return createElement(
|
|
19
|
-
...props,
|
|
20
|
-
ref: ref,
|
|
17
|
+
return createElement(ToolbarButton, {
|
|
21
18
|
icon: !isRTL() ? redoIcon : undoIcon,
|
|
22
19
|
label: __('Redo'),
|
|
23
20
|
shortcut: shortcut
|
|
@@ -29,5 +26,4 @@ function RedoButton(props, ref) {
|
|
|
29
26
|
onClick: hasRedo ? redo : undefined
|
|
30
27
|
});
|
|
31
28
|
}
|
|
32
|
-
export default forwardRef(RedoButton);
|
|
33
29
|
//# sourceMappingURL=redo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","isRTL","
|
|
1
|
+
{"version":3,"names":["__","isRTL","ToolbarButton","useSelect","useDispatch","redo","redoIcon","undo","undoIcon","displayShortcut","isAppleOS","store","coreStore","RedoButton","shortcut","primaryShift","primary","hasRedo","select","createElement","icon","label","onClick","undefined"],"sources":["@wordpress/edit-widgets/src/components/header/undo-redo/redo.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\n\nexport default function RedoButton() {\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tconst hasRedo = useSelect(\n\t\t( select ) => select( coreStore ).hasRedo(),\n\t\t[]\n\t);\n\tconst { redo } = useDispatch( coreStore );\n\treturn (\n\t\t<ToolbarButton\n\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\tlabel={ __( 'Redo' ) }\n\t\t\tshortcut={ shortcut }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasRedo }\n\t\t\tonClick={ hasRedo ? redo : undefined }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,IAAI,IAAIC,QAAQ,EAAEC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;AACrE,SAASC,eAAe,EAAEC,SAAS,QAAQ,qBAAqB;AAChE,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAEzD,eAAe,SAASC,UAAUA,CAAA,EAAG;EACpC,MAAMC,QAAQ,GAAGJ,SAAS,CAAC,CAAC,GACzBD,eAAe,CAACM,YAAY,CAAE,GAAI,CAAC,GACnCN,eAAe,CAACO,OAAO,CAAE,GAAI,CAAC;EAEjC,MAAMC,OAAO,GAAGd,SAAS,CACtBe,MAAM,IAAMA,MAAM,CAAEN,SAAU,CAAC,CAACK,OAAO,CAAC,CAAC,EAC3C,EACD,CAAC;EACD,MAAM;IAAEZ;EAAK,CAAC,GAAGD,WAAW,CAAEQ,SAAU,CAAC;EACzC,OACCO,aAAA,CAACjB,aAAa;IACbkB,IAAI,EAAG,CAAEnB,KAAK,CAAC,CAAC,GAAGK,QAAQ,GAAGE,QAAU;IACxCa,KAAK,EAAGrB,EAAE,CAAE,MAAO,CAAG;IACtBc,QAAQ,EAAGA;IACX;IACA;IACA;IAAA;IACA,iBAAgB,CAAEG,OAAS;IAC3BK,OAAO,EAAGL,OAAO,GAAGZ,IAAI,GAAGkB;EAAW,CACtC,CAAC;AAEJ"}
|
|
@@ -3,20 +3,17 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
6
|
+
import { ToolbarButton } from '@wordpress/components';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
8
|
import { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';
|
|
9
9
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
-
|
|
12
|
-
function UndoButton(props, ref) {
|
|
11
|
+
export default function UndoButton() {
|
|
13
12
|
const hasUndo = useSelect(select => select(coreStore).hasUndo(), []);
|
|
14
13
|
const {
|
|
15
14
|
undo
|
|
16
15
|
} = useDispatch(coreStore);
|
|
17
|
-
return createElement(
|
|
18
|
-
...props,
|
|
19
|
-
ref: ref,
|
|
16
|
+
return createElement(ToolbarButton, {
|
|
20
17
|
icon: !isRTL() ? undoIcon : redoIcon,
|
|
21
18
|
label: __('Undo'),
|
|
22
19
|
shortcut: displayShortcut.primary('z')
|
|
@@ -28,5 +25,4 @@ function UndoButton(props, ref) {
|
|
|
28
25
|
onClick: hasUndo ? undo : undefined
|
|
29
26
|
});
|
|
30
27
|
}
|
|
31
|
-
export default forwardRef(UndoButton);
|
|
32
28
|
//# sourceMappingURL=undo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","isRTL","
|
|
1
|
+
{"version":3,"names":["__","isRTL","ToolbarButton","useSelect","useDispatch","undo","undoIcon","redo","redoIcon","displayShortcut","store","coreStore","UndoButton","hasUndo","select","createElement","icon","label","shortcut","primary","onClick","undefined"],"sources":["@wordpress/edit-widgets/src/components/header/undo-redo/undo.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\n\nexport default function UndoButton() {\n\tconst hasUndo = useSelect(\n\t\t( select ) => select( coreStore ).hasUndo(),\n\t\t[]\n\t);\n\tconst { undo } = useDispatch( coreStore );\n\treturn (\n\t\t<ToolbarButton\n\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\tlabel={ __( 'Undo' ) }\n\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasUndo }\n\t\t\tonClick={ hasUndo ? undo : undefined }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,IAAI,IAAIC,QAAQ,EAAEC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;AACrE,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAEzD,eAAe,SAASC,UAAUA,CAAA,EAAG;EACpC,MAAMC,OAAO,GAAGV,SAAS,CACtBW,MAAM,IAAMA,MAAM,CAAEH,SAAU,CAAC,CAACE,OAAO,CAAC,CAAC,EAC3C,EACD,CAAC;EACD,MAAM;IAAER;EAAK,CAAC,GAAGD,WAAW,CAAEO,SAAU,CAAC;EACzC,OACCI,aAAA,CAACb,aAAa;IACbc,IAAI,EAAG,CAAEf,KAAK,CAAC,CAAC,GAAGK,QAAQ,GAAGE,QAAU;IACxCS,KAAK,EAAGjB,EAAE,CAAE,MAAO,CAAG;IACtBkB,QAAQ,EAAGT,eAAe,CAACU,OAAO,CAAE,GAAI;IACxC;IACA;IACA;IAAA;IACA,iBAAgB,CAAEN,OAAS;IAC3BO,OAAO,EAAGP,OAAO,GAAGR,IAAI,GAAGgB;EAAW,CACtC,CAAC;AAEJ"}
|
|
@@ -678,6 +678,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
678
678
|
align-items: center;
|
|
679
679
|
justify-content: center;
|
|
680
680
|
flex-shrink: 2;
|
|
681
|
+
overflow-x: hidden;
|
|
681
682
|
padding-right: 16px;
|
|
682
683
|
}
|
|
683
684
|
|
|
@@ -700,7 +701,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
700
701
|
}
|
|
701
702
|
|
|
702
703
|
.edit-widgets-header-toolbar {
|
|
703
|
-
|
|
704
|
+
border: none;
|
|
704
705
|
}
|
|
705
706
|
.edit-widgets-header-toolbar > .components-button.has-icon.has-icon.has-icon,
|
|
706
707
|
.edit-widgets-header-toolbar > .components-dropdown > .components-button.has-icon.has-icon {
|
package/build-style/style.css
CHANGED
|
@@ -678,6 +678,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
678
678
|
align-items: center;
|
|
679
679
|
justify-content: center;
|
|
680
680
|
flex-shrink: 2;
|
|
681
|
+
overflow-x: hidden;
|
|
681
682
|
padding-left: 16px;
|
|
682
683
|
}
|
|
683
684
|
|
|
@@ -700,7 +701,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
700
701
|
}
|
|
701
702
|
|
|
702
703
|
.edit-widgets-header-toolbar {
|
|
703
|
-
|
|
704
|
+
border: none;
|
|
704
705
|
}
|
|
705
706
|
.edit-widgets-header-toolbar > .components-button.has-icon.has-icon.has-icon,
|
|
706
707
|
.edit-widgets-header-toolbar > .components-dropdown > .components-button.has-icon.has-icon {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.26.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.
|
|
31
|
-
"@wordpress/block-editor": "^12.
|
|
32
|
-
"@wordpress/block-library": "^8.
|
|
33
|
-
"@wordpress/blocks": "^12.
|
|
34
|
-
"@wordpress/components": "^25.15.
|
|
35
|
-
"@wordpress/compose": "^6.
|
|
36
|
-
"@wordpress/core-data": "^6.
|
|
37
|
-
"@wordpress/data": "^9.
|
|
38
|
-
"@wordpress/deprecated": "^3.
|
|
39
|
-
"@wordpress/dom": "^3.
|
|
40
|
-
"@wordpress/element": "^5.
|
|
41
|
-
"@wordpress/hooks": "^3.
|
|
42
|
-
"@wordpress/i18n": "^4.
|
|
43
|
-
"@wordpress/icons": "^9.
|
|
44
|
-
"@wordpress/interface": "^5.
|
|
45
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
46
|
-
"@wordpress/keycodes": "^3.
|
|
47
|
-
"@wordpress/media-utils": "^4.
|
|
48
|
-
"@wordpress/notices": "^4.
|
|
49
|
-
"@wordpress/patterns": "^1.
|
|
50
|
-
"@wordpress/plugins": "^6.
|
|
51
|
-
"@wordpress/preferences": "^3.
|
|
52
|
-
"@wordpress/private-apis": "^0.
|
|
53
|
-
"@wordpress/reusable-blocks": "^4.
|
|
54
|
-
"@wordpress/url": "^3.
|
|
55
|
-
"@wordpress/widgets": "^3.
|
|
30
|
+
"@wordpress/api-fetch": "^6.46.0",
|
|
31
|
+
"@wordpress/block-editor": "^12.17.0",
|
|
32
|
+
"@wordpress/block-library": "^8.26.0",
|
|
33
|
+
"@wordpress/blocks": "^12.26.0",
|
|
34
|
+
"@wordpress/components": "^25.15.0",
|
|
35
|
+
"@wordpress/compose": "^6.26.0",
|
|
36
|
+
"@wordpress/core-data": "^6.26.0",
|
|
37
|
+
"@wordpress/data": "^9.19.0",
|
|
38
|
+
"@wordpress/deprecated": "^3.49.0",
|
|
39
|
+
"@wordpress/dom": "^3.49.0",
|
|
40
|
+
"@wordpress/element": "^5.26.0",
|
|
41
|
+
"@wordpress/hooks": "^3.49.0",
|
|
42
|
+
"@wordpress/i18n": "^4.49.0",
|
|
43
|
+
"@wordpress/icons": "^9.40.0",
|
|
44
|
+
"@wordpress/interface": "^5.26.0",
|
|
45
|
+
"@wordpress/keyboard-shortcuts": "^4.26.0",
|
|
46
|
+
"@wordpress/keycodes": "^3.49.0",
|
|
47
|
+
"@wordpress/media-utils": "^4.40.0",
|
|
48
|
+
"@wordpress/notices": "^4.17.0",
|
|
49
|
+
"@wordpress/patterns": "^1.10.0",
|
|
50
|
+
"@wordpress/plugins": "^6.17.0",
|
|
51
|
+
"@wordpress/preferences": "^3.26.0",
|
|
52
|
+
"@wordpress/private-apis": "^0.31.0",
|
|
53
|
+
"@wordpress/reusable-blocks": "^4.26.0",
|
|
54
|
+
"@wordpress/url": "^3.50.0",
|
|
55
|
+
"@wordpress/widgets": "^3.26.0",
|
|
56
56
|
"classnames": "^2.3.1",
|
|
57
57
|
"rememo": "^4.0.2"
|
|
58
58
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "5e6f9caa205d3bfdbac131952b7bf9c6ec60569b"
|
|
67
67
|
}
|
|
@@ -83,7 +83,6 @@ function DocumentTools() {
|
|
|
83
83
|
className="edit-widgets-header-toolbar"
|
|
84
84
|
aria-label={ __( 'Document tools' ) }
|
|
85
85
|
shouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }
|
|
86
|
-
variant="unstyled"
|
|
87
86
|
>
|
|
88
87
|
<ToolbarItem
|
|
89
88
|
ref={ inserterButton }
|
|
@@ -105,8 +104,8 @@ function DocumentTools() {
|
|
|
105
104
|
/>
|
|
106
105
|
{ isMediumViewport && (
|
|
107
106
|
<>
|
|
108
|
-
<
|
|
109
|
-
<
|
|
107
|
+
<UndoButton />
|
|
108
|
+
<RedoButton />
|
|
110
109
|
<ToolbarItem
|
|
111
110
|
as={ Button }
|
|
112
111
|
className="edit-widgets-header-toolbar__list-view-toggle"
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
align-items: center;
|
|
46
46
|
justify-content: center;
|
|
47
47
|
flex-shrink: 2;
|
|
48
|
+
overflow-x: hidden;
|
|
48
49
|
padding-left: $grid-unit-20;
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
.edit-widgets-header-toolbar {
|
|
69
|
-
|
|
70
|
+
border: none;
|
|
70
71
|
|
|
71
72
|
// The Toolbar component adds different styles to buttons, so we reset them
|
|
72
73
|
// here to the original button styles
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { ToolbarButton } 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';
|
|
11
10
|
|
|
12
|
-
function RedoButton(
|
|
11
|
+
export default function RedoButton() {
|
|
13
12
|
const shortcut = isAppleOS()
|
|
14
13
|
? displayShortcut.primaryShift( 'z' )
|
|
15
14
|
: displayShortcut.primary( 'y' );
|
|
@@ -20,9 +19,7 @@ function RedoButton( props, ref ) {
|
|
|
20
19
|
);
|
|
21
20
|
const { redo } = useDispatch( coreStore );
|
|
22
21
|
return (
|
|
23
|
-
<
|
|
24
|
-
{ ...props }
|
|
25
|
-
ref={ ref }
|
|
22
|
+
<ToolbarButton
|
|
26
23
|
icon={ ! isRTL() ? redoIcon : undoIcon }
|
|
27
24
|
label={ __( 'Redo' ) }
|
|
28
25
|
shortcut={ shortcut }
|
|
@@ -34,5 +31,3 @@ function RedoButton( props, ref ) {
|
|
|
34
31
|
/>
|
|
35
32
|
);
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
export default forwardRef( RedoButton );
|
|
@@ -2,23 +2,20 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { ToolbarButton } 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';
|
|
11
10
|
|
|
12
|
-
function UndoButton(
|
|
11
|
+
export default function UndoButton() {
|
|
13
12
|
const hasUndo = useSelect(
|
|
14
13
|
( select ) => select( coreStore ).hasUndo(),
|
|
15
14
|
[]
|
|
16
15
|
);
|
|
17
16
|
const { undo } = useDispatch( coreStore );
|
|
18
17
|
return (
|
|
19
|
-
<
|
|
20
|
-
{ ...props }
|
|
21
|
-
ref={ ref }
|
|
18
|
+
<ToolbarButton
|
|
22
19
|
icon={ ! isRTL() ? undoIcon : redoIcon }
|
|
23
20
|
label={ __( 'Undo' ) }
|
|
24
21
|
shortcut={ displayShortcut.primary( 'z' ) }
|
|
@@ -30,5 +27,3 @@ function UndoButton( props, ref ) {
|
|
|
30
27
|
/>
|
|
31
28
|
);
|
|
32
29
|
}
|
|
33
|
-
|
|
34
|
-
export default forwardRef( UndoButton );
|