1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import { createElement } from "@wordpress/element";
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import classnames from 'classnames';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | import { Button, Popover, ScrollLock, FocusReturnProvider, navigateRegions } from '@wordpress/components';
|
13 | import { __ } from '@wordpress/i18n';
|
14 | import { PreserveScrollInReorder } from '@wordpress/block-editor';
|
15 | import { AutosaveMonitor, UnsavedChangesWarning, EditorNotices, PostPublishPanel } from '@wordpress/editor';
|
16 | import { withDispatch, withSelect } from '@wordpress/data';
|
17 | import { Fragment } from '@wordpress/element';
|
18 | import { PluginArea } from '@wordpress/plugins';
|
19 | import { withViewportMatch } from '@wordpress/viewport';
|
20 | import { compose } from '@wordpress/compose';
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | import BrowserURL from '../browser-url';
|
26 | import Header from '../header';
|
27 | import TextEditor from '../text-editor';
|
28 | import VisualEditor from '../visual-editor';
|
29 | import EditorModeKeyboardShortcuts from '../keyboard-shortcuts';
|
30 | import KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';
|
31 | import ManageBlocksModal from '../manage-blocks-modal';
|
32 | import OptionsModal from '../options-modal';
|
33 | import MetaBoxes from '../meta-boxes';
|
34 | import SettingsSidebar from '../sidebar/settings-sidebar';
|
35 | import Sidebar from '../sidebar';
|
36 | import PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel';
|
37 | import PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel';
|
38 | import FullscreenMode from '../fullscreen-mode';
|
39 |
|
40 | function 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 |
|
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 |
|
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 |
|
103 | export 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 |
|
\ | No newline at end of file |