@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
62 lines (59 loc) • 1.91 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EditorNotices = EditorNotices;
exports.default = void 0;
var _components = require("@wordpress/components");
var _data = require("@wordpress/data");
var _notices = require("@wordpress/notices");
var _templateValidationNotice = _interopRequireDefault(require("../template-validation-notice"));
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* This component renders the notices displayed in the editor. It displays pinned notices first, followed by dismissible
*
* @example
* ```jsx
* <EditorNotices />
* ```
*
* @return {JSX.Element} The rendered EditorNotices component.
*/
function EditorNotices() {
const {
notices
} = (0, _data.useSelect)(select => ({
notices: select(_notices.store).getNotices()
}), []);
const {
removeNotice
} = (0, _data.useDispatch)(_notices.store);
const dismissibleNotices = notices.filter(({
isDismissible,
type
}) => isDismissible && type === 'default');
const nonDismissibleNotices = notices.filter(({
isDismissible,
type
}) => !isDismissible && type === 'default');
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.NoticeList, {
notices: nonDismissibleNotices,
className: "components-editor-notices__pinned"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.NoticeList, {
notices: dismissibleNotices,
className: "components-editor-notices__dismissible",
onRemove: removeNotice,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_templateValidationNotice.default, {})
})]
});
}
var _default = exports.default = EditorNotices;
//# sourceMappingURL=index.js.map