@wordpress/edit-post 7.24.0 → 7.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/header/header-toolbar/index.js +8 -4
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js +13 -11
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +1 -1
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +2 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +13 -12
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/layout/index.js +12 -12
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +65 -49
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +1 -2
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js +17 -43
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +80 -20
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +3 -3
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/index.js +20 -257
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +6 -3
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/editor.js +5 -6
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -2
- package/build/editor.native.js.map +1 -1
- package/build/index.js +5 -4
- package/build/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +2 -6
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +35 -39
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +1 -34
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +22 -12
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +8 -4
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js +15 -13
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +1 -1
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +2 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +14 -13
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/layout/index.js +13 -13
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +65 -49
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -3
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js +20 -46
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +80 -21
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +3 -3
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +24 -261
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +6 -3
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/editor.js +5 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +1 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/index.js +3 -2
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +2 -6
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +31 -36
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -33
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +18 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +63 -200
- package/build-style/style.css +63 -200
- package/package.json +32 -32
- package/src/components/header/header-toolbar/index.js +4 -0
- package/src/components/header/header-toolbar/style.scss +15 -13
- package/src/components/header/index.js +28 -13
- package/src/components/header/mode-switcher/index.js +2 -1
- package/src/components/header/more-menu/index.js +1 -0
- package/src/components/header/style.scss +60 -34
- package/src/components/header/writing-menu/index.js +16 -18
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +1 -1
- package/src/components/layout/index.js +13 -12
- package/src/components/preferences-modal/index.js +109 -96
- package/src/components/preferences-modal/test/index.js +1 -52
- package/src/components/sidebar/post-status/index.js +2 -2
- package/src/components/sidebar/settings-header/index.js +19 -71
- package/src/components/sidebar/settings-sidebar/index.js +117 -54
- package/src/components/sidebar/style.scss +4 -12
- package/src/components/start-page-options/index.js +3 -3
- package/src/components/visual-editor/index.js +26 -359
- package/src/components/visual-editor/style.scss +0 -15
- package/src/components/welcome-guide/index.js +4 -2
- package/src/editor.js +7 -7
- package/src/editor.native.js +3 -9
- package/src/index.js +3 -2
- package/src/plugins/welcome-guide-menu-item/index.js +3 -6
- package/src/store/actions.js +32 -46
- package/src/store/reducer.js +0 -33
- package/src/store/selectors.js +23 -9
- package/src/store/test/actions.js +0 -28
- package/src/style.scss +0 -3
- package/src/test/__snapshots__/editor.native.js.snap +21 -0
- package/src/test/editor.native.js +90 -56
- package/build/components/device-preview/index.js +0 -72
- package/build/components/device-preview/index.js.map +0 -1
- package/build/components/header/document-actions/index.js +0 -82
- package/build/components/header/document-actions/index.js.map +0 -1
- package/build/components/sidebar/post-template/create-modal.js +0 -99
- package/build/components/sidebar/post-template/create-modal.js.map +0 -1
- package/build/components/sidebar/post-template/form.js +0 -110
- package/build/components/sidebar/post-template/form.js.map +0 -1
- package/build/components/sidebar/post-template/index.js +0 -106
- package/build/components/sidebar/post-template/index.js.map +0 -1
- package/build-module/components/device-preview/index.js +0 -65
- package/build-module/components/device-preview/index.js.map +0 -1
- package/build-module/components/header/document-actions/index.js +0 -74
- package/build-module/components/header/document-actions/index.js.map +0 -1
- package/build-module/components/sidebar/post-template/create-modal.js +0 -92
- package/build-module/components/sidebar/post-template/create-modal.js.map +0 -1
- package/build-module/components/sidebar/post-template/form.js +0 -102
- package/build-module/components/sidebar/post-template/form.js.map +0 -1
- package/build-module/components/sidebar/post-template/index.js +0 -98
- package/build-module/components/sidebar/post-template/index.js.map +0 -1
- package/src/components/device-preview/index.js +0 -73
- package/src/components/header/document-actions/index.js +0 -82
- package/src/components/header/document-actions/style.scss +0 -64
- package/src/components/sidebar/post-template/create-modal.js +0 -140
- package/src/components/sidebar/post-template/form.js +0 -141
- package/src/components/sidebar/post-template/index.js +0 -120
- package/src/components/sidebar/post-template/style.scss +0 -22
- package/src/components/sidebar/settings-header/style.scss +0 -74
- package/src/components/sidebar/template/style.scss +0 -35
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = void 0;
|
|
7
|
+
exports.sidebars = exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
10
10
|
var _data = require("@wordpress/data");
|
|
@@ -13,6 +13,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
var _icons = require("@wordpress/icons");
|
|
14
14
|
var _interface = require("@wordpress/interface");
|
|
15
15
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
16
|
+
var _editor = require("@wordpress/editor");
|
|
16
17
|
var _settingsHeader = _interopRequireDefault(require("../settings-header"));
|
|
17
18
|
var _postStatus = _interopRequireDefault(require("../post-status"));
|
|
18
19
|
var _lastRevision = _interopRequireDefault(require("../last-revision"));
|
|
@@ -26,6 +27,8 @@ var _pluginDocumentSettingPanel = _interopRequireDefault(require("../plugin-docu
|
|
|
26
27
|
var _pluginSidebar = _interopRequireDefault(require("../plugin-sidebar"));
|
|
27
28
|
var _templateSummary = _interopRequireDefault(require("../template-summary"));
|
|
28
29
|
var _store = require("../../../store");
|
|
30
|
+
var _components = require("@wordpress/components");
|
|
31
|
+
var _lockUnlock = require("../../../lock-unlock");
|
|
29
32
|
/**
|
|
30
33
|
* WordPress dependencies
|
|
31
34
|
*/
|
|
@@ -34,13 +37,60 @@ var _store = require("../../../store");
|
|
|
34
37
|
* Internal dependencies
|
|
35
38
|
*/
|
|
36
39
|
|
|
40
|
+
const {
|
|
41
|
+
Tabs
|
|
42
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
37
43
|
const SIDEBAR_ACTIVE_BY_DEFAULT = _element.Platform.select({
|
|
38
44
|
web: true,
|
|
39
45
|
native: false
|
|
40
46
|
});
|
|
47
|
+
const sidebars = {
|
|
48
|
+
document: 'edit-post/document',
|
|
49
|
+
block: 'edit-post/block'
|
|
50
|
+
};
|
|
51
|
+
exports.sidebars = sidebars;
|
|
52
|
+
const SidebarContent = ({
|
|
53
|
+
sidebarName,
|
|
54
|
+
keyboardShortcut,
|
|
55
|
+
isTemplateMode
|
|
56
|
+
}) => {
|
|
57
|
+
// Because `PluginSidebarEditPost` renders a `ComplementaryArea`, we
|
|
58
|
+
// need to forward the `Tabs` context so it can be passed through the
|
|
59
|
+
// underlying slot/fill.
|
|
60
|
+
const tabsContextValue = (0, _element.useContext)(Tabs.Context);
|
|
61
|
+
return (0, _react.createElement)(_pluginSidebar.default, {
|
|
62
|
+
identifier: sidebarName,
|
|
63
|
+
header: (0, _react.createElement)(Tabs.Context.Provider, {
|
|
64
|
+
value: tabsContextValue
|
|
65
|
+
}, (0, _react.createElement)(_settingsHeader.default, null)),
|
|
66
|
+
closeLabel: (0, _i18n.__)('Close Settings')
|
|
67
|
+
// This classname is added so we can apply a corrective negative
|
|
68
|
+
// margin to the panel.
|
|
69
|
+
// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
|
|
70
|
+
,
|
|
71
|
+
className: "edit-post-sidebar__panel",
|
|
72
|
+
headerClassName: "edit-post-sidebar__panel-tabs"
|
|
73
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
74
|
+
title: (0, _i18n.__)('Settings'),
|
|
75
|
+
toggleShortcut: keyboardShortcut,
|
|
76
|
+
icon: (0, _i18n.isRTL)() ? _icons.drawerLeft : _icons.drawerRight,
|
|
77
|
+
isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT
|
|
78
|
+
}, (0, _react.createElement)(Tabs.Context.Provider, {
|
|
79
|
+
value: tabsContextValue
|
|
80
|
+
}, (0, _react.createElement)(Tabs.TabPanel, {
|
|
81
|
+
tabId: sidebars.document,
|
|
82
|
+
focusable: false
|
|
83
|
+
}, !isTemplateMode && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_postStatus.default, null), (0, _react.createElement)(_pluginDocumentSettingPanel.default.Slot, null), (0, _react.createElement)(_lastRevision.default, null), (0, _react.createElement)(_postTaxonomies.default, null), (0, _react.createElement)(_featuredImage.default, null), (0, _react.createElement)(_postExcerpt.default, null), (0, _react.createElement)(_discussionPanel.default, null), (0, _react.createElement)(_pageAttributes.default, null), (0, _react.createElement)(_metaBoxes.default, {
|
|
84
|
+
location: "side"
|
|
85
|
+
})), isTemplateMode && (0, _react.createElement)(_templateSummary.default, null)), (0, _react.createElement)(Tabs.TabPanel, {
|
|
86
|
+
tabId: sidebars.block,
|
|
87
|
+
focusable: false
|
|
88
|
+
}, (0, _react.createElement)(_blockEditor.BlockInspector, null))));
|
|
89
|
+
};
|
|
41
90
|
const SettingsSidebar = () => {
|
|
42
91
|
const {
|
|
43
92
|
sidebarName,
|
|
93
|
+
isSettingsSidebarActive,
|
|
44
94
|
keyboardShortcut,
|
|
45
95
|
isTemplateMode
|
|
46
96
|
} = (0, _data.useSelect)(select => {
|
|
@@ -52,34 +102,44 @@ const SettingsSidebar = () => {
|
|
|
52
102
|
// should contain the sidebar that will be active when the toggle button is pressed. If a block
|
|
53
103
|
// is selected, that should be edit-post/block otherwise it's edit-post/document.
|
|
54
104
|
let sidebar = select(_interface.store).getActiveComplementaryArea(_store.store.name);
|
|
55
|
-
|
|
105
|
+
let isSettingsSidebar = true;
|
|
106
|
+
if (![sidebars.document, sidebars.block].includes(sidebar)) {
|
|
107
|
+
isSettingsSidebar = false;
|
|
56
108
|
if (select(_blockEditor.store).getBlockSelectionStart()) {
|
|
57
|
-
sidebar =
|
|
109
|
+
sidebar = sidebars.block;
|
|
58
110
|
}
|
|
59
|
-
sidebar =
|
|
111
|
+
sidebar = sidebars.document;
|
|
60
112
|
}
|
|
61
113
|
const shortcut = select(_keyboardShortcuts.store).getShortcutRepresentation('core/edit-post/toggle-sidebar');
|
|
62
114
|
return {
|
|
63
115
|
sidebarName: sidebar,
|
|
116
|
+
isSettingsSidebarActive: isSettingsSidebar,
|
|
64
117
|
keyboardShortcut: shortcut,
|
|
65
|
-
isTemplateMode: select(
|
|
118
|
+
isTemplateMode: select(_editor.store).getRenderingMode() === 'template-only'
|
|
66
119
|
};
|
|
67
120
|
}, []);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
121
|
+
const {
|
|
122
|
+
openGeneralSidebar
|
|
123
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
124
|
+
const onTabSelect = (0, _element.useCallback)(newSelectedTabId => {
|
|
125
|
+
if (!!newSelectedTabId) {
|
|
126
|
+
openGeneralSidebar(newSelectedTabId);
|
|
127
|
+
}
|
|
128
|
+
}, [openGeneralSidebar]);
|
|
129
|
+
return (0, _react.createElement)(Tabs
|
|
130
|
+
// Due to how this component is controlled (via a value from the
|
|
131
|
+
// `interfaceStore`), when the sidebar closes the currently selected
|
|
132
|
+
// tab can't be found. This causes the component to continuously reset
|
|
133
|
+
// the selection to `null` in an infinite loop.Proactively setting
|
|
134
|
+
// the selected tab to `null` avoids that.
|
|
135
|
+
, {
|
|
136
|
+
selectedTabId: isSettingsSidebarActive ? sidebarName : null,
|
|
137
|
+
onSelect: onTabSelect
|
|
138
|
+
}, (0, _react.createElement)(SidebarContent, {
|
|
139
|
+
sidebarName: sidebarName,
|
|
140
|
+
keyboardShortcut: keyboardShortcut,
|
|
141
|
+
isTemplateMode: isTemplateMode
|
|
142
|
+
}));
|
|
83
143
|
};
|
|
84
144
|
var _default = SettingsSidebar;
|
|
85
145
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","_data","_element","_i18n","_icons","_interface","_keyboardShortcuts","_settingsHeader","_interopRequireDefault","_postStatus","_lastRevision","_postTaxonomies","_featuredImage","_postExcerpt","_discussionPanel","_pageAttributes","_metaBoxes","_pluginDocumentSettingPanel","_pluginSidebar","_templateSummary","_store","SIDEBAR_ACTIVE_BY_DEFAULT","Platform","select","web","native","SettingsSidebar","sidebarName","keyboardShortcut","isTemplateMode","useSelect","sidebar","interfaceStore","getActiveComplementaryArea","editPostStore","name","includes","blockEditorStore","getBlockSelectionStart","shortcut","keyboardShortcutsStore","getShortcutRepresentation","isEditingTemplate","_react","createElement","default","identifier","header","closeLabel","__","headerClassName","title","toggleShortcut","icon","isRTL","drawerLeft","drawerRight","isActiveByDefault","Fragment","Slot","location","BlockInspector","_default","exports"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { Platform } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport LastRevision from '../last-revision';\nimport PostTaxonomies from '../post-taxonomies';\nimport FeaturedImage from '../featured-image';\nimport PostExcerpt from '../post-excerpt';\nimport DiscussionPanel from '../discussion-panel';\nimport PageAttributes from '../page-attributes';\nimport MetaBoxes from '../../meta-boxes';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebarEditPost from '../plugin-sidebar';\nimport TemplateSummary from '../template-summary';\nimport { store as editPostStore } from '../../../store';\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst SettingsSidebar = () => {\n\tconst { sidebarName, keyboardShortcut, isTemplateMode } = useSelect(\n\t\t( select ) => {\n\t\t\t// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.\n\t\t\t// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.\n\t\t\t// If one of the two sidebars is active the component will contain the content of that sidebar.\n\t\t\t// When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost\n\t\t\t// component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName\n\t\t\t// should contain the sidebar that will be active when the toggle button is pressed. If a block\n\t\t\t// is selected, that should be edit-post/block otherwise it's edit-post/document.\n\t\t\tlet sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditPostStore.name\n\t\t\t);\n\t\t\tif (\n\t\t\t\t! [ 'edit-post/document', 'edit-post/block' ].includes(\n\t\t\t\t\tsidebar\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( select( blockEditorStore ).getBlockSelectionStart() ) {\n\t\t\t\t\tsidebar = 'edit-post/block';\n\t\t\t\t}\n\t\t\t\tsidebar = 'edit-post/document';\n\t\t\t}\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );\n\t\t\treturn {\n\t\t\t\tsidebarName: sidebar,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tisTemplateMode: select( editPostStore ).isEditingTemplate(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn (\n\t\t<PluginSidebarEditPost\n\t\t\tidentifier={ sidebarName }\n\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t{ ! isTemplateMode && sidebarName === 'edit-post/document' && (\n\t\t\t\t<>\n\t\t\t\t\t<PostStatus />\n\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t<LastRevision />\n\t\t\t\t\t<PostTaxonomies />\n\t\t\t\t\t<FeaturedImage />\n\t\t\t\t\t<PostExcerpt />\n\t\t\t\t\t<DiscussionPanel />\n\t\t\t\t\t<PageAttributes />\n\t\t\t\t\t<MetaBoxes location=\"side\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ isTemplateMode && sidebarName === 'edit-post/document' && (\n\t\t\t\t<TemplateSummary />\n\t\t\t) }\n\t\t\t{ sidebarName === 'edit-post/block' && <BlockInspector /> }\n\t\t</PluginSidebarEditPost>\n\t);\n};\n\nexport default SettingsSidebar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAA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,MAAE,CAAC,EACjB,IAAAF,MAAA,CAAAC,aAAA,EAAC/B,YAAA,CAAAgC,OAAW,MAAE,CAAC,EACf,IAAAF,MAAA,CAAAC,aAAA,EAAC9B,gBAAA,CAAA+B,OAAe,MAAE,CAAC,EACnB,IAAAF,MAAA,CAAAC,aAAA,EAAC7B,eAAA,CAAA8B,OAAc,MAAE,CAAC,EAClB,IAAAF,MAAA,CAAAC,aAAA,EAAC5B,UAAA,CAAA6B,OAAS;IAACe,QAAQ,EAAC;EAAM,CAAE,CAC3B,CACF,EACC/B,cAAc,IAAIF,WAAW,KAAK,oBAAoB,IACvD,IAAAgB,MAAA,CAAAC,aAAA,EAACzB,gBAAA,CAAA0B,OAAe,MAAE,CAClB,EACClB,WAAW,KAAK,iBAAiB,IAAI,IAAAgB,MAAA,CAAAC,aAAA,EAAC7C,YAAA,CAAA8D,cAAc,MAAE,CAClC,CAAC;AAE1B,CAAC;AAAC,IAAAC,QAAA,GAEapC,eAAe;AAAAqC,OAAA,CAAAlB,OAAA,GAAAiB,QAAA"}
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_data","_element","_i18n","_icons","_interface","_keyboardShortcuts","_editor","_settingsHeader","_interopRequireDefault","_postStatus","_lastRevision","_postTaxonomies","_featuredImage","_postExcerpt","_discussionPanel","_pageAttributes","_metaBoxes","_pluginDocumentSettingPanel","_pluginSidebar","_templateSummary","_store","_components","_lockUnlock","Tabs","unlock","componentsPrivateApis","SIDEBAR_ACTIVE_BY_DEFAULT","Platform","select","web","native","sidebars","document","block","exports","SidebarContent","sidebarName","keyboardShortcut","isTemplateMode","tabsContextValue","useContext","Context","_react","createElement","default","identifier","header","Provider","value","closeLabel","__","className","headerClassName","title","toggleShortcut","icon","isRTL","drawerLeft","drawerRight","isActiveByDefault","TabPanel","tabId","focusable","Fragment","Slot","location","BlockInspector","SettingsSidebar","isSettingsSidebarActive","useSelect","sidebar","interfaceStore","getActiveComplementaryArea","editPostStore","name","isSettingsSidebar","includes","blockEditorStore","getBlockSelectionStart","shortcut","keyboardShortcutsStore","getShortcutRepresentation","editorStore","getRenderingMode","openGeneralSidebar","useDispatch","onTabSelect","useCallback","newSelectedTabId","selectedTabId","onSelect","_default"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Platform, useCallback, useContext } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport LastRevision from '../last-revision';\nimport PostTaxonomies from '../post-taxonomies';\nimport FeaturedImage from '../featured-image';\nimport PostExcerpt from '../post-excerpt';\nimport DiscussionPanel from '../discussion-panel';\nimport PageAttributes from '../page-attributes';\nimport MetaBoxes from '../../meta-boxes';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebarEditPost from '../plugin-sidebar';\nimport TemplateSummary from '../template-summary';\nimport { store as editPostStore } from '../../../store';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { unlock } from '../../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\nexport const sidebars = {\n\tdocument: 'edit-post/document',\n\tblock: 'edit-post/block',\n};\n\nconst SidebarContent = ( {\n\tsidebarName,\n\tkeyboardShortcut,\n\tisTemplateMode,\n} ) => {\n\t// Because `PluginSidebarEditPost` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\treturn (\n\t\t<PluginSidebarEditPost\n\t\t\tidentifier={ sidebarName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SettingsHeader />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"edit-post-sidebar__panel\"\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<PostStatus />\n\t\t\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t\t\t<LastRevision />\n\t\t\t\t\t\t\t<PostTaxonomies />\n\t\t\t\t\t\t\t<FeaturedImage />\n\t\t\t\t\t\t\t<PostExcerpt />\n\t\t\t\t\t\t\t<DiscussionPanel />\n\t\t\t\t\t\t\t<PageAttributes />\n\t\t\t\t\t\t\t<MetaBoxes location=\"side\" />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isTemplateMode && <TemplateSummary /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebarEditPost>\n\t);\n};\n\nconst SettingsSidebar = () => {\n\tconst {\n\t\tsidebarName,\n\t\tisSettingsSidebarActive,\n\t\tkeyboardShortcut,\n\t\tisTemplateMode,\n\t} = useSelect( ( select ) => {\n\t\t// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.\n\t\t// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.\n\t\t// If one of the two sidebars is active the component will contain the content of that sidebar.\n\t\t// When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost\n\t\t// component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName\n\t\t// should contain the sidebar that will be active when the toggle button is pressed. If a block\n\t\t// is selected, that should be edit-post/block otherwise it's edit-post/document.\n\t\tlet sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\teditPostStore.name\n\t\t);\n\t\tlet isSettingsSidebar = true;\n\t\tif ( ! [ sidebars.document, sidebars.block ].includes( sidebar ) ) {\n\t\t\tisSettingsSidebar = false;\n\t\t\tif ( select( blockEditorStore ).getBlockSelectionStart() ) {\n\t\t\t\tsidebar = sidebars.block;\n\t\t\t}\n\t\t\tsidebar = sidebars.document;\n\t\t}\n\t\tconst shortcut = select(\n\t\t\tkeyboardShortcutsStore\n\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );\n\t\treturn {\n\t\t\tsidebarName: sidebar,\n\t\t\tisSettingsSidebarActive: isSettingsSidebar,\n\t\t\tkeyboardShortcut: shortcut,\n\t\t\tisTemplateMode:\n\t\t\t\tselect( editorStore ).getRenderingMode() === 'template-only',\n\t\t};\n\t}, [] );\n\n\tconst { openGeneralSidebar } = useDispatch( editPostStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\topenGeneralSidebar( newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ openGeneralSidebar ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop.Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isSettingsSidebarActive ? sidebarName : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\tsidebarName={ sidebarName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tisTemplateMode={ isTemplateMode }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default SettingsSidebar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,eAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,WAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,aAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,eAAA,GAAAH,sBAAA,CAAAT,OAAA;AACA,IAAAa,cAAA,GAAAJ,sBAAA,CAAAT,OAAA;AACA,IAAAc,YAAA,GAAAL,sBAAA,CAAAT,OAAA;AACA,IAAAe,gBAAA,GAAAN,sBAAA,CAAAT,OAAA;AACA,IAAAgB,eAAA,GAAAP,sBAAA,CAAAT,OAAA;AACA,IAAAiB,UAAA,GAAAR,sBAAA,CAAAT,OAAA;AACA,IAAAkB,2BAAA,GAAAT,sBAAA,CAAAT,OAAA;AACA,IAAAmB,cAAA,GAAAV,sBAAA,CAAAT,OA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,IAAM;IACvB,IAAK,CAAC,CAAEA,gBAAgB,EAAG;MAC1BJ,kBAAkB,CAAEI,gBAAiB,CAAC;IACvC;EACD,CAAC,EACD,CAAEJ,kBAAkB,CACrB,CAAC;EAED,OACC,IAAA1C,MAAA,CAAAC,aAAA,EAACpB;EACA;EACA;EACA;EACA;EACA;EAAA;IACAkE,aAAa,EAAGrB,uBAAuB,GAAGhC,WAAW,GAAG,IAAM;IAC9DsD,QAAQ,EAAGJ;EAAa,GAExB,IAAA5C,MAAA,CAAAC,aAAA,EAACR,cAAc;IACdC,WAAW,EAAGA,WAAa;IAC3BC,gBAAgB,EAAGA,gBAAkB;IACrCC,cAAc,EAAGA;EAAgB,CACjC,CACI,CAAC;AAET,CAAC;AAAC,IAAAqD,QAAA,GAEaxB,eAAe;AAAAjC,OAAA,CAAAU,OAAA,GAAA+C,QAAA"}
|
|
@@ -89,13 +89,13 @@ function StartPageOptions() {
|
|
|
89
89
|
const [isClosed, setIsClosed] = (0, _element.useState)(false);
|
|
90
90
|
const shouldEnableModal = (0, _data.useSelect)(select => {
|
|
91
91
|
const {
|
|
92
|
-
isCleanNewPost
|
|
92
|
+
isCleanNewPost,
|
|
93
|
+
getRenderingMode
|
|
93
94
|
} = select(_editor.store);
|
|
94
95
|
const {
|
|
95
|
-
isEditingTemplate,
|
|
96
96
|
isFeatureActive
|
|
97
97
|
} = select(_store.store);
|
|
98
|
-
return
|
|
98
|
+
return getRenderingMode() === 'post-only' && !isFeatureActive('welcomeGuide') && isCleanNewPost();
|
|
99
99
|
}, []);
|
|
100
100
|
if (!shouldEnableModal || isClosed) {
|
|
101
101
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_editor","_store","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","blockEditorStore","getCurrentPostType","editorStore","useMemo","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","useAsyncList","resetEditorBlocks","useDispatch","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","_pattern","blocks","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","Modal","className","title","__","isFullScreen","onRequestClose","StartPageOptions","isClosed","setIsClosed","useState","shouldEnableModal","isCleanNewPost","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_editor","_store","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","blockEditorStore","getCurrentPostType","editorStore","useMemo","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","useAsyncList","resetEditorBlocks","useDispatch","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","_pattern","blocks","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","Modal","className","title","__","isFullScreen","onRequestClose","StartPageOptions","isClosed","setIsClosed","useState","shouldEnableModal","isCleanNewPost","getRenderingMode","isFeatureActive","editPostStore"],"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ onClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst shouldEnableModal = useSelect( ( select ) => {\n\t\tconst { isCleanNewPost, getRenderingMode } = select( editorStore );\n\t\tconst { isFeatureActive } = select( editPostStore );\n\n\t\treturn (\n\t\t\tgetRenderingMode() === 'post-only' &&\n\t\t\t! isFeatureActive( 'welcomeGuide' ) &&\n\t\t\tisCleanNewPost()\n\t\t);\n\t}, [] );\n\n\tif ( ! shouldEnableModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsClosed( true ) } />;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AAjBA;AACA;AACA;;AAYA;AACA;AACA;;AAGA,SAASQ,gBAAgBA,CAAA,EAAG;EAC3B;EACA;EACA;EACA,MAAM;IAAEC,qCAAqC;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EAClEC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAwB,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC;IAC9D,MAAM;MAAEC;IAAmB,CAAC,GAAGH,MAAM,CAAEI,aAAY,CAAC;IACpD,OAAO;MACNP,qCAAqC,EACpCI,uBAAuB,CAAE,mBAAoB,CAAC;MAC/CH,QAAQ,EAAEK,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,OAAO,IAAAE,gBAAO,EAAE,MAAM;IACrB;IACA;IACA,OAAOR,qCAAqC,CAACS,MAAM,CAAIC,OAAO,IAAM;MACnE,OACGT,QAAQ,KAAK,MA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AAGe,aAAe;IAC/Bd,eAAe,EAAGa;EAAS,CAC3B,CACG,CACC,CAAC;AAEV;AAEe,SAASU,gBAAgBA,CAAA,EAAG;EAC1C,MAAM,CAAEC,QAAQ,EAAEC,WAAW,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACnD,MAAMC,iBAAiB,GAAG,IAAA1C,eAAS,EAAIC,MAAM,IAAM;IAClD,MAAM;MAAE0C,cAAc;MAAEC;IAAiB,CAAC,GAAG3C,MAAM,CAAEI,aAAY,CAAC;IAClE,MAAM;MAAEwC;IAAgB,CAAC,GAAG5C,MAAM,CAAE6C,YAAc,CAAC;IAEnD,OACCF,gBAAgB,CAAC,CAAC,KAAK,WAAW,IAClC,CAAEC,eAAe,CAAE,cAAe,CAAC,IACnCF,cAAc,CAAC,CAAC;EAElB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAED,iBAAiB,IAAIH,QAAQ,EAAG;IACtC,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAnB,MAAA,CAAAC,aAAA,EAACM,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMY,WAAW,CAAE,IAAK;EAAG,CAAE,CAAC;AACvE"}
|
|
@@ -8,13 +8,9 @@ exports.default = VisualEditor;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _editor = require("@wordpress/editor");
|
|
11
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
12
11
|
var _element = require("@wordpress/element");
|
|
13
|
-
var _components = require("@wordpress/components");
|
|
14
12
|
var _data = require("@wordpress/data");
|
|
15
|
-
var _compose = require("@wordpress/compose");
|
|
16
13
|
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
var _coreData = require("@wordpress/core-data");
|
|
18
14
|
var _store = require("../../store");
|
|
19
15
|
var _lockUnlock = require("../../lock-unlock");
|
|
20
16
|
/**
|
|
@@ -30,296 +26,63 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
30
26
|
*/
|
|
31
27
|
|
|
32
28
|
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
useLayoutStyles,
|
|
36
|
-
ExperimentalBlockCanvas: BlockCanvas
|
|
37
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
29
|
+
EditorCanvas
|
|
30
|
+
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
38
31
|
const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Given an array of nested blocks, find the first Post Content
|
|
42
|
-
* block inside it, recursing through any nesting levels,
|
|
43
|
-
* and return its attributes.
|
|
44
|
-
*
|
|
45
|
-
* @param {Array} blocks A list of blocks.
|
|
46
|
-
*
|
|
47
|
-
* @return {Object | undefined} The Post Content block.
|
|
48
|
-
*/
|
|
49
|
-
function getPostContentAttributes(blocks) {
|
|
50
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
51
|
-
if (blocks[i].name === 'core/post-content') {
|
|
52
|
-
return blocks[i].attributes;
|
|
53
|
-
}
|
|
54
|
-
if (blocks[i].innerBlocks.length) {
|
|
55
|
-
const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
|
|
56
|
-
if (nestedPostContent) {
|
|
57
|
-
return nestedPostContent;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function checkForPostContentAtRootLevel(blocks) {
|
|
63
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
64
|
-
if (blocks[i].name === 'core/post-content') {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
32
|
function VisualEditor({
|
|
71
33
|
styles
|
|
72
34
|
}) {
|
|
73
35
|
const {
|
|
74
|
-
deviceType,
|
|
75
36
|
isWelcomeGuideVisible,
|
|
76
|
-
|
|
77
|
-
postContentAttributes,
|
|
78
|
-
editedPostTemplate = {},
|
|
79
|
-
wrapperBlockName,
|
|
80
|
-
wrapperUniqueId,
|
|
37
|
+
renderingMode,
|
|
81
38
|
isBlockBasedTheme,
|
|
82
39
|
hasV3BlocksOnly
|
|
83
40
|
} = (0, _data.useSelect)(select => {
|
|
84
41
|
const {
|
|
85
|
-
isFeatureActive
|
|
86
|
-
isEditingTemplate,
|
|
87
|
-
getEditedPostTemplate,
|
|
88
|
-
__experimentalGetPreviewDeviceType
|
|
42
|
+
isFeatureActive
|
|
89
43
|
} = select(_store.store);
|
|
90
44
|
const {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
getEditorSettings
|
|
45
|
+
getEditorSettings,
|
|
46
|
+
getRenderingMode
|
|
94
47
|
} = select(_editor.store);
|
|
95
48
|
const {
|
|
96
49
|
getBlockTypes
|
|
97
50
|
} = select(_blocks.store);
|
|
98
|
-
const _isTemplateMode = isEditingTemplate();
|
|
99
|
-
const postTypeSlug = getCurrentPostType();
|
|
100
|
-
let _wrapperBlockName;
|
|
101
|
-
if (postTypeSlug === 'wp_block') {
|
|
102
|
-
_wrapperBlockName = 'core/block';
|
|
103
|
-
} else if (!_isTemplateMode) {
|
|
104
|
-
_wrapperBlockName = 'core/post-content';
|
|
105
|
-
}
|
|
106
51
|
const editorSettings = getEditorSettings();
|
|
107
|
-
const supportsTemplateMode = editorSettings.supportsTemplateMode;
|
|
108
|
-
const postType = select(_coreData.store).getPostType(postTypeSlug);
|
|
109
|
-
const canEditTemplate = select(_coreData.store).canUser('create', 'templates');
|
|
110
52
|
return {
|
|
111
|
-
deviceType: __experimentalGetPreviewDeviceType(),
|
|
112
53
|
isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
|
|
113
|
-
|
|
114
|
-
postContentAttributes: getEditorSettings().postContentAttributes,
|
|
115
|
-
// Post template fetch returns a 404 on classic themes, which
|
|
116
|
-
// messes with e2e tests, so check it's a block theme first.
|
|
117
|
-
editedPostTemplate: postType?.viewable && supportsTemplateMode && canEditTemplate ? getEditedPostTemplate() : undefined,
|
|
118
|
-
wrapperBlockName: _wrapperBlockName,
|
|
119
|
-
wrapperUniqueId: getCurrentPostId(),
|
|
54
|
+
renderingMode: getRenderingMode(),
|
|
120
55
|
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
|
|
121
56
|
hasV3BlocksOnly: getBlockTypes().every(type => {
|
|
122
57
|
return type.apiVersion >= 3;
|
|
123
58
|
})
|
|
124
59
|
};
|
|
125
60
|
}, []);
|
|
126
|
-
const {
|
|
127
|
-
isCleanNewPost
|
|
128
|
-
} = (0, _data.useSelect)(_editor.store);
|
|
129
61
|
const hasMetaBoxes = (0, _data.useSelect)(select => select(_store.store).hasMetaBoxes(), []);
|
|
130
|
-
const {
|
|
131
|
-
hasRootPaddingAwareAlignments,
|
|
132
|
-
isFocusMode,
|
|
133
|
-
themeHasDisabledLayoutStyles,
|
|
134
|
-
themeSupportsLayout
|
|
135
|
-
} = (0, _data.useSelect)(select => {
|
|
136
|
-
const _settings = select(_blockEditor.store).getSettings();
|
|
137
|
-
return {
|
|
138
|
-
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
139
|
-
themeSupportsLayout: _settings.supportsLayout,
|
|
140
|
-
isFocusMode: _settings.focusMode,
|
|
141
|
-
hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments
|
|
142
|
-
};
|
|
143
|
-
}, []);
|
|
144
|
-
const desktopCanvasStyles = {
|
|
145
|
-
height: '100%',
|
|
146
|
-
width: '100%',
|
|
147
|
-
marginLeft: 'auto',
|
|
148
|
-
marginRight: 'auto',
|
|
149
|
-
display: 'flex',
|
|
150
|
-
flexFlow: 'column',
|
|
151
|
-
// Default background color so that grey
|
|
152
|
-
// .edit-post-editor-regions__content color doesn't show through.
|
|
153
|
-
background: 'white'
|
|
154
|
-
};
|
|
155
|
-
const templateModeStyles = {
|
|
156
|
-
...desktopCanvasStyles,
|
|
157
|
-
borderRadius: '2px 2px 0 0',
|
|
158
|
-
border: '1px solid #ddd',
|
|
159
|
-
borderBottom: 0
|
|
160
|
-
};
|
|
161
|
-
const resizedCanvasStyles = (0, _blockEditor.__experimentalUseResizeCanvas)(deviceType, isTemplateMode);
|
|
162
|
-
const [globalLayoutSettings] = (0, _blockEditor.useSettings)('layout');
|
|
163
|
-
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
164
|
-
let animatedStyles = isTemplateMode ? templateModeStyles : desktopCanvasStyles;
|
|
165
|
-
if (resizedCanvasStyles) {
|
|
166
|
-
animatedStyles = resizedCanvasStyles;
|
|
167
|
-
}
|
|
168
62
|
let paddingBottom;
|
|
169
63
|
|
|
170
64
|
// Add a constant padding for the typewritter effect. When typing at the
|
|
171
65
|
// bottom, there needs to be room to scroll up.
|
|
172
|
-
if (!hasMetaBoxes &&
|
|
66
|
+
if (!hasMetaBoxes && renderingMode === 'post-only') {
|
|
173
67
|
paddingBottom = '40vh';
|
|
174
68
|
}
|
|
175
|
-
const ref = (0, _element.useRef)();
|
|
176
|
-
const contentRef = (0, _compose.useMergeRefs)([ref, (0, _blockEditor.__unstableUseTypewriter)()]);
|
|
177
|
-
|
|
178
|
-
// fallbackLayout is used if there is no Post Content,
|
|
179
|
-
// and for Post Title.
|
|
180
|
-
const fallbackLayout = (0, _element.useMemo)(() => {
|
|
181
|
-
if (isTemplateMode) {
|
|
182
|
-
return {
|
|
183
|
-
type: 'default'
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
if (themeSupportsLayout) {
|
|
187
|
-
// We need to ensure support for wide and full alignments,
|
|
188
|
-
// so we add the constrained type.
|
|
189
|
-
return {
|
|
190
|
-
...globalLayoutSettings,
|
|
191
|
-
type: 'constrained'
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
// Set default layout for classic themes so all alignments are supported.
|
|
195
|
-
return {
|
|
196
|
-
type: 'default'
|
|
197
|
-
};
|
|
198
|
-
}, [isTemplateMode, themeSupportsLayout, globalLayoutSettings]);
|
|
199
|
-
const newestPostContentAttributes = (0, _element.useMemo)(() => {
|
|
200
|
-
if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
|
|
201
|
-
return postContentAttributes;
|
|
202
|
-
}
|
|
203
|
-
// When in template editing mode, we can access the blocks directly.
|
|
204
|
-
if (editedPostTemplate?.blocks) {
|
|
205
|
-
return getPostContentAttributes(editedPostTemplate?.blocks);
|
|
206
|
-
}
|
|
207
|
-
// If there are no blocks, we have to parse the content string.
|
|
208
|
-
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
209
|
-
const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
|
|
210
|
-
return getPostContentAttributes((0, _blocks.parse)(parseableContent)) || {};
|
|
211
|
-
}, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
|
|
212
|
-
const hasPostContentAtRootLevel = (0, _element.useMemo)(() => {
|
|
213
|
-
if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
// When in template editing mode, we can access the blocks directly.
|
|
217
|
-
if (editedPostTemplate?.blocks) {
|
|
218
|
-
return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
|
|
219
|
-
}
|
|
220
|
-
// If there are no blocks, we have to parse the content string.
|
|
221
|
-
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
222
|
-
const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
|
|
223
|
-
return checkForPostContentAtRootLevel((0, _blocks.parse)(parseableContent)) || false;
|
|
224
|
-
}, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
|
|
225
|
-
const {
|
|
226
|
-
layout = {},
|
|
227
|
-
align = ''
|
|
228
|
-
} = newestPostContentAttributes || {};
|
|
229
|
-
const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
|
|
230
|
-
const blockListLayoutClass = (0, _classnames.default)({
|
|
231
|
-
'is-layout-flow': !themeSupportsLayout
|
|
232
|
-
}, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
|
|
233
|
-
const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
|
|
234
|
-
|
|
235
|
-
// Update type for blocks using legacy layouts.
|
|
236
|
-
const postContentLayout = (0, _element.useMemo)(() => {
|
|
237
|
-
return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
|
|
238
|
-
...globalLayoutSettings,
|
|
239
|
-
...layout,
|
|
240
|
-
type: 'constrained'
|
|
241
|
-
} : {
|
|
242
|
-
...globalLayoutSettings,
|
|
243
|
-
...layout,
|
|
244
|
-
type: 'default'
|
|
245
|
-
};
|
|
246
|
-
}, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
|
|
247
|
-
|
|
248
|
-
// If there is a Post Content block we use its layout for the block list;
|
|
249
|
-
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
250
|
-
const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
|
|
251
|
-
const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
|
|
252
|
-
const observeTypingRef = (0, _blockEditor.__unstableUseTypingObserver)();
|
|
253
|
-
const titleRef = (0, _element.useRef)();
|
|
254
|
-
(0, _element.useEffect)(() => {
|
|
255
|
-
if (isWelcomeGuideVisible || !isCleanNewPost()) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
titleRef?.current?.focus();
|
|
259
|
-
}, [isWelcomeGuideVisible, isCleanNewPost]);
|
|
260
69
|
styles = (0, _element.useMemo)(() => [...styles, {
|
|
261
70
|
// We should move this in to future to the body.
|
|
262
|
-
css:
|
|
263
|
-
}], [styles]);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
|
|
267
|
-
.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
|
|
268
|
-
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
|
|
269
|
-
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
|
|
270
|
-
const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || isTemplateMode || deviceType === 'Tablet' || deviceType === 'Mobile';
|
|
271
|
-
return (0, _react.createElement)(_blockEditor.BlockTools, {
|
|
272
|
-
__unstableContentRef: ref,
|
|
71
|
+
css: paddingBottom ? `body{padding-bottom:${paddingBottom}}` : ''
|
|
72
|
+
}], [styles, paddingBottom]);
|
|
73
|
+
const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || renderingMode === 'template-only';
|
|
74
|
+
return (0, _react.createElement)("div", {
|
|
273
75
|
className: (0, _classnames.default)('edit-post-visual-editor', {
|
|
274
|
-
'is-template-mode':
|
|
76
|
+
'is-template-mode': renderingMode === 'template-only',
|
|
275
77
|
'has-inline-canvas': !isToBeIframed
|
|
276
78
|
})
|
|
277
|
-
}, (0, _react.createElement)(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}, (0, _react.createElement)(_components.__unstableMotion.div, {
|
|
283
|
-
animate: animatedStyles,
|
|
284
|
-
initial: desktopCanvasStyles,
|
|
285
|
-
className: previewMode
|
|
286
|
-
}, (0, _react.createElement)(BlockCanvas, {
|
|
287
|
-
shouldIframe: isToBeIframed,
|
|
288
|
-
contentRef: contentRef,
|
|
289
|
-
styles: styles,
|
|
290
|
-
height: "100%"
|
|
291
|
-
}, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(LayoutStyle, {
|
|
292
|
-
selector: ".edit-post-visual-editor__post-title-wrapper",
|
|
293
|
-
layout: fallbackLayout
|
|
294
|
-
}), (0, _react.createElement)(LayoutStyle, {
|
|
295
|
-
selector: ".block-editor-block-list__layout.is-root-container",
|
|
296
|
-
layout: postEditorLayout
|
|
297
|
-
}), align && (0, _react.createElement)(LayoutStyle, {
|
|
298
|
-
css: alignCSS
|
|
299
|
-
}), postContentLayoutStyles && (0, _react.createElement)(LayoutStyle, {
|
|
300
|
-
layout: postContentLayout,
|
|
301
|
-
css: postContentLayoutStyles
|
|
302
|
-
})), !isTemplateMode && (0, _react.createElement)("div", {
|
|
303
|
-
className: (0, _classnames.default)('edit-post-visual-editor__post-title-wrapper', {
|
|
304
|
-
'is-focus-mode': isFocusMode,
|
|
305
|
-
'has-global-padding': hasRootPaddingAwareAlignments
|
|
306
|
-
}),
|
|
307
|
-
contentEditable: false,
|
|
308
|
-
ref: observeTypingRef
|
|
309
|
-
}, (0, _react.createElement)(_editor.PostTitle, {
|
|
310
|
-
ref: titleRef
|
|
311
|
-
})), (0, _react.createElement)(_blockEditor.__experimentalRecursionProvider, {
|
|
312
|
-
blockName: wrapperBlockName,
|
|
313
|
-
uniqueId: wrapperUniqueId
|
|
314
|
-
}, (0, _react.createElement)(_blockEditor.BlockList, {
|
|
315
|
-
className: isTemplateMode ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
79
|
+
}, (0, _react.createElement)(EditorCanvas, {
|
|
80
|
+
disableIframe: !isToBeIframed,
|
|
81
|
+
styles: styles
|
|
82
|
+
// We should auto-focus the canvas (title) on load.
|
|
83
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
316
84
|
,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
dropZoneElement:
|
|
320
|
-
// When iframed, pass in the html element of the iframe to
|
|
321
|
-
// ensure the drop zone extends to the edges of the iframe.
|
|
322
|
-
isToBeIframed ? ref.current?.parentNode : ref.current
|
|
323
|
-
}))))));
|
|
85
|
+
autoFocus: !isWelcomeGuideVisible
|
|
86
|
+
}));
|
|
324
87
|
}
|
|
325
88
|
//# sourceMappingURL=index.js.map
|