@wordpress/editor 13.34.0 → 13.35.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 +10 -4
- package/build/bindings/pattern-overrides.js +70 -1
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +126 -0
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -0
- package/build/components/block-settings-menu/content-only-settings-menu.native.js +11 -0
- package/build/components/block-settings-menu/content-only-settings-menu.native.js.map +1 -0
- package/build/components/collapsible-block-toolbar/index.js +2 -2
- package/build/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build/components/document-bar/index.js +2 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/item.js +2 -2
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/document-tools/index.js +15 -18
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/index.js +19 -8
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/global-styles-provider/index.js +130 -0
- package/build/components/global-styles-provider/index.js.map +1 -0
- package/build/components/header/index.js +147 -0
- package/build/components/header/index.js.map +1 -0
- package/build/components/inserter-sidebar/index.js +56 -31
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/post-actions/actions.js +122 -64
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +7 -14
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +5 -29
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-comments/index.js +28 -8
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-discussion/panel.js +103 -21
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/panel.js +2 -2
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-format/panel.js +27 -0
- package/build/components/post-format/panel.js.map +1 -0
- package/build/components/post-panel-row/index.js +2 -2
- package/build/components/post-panel-row/index.js.map +1 -1
- package/build/components/post-panel-section/index.js +28 -0
- package/build/components/post-panel-section/index.js.map +1 -0
- package/build/components/post-pingbacks/index.js +5 -2
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +2 -2
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-slug/panel.js +27 -0
- package/build/components/post-slug/panel.js.map +1 -0
- package/build/components/post-status/index.js +4 -4
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/panel.js +21 -0
- package/build/components/post-sticky/panel.js.map +1 -0
- package/build/components/post-title/index.js +2 -2
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/post-title-raw.js +2 -2
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-transform-panel/hooks.js +90 -0
- package/build/components/post-transform-panel/hooks.js.map +1 -0
- package/build/components/post-transform-panel/index.js +101 -0
- package/build/components/post-transform-panel/index.js.map +1 -0
- package/build/components/post-trash/panel.js +18 -0
- package/build/components/post-trash/panel.js.map +1 -0
- package/build/components/post-type-support-check/index.js +1 -1
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +3 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +21 -3
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/sidebar/constants.js +11 -0
- package/build/components/sidebar/constants.js.map +1 -0
- package/build/components/sidebar/header.js +53 -0
- package/build/components/sidebar/header.js.map +1 -0
- package/build/components/sidebar/index.js +157 -0
- package/build/components/sidebar/index.js.map +1 -0
- package/build/components/sidebar/post-summary.js +84 -0
- package/build/components/sidebar/post-summary.js.map +1 -0
- package/build/components/start-page-options/index.js +5 -7
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/start-template-options/index.js +192 -0
- package/build/components/start-template-options/index.js.map +1 -0
- package/build/components/template-content-panel/index.js +38 -0
- package/build/components/template-content-panel/index.js.map +1 -0
- package/build/hooks/pattern-overrides.js +10 -5
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/private-apis.js +7 -12
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +72 -0
- package/build/private-apis.native.js.map +1 -0
- package/build/store/private-selectors.js +6 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +15 -0
- package/build/store/reducer.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +69 -1
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +119 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.native.js +5 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.native.js.map +1 -0
- package/build-module/components/collapsible-block-toolbar/index.js +2 -2
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +2 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +2 -2
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/document-tools/index.js +16 -19
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +19 -8
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +120 -0
- package/build-module/components/global-styles-provider/index.js.map +1 -0
- package/build-module/components/header/index.js +139 -0
- package/build-module/components/header/index.js.map +1 -0
- package/build-module/components/inserter-sidebar/index.js +59 -34
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +125 -66
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +7 -14
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +7 -30
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +30 -10
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-discussion/panel.js +105 -23
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +2 -2
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-format/panel.js +18 -0
- package/build-module/components/post-format/panel.js.map +1 -0
- package/build-module/components/post-panel-row/index.js +2 -2
- package/build-module/components/post-panel-row/index.js.map +1 -1
- package/build-module/components/post-panel-section/index.js +20 -0
- package/build-module/components/post-panel-section/index.js.map +1 -0
- package/build-module/components/post-pingbacks/index.js +6 -3
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +2 -2
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-slug/panel.js +18 -0
- package/build-module/components/post-slug/panel.js.map +1 -0
- package/build-module/components/post-status/index.js +4 -4
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/panel.js +12 -0
- package/build-module/components/post-sticky/panel.js.map +1 -0
- package/build-module/components/post-title/index.js +2 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js +2 -2
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-transform-panel/hooks.js +83 -0
- package/build-module/components/post-transform-panel/hooks.js.map +1 -0
- package/build-module/components/post-transform-panel/index.js +94 -0
- package/build-module/components/post-transform-panel/index.js.map +1 -0
- package/build-module/components/post-trash/panel.js +10 -0
- package/build-module/components/post-trash/panel.js.map +1 -0
- package/build-module/components/post-type-support-check/index.js +1 -1
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +3 -3
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +21 -3
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/sidebar/constants.js +5 -0
- package/build-module/components/sidebar/constants.js.map +1 -0
- package/build-module/components/sidebar/header.js +46 -0
- package/build-module/components/sidebar/header.js.map +1 -0
- package/build-module/components/sidebar/index.js +149 -0
- package/build-module/components/sidebar/index.js.map +1 -0
- package/build-module/components/sidebar/post-summary.js +77 -0
- package/build-module/components/sidebar/post-summary.js.map +1 -0
- package/build-module/components/start-page-options/index.js +5 -7
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +185 -0
- package/build-module/components/start-template-options/index.js.map +1 -0
- package/build-module/components/template-content-panel/index.js +31 -0
- package/build-module/components/template-content-panel/index.js.map +1 -0
- package/build-module/hooks/pattern-overrides.js +10 -5
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/private-apis.js +7 -12
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +62 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/store/private-selectors.js +3 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +14 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +328 -18
- package/build-style/style.css +328 -18
- package/package.json +38 -36
- package/src/bindings/pattern-overrides.js +83 -1
- package/src/components/autocompleters/style.scss +1 -2
- package/src/components/block-settings-menu/content-only-settings-menu.js +175 -0
- package/src/components/block-settings-menu/content-only-settings-menu.native.js +4 -0
- package/src/components/block-settings-menu/style.scss +4 -0
- package/src/components/collapsible-block-toolbar/index.js +2 -2
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/item.js +2 -2
- package/src/components/document-tools/index.js +19 -21
- package/src/components/editor-canvas/index.js +18 -6
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/src/components/global-styles-provider/index.js +162 -0
- package/src/components/header/index.js +154 -0
- package/src/components/header/style.scss +231 -0
- package/src/components/inserter-sidebar/index.js +52 -29
- package/src/components/inserter-sidebar/style.scss +10 -3
- package/src/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/src/components/list-view-sidebar/style.scss +1 -0
- package/src/components/page-attributes/test/order.js +5 -1
- package/src/components/post-actions/actions.js +256 -150
- package/src/components/post-actions/index.js +5 -38
- package/src/components/post-card-panel/index.js +39 -85
- package/src/components/post-comments/index.js +47 -9
- package/src/components/post-discussion/panel.js +108 -31
- package/src/components/post-discussion/style.scss +26 -0
- package/src/components/post-excerpt/panel.js +2 -2
- package/src/components/post-format/panel.js +22 -0
- package/src/components/post-format/style.scss +6 -0
- package/src/components/post-last-revision/test/check.js +5 -1
- package/src/components/post-panel-row/index.js +2 -2
- package/src/components/post-panel-section/index.js +19 -0
- package/src/components/post-panel-section/style.scss +3 -0
- package/src/components/post-pingbacks/index.js +11 -2
- package/src/components/post-publish-panel/style.scss +5 -0
- package/src/components/post-saved-state/index.js +2 -2
- package/src/components/post-slug/panel.js +22 -0
- package/src/components/post-slug/style.scss +5 -0
- package/src/components/post-slug/test/index.js +5 -1
- package/src/components/post-status/index.js +4 -4
- package/src/components/post-sticky/panel.js +18 -0
- package/src/components/post-title/index.js +2 -2
- package/src/components/post-title/post-title-raw.js +2 -2
- package/src/components/post-transform-panel/hooks.js +114 -0
- package/src/components/post-transform-panel/index.js +99 -0
- package/src/components/post-trash/panel.js +13 -0
- package/src/components/post-type-support-check/index.js +1 -1
- package/src/components/post-type-support-check/test/index.js +2 -2
- package/src/components/preferences-modal/index.js +3 -3
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/use-block-editor-settings.js +19 -4
- package/src/components/sidebar/constants.js +4 -0
- package/src/components/sidebar/header.js +49 -0
- package/src/components/sidebar/index.js +200 -0
- package/src/components/sidebar/post-summary.js +104 -0
- package/src/components/sidebar/style.scss +18 -0
- package/src/components/start-page-options/index.js +6 -4
- package/src/components/start-template-options/index.js +219 -0
- package/src/components/start-template-options/style.scss +55 -0
- package/src/components/template-areas/style.scss +0 -1
- package/src/components/template-content-panel/index.js +36 -0
- package/src/hooks/pattern-overrides.js +12 -6
- package/src/private-apis.js +10 -12
- package/src/private-apis.native.js +61 -0
- package/src/store/private-selectors.js +3 -0
- package/src/store/reducer.js +12 -0
- package/src/style.scss +7 -0
- package/src/components/post-slug/test/check.js +0 -17
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
var _element = require("@wordpress/element");
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
13
|
+
var _icons = require("@wordpress/icons");
|
|
14
|
+
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
15
|
+
var _components = require("@wordpress/components");
|
|
16
|
+
var _interface = require("@wordpress/interface");
|
|
17
|
+
var _panel = _interopRequireDefault(require("../page-attributes/panel"));
|
|
18
|
+
var _patternOverridesPanel = _interopRequireDefault(require("../pattern-overrides-panel"));
|
|
19
|
+
var _pluginDocumentSettingPanel = _interopRequireDefault(require("../plugin-document-setting-panel"));
|
|
20
|
+
var _pluginSidebar = _interopRequireDefault(require("../plugin-sidebar"));
|
|
21
|
+
var _panel2 = _interopRequireDefault(require("../post-last-revision/panel"));
|
|
22
|
+
var _postSummary = _interopRequireDefault(require("./post-summary"));
|
|
23
|
+
var _panel3 = _interopRequireDefault(require("../post-taxonomies/panel"));
|
|
24
|
+
var _postTransformPanel = _interopRequireDefault(require("../post-transform-panel"));
|
|
25
|
+
var _header = _interopRequireDefault(require("./header"));
|
|
26
|
+
var _templateContentPanel = _interopRequireDefault(require("../template-content-panel"));
|
|
27
|
+
var _useAutoSwitchEditorSidebars = _interopRequireDefault(require("../provider/use-auto-switch-editor-sidebars"));
|
|
28
|
+
var _constants = require("./constants");
|
|
29
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
30
|
+
var _store = require("../../store");
|
|
31
|
+
var _constants2 = require("../../store/constants");
|
|
32
|
+
/**
|
|
33
|
+
* WordPress dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Internal dependencies
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
Tabs
|
|
42
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
43
|
+
const SIDEBAR_ACTIVE_BY_DEFAULT = _element.Platform.select({
|
|
44
|
+
web: true,
|
|
45
|
+
native: false
|
|
46
|
+
});
|
|
47
|
+
const SidebarContent = ({
|
|
48
|
+
tabName,
|
|
49
|
+
keyboardShortcut,
|
|
50
|
+
renderingMode,
|
|
51
|
+
onActionPerformed,
|
|
52
|
+
extraPanels
|
|
53
|
+
}) => {
|
|
54
|
+
const tabListRef = (0, _element.useRef)(null);
|
|
55
|
+
// Because `PluginSidebar` renders a `ComplementaryArea`, we
|
|
56
|
+
// need to forward the `Tabs` context so it can be passed through the
|
|
57
|
+
// underlying slot/fill.
|
|
58
|
+
const tabsContextValue = (0, _element.useContext)(Tabs.Context);
|
|
59
|
+
|
|
60
|
+
// This effect addresses a race condition caused by tabbing from the last
|
|
61
|
+
// block in the editor into the settings sidebar. Without this effect, the
|
|
62
|
+
// selected tab and browser focus can become separated in an unexpected way
|
|
63
|
+
// (e.g the "block" tab is focused, but the "post" tab is selected).
|
|
64
|
+
(0, _element.useEffect)(() => {
|
|
65
|
+
const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
|
|
66
|
+
const selectedTabElement = tabsElements.find(
|
|
67
|
+
// We are purposefully using a custom `data-tab-id` attribute here
|
|
68
|
+
// because we don't want rely on any assumptions about `Tabs`
|
|
69
|
+
// component internals.
|
|
70
|
+
element => element.getAttribute('data-tab-id') === tabName);
|
|
71
|
+
const activeElement = selectedTabElement?.ownerDocument.activeElement;
|
|
72
|
+
const tabsHasFocus = tabsElements.some(element => {
|
|
73
|
+
return activeElement && activeElement.id === element.id;
|
|
74
|
+
});
|
|
75
|
+
if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
|
|
76
|
+
selectedTabElement?.focus();
|
|
77
|
+
}
|
|
78
|
+
}, [tabName]);
|
|
79
|
+
return (0, _react.createElement)(_pluginSidebar.default, {
|
|
80
|
+
identifier: tabName,
|
|
81
|
+
header: (0, _react.createElement)(Tabs.Context.Provider, {
|
|
82
|
+
value: tabsContextValue
|
|
83
|
+
}, (0, _react.createElement)(_header.default, {
|
|
84
|
+
ref: tabListRef
|
|
85
|
+
})),
|
|
86
|
+
closeLabel: (0, _i18n.__)('Close Settings')
|
|
87
|
+
// This classname is added so we can apply a corrective negative
|
|
88
|
+
// margin to the panel.
|
|
89
|
+
// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
|
|
90
|
+
,
|
|
91
|
+
className: "editor-sidebar__panel",
|
|
92
|
+
headerClassName: "editor-sidebar__panel-tabs"
|
|
93
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
94
|
+
title: (0, _i18n.__)('Settings'),
|
|
95
|
+
toggleShortcut: keyboardShortcut,
|
|
96
|
+
icon: (0, _i18n.isRTL)() ? _icons.drawerLeft : _icons.drawerRight,
|
|
97
|
+
isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT
|
|
98
|
+
}, (0, _react.createElement)(Tabs.Context.Provider, {
|
|
99
|
+
value: tabsContextValue
|
|
100
|
+
}, (0, _react.createElement)(Tabs.TabPanel, {
|
|
101
|
+
tabId: _constants.sidebars.document,
|
|
102
|
+
focusable: false
|
|
103
|
+
}, (0, _react.createElement)(_postSummary.default, {
|
|
104
|
+
onActionPerformed: onActionPerformed
|
|
105
|
+
}), (0, _react.createElement)(_pluginDocumentSettingPanel.default.Slot, null), renderingMode !== 'post-only' && (0, _react.createElement)(_templateContentPanel.default, null), (0, _react.createElement)(_postTransformPanel.default, null), (0, _react.createElement)(_panel2.default, null), (0, _react.createElement)(_panel3.default, null), (0, _react.createElement)(_panel.default, null), (0, _react.createElement)(_patternOverridesPanel.default, null), extraPanels), (0, _react.createElement)(Tabs.TabPanel, {
|
|
106
|
+
tabId: _constants.sidebars.block,
|
|
107
|
+
focusable: false
|
|
108
|
+
}, (0, _react.createElement)(_blockEditor.BlockInspector, null))));
|
|
109
|
+
};
|
|
110
|
+
const Sidebar = ({
|
|
111
|
+
extraPanels,
|
|
112
|
+
onActionPerformed
|
|
113
|
+
}) => {
|
|
114
|
+
(0, _useAutoSwitchEditorSidebars.default)();
|
|
115
|
+
const {
|
|
116
|
+
tabName,
|
|
117
|
+
keyboardShortcut,
|
|
118
|
+
showSummary,
|
|
119
|
+
renderingMode
|
|
120
|
+
} = (0, _data.useSelect)(select => {
|
|
121
|
+
const shortcut = select(_keyboardShortcuts.store).getShortcutRepresentation('core/editor/toggle-sidebar');
|
|
122
|
+
const sidebar = select(_interface.store).getActiveComplementaryArea('core');
|
|
123
|
+
const _isEditorSidebarOpened = [_constants.sidebars.block, _constants.sidebars.document].includes(sidebar);
|
|
124
|
+
let _tabName = sidebar;
|
|
125
|
+
if (!_isEditorSidebarOpened) {
|
|
126
|
+
_tabName = !!select(_blockEditor.store).getBlockSelectionStart() ? _constants.sidebars.block : _constants.sidebars.document;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
tabName: _tabName,
|
|
130
|
+
keyboardShortcut: shortcut,
|
|
131
|
+
showSummary: ![_constants2.TEMPLATE_POST_TYPE, _constants2.TEMPLATE_PART_POST_TYPE, _constants2.NAVIGATION_POST_TYPE].includes(select(_store.store).getCurrentPostType()),
|
|
132
|
+
renderingMode: select(_store.store).getRenderingMode()
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
const {
|
|
136
|
+
enableComplementaryArea
|
|
137
|
+
} = (0, _data.useDispatch)(_interface.store);
|
|
138
|
+
const onTabSelect = (0, _element.useCallback)(newSelectedTabId => {
|
|
139
|
+
if (!!newSelectedTabId) {
|
|
140
|
+
enableComplementaryArea('core', newSelectedTabId);
|
|
141
|
+
}
|
|
142
|
+
}, [enableComplementaryArea]);
|
|
143
|
+
return (0, _react.createElement)(Tabs, {
|
|
144
|
+
selectedTabId: tabName,
|
|
145
|
+
onSelect: onTabSelect,
|
|
146
|
+
selectOnMove: false
|
|
147
|
+
}, (0, _react.createElement)(SidebarContent, {
|
|
148
|
+
tabName: tabName,
|
|
149
|
+
keyboardShortcut: keyboardShortcut,
|
|
150
|
+
showSummary: showSummary,
|
|
151
|
+
renderingMode: renderingMode,
|
|
152
|
+
onActionPerformed: onActionPerformed,
|
|
153
|
+
extraPanels: extraPanels
|
|
154
|
+
}));
|
|
155
|
+
};
|
|
156
|
+
var _default = exports.default = Sidebar;
|
|
157
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_data","_element","_i18n","_icons","_keyboardShortcuts","_components","_interface","_panel","_interopRequireDefault","_patternOverridesPanel","_pluginDocumentSettingPanel","_pluginSidebar","_panel2","_postSummary","_panel3","_postTransformPanel","_header","_templateContentPanel","_useAutoSwitchEditorSidebars","_constants","_lockUnlock","_store","_constants2","Tabs","unlock","componentsPrivateApis","SIDEBAR_ACTIVE_BY_DEFAULT","Platform","select","web","native","SidebarContent","tabName","keyboardShortcut","renderingMode","onActionPerformed","extraPanels","tabListRef","useRef","tabsContextValue","useContext","Context","useEffect","tabsElements","Array","from","current","querySelectorAll","selectedTabElement","find","element","getAttribute","activeElement","ownerDocument","tabsHasFocus","some","id","focus","_react","createElement","default","identifier","header","Provider","value","ref","closeLabel","__","className","headerClassName","title","toggleShortcut","icon","isRTL","drawerLeft","drawerRight","isActiveByDefault","TabPanel","tabId","sidebars","document","focusable","Slot","block","BlockInspector","Sidebar","useAutoSwitchEditorSidebars","showSummary","useSelect","shortcut","keyboardShortcutsStore","getShortcutRepresentation","sidebar","interfaceStore","getActiveComplementaryArea","_isEditorSidebarOpened","includes","_tabName","blockEditorStore","getBlockSelectionStart","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","NAVIGATION_POST_TYPE","editorStore","getCurrentPostType","getRenderingMode","enableComplementaryArea","useDispatch","onTabSelect","useCallback","newSelectedTabId","selectedTabId","onSelect","selectOnMove","_default","exports"],"sources":["@wordpress/editor/src/components/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 {\n\tPlatform,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PageAttributesPanel from '../page-attributes/panel';\nimport PatternOverridesPanel from '../pattern-overrides-panel';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebar from '../plugin-sidebar';\nimport PostLastRevisionPanel from '../post-last-revision/panel';\nimport PostSummary from './post-summary';\nimport PostTaxonomiesPanel from '../post-taxonomies/panel';\nimport PostTransformPanel from '../post-transform-panel';\nimport SidebarHeader from './header';\nimport TemplateContentPanel from '../template-content-panel';\nimport useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-sidebars';\nimport { sidebars } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst SidebarContent = ( {\n\ttabName,\n\tkeyboardShortcut,\n\trenderingMode,\n\tonActionPerformed,\n\textraPanels,\n} ) => {\n\tconst tabListRef = useRef( null );\n\t// Because `PluginSidebar` 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\t// This effect addresses a race condition caused by tabbing from the last\n\t// block in the editor into the settings sidebar. Without this effect, the\n\t// selected tab and browser focus can become separated in an unexpected way\n\t// (e.g the \"block\" tab is focused, but the \"post\" tab is selected).\n\tuseEffect( () => {\n\t\tconst tabsElements = Array.from(\n\t\t\ttabListRef.current?.querySelectorAll( '[role=\"tab\"]' ) || []\n\t\t);\n\t\tconst selectedTabElement = tabsElements.find(\n\t\t\t// We are purposefully using a custom `data-tab-id` attribute here\n\t\t\t// because we don't want rely on any assumptions about `Tabs`\n\t\t\t// component internals.\n\t\t\t( element ) => element.getAttribute( 'data-tab-id' ) === tabName\n\t\t);\n\t\tconst activeElement = selectedTabElement?.ownerDocument.activeElement;\n\t\tconst tabsHasFocus = tabsElements.some( ( element ) => {\n\t\t\treturn activeElement && activeElement.id === element.id;\n\t\t} );\n\t\tif (\n\t\t\ttabsHasFocus &&\n\t\t\tselectedTabElement &&\n\t\t\tselectedTabElement.id !== activeElement?.id\n\t\t) {\n\t\t\tselectedTabElement?.focus();\n\t\t}\n\t}, [ tabName ] );\n\n\treturn (\n\t\t<PluginSidebar\n\t\t\tidentifier={ tabName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader ref={ tabListRef } />\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=\"editor-sidebar__panel\"\n\t\t\theaderClassName=\"editor-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<PostSummary onActionPerformed={ onActionPerformed } />\n\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t{ renderingMode !== 'post-only' && (\n\t\t\t\t\t\t<TemplateContentPanel />\n\t\t\t\t\t) }\n\t\t\t\t\t<PostTransformPanel />\n\t\t\t\t\t<PostLastRevisionPanel />\n\t\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t\t<PageAttributesPanel />\n\t\t\t\t\t<PatternOverridesPanel />\n\t\t\t\t\t{ extraPanels }\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</PluginSidebar>\n\t);\n};\n\nconst Sidebar = ( { extraPanels, onActionPerformed } ) => {\n\tuseAutoSwitchEditorSidebars();\n\tconst { tabName, keyboardShortcut, showSummary, renderingMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' );\n\n\t\t\tconst sidebar =\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tsidebars.block,\n\t\t\t\tsidebars.document,\n\t\t\t].includes( sidebar );\n\t\t\tlet _tabName = sidebar;\n\t\t\tif ( ! _isEditorSidebarOpened ) {\n\t\t\t\t_tabName = !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart()\n\t\t\t\t\t? sidebars.block\n\t\t\t\t\t: sidebars.document;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttabName: _tabName,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tshowSummary: ! [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t\tNAVIGATION_POST_TYPE,\n\t\t\t\t].includes( select( editorStore ).getCurrentPostType() ),\n\t\t\t\trenderingMode: select( editorStore ).getRenderingMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea( 'core', newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\tselectedTabId={ tabName }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\ttabName={ tabName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tshowSummary={ showSummary }\n\t\t\t\trenderingMode={ renderingMode }\n\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\textraPanels={ extraPanels }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default Sidebar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAOA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,sBAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,2BAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,cAAA,GAAAH,sBAAA,CAAAT,OAAA;AACA,IAAAa,OAAA,GAAAJ,sBAAA,CAAAT,OAAA;AACA,IAAAc,YAAA,GAAAL,sBAAA,CAAAT,OAAA;AACA,IAAAe,OAAA,GAAAN,sBAAA,CAAAT,OAAA;AACA,IAAAgB,mBAAA,GAAAP,sBAAA,CAAAT,OAAA;AACA,IAAAiB,OAAA,GAAAR,sBAAA,CAAAT,OAAA;AACA,IAAAkB,qBAAA,GAAAT,sBAAA,CAAAT,OAAA;AACA,IAAAmB,4BAAA,GAAAV,sBAAA,CAAAT,OAAA;AACA,IAAAoB,UAAA,GAAApB,OAAA;AACA,IAAAqB,WAAA,GAAArB,OAAA;AACA,IAAAsB,MAAA,GAAAtB,OAAA;AACA,IAAAuB,WAAA,GAAAvB,OAAA;AAtCA;AACA;AACA;;AAmBA;AACA;AACA;;AAqBA,MAAM;EAAEwB;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBA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1BF,WAAW,EAAE,CAAE,CACda,8BAAkB,EAClBC,mCAAuB,EACvBC,gCAAoB,CACpB,CAACN,QAAQ,CAAEpE,MAAM,CAAE2E,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAE,CAAC;MACxDtE,aAAa,EAAEN,MAAM,CAAE2E,YAAY,CAAC,CAACE,gBAAgB,CAAC;IACvD,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,MAAM;IAAEC;EAAwB,CAAC,GAAG,IAAAC,iBAAW,EAAEd,gBAAe,CAAC;EAEjE,MAAMe,WAAW,GAAG,IAAAC,oBAAW,EAC5BC,gBAAgB,IAAM;IACvB,IAAK,CAAC,CAAEA,gBAAgB,EAAG;MAC1BJ,uBAAuB,CAAE,MAAM,EAAEI,gBAAiB,CAAC;IACpD;EACD,CAAC,EACD,CAAEJ,uBAAuB,CAC1B,CAAC;EAED,OACC,IAAAhD,MAAA,CAAAC,aAAA,EAACpC,IAAI;IACJwF,aAAa,EAAG/E,OAAS;IACzBgF,QAAQ,EAAGJ,WAAa;IACxBK,YAAY,EAAG;EAAO,GAEtB,IAAAvD,MAAA,CAAAC,aAAA,EAAC5B,cAAc;IACdC,OAAO,EAAGA,OAAS;IACnBC,gBAAgB,EAAGA,gBAAkB;IACrCsD,WAAW,EAAGA,WAAa;IAC3BrD,aAAa,EAAGA,aAAe;IAC/BC,iBAAiB,EAAGA,iBAAmB;IACvCC,WAAW,EAAGA;EAAa,CAC3B,CACI,CAAC;AAET,CAAC;AAAC,IAAA8E,QAAA,GAAAC,OAAA,CAAAvD,OAAA,GAEayB,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = PostSummary;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
var _pluginPostStatusInfo = _interopRequireDefault(require("../plugin-post-status-info"));
|
|
12
|
+
var _postActions = _interopRequireDefault(require("../post-actions"));
|
|
13
|
+
var _panel = _interopRequireDefault(require("../post-author/panel"));
|
|
14
|
+
var _postCardPanel = _interopRequireDefault(require("../post-card-panel"));
|
|
15
|
+
var _postContentInformation = _interopRequireDefault(require("../post-content-information"));
|
|
16
|
+
var _panel2 = _interopRequireDefault(require("../post-discussion/panel"));
|
|
17
|
+
var _panel3 = require("../post-excerpt/panel");
|
|
18
|
+
var _panel4 = _interopRequireDefault(require("../post-featured-image/panel"));
|
|
19
|
+
var _panel5 = _interopRequireDefault(require("../post-format/panel"));
|
|
20
|
+
var _postLastEditedPanel = _interopRequireDefault(require("../post-last-edited-panel"));
|
|
21
|
+
var _postPanelSection = _interopRequireDefault(require("../post-panel-section"));
|
|
22
|
+
var _panel6 = _interopRequireDefault(require("../post-schedule/panel"));
|
|
23
|
+
var _postStatus = _interopRequireDefault(require("../post-status"));
|
|
24
|
+
var _postSticky = _interopRequireDefault(require("../post-sticky"));
|
|
25
|
+
var _postSyncStatus = _interopRequireDefault(require("../post-sync-status"));
|
|
26
|
+
var _panel7 = _interopRequireDefault(require("../post-template/panel"));
|
|
27
|
+
var _panel8 = _interopRequireDefault(require("../post-trash/panel"));
|
|
28
|
+
var _panel9 = _interopRequireDefault(require("../post-url/panel"));
|
|
29
|
+
var _store = require("../../store");
|
|
30
|
+
var _constants = require("../../store/constants");
|
|
31
|
+
var _templateAreas = _interopRequireDefault(require("../template-areas"));
|
|
32
|
+
/**
|
|
33
|
+
* WordPress dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Internal dependencies
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Module Constants
|
|
42
|
+
*/
|
|
43
|
+
const PANEL_NAME = 'post-status';
|
|
44
|
+
function PostSummary({
|
|
45
|
+
onActionPerformed
|
|
46
|
+
}) {
|
|
47
|
+
const {
|
|
48
|
+
isRemovedPostStatusPanel,
|
|
49
|
+
postType
|
|
50
|
+
} = (0, _data.useSelect)(select => {
|
|
51
|
+
// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
|
|
52
|
+
// not use isEditorPanelEnabled since this panel should not be disabled through the UI.
|
|
53
|
+
const {
|
|
54
|
+
isEditorPanelRemoved,
|
|
55
|
+
getCurrentPostType
|
|
56
|
+
} = select(_store.store);
|
|
57
|
+
return {
|
|
58
|
+
isRemovedPostStatusPanel: isEditorPanelRemoved(PANEL_NAME),
|
|
59
|
+
postType: getCurrentPostType()
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
const isPattern = postType === _constants.PATTERN_POST_TYPE;
|
|
63
|
+
const isTemplate = postType === _constants.TEMPLATE_POST_TYPE;
|
|
64
|
+
const isTemplatePart = postType === _constants.TEMPLATE_PART_POST_TYPE;
|
|
65
|
+
const isNavigation = postType === _constants.NAVIGATION_POST_TYPE;
|
|
66
|
+
return (0, _react.createElement)(_postPanelSection.default, {
|
|
67
|
+
className: "editor-post-summary"
|
|
68
|
+
}, (0, _react.createElement)(_pluginPostStatusInfo.default.Slot, null, fills => (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.__experimentalVStack, {
|
|
69
|
+
spacing: 4
|
|
70
|
+
}, (0, _react.createElement)(_postCardPanel.default, {
|
|
71
|
+
actions: (0, _react.createElement)(_postActions.default, {
|
|
72
|
+
onActionPerformed: onActionPerformed
|
|
73
|
+
})
|
|
74
|
+
}), (0, _react.createElement)(_panel4.default, {
|
|
75
|
+
withPanelBody: false
|
|
76
|
+
}), (0, _react.createElement)(_panel3.PrivatePostExcerptPanel, null), (0, _react.createElement)(_components.__experimentalVStack, {
|
|
77
|
+
spacing: 1
|
|
78
|
+
}, (0, _react.createElement)(_postContentInformation.default, null), (0, _react.createElement)(_postLastEditedPanel.default, null)), !isRemovedPostStatusPanel && (0, _react.createElement)(_components.__experimentalVStack, {
|
|
79
|
+
spacing: 2
|
|
80
|
+
}, (0, _react.createElement)(_components.__experimentalVStack, {
|
|
81
|
+
spacing: 1
|
|
82
|
+
}, (0, _react.createElement)(_postStatus.default, null), (0, _react.createElement)(_panel6.default, null), (0, _react.createElement)(_panel7.default, null), (0, _react.createElement)(_panel9.default, null), (0, _react.createElement)(_panel2.default, null), (0, _react.createElement)(_postSyncStatus.default, null)), (0, _react.createElement)(_postSticky.default, null), (0, _react.createElement)(_panel5.default, null), (0, _react.createElement)(_panel.default, null), isTemplate && (0, _react.createElement)(_templateAreas.default, null), fills, !isPattern && !isTemplate && !isTemplatePart && !isNavigation && (0, _react.createElement)(_panel8.default, null))))));
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=post-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_pluginPostStatusInfo","_interopRequireDefault","_postActions","_panel","_postCardPanel","_postContentInformation","_panel2","_panel3","_panel4","_panel5","_postLastEditedPanel","_postPanelSection","_panel6","_postStatus","_postSticky","_postSyncStatus","_panel7","_panel8","_panel9","_store","_constants","_templateAreas","PANEL_NAME","PostSummary","onActionPerformed","isRemovedPostStatusPanel","postType","useSelect","select","isEditorPanelRemoved","getCurrentPostType","editorStore","isPattern","PATTERN_POST_TYPE","isTemplate","TEMPLATE_POST_TYPE","isTemplatePart","TEMPLATE_PART_POST_TYPE","isNavigation","NAVIGATION_POST_TYPE","_react","createElement","default","className","Slot","fills","Fragment","__experimentalVStack","spacing","actions","withPanelBody","PrivatePostExcerptPanel"],"sources":["@wordpress/editor/src/components/sidebar/post-summary.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PluginPostStatusInfo from '../plugin-post-status-info';\nimport PostActions from '../post-actions';\nimport PostAuthorPanel from '../post-author/panel';\nimport PostCardPanel from '../post-card-panel';\nimport PostContentInformation from '../post-content-information';\nimport PostDiscussionPanel from '../post-discussion/panel';\nimport { PrivatePostExcerptPanel as PostExcerptPanel } from '../post-excerpt/panel';\nimport PostFeaturedImagePanel from '../post-featured-image/panel';\nimport PostFormatPanel from '../post-format/panel';\nimport PostLastEditedPanel from '../post-last-edited-panel';\nimport PostPanelSection from '../post-panel-section';\nimport PostSchedulePanel from '../post-schedule/panel';\nimport PostStatusPanel from '../post-status';\nimport PostStickyPanel from '../post-sticky';\nimport PostSyncStatus from '../post-sync-status';\nimport PostTemplatePanel from '../post-template/panel';\nimport PostTrashPanel from '../post-trash/panel';\nimport PostURLPanel from '../post-url/panel';\nimport { store as editorStore } from '../../store';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\nimport TemplateAreas from '../template-areas';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-status';\n\nexport default function PostSummary( { onActionPerformed } ) {\n\tconst { isRemovedPostStatusPanel, postType } = useSelect( ( select ) => {\n\t\t// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do\n\t\t// not use isEditorPanelEnabled since this panel should not be disabled through the UI.\n\t\tconst { isEditorPanelRemoved, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisRemovedPostStatusPanel: isEditorPanelRemoved( PANEL_NAME ),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\tconst isPattern = postType === PATTERN_POST_TYPE;\n\tconst isTemplate = postType === TEMPLATE_POST_TYPE;\n\tconst isTemplatePart = postType === TEMPLATE_PART_POST_TYPE;\n\tconst isNavigation = postType === NAVIGATION_POST_TYPE;\n\n\treturn (\n\t\t<PostPanelSection className=\"editor-post-summary\">\n\t\t\t<PluginPostStatusInfo.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t<PostCardPanel\n\t\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\t\t<PostActions\n\t\t\t\t\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<PostFeaturedImagePanel withPanelBody={ false } />\n\t\t\t\t\t\t\t<PostExcerptPanel />\n\t\t\t\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t\t\t\t<PostContentInformation />\n\t\t\t\t\t\t\t\t<PostLastEditedPanel />\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t{ ! isRemovedPostStatusPanel && (\n\t\t\t\t\t\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t\t\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t\t\t\t\t\t<PostStatusPanel />\n\t\t\t\t\t\t\t\t\t\t<PostSchedulePanel />\n\t\t\t\t\t\t\t\t\t\t<PostTemplatePanel />\n\t\t\t\t\t\t\t\t\t\t<PostURLPanel />\n\t\t\t\t\t\t\t\t\t\t<PostDiscussionPanel />\n\t\t\t\t\t\t\t\t\t\t<PostSyncStatus />\n\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t<PostStickyPanel />\n\t\t\t\t\t\t\t\t\t<PostFormatPanel />\n\t\t\t\t\t\t\t\t\t<PostAuthorPanel />\n\t\t\t\t\t\t\t\t\t{ isTemplate && <TemplateAreas /> }\n\t\t\t\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t\t\t\t{ ! isPattern &&\n\t\t\t\t\t\t\t\t\t\t! isTemplate &&\n\t\t\t\t\t\t\t\t\t\t! isTemplatePart &&\n\t\t\t\t\t\t\t\t\t\t! isNavigation && <PostTrashPanel /> }\n\t\t\t\t\t\t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,KAAK,EACL,CAAEb,SAAS,IACZ,CAAEE,UAAU,IACZ,CAAEE,cAAc,IAChB,CAAEE,YAAY,IAAI,IAAAE,MAAA,CAAAC,aAAA,EAACxB,OAAA,CAAAyB,OAAc,MAAE,CAC7B,CAEF,CACP,CAEuB,CACV,CAAC;AAErB","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ var _compose = require("@wordpress/compose");
|
|
|
14
14
|
var _coreData = require("@wordpress/core-data");
|
|
15
15
|
var _blocks = require("@wordpress/blocks");
|
|
16
16
|
var _store = require("../../store");
|
|
17
|
+
var _constants = require("../../store/constants");
|
|
17
18
|
/**
|
|
18
19
|
* WordPress dependencies
|
|
19
20
|
*/
|
|
@@ -117,15 +118,12 @@ function StartPageOptions() {
|
|
|
117
118
|
isEditedPostDirty,
|
|
118
119
|
isEditedPostEmpty,
|
|
119
120
|
getCurrentPostType,
|
|
120
|
-
getCurrentPostId
|
|
121
|
-
getEditorSettings
|
|
121
|
+
getCurrentPostId
|
|
122
122
|
} = select(_store.store);
|
|
123
|
-
const
|
|
124
|
-
__unstableIsPreviewMode: isPreviewMode
|
|
125
|
-
} = getEditorSettings();
|
|
123
|
+
const _postType = getCurrentPostType();
|
|
126
124
|
return {
|
|
127
|
-
shouldEnableModal: !
|
|
128
|
-
postType:
|
|
125
|
+
shouldEnableModal: !isEditedPostDirty() && isEditedPostEmpty() && _constants.TEMPLATE_POST_TYPE !== _postType,
|
|
126
|
+
postType: _postType,
|
|
129
127
|
postId: getCurrentPostId()
|
|
130
128
|
};
|
|
131
129
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_coreData","_blocks","_store","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","getBlocksByName","blockEditorStore","getCurrentPostType","getRenderingMode","editorStore","rootClientId","useMemo","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","useAsyncList","editEntityRecord","useDispatch","coreStore","postId","getCurrentPostId","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","_pattern","blocks","content","blocksForSerialization","__unstableSerializeAndClean","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","Modal","title","__","isFullScreen","onRequestClose","className","StartPageOptions","isClosed","setIsClosed","useState","shouldEnableModal","isEditedPostDirty","isEditedPostEmpty","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_coreData","_blocks","_store","_constants","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","getBlocksByName","blockEditorStore","getCurrentPostType","getRenderingMode","editorStore","rootClientId","useMemo","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","useAsyncList","editEntityRecord","useDispatch","coreStore","postId","getCurrentPostId","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","_pattern","blocks","content","blocksForSerialization","__unstableSerializeAndClean","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","Modal","title","__","isFullScreen","onRequestClose","className","StartPageOptions","isClosed","setIsClosed","useState","shouldEnableModal","isEditedPostDirty","isEditedPostEmpty","_postType","TEMPLATE_POST_TYPE","useEffect"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } 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 coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\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, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\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 { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\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\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\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\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"editor-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, postType, postId } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditedPostDirty,\n\t\t\tisEditedPostEmpty,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t} = select( editorStore );\n\t\tconst _postType = getCurrentPostType();\n\n\t\treturn {\n\t\t\tshouldEnableModal:\n\t\t\t\t! isEditedPostDirty() &&\n\t\t\t\tisEditedPostEmpty() &&\n\t\t\t\tTEMPLATE_POST_TYPE !== _postType,\n\t\t\tpostType: _postType,\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Should reset the modal state when navigating to a new page/post.\n\t\tsetIsClosed( false );\n\t}, [ postType, postId ] );\n\n\tif ( ! shouldEnableModal || isClosed ) {\n\t\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ACZ;EAEA,OAAO,IAAAtB,MAAA,CAAAC,aAAA,EAACS,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMY,WAAW,CAAE,IAAK;EAAG,CAAE,CAAC;AACvE","ignoreList":[]}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = StartTemplateOptions;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _components = require("@wordpress/components");
|
|
9
|
+
var _i18n = require("@wordpress/i18n");
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
var _compose = require("@wordpress/compose");
|
|
14
|
+
var _blocks = require("@wordpress/blocks");
|
|
15
|
+
var _coreData = require("@wordpress/core-data");
|
|
16
|
+
var _store = require("../../store");
|
|
17
|
+
var _constants = require("../../store/constants");
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function useFallbackTemplateContent(slug, isCustom = false) {
|
|
27
|
+
return (0, _data.useSelect)(select => {
|
|
28
|
+
const {
|
|
29
|
+
getEntityRecord,
|
|
30
|
+
getDefaultTemplateId
|
|
31
|
+
} = select(_coreData.store);
|
|
32
|
+
const templateId = getDefaultTemplateId({
|
|
33
|
+
slug,
|
|
34
|
+
is_custom: isCustom,
|
|
35
|
+
ignore_empty: true
|
|
36
|
+
});
|
|
37
|
+
return templateId ? getEntityRecord('postType', _constants.TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
|
|
38
|
+
}, [slug, isCustom]);
|
|
39
|
+
}
|
|
40
|
+
function useStartPatterns(fallbackContent) {
|
|
41
|
+
const {
|
|
42
|
+
slug,
|
|
43
|
+
patterns
|
|
44
|
+
} = (0, _data.useSelect)(select => {
|
|
45
|
+
const {
|
|
46
|
+
getCurrentPostType,
|
|
47
|
+
getCurrentPostId
|
|
48
|
+
} = select(_store.store);
|
|
49
|
+
const {
|
|
50
|
+
getEntityRecord,
|
|
51
|
+
getBlockPatterns
|
|
52
|
+
} = select(_coreData.store);
|
|
53
|
+
const postId = getCurrentPostId();
|
|
54
|
+
const postType = getCurrentPostType();
|
|
55
|
+
const record = getEntityRecord('postType', postType, postId);
|
|
56
|
+
return {
|
|
57
|
+
slug: record.slug,
|
|
58
|
+
patterns: getBlockPatterns()
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
const currentThemeStylesheet = (0, _data.useSelect)(select => select(_coreData.store).getCurrentTheme().stylesheet);
|
|
62
|
+
|
|
63
|
+
// Duplicated from packages/block-library/src/pattern/edit.js.
|
|
64
|
+
function injectThemeAttributeInBlockTemplateContent(block) {
|
|
65
|
+
if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
|
|
66
|
+
block.innerBlocks = block.innerBlocks.map(innerBlock => {
|
|
67
|
+
if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
|
|
68
|
+
innerBlock.attributes.theme = currentThemeStylesheet;
|
|
69
|
+
}
|
|
70
|
+
return innerBlock;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
|
|
74
|
+
block.attributes.theme = currentThemeStylesheet;
|
|
75
|
+
}
|
|
76
|
+
return block;
|
|
77
|
+
}
|
|
78
|
+
return (0, _element.useMemo)(() => {
|
|
79
|
+
// filter patterns that are supposed to be used in the current template being edited.
|
|
80
|
+
return [{
|
|
81
|
+
name: 'fallback',
|
|
82
|
+
blocks: (0, _blocks.parse)(fallbackContent),
|
|
83
|
+
title: (0, _i18n.__)('Fallback content')
|
|
84
|
+
}, ...patterns.filter(pattern => {
|
|
85
|
+
return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
|
|
86
|
+
}).map(pattern => {
|
|
87
|
+
return {
|
|
88
|
+
...pattern,
|
|
89
|
+
blocks: (0, _blocks.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
|
|
90
|
+
};
|
|
91
|
+
})];
|
|
92
|
+
}, [fallbackContent, slug, patterns]);
|
|
93
|
+
}
|
|
94
|
+
function PatternSelection({
|
|
95
|
+
fallbackContent,
|
|
96
|
+
onChoosePattern,
|
|
97
|
+
postType
|
|
98
|
+
}) {
|
|
99
|
+
const [,, onChange] = (0, _coreData.useEntityBlockEditor)('postType', postType);
|
|
100
|
+
const blockPatterns = useStartPatterns(fallbackContent);
|
|
101
|
+
const shownBlockPatterns = (0, _compose.useAsyncList)(blockPatterns);
|
|
102
|
+
return (0, _react.createElement)(_blockEditor.__experimentalBlockPatternsList, {
|
|
103
|
+
blockPatterns: blockPatterns,
|
|
104
|
+
shownPatterns: shownBlockPatterns,
|
|
105
|
+
onClickPattern: (pattern, blocks) => {
|
|
106
|
+
onChange(blocks, {
|
|
107
|
+
selection: undefined
|
|
108
|
+
});
|
|
109
|
+
onChoosePattern();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function StartModal({
|
|
114
|
+
slug,
|
|
115
|
+
isCustom,
|
|
116
|
+
onClose,
|
|
117
|
+
postType
|
|
118
|
+
}) {
|
|
119
|
+
const fallbackContent = useFallbackTemplateContent(slug, isCustom);
|
|
120
|
+
if (!fallbackContent) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return (0, _react.createElement)(_components.Modal, {
|
|
124
|
+
className: "editor-start-template-options__modal",
|
|
125
|
+
title: (0, _i18n.__)('Choose a pattern'),
|
|
126
|
+
closeLabel: (0, _i18n.__)('Cancel'),
|
|
127
|
+
focusOnMount: "firstElement",
|
|
128
|
+
onRequestClose: onClose,
|
|
129
|
+
isFullScreen: true
|
|
130
|
+
}, (0, _react.createElement)("div", {
|
|
131
|
+
className: "editor-start-template-options__modal-content"
|
|
132
|
+
}, (0, _react.createElement)(PatternSelection, {
|
|
133
|
+
fallbackContent: fallbackContent,
|
|
134
|
+
slug: slug,
|
|
135
|
+
isCustom: isCustom,
|
|
136
|
+
postType: postType,
|
|
137
|
+
onChoosePattern: () => {
|
|
138
|
+
onClose();
|
|
139
|
+
}
|
|
140
|
+
})), (0, _react.createElement)(_components.Flex, {
|
|
141
|
+
className: "editor-start-template-options__modal__actions",
|
|
142
|
+
justify: "flex-end",
|
|
143
|
+
expanded: false
|
|
144
|
+
}, (0, _react.createElement)(_components.FlexItem, null, (0, _react.createElement)(_components.Button, {
|
|
145
|
+
variant: "tertiary",
|
|
146
|
+
onClick: onClose
|
|
147
|
+
}, (0, _i18n.__)('Skip')))));
|
|
148
|
+
}
|
|
149
|
+
function StartTemplateOptions() {
|
|
150
|
+
const [isClosed, setIsClosed] = (0, _element.useState)(false);
|
|
151
|
+
const {
|
|
152
|
+
shouldOpenModal,
|
|
153
|
+
slug,
|
|
154
|
+
isCustom,
|
|
155
|
+
postType,
|
|
156
|
+
postId
|
|
157
|
+
} = (0, _data.useSelect)(select => {
|
|
158
|
+
const {
|
|
159
|
+
getCurrentPostType,
|
|
160
|
+
getCurrentPostId
|
|
161
|
+
} = select(_store.store);
|
|
162
|
+
const _postType = getCurrentPostType();
|
|
163
|
+
const _postId = getCurrentPostId();
|
|
164
|
+
const {
|
|
165
|
+
getEditedEntityRecord,
|
|
166
|
+
hasEditsForEntityRecord
|
|
167
|
+
} = select(_coreData.store);
|
|
168
|
+
const templateRecord = getEditedEntityRecord('postType', _postType, _postId);
|
|
169
|
+
const hasEdits = hasEditsForEntityRecord('postType', _postType, _postId);
|
|
170
|
+
return {
|
|
171
|
+
shouldOpenModal: !hasEdits && '' === templateRecord.content && _constants.TEMPLATE_POST_TYPE === _postType,
|
|
172
|
+
slug: templateRecord.slug,
|
|
173
|
+
isCustom: templateRecord.is_custom,
|
|
174
|
+
postType: _postType,
|
|
175
|
+
postId: _postId
|
|
176
|
+
};
|
|
177
|
+
}, []);
|
|
178
|
+
(0, _element.useEffect)(() => {
|
|
179
|
+
// Should reset the modal state when navigating to a new page/post.
|
|
180
|
+
setIsClosed(false);
|
|
181
|
+
}, [postType, postId]);
|
|
182
|
+
if (!shouldOpenModal || isClosed) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return (0, _react.createElement)(StartModal, {
|
|
186
|
+
slug: slug,
|
|
187
|
+
isCustom: isCustom,
|
|
188
|
+
postType: postType,
|
|
189
|
+
onClose: () => setIsClosed(true)
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_compose","_blocks","_coreData","_store","_constants","useFallbackTemplateContent","slug","isCustom","useSelect","select","getEntityRecord","getDefaultTemplateId","coreStore","templateId","is_custom","ignore_empty","TEMPLATE_POST_TYPE","content","raw","undefined","useStartPatterns","fallbackContent","patterns","getCurrentPostType","getCurrentPostId","editorStore","getBlockPatterns","postId","postType","record","currentThemeStylesheet","getCurrentTheme","stylesheet","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","attributes","theme","useMemo","blocks","parse","title","__","filter","pattern","Array","isArray","templateTypes","some","templateType","startsWith","PatternSelection","onChoosePattern","onChange","useEntityBlockEditor","blockPatterns","shownBlockPatterns","useAsyncList","_react","createElement","__experimentalBlockPatternsList","shownPatterns","onClickPattern","selection","StartModal","onClose","Modal","className","closeLabel","focusOnMount","onRequestClose","isFullScreen","Flex","justify","expanded","FlexItem","Button","variant","onClick","StartTemplateOptions","isClosed","setIsClosed","useState","shouldOpenModal","_postType","_postId","getEditedEntityRecord","hasEditsForEntityRecord","templateRecord","hasEdits","useEffect"],"sources":["@wordpress/editor/src/components/start-template-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal, Flex, FlexItem, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getDefaultTemplateId } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateId = getDefaultTemplateId( {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} );\n\t\t\treturn templateId\n\t\t\t\t? getEntityRecord( 'postType', TEMPLATE_POST_TYPE, templateId )\n\t\t\t\t\t\t?.content?.raw\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ slug, isCustom ]\n\t);\n}\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\t\tconst { getEntityRecord, getBlockPatterns } = select( coreStore );\n\t\tconst postId = getCurrentPostId();\n\t\tconst postType = getCurrentPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getBlockPatterns(),\n\t\t};\n\t}, [] );\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\t// Duplicated from packages/block-library/src/pattern/edit.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pattern,\n\t\t\t\t\t\tblocks: parse( pattern.content ).map( ( block ) =>\n\t\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\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\tonChange( blocks, { selection: undefined } );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<div className=\"editor-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-template-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t{ __( 'Skip' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartTemplateOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst { shouldOpenModal, slug, isCustom, postType, postId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getCurrentPostId } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst _postType = getCurrentPostType();\n\t\t\tconst _postId = getCurrentPostId();\n\t\t\tconst { getEditedEntityRecord, hasEditsForEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\t_postId\n\t\t\t);\n\t\t\tconst hasEdits = hasEditsForEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\t_postId\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModal:\n\t\t\t\t\t! hasEdits &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\tTEMPLATE_POST_TYPE === _postType,\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t\tpostId: _postId,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\t// Should reset the modal state when navigating to a new page/post.\n\t\tsetIsClosed( false );\n\t}, [ postType, postId ] );\n\n\tif ( ! shouldOpenModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug }\n\t\t\tisCustom={ isCustom }\n\t\t\tpostType={ postType }\n\t\t\tonClose={ () => setIsClosed( true ) }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AAhBA;AACA;AACA;;AAUA;AACA;AAC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,EACTC,OACD,CAAC;IACD,MAAMI,QAAQ,GAAGF,uBAAuB,CACvC,UAAU,EACVH,SAAS,EACTC,OACD,CAAC;IAED,OAAO;MACNF,eAAe,EACd,CAAEM,QAAQ,IACV,EAAE,KAAKD,cAAc,CAAC3E,OAAO,IAC7BD,6BAAkB,KAAKwE,SAAS;MACjClF,IAAI,EAAEsF,cAAc,CAACtF,IAAI;MACzBC,QAAQ,EAAEqF,cAAc,CAAC9E,SAAS;MAClCc,QAAQ,EAAE4D,SAAS;MACnB7D,MAAM,EAAE8D;IACT,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,IAAAK,kBAAS,EAAE,MAAM;IAChB;IACAT,WAAW,CAAE,KAAM,CAAC;EACrB,CAAC,EAAE,CAAEzD,QAAQ,EAAED,MAAM,CAAG,CAAC;EAEzB,IAAK,CAAE4D,eAAe,IAAIH,QAAQ,EAAG;IACpC,OAAO,IAAI;EACZ;EAEA,OACC,IAAAtB,MAAA,CAAAC,aAAA,EAACK,UAAU;IACV9D,IAAI,EAAGA,IAAM;IACbC,QAAQ,EAAGA,QAAU;IACrBqB,QAAQ,EAAGA,QAAU;IACrByC,OAAO,EAAGA,CAAA,KAAMgB,WAAW,CAAE,IAAK;EAAG,CACrC,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = TemplateContentPanel;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _data = require("@wordpress/data");
|
|
9
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
var _i18n = require("@wordpress/i18n");
|
|
12
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
BlockQuickNavigation
|
|
23
|
+
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
24
|
+
const PAGE_CONTENT_BLOCKS = ['core/post-content', 'core/post-featured-image', 'core/post-title'];
|
|
25
|
+
function TemplateContentPanel() {
|
|
26
|
+
const clientIds = (0, _data.useSelect)(select => {
|
|
27
|
+
const {
|
|
28
|
+
getBlocksByName
|
|
29
|
+
} = select(_blockEditor.store);
|
|
30
|
+
return getBlocksByName(PAGE_CONTENT_BLOCKS);
|
|
31
|
+
}, []);
|
|
32
|
+
return (0, _react.createElement)(_components.PanelBody, {
|
|
33
|
+
title: (0, _i18n.__)('Content')
|
|
34
|
+
}, (0, _react.createElement)(BlockQuickNavigation, {
|
|
35
|
+
clientIds: clientIds
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.js.map
|