UNPKG

5.76 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import { createElement } from "@wordpress/element";
3
4/**
5 * External dependencies
6 */
7import classnames from 'classnames';
8/**
9 * WordPress dependencies
10 */
11
12import { Button, Popover, ScrollLock, FocusReturnProvider, navigateRegions } from '@wordpress/components';
13import { __ } from '@wordpress/i18n';
14import { PreserveScrollInReorder } from '@wordpress/block-editor';
15import { AutosaveMonitor, UnsavedChangesWarning, EditorNotices, PostPublishPanel } from '@wordpress/editor';
16import { withDispatch, withSelect } from '@wordpress/data';
17import { Fragment } from '@wordpress/element';
18import { PluginArea } from '@wordpress/plugins';
19import { withViewportMatch } from '@wordpress/viewport';
20import { compose } from '@wordpress/compose';
21/**
22 * Internal dependencies
23 */
24
25import BrowserURL from '../browser-url';
26import Header from '../header';
27import TextEditor from '../text-editor';
28import VisualEditor from '../visual-editor';
29import EditorModeKeyboardShortcuts from '../keyboard-shortcuts';
30import KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';
31import ManageBlocksModal from '../manage-blocks-modal';
32import OptionsModal from '../options-modal';
33import MetaBoxes from '../meta-boxes';
34import SettingsSidebar from '../sidebar/settings-sidebar';
35import Sidebar from '../sidebar';
36import PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel';
37import PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel';
38import FullscreenMode from '../fullscreen-mode';
39
40function Layout(_ref) {
41 var mode = _ref.mode,
42 editorSidebarOpened = _ref.editorSidebarOpened,
43 pluginSidebarOpened = _ref.pluginSidebarOpened,
44 publishSidebarOpened = _ref.publishSidebarOpened,
45 hasFixedToolbar = _ref.hasFixedToolbar,
46 closePublishSidebar = _ref.closePublishSidebar,
47 togglePublishSidebar = _ref.togglePublishSidebar,
48 hasActiveMetaboxes = _ref.hasActiveMetaboxes,
49 isSaving = _ref.isSaving,
50 isMobileViewport = _ref.isMobileViewport,
51 isRichEditingEnabled = _ref.isRichEditingEnabled;
52 var sidebarIsOpened = editorSidebarOpened || pluginSidebarOpened || publishSidebarOpened;
53 var className = classnames('edit-post-layout', {
54 'is-sidebar-opened': sidebarIsOpened,
55 'has-fixed-toolbar': hasFixedToolbar
56 });
57 var publishLandmarkProps = {
58 role: 'region',
59
60 /* translators: accessibility text for the publish landmark region. */
61 'aria-label': __('Editor publish'),
62 tabIndex: -1
63 };
64 return createElement(FocusReturnProvider, {
65 className: className
66 }, createElement(FullscreenMode, null), createElement(BrowserURL, null), createElement(UnsavedChangesWarning, null), createElement(AutosaveMonitor, null), createElement(Header, null), createElement("div", {
67 className: "edit-post-layout__content",
68 role: "region"
69 /* translators: accessibility text for the content landmark region. */
70 ,
71 "aria-label": __('Editor content'),
72 tabIndex: "-1"
73 }, createElement(EditorNotices, {
74 dismissible: false,
75 className: "is-pinned"
76 }), createElement(EditorNotices, {
77 dismissible: true
78 }), createElement(PreserveScrollInReorder, null), createElement(EditorModeKeyboardShortcuts, null), createElement(KeyboardShortcutHelpModal, null), createElement(ManageBlocksModal, null), createElement(OptionsModal, null), (mode === 'text' || !isRichEditingEnabled) && createElement(TextEditor, null), isRichEditingEnabled && mode === 'visual' && createElement(VisualEditor, null), createElement("div", {
79 className: "edit-post-layout__metaboxes"
80 }, createElement(MetaBoxes, {
81 location: "normal"
82 })), createElement("div", {
83 className: "edit-post-layout__metaboxes"
84 }, createElement(MetaBoxes, {
85 location: "advanced"
86 }))), publishSidebarOpened ? createElement(PostPublishPanel, _extends({}, publishLandmarkProps, {
87 onClose: closePublishSidebar,
88 forceIsDirty: hasActiveMetaboxes,
89 forceIsSaving: isSaving,
90 PrePublishExtension: PluginPrePublishPanel.Slot,
91 PostPublishExtension: PluginPostPublishPanel.Slot
92 })) : createElement(Fragment, null, createElement("div", _extends({
93 className: "edit-post-toggle-publish-panel"
94 }, publishLandmarkProps), createElement(Button, {
95 isDefault: true,
96 type: "button",
97 className: "edit-post-toggle-publish-panel__button",
98 onClick: togglePublishSidebar,
99 "aria-expanded": false
100 }, __('Open publish panel'))), createElement(SettingsSidebar, null), createElement(Sidebar.Slot, null), isMobileViewport && sidebarIsOpened && createElement(ScrollLock, null)), createElement(Popover.Slot, null), createElement(PluginArea, null));
101}
102
103export default compose(withSelect(function (select) {
104 return {
105 mode: select('core/edit-post').getEditorMode(),
106 editorSidebarOpened: select('core/edit-post').isEditorSidebarOpened(),
107 pluginSidebarOpened: select('core/edit-post').isPluginSidebarOpened(),
108 publishSidebarOpened: select('core/edit-post').isPublishSidebarOpened(),
109 hasFixedToolbar: select('core/edit-post').isFeatureActive('fixedToolbar'),
110 hasActiveMetaboxes: select('core/edit-post').hasMetaBoxes(),
111 isSaving: select('core/edit-post').isSavingMetaBoxes(),
112 isRichEditingEnabled: select('core/editor').getEditorSettings().richEditingEnabled
113 };
114}), withDispatch(function (dispatch) {
115 var _dispatch = dispatch('core/edit-post'),
116 closePublishSidebar = _dispatch.closePublishSidebar,
117 togglePublishSidebar = _dispatch.togglePublishSidebar;
118
119 return {
120 closePublishSidebar: closePublishSidebar,
121 togglePublishSidebar: togglePublishSidebar
122 };
123}), navigateRegions, withViewportMatch({
124 isMobileViewport: '< small'
125}))(Layout);
126//# sourceMappingURL=index.js.map
\No newline at end of file