UNPKG

@wordpress/editor

Version:
57 lines (52 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _i18n = require("@wordpress/i18n"); var _components = require("@wordpress/components"); var _data = require("@wordpress/data"); var _keycodes = require("@wordpress/keycodes"); var _icons = require("@wordpress/icons"); var _element = require("@wordpress/element"); var _store = require("../../store"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ function EditorHistoryUndo(props, ref) { const hasUndo = (0, _data.useSelect)(select => select(_store.store).hasEditorUndo(), []); const { undo } = (0, _data.useDispatch)(_store.store); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, { __next40pxDefaultSize: true, ...props, ref: ref, icon: !(0, _i18n.isRTL)() ? _icons.undo : _icons.redo /* translators: button label text should, if possible, be under 16 characters. */, label: (0, _i18n.__)('Undo'), shortcut: _keycodes.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this // button, because it will remove focus for keyboard users. // See: https://github.com/WordPress/gutenberg/issues/3486 , "aria-disabled": !hasUndo, onClick: hasUndo ? undo : undefined, className: "editor-history__undo" }); } /** @typedef {import('react').Ref<HTMLElement>} Ref */ /** * Renders the undo button for the editor history. * * @param {Object} props - Props. * @param {Ref} ref - Forwarded ref. * * @return {Component} The component to be rendered. */ var _default = exports.default = (0, _element.forwardRef)(EditorHistoryUndo); //# sourceMappingURL=undo.js.map