UNPKG

@wordpress/editor

Version:
104 lines (101 loc) 4.21 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _i18n = require("@wordpress/i18n"); var _data = require("@wordpress/data"); var _blockEditor = require("@wordpress/block-editor"); var _wordCount = _interopRequireDefault(require("../word-count")); var _timeToRead = _interopRequireDefault(require("../time-to-read")); var _documentOutline = _interopRequireDefault(require("../document-outline")); var _characterCount = _interopRequireDefault(require("../character-count")); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ function TableOfContentsPanel({ hasOutlineItemsDisabled, onRequestClose }) { const { headingCount, paragraphCount, numberOfBlocks } = (0, _data.useSelect)(select => { const { getGlobalBlockCount } = select(_blockEditor.store); return { headingCount: getGlobalBlockCount('core/heading'), paragraphCount: getGlobalBlockCount('core/paragraph'), numberOfBlocks: getGlobalBlockCount() }; }, []); return ( /*#__PURE__*/ /* * Disable reason: The `list` ARIA role is redundant but * Safari+VoiceOver won't announce the list otherwise. */ /* eslint-disable jsx-a11y/no-redundant-roles */ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: "table-of-contents__wrapper", role: "note", "aria-label": (0, _i18n.__)('Document Statistics'), tabIndex: "0", children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", { role: "list", className: "table-of-contents__counts", children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("li", { className: "table-of-contents__count", children: [(0, _i18n.__)('Words'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_wordCount.default, {})] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", { className: "table-of-contents__count", children: [(0, _i18n.__)('Characters'), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { className: "table-of-contents__number", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_characterCount.default, {}) })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", { className: "table-of-contents__count", children: [(0, _i18n.__)('Time to read'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_timeToRead.default, {})] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", { className: "table-of-contents__count", children: [(0, _i18n.__)('Headings'), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { className: "table-of-contents__number", children: headingCount })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", { className: "table-of-contents__count", children: [(0, _i18n.__)('Paragraphs'), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { className: "table-of-contents__number", children: paragraphCount })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", { className: "table-of-contents__count", children: [(0, _i18n.__)('Blocks'), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { className: "table-of-contents__number", children: numberOfBlocks })] })] }) }), headingCount > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("hr", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", { className: "table-of-contents__title", children: (0, _i18n.__)('Document Outline') }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_documentOutline.default, { onSelect: onRequestClose, hasOutlineItemsDisabled: hasOutlineItemsDisabled })] })] }) /* eslint-enable jsx-a11y/no-redundant-roles */ ); } var _default = exports.default = TableOfContentsPanel; //# sourceMappingURL=panel.js.map