@wordpress/edit-post 7.24.1 → 7.26.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 +8 -0
- package/LICENSE.md +1 -1
- package/build/components/browser-url/index.js +3 -2
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/header/index.js +35 -33
- 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 +22 -18
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -20
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +45 -38
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +3 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js +2 -6
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/preferences-modal/index.js +87 -54
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +23 -23
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js +3 -6
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +2 -10
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +3 -5
- 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 -26
- 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 +20 -30
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +3 -11
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +16 -12
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/use-post-history.js +79 -0
- package/build/hooks/use-post-history.js.map +1 -0
- package/build/index.js +24 -20
- package/build/index.js.map +1 -1
- package/build/index.native.js +7 -1
- package/build/index.native.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 +94 -112
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +1 -95
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +86 -48
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/browser-url/index.js +3 -2
- package/build-module/components/browser-url/index.js.map +1 -1
- package/build-module/components/header/index.js +37 -35
- 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 +23 -19
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -20
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +46 -38
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +4 -2
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js +2 -6
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +87 -54
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +22 -23
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js +3 -7
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +2 -10
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +4 -6
- 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 -27
- 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 +20 -30
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +3 -11
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +16 -12
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/use-post-history.js +73 -0
- package/build-module/hooks/use-post-history.js.map +1 -0
- package/build-module/index.js +19 -12
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +7 -1
- package/build-module/index.native.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 +86 -105
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -92
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +76 -38
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +65 -473
- package/build-style/style.css +65 -473
- package/package.json +32 -32
- package/src/components/browser-url/index.js +4 -2
- package/src/components/header/index.js +45 -46
- 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 +63 -37
- package/src/components/header/writing-menu/index.js +24 -24
- package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -15
- package/src/components/keyboard-shortcuts/index.js +1 -23
- package/src/components/layout/index.js +31 -39
- package/src/components/layout/index.native.js +9 -1
- package/src/components/meta-boxes/meta-box-visibility.js +2 -8
- package/src/components/preferences-modal/index.js +128 -97
- package/src/components/preferences-modal/options/enable-feature.js +26 -21
- package/src/components/preferences-modal/options/enable-panel.js +3 -7
- package/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +187 -175
- package/src/components/preferences-modal/test/index.js +1 -52
- package/src/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/src/components/sidebar/plugin-sidebar/index.js +1 -9
- package/src/components/sidebar/post-status/index.js +5 -5
- package/src/components/sidebar/settings-header/index.js +19 -71
- package/src/components/sidebar/settings-sidebar/index.js +125 -60
- package/src/components/sidebar/style.scss +4 -12
- package/src/components/start-page-options/index.js +3 -3
- package/src/components/text-editor/style.scss +0 -6
- 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 +36 -35
- package/src/editor.native.js +2 -23
- package/src/hooks/commands/use-common-commands.js +14 -16
- package/src/hooks/use-post-history.js +73 -0
- package/src/index.js +24 -13
- package/src/index.native.js +8 -1
- package/src/plugins/welcome-guide-menu-item/index.js +3 -6
- package/src/store/actions.js +80 -131
- package/src/store/reducer.js +0 -93
- package/src/store/selectors.js +97 -55
- package/src/store/test/actions.js +10 -131
- package/src/store/test/reducer.js +1 -108
- package/src/store/test/selectors.js +0 -50
- package/src/style.scss +1 -8
- package/src/test/__snapshots__/editor.native.js.snap +21 -0
- package/src/test/editor.native.js +107 -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/header/header-toolbar/index.js +0 -156
- package/build/components/header/header-toolbar/index.js.map +0 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +0 -73
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-outline.js +0 -112
- package/build/components/secondary-sidebar/list-view-outline.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -148
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build/components/sidebar/discussion-panel/index.js +0 -59
- package/build/components/sidebar/discussion-panel/index.js.map +0 -1
- package/build/components/sidebar/featured-image/index.js +0 -70
- package/build/components/sidebar/featured-image/index.js.map +0 -1
- package/build/components/sidebar/last-revision/index.js +0 -21
- package/build/components/sidebar/last-revision/index.js.map +0 -1
- package/build/components/sidebar/page-attributes/index.js +0 -65
- package/build/components/sidebar/page-attributes/index.js.map +0 -1
- package/build/components/sidebar/plugin-post-excerpt/index.js +0 -72
- package/build/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
- package/build/components/sidebar/post-excerpt/index.js +0 -54
- package/build/components/sidebar/post-excerpt/index.js.map +0 -1
- package/build/components/sidebar/post-taxonomies/index.js +0 -30
- package/build/components/sidebar/post-taxonomies/index.js.map +0 -1
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -56
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.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/components/view-link/index.js +0 -53
- package/build/components/view-link/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/header/header-toolbar/index.js +0 -148
- package/build-module/components/header/header-toolbar/index.js.map +0 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -66
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-outline.js +0 -105
- package/build-module/components/secondary-sidebar/list-view-outline.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -140
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build-module/components/sidebar/discussion-panel/index.js +0 -52
- package/build-module/components/sidebar/discussion-panel/index.js.map +0 -1
- package/build-module/components/sidebar/featured-image/index.js +0 -63
- package/build-module/components/sidebar/featured-image/index.js.map +0 -1
- package/build-module/components/sidebar/last-revision/index.js +0 -13
- package/build-module/components/sidebar/last-revision/index.js.map +0 -1
- package/build-module/components/sidebar/page-attributes/index.js +0 -57
- package/build-module/components/sidebar/page-attributes/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-post-excerpt/index.js +0 -64
- package/build-module/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
- package/build-module/components/sidebar/post-excerpt/index.js +0 -47
- package/build-module/components/sidebar/post-excerpt/index.js.map +0 -1
- package/build-module/components/sidebar/post-taxonomies/index.js +0 -21
- package/build-module/components/sidebar/post-taxonomies/index.js.map +0 -1
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.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/build-module/components/view-link/index.js +0 -46
- package/build-module/components/view-link/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/header/header-toolbar/index.js +0 -182
- package/src/components/header/header-toolbar/style.scss +0 -114
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +0 -929
- package/src/components/secondary-sidebar/inserter-sidebar.js +0 -71
- package/src/components/secondary-sidebar/list-view-outline.js +0 -98
- package/src/components/secondary-sidebar/list-view-sidebar.js +0 -170
- package/src/components/secondary-sidebar/style.scss +0 -120
- package/src/components/sidebar/discussion-panel/index.js +0 -62
- package/src/components/sidebar/featured-image/index.js +0 -67
- package/src/components/sidebar/last-revision/index.js +0 -17
- package/src/components/sidebar/last-revision/style.scss +0 -10
- package/src/components/sidebar/page-attributes/index.js +0 -65
- package/src/components/sidebar/plugin-post-excerpt/index.js +0 -61
- package/src/components/sidebar/plugin-post-excerpt/test/index.js +0 -36
- package/src/components/sidebar/post-excerpt/index.js +0 -59
- package/src/components/sidebar/post-taxonomies/index.js +0 -30
- package/src/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
- 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
- package/src/components/view-link/index.js +0 -48
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = PostTemplate;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _element = require("@wordpress/element");
|
|
10
|
-
var _components = require("@wordpress/components");
|
|
11
|
-
var _i18n = require("@wordpress/i18n");
|
|
12
|
-
var _data = require("@wordpress/data");
|
|
13
|
-
var _editor = require("@wordpress/editor");
|
|
14
|
-
var _coreData = require("@wordpress/core-data");
|
|
15
|
-
var _form = _interopRequireDefault(require("./form"));
|
|
16
|
-
var _store = require("../../../store");
|
|
17
|
-
var _lockUnlock = require("../../../lock-unlock");
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
PostPanelRow
|
|
28
|
-
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
29
|
-
function PostTemplate() {
|
|
30
|
-
// Use internal state instead of a ref to make sure that the component
|
|
31
|
-
// re-renders when the popover's anchor updates.
|
|
32
|
-
const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
|
|
33
|
-
// Memoize popoverProps to avoid returning a new object every time.
|
|
34
|
-
const popoverProps = (0, _element.useMemo)(() => ({
|
|
35
|
-
anchor: popoverAnchor,
|
|
36
|
-
placement: 'bottom-end'
|
|
37
|
-
}), [popoverAnchor]);
|
|
38
|
-
const isVisible = (0, _data.useSelect)(select => {
|
|
39
|
-
var _select$canUser;
|
|
40
|
-
const postTypeSlug = select(_editor.store).getCurrentPostType();
|
|
41
|
-
const postType = select(_coreData.store).getPostType(postTypeSlug);
|
|
42
|
-
if (!postType?.viewable) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const settings = select(_editor.store).getEditorSettings();
|
|
46
|
-
const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
|
|
47
|
-
if (hasTemplates) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
if (!settings.supportsTemplateMode) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
const canCreateTemplates = (_select$canUser = select(_coreData.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
|
|
54
|
-
return canCreateTemplates;
|
|
55
|
-
}, []);
|
|
56
|
-
if (!isVisible) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return (0, _react.createElement)(PostPanelRow, {
|
|
60
|
-
label: (0, _i18n.__)('Template'),
|
|
61
|
-
ref: setPopoverAnchor
|
|
62
|
-
}, (0, _react.createElement)(_components.Dropdown, {
|
|
63
|
-
popoverProps: popoverProps,
|
|
64
|
-
contentClassName: "edit-post-post-template__dialog",
|
|
65
|
-
focusOnMount: true,
|
|
66
|
-
renderToggle: ({
|
|
67
|
-
isOpen,
|
|
68
|
-
onToggle
|
|
69
|
-
}) => (0, _react.createElement)(PostTemplateToggle, {
|
|
70
|
-
isOpen: isOpen,
|
|
71
|
-
onClick: onToggle
|
|
72
|
-
}),
|
|
73
|
-
renderContent: ({
|
|
74
|
-
onClose
|
|
75
|
-
}) => (0, _react.createElement)(_form.default, {
|
|
76
|
-
onClose: onClose
|
|
77
|
-
})
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
function PostTemplateToggle({
|
|
81
|
-
isOpen,
|
|
82
|
-
onClick
|
|
83
|
-
}) {
|
|
84
|
-
const templateTitle = (0, _data.useSelect)(select => {
|
|
85
|
-
const templateSlug = select(_editor.store).getEditedPostAttribute('template');
|
|
86
|
-
const {
|
|
87
|
-
supportsTemplateMode,
|
|
88
|
-
availableTemplates
|
|
89
|
-
} = select(_editor.store).getEditorSettings();
|
|
90
|
-
if (!supportsTemplateMode && availableTemplates[templateSlug]) {
|
|
91
|
-
return availableTemplates[templateSlug];
|
|
92
|
-
}
|
|
93
|
-
const template = select(_coreData.store).canUser('create', 'templates') && select(_store.store).getEditedPostTemplate();
|
|
94
|
-
return template?.title || template?.slug || availableTemplates?.[templateSlug];
|
|
95
|
-
}, []);
|
|
96
|
-
return (0, _react.createElement)(_components.Button, {
|
|
97
|
-
className: "edit-post-post-template__toggle",
|
|
98
|
-
variant: "tertiary",
|
|
99
|
-
"aria-expanded": isOpen,
|
|
100
|
-
"aria-label": templateTitle ? (0, _i18n.sprintf)(
|
|
101
|
-
// translators: %s: Name of the currently selected template.
|
|
102
|
-
(0, _i18n.__)('Select template: %s'), templateTitle) : (0, _i18n.__)('Select template'),
|
|
103
|
-
onClick: onClick
|
|
104
|
-
}, templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0, _i18n.__)('Default template'));
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_components","_i18n","_data","_editor","_coreData","_form","_interopRequireDefault","_store","_lockUnlock","PostPanelRow","unlock","editorPrivateApis","PostTemplate","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","placement","isVisible","useSelect","select","_select$canUser","postTypeSlug","editorStore","getCurrentPostType","postType","coreStore","getPostType","viewable","settings","getEditorSettings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","_react","createElement","label","__","ref","Dropdown","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostTemplateToggle","onClick","renderContent","onClose","default","templateTitle","templateSlug","getEditedPostAttribute","template","editPostStore","getEditedPostTemplate","title","slug","Button","className","variant","sprintf"],"sources":["@wordpress/edit-post/src/components/sidebar/post-template/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTemplateForm from './form';\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { PostPanelRow } = unlock( editorPrivateApis );\n\nexport default function PostTemplate() {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( hasTemplates ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tcontentClassName=\"edit-post-post-template__dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostTemplateToggle\n\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<PostTemplateForm onClose={ onClose } />\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editPostStore ).getEditedPostTemplate();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\ttemplateTitle\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the currently selected template.\n\t\t\t\t\t\t\t__( 'Select template: %s' ),\n\t\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Select template' )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAIA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,KAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,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C,CAACY,OAAO,CAAE,QAAQ,EAAE,WAAY,CAAC,IACpDlB,MAAM,CAAEuC,YAAc,CAAC,CAACC,qBAAqB,CAAC,CAAC;IAChD,OACCF,QAAQ,EAAEG,KAAK,IACfH,QAAQ,EAAEI,IAAI,IACd9B,kBAAkB,GAAIwB,YAAY,CAAE;EAEtC,CAAC,EAAE,EAAG,CAAC;EAEP,OACC,IAAAjB,MAAA,CAAAC,aAAA,EAAC1C,WAAA,CAAAiE,MAAM;IACNC,SAAS,EAAC,iCAAiC;IAC3CC,OAAO,EAAC,UAAU;IAClB,iBAAgBjB,MAAQ;IACxB,cACCO,aAAa,GACV,IAAAW,aAAO;IACP;IACA,IAAAxB,QAAE,EAAE,qBAAsB,CAAC,EAC3Ba,aACA,CAAC,GACD,IAAAb,QAAE,EAAE,iBAAkB,CACzB;IACDS,OAAO,EAAGA;EAAS,GAEjBI,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAI,IAAAb,QAAE,EAAE,kBAAmB,CACnC,CAAC;AAEX"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = ViewLink;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
|
-
var _icons = require("@wordpress/icons");
|
|
11
|
-
var _editor = require("@wordpress/editor");
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _data = require("@wordpress/data");
|
|
14
|
-
var _store = require("../../store");
|
|
15
|
-
/**
|
|
16
|
-
* WordPress dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
function ViewLink() {
|
|
24
|
-
const {
|
|
25
|
-
permalink,
|
|
26
|
-
isPublished,
|
|
27
|
-
label,
|
|
28
|
-
showIconLabels
|
|
29
|
-
} = (0, _data.useSelect)(select => {
|
|
30
|
-
// Grab post type to retrieve the view_item label.
|
|
31
|
-
const postTypeSlug = select(_editor.store).getCurrentPostType();
|
|
32
|
-
const postType = select(_coreData.store).getPostType(postTypeSlug);
|
|
33
|
-
return {
|
|
34
|
-
permalink: select(_editor.store).getPermalink(),
|
|
35
|
-
isPublished: select(_editor.store).isCurrentPostPublished(),
|
|
36
|
-
label: postType?.labels.view_item,
|
|
37
|
-
showIconLabels: select(_store.store).isFeatureActive('showIconLabels')
|
|
38
|
-
};
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
// Only render the view button if the post is published and has a permalink.
|
|
42
|
-
if (!isPublished || !permalink) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return (0, _react.createElement)(_components.Button, {
|
|
46
|
-
icon: _icons.external,
|
|
47
|
-
label: label || (0, _i18n.__)('View post'),
|
|
48
|
-
href: permalink,
|
|
49
|
-
target: "_blank",
|
|
50
|
-
showTooltip: !showIconLabels
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_icons","_editor","_coreData","_data","_store","ViewLink","permalink","isPublished","label","showIconLabels","useSelect","select","postTypeSlug","editorStore","getCurrentPostType","postType","coreStore","getPostType","getPermalink","isCurrentPostPublished","labels","view_item","editPostStore","isFeatureActive","_react","createElement","Button","icon","external","__","href","target","showTooltip"],"sources":["@wordpress/edit-post/src/components/view-link/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { external } from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function ViewLink() {\n\tconst { permalink, isPublished, label, showIconLabels } = useSelect(\n\t\t( select ) => {\n\t\t\t// Grab post type to retrieve the view_item label.\n\t\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\n\t\t\treturn {\n\t\t\t\tpermalink: select( editorStore ).getPermalink(),\n\t\t\t\tisPublished: select( editorStore ).isCurrentPostPublished(),\n\t\t\t\tlabel: postType?.labels.view_item,\n\t\t\t\tshowIconLabels:\n\t\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\t// Only render the view button if the post is published and has a permalink.\n\tif ( ! isPublished || ! permalink ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ external }\n\t\t\tlabel={ label || __( 'View post' ) }\n\t\t\thref={ permalink }\n\t\t\ttarget=\"_blank\"\n\t\t\tshowTooltip={ ! showIconLabels }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAQA;AACA;AACA;;AAGe,SAASO,QAAQA,CAAA,EAAG;EAClC,MAAM;IAAEC,SAAS;IAAEC,WAAW;IAAEC,KAAK;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EAChEC,MAAM,IAAM;IACb;IACA,MAAMC,YAAY,GAAGD,MAAM,CAAEE,aAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC;IAC/D,MAAMC,QAAQ,GAAGJ,MAAM,CAAEK,eAAU,CAAC,CAACC,WAAW,CAAEL,YAAa,CAAC;IAEhE,OAAO;MACNN,SAAS,EAAEK,MAAM,CAAEE,aAAY,CAAC,CAACK,YAAY,CAAC,CAAC;MAC/CX,WAAW,EAAEI,MAAM,CAAEE,aAAY,CAAC,CAACM,sBAAsB,CAAC,CAAC;MAC3DX,KAAK,EAAEO,QAAQ,EAAEK,MAAM,CAACC,SAAS;MACjCZ,cAAc,EACbE,MAAM,CAAEW,YAAc,CAAC,CAACC,eAAe,CAAE,gBAAiB;IAC5D,CAAC;EACF,CAAC,EACD,EACD,CAAC;;EAED;EACA,IAAK,CAAEhB,WAAW,IAAI,CAAED,SAAS,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,OACC,IAAAkB,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAA2B,MAAM;IACNC,IAAI,EAAGC,eAAU;IACjBpB,KAAK,EAAGA,KAAK,IAAI,IAAAqB,QAAE,EAAE,WAAY,CAAG;IACpCC,IAAI,EAAGxB,SAAW;IAClByB,MAAM,EAAC,QAAQ;IACfC,WAAW,EAAG,CAAEvB;EAAgB,CAChC,CAAC;AAEJ"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { Icon, MenuGroup } from '@wordpress/components';
|
|
6
|
-
import { PostPreviewButton, store as editorStore } from '@wordpress/editor';
|
|
7
|
-
import { external } from '@wordpress/icons';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
|
|
10
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { store as editPostStore } from '../../store';
|
|
17
|
-
export default function DevicePreview() {
|
|
18
|
-
const {
|
|
19
|
-
hasActiveMetaboxes,
|
|
20
|
-
isPostSaveable,
|
|
21
|
-
isViewable,
|
|
22
|
-
deviceType,
|
|
23
|
-
showIconLabels
|
|
24
|
-
} = useSelect(select => {
|
|
25
|
-
var _postType$viewable;
|
|
26
|
-
const {
|
|
27
|
-
getEditedPostAttribute
|
|
28
|
-
} = select(editorStore);
|
|
29
|
-
const {
|
|
30
|
-
getPostType
|
|
31
|
-
} = select(coreStore);
|
|
32
|
-
const postType = getPostType(getEditedPostAttribute('type'));
|
|
33
|
-
return {
|
|
34
|
-
hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
|
|
35
|
-
isPostSaveable: select(editorStore).isEditedPostSaveable(),
|
|
36
|
-
isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false,
|
|
37
|
-
deviceType: select(editPostStore).__experimentalGetPreviewDeviceType(),
|
|
38
|
-
showIconLabels: select(editPostStore).isFeatureActive('showIconLabels')
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
41
|
-
const {
|
|
42
|
-
__experimentalSetPreviewDeviceType: setPreviewDeviceType
|
|
43
|
-
} = useDispatch(editPostStore);
|
|
44
|
-
return createElement(PreviewOptions, {
|
|
45
|
-
isEnabled: isPostSaveable,
|
|
46
|
-
className: "edit-post-post-preview-dropdown",
|
|
47
|
-
deviceType: deviceType,
|
|
48
|
-
setDeviceType: setPreviewDeviceType,
|
|
49
|
-
label: __('Preview'),
|
|
50
|
-
showIconLabels: showIconLabels
|
|
51
|
-
}, ({
|
|
52
|
-
onClose
|
|
53
|
-
}) => isViewable && createElement(MenuGroup, null, createElement("div", {
|
|
54
|
-
className: "edit-post-header-preview__grouping-external"
|
|
55
|
-
}, createElement(PostPreviewButton, {
|
|
56
|
-
className: "edit-post-header-preview__button-external",
|
|
57
|
-
role: "menuitem",
|
|
58
|
-
forceIsAutosaveable: hasActiveMetaboxes,
|
|
59
|
-
textContent: createElement(Fragment, null, __('Preview in new tab'), createElement(Icon, {
|
|
60
|
-
icon: external
|
|
61
|
-
})),
|
|
62
|
-
onPreview: onClose
|
|
63
|
-
}))));
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Icon","MenuGroup","PostPreviewButton","store","editorStore","external","__","__experimentalPreviewOptions","PreviewOptions","useDispatch","useSelect","coreStore","editPostStore","DevicePreview","hasActiveMetaboxes","isPostSaveable","isViewable","deviceType","showIconLabels","select","_postType$viewable","getEditedPostAttribute","getPostType","postType","hasMetaBoxes","isEditedPostSaveable","viewable","__experimentalGetPreviewDeviceType","isFeatureActive","__experimentalSetPreviewDeviceType","setPreviewDeviceType","createElement","isEnabled","className","setDeviceType","label","onClose","role","forceIsAutosaveable","textContent","Fragment","icon","onPreview"],"sources":["@wordpress/edit-post/src/components/device-preview/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, MenuGroup } from '@wordpress/components';\nimport { PostPreviewButton, store as editorStore } from '@wordpress/editor';\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function DevicePreview() {\n\tconst {\n\t\thasActiveMetaboxes,\n\t\tisPostSaveable,\n\t\tisViewable,\n\t\tdeviceType,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\tisPostSaveable: select( editorStore ).isEditedPostSaveable(),\n\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\tdeviceType:\n\t\t\t\tselect( editPostStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tshowIconLabels:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t};\n\t}, [] );\n\tconst { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =\n\t\tuseDispatch( editPostStore );\n\n\treturn (\n\t\t<PreviewOptions\n\t\t\tisEnabled={ isPostSaveable }\n\t\t\tclassName=\"edit-post-post-preview-dropdown\"\n\t\t\tdeviceType={ deviceType }\n\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\tlabel={ __( 'Preview' ) }\n\t\t\tshowIconLabels={ showIconLabels }\n\t\t>\n\t\t\t{ ( { onClose } ) =>\n\t\t\t\tisViewable && (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<div className=\"edit-post-header-preview__grouping-external\">\n\t\t\t\t\t\t\t<PostPreviewButton\n\t\t\t\t\t\t\t\tclassName=\"edit-post-header-preview__button-external\"\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t\t\t\t\ttextContent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ external } />\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\tonPreview={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t)\n\t\t\t}\n\t\t</PreviewOptions>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,SAAS,QAAQ,uBAAuB;AACvD,SAASC,iBAAiB,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AAC3E,SAASC,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;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B,aAAa,EAAGJ,oBAAsB;IACtCK,KAAK,EAAG7B,EAAE,CAAE,SAAU,CAAG;IACzBY,cAAc,EAAGA;EAAgB,GAE/B,CAAE;IAAEkB;EAAQ,CAAC,KACdpB,UAAU,IACTe,aAAA,CAAC9B,SAAS,QACT8B,aAAA;IAAKE,SAAS,EAAC;EAA6C,GAC3DF,aAAA,CAAC7B,iBAAiB;IACjB+B,SAAS,EAAC,2CAA2C;IACrDI,IAAI,EAAC,UAAU;IACfC,mBAAmB,EAAGxB,kBAAoB;IAC1CyB,WAAW,EACVR,aAAA,CAAAS,QAAA,QACGlC,EAAE,CAAE,oBAAqB,CAAC,EAC5ByB,aAAA,CAAC/B,IAAI;MAACyC,IAAI,EAAGpC;IAAU,CAAE,CACxB,CACF;IACDqC,SAAS,EAAGN;EAAS,CACrB,CACG,CACK,CAGE,CAAC;AAEnB"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
|
-
import { Button, VisuallyHidden, __experimentalHStack as HStack, __experimentalText as Text } from '@wordpress/components';
|
|
9
|
-
import { layout, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
|
|
10
|
-
import { store as commandsStore } from '@wordpress/commands';
|
|
11
|
-
import { displayShortcut } from '@wordpress/keycodes';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { store as editPostStore } from '../../../store';
|
|
17
|
-
function DocumentActions() {
|
|
18
|
-
const {
|
|
19
|
-
template
|
|
20
|
-
} = useSelect(select => {
|
|
21
|
-
const {
|
|
22
|
-
getEditedPostTemplate
|
|
23
|
-
} = select(editPostStore);
|
|
24
|
-
return {
|
|
25
|
-
template: getEditedPostTemplate()
|
|
26
|
-
};
|
|
27
|
-
}, []);
|
|
28
|
-
const {
|
|
29
|
-
clearSelectedBlock
|
|
30
|
-
} = useDispatch(blockEditorStore);
|
|
31
|
-
const {
|
|
32
|
-
setIsEditingTemplate
|
|
33
|
-
} = useDispatch(editPostStore);
|
|
34
|
-
const {
|
|
35
|
-
open: openCommandCenter
|
|
36
|
-
} = useDispatch(commandsStore);
|
|
37
|
-
if (!template) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
let templateTitle = __('Default');
|
|
41
|
-
if (template?.title) {
|
|
42
|
-
templateTitle = template.title;
|
|
43
|
-
} else if (!!template) {
|
|
44
|
-
templateTitle = template.slug;
|
|
45
|
-
}
|
|
46
|
-
return createElement("div", {
|
|
47
|
-
className: "edit-post-document-actions"
|
|
48
|
-
}, createElement(Button, {
|
|
49
|
-
className: "edit-post-document-actions__back",
|
|
50
|
-
onClick: () => {
|
|
51
|
-
clearSelectedBlock();
|
|
52
|
-
setIsEditingTemplate(false);
|
|
53
|
-
},
|
|
54
|
-
icon: isRTL() ? chevronRightSmall : chevronLeftSmall
|
|
55
|
-
}, __('Back')), createElement(Button, {
|
|
56
|
-
className: "edit-post-document-actions__command",
|
|
57
|
-
onClick: () => openCommandCenter()
|
|
58
|
-
}, createElement(HStack, {
|
|
59
|
-
className: "edit-post-document-actions__title",
|
|
60
|
-
spacing: 1,
|
|
61
|
-
justify: "center"
|
|
62
|
-
}, createElement(BlockIcon, {
|
|
63
|
-
icon: layout
|
|
64
|
-
}), createElement(Text, {
|
|
65
|
-
size: "body",
|
|
66
|
-
as: "h1"
|
|
67
|
-
}, createElement(VisuallyHidden, {
|
|
68
|
-
as: "span"
|
|
69
|
-
}, __('Editing template: ')), templateTitle)), createElement("span", {
|
|
70
|
-
className: "edit-post-document-actions__shortcut"
|
|
71
|
-
}, displayShortcut.primary('k'))));
|
|
72
|
-
}
|
|
73
|
-
export default DocumentActions;
|
|
74
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","isRTL","useSelect","useDispatch","BlockIcon","store","blockEditorStore","Button","VisuallyHidden","__experimentalHStack","HStack","__experimentalText","Text","layout","chevronLeftSmall","chevronRightSmall","commandsStore","displayShortcut","editPostStore","DocumentActions","template","select","getEditedPostTemplate","clearSelectedBlock","setIsEditingTemplate","open","openCommandCenter","templateTitle","title","slug","createElement","className","onClick","icon","spacing","justify","size","as","primary"],"sources":["@wordpress/edit-post/src/components/header/document-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { layout, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nfunction DocumentActions() {\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-post-document-actions\">\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-actions__back\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t} }\n\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t>\n\t\t\t\t{ __( 'Back' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-actions__command\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-post-document-actions__title\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t>\n\t\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{ __( 'Editing template: ' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t\t<span className=\"edit-post-document-actions__shortcut\">\n\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport default DocumentActions;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAC9E,SACCC,MAAM,EACNC,cAAc,EACdC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,QACpB,uBAAuB;AAC9B,SAASC,MAAM,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,kBAAkB;AAC9E,SAASV,KAAK,IAAIW,aAAa,QAAQ,qBAAqB;AAC5D,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA,SA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A,CAACpB,MAAM;IACNqB,SAAS,EAAC,mCAAmC;IAC7CG,OAAO,EAAG,CAAG;IACbC,OAAO,EAAC;EAAQ,GAEhBL,aAAA,CAAC1B,SAAS;IAAC6B,IAAI,EAAGpB;EAAQ,CAAE,CAAC,EAC7BiB,aAAA,CAAClB,IAAI;IAACwB,IAAI,EAAC,MAAM;IAACC,EAAE,EAAC;EAAI,GACxBP,aAAA,CAACtB,cAAc;IAAC6B,EAAE,EAAC;EAAM,GACtBrC,EAAE,CAAE,oBAAqB,CACZ,CAAC,EACf2B,aACG,CACC,CAAC,EACTG,aAAA;IAAMC,SAAS,EAAC;EAAsC,GACnDd,eAAe,CAACqB,OAAO,CAAE,GAAI,CAC1B,CACC,CACJ,CAAC;AAER;AAEA,eAAenB,eAAe"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import { __, _x } from '@wordpress/i18n';
|
|
8
|
-
import { NavigableToolbar, ToolSelector, store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
9
|
-
import { EditorHistoryRedo, EditorHistoryUndo, store as editorStore } from '@wordpress/editor';
|
|
10
|
-
import { Button, ToolbarItem } from '@wordpress/components';
|
|
11
|
-
import { listView, plus } from '@wordpress/icons';
|
|
12
|
-
import { useRef, useCallback } from '@wordpress/element';
|
|
13
|
-
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { store as editPostStore } from '../../../store';
|
|
19
|
-
import { unlock } from '../../../lock-unlock';
|
|
20
|
-
const {
|
|
21
|
-
useShouldContextualToolbarShow
|
|
22
|
-
} = unlock(blockEditorPrivateApis);
|
|
23
|
-
const preventDefault = event => {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
};
|
|
26
|
-
function HeaderToolbar({
|
|
27
|
-
hasFixedToolbar,
|
|
28
|
-
setListViewToggleElement
|
|
29
|
-
}) {
|
|
30
|
-
const inserterButton = useRef();
|
|
31
|
-
const {
|
|
32
|
-
setIsInserterOpened,
|
|
33
|
-
setIsListViewOpened
|
|
34
|
-
} = useDispatch(editPostStore);
|
|
35
|
-
const {
|
|
36
|
-
isInserterEnabled,
|
|
37
|
-
isInserterOpened,
|
|
38
|
-
isTextModeEnabled,
|
|
39
|
-
showIconLabels,
|
|
40
|
-
isListViewOpen,
|
|
41
|
-
listViewShortcut
|
|
42
|
-
} = useSelect(select => {
|
|
43
|
-
const {
|
|
44
|
-
hasInserterItems,
|
|
45
|
-
getBlockRootClientId,
|
|
46
|
-
getBlockSelectionEnd
|
|
47
|
-
} = select(blockEditorStore);
|
|
48
|
-
const {
|
|
49
|
-
getEditorSettings
|
|
50
|
-
} = select(editorStore);
|
|
51
|
-
const {
|
|
52
|
-
getEditorMode,
|
|
53
|
-
isFeatureActive,
|
|
54
|
-
isListViewOpened
|
|
55
|
-
} = select(editPostStore);
|
|
56
|
-
const {
|
|
57
|
-
getShortcutRepresentation
|
|
58
|
-
} = select(keyboardShortcutsStore);
|
|
59
|
-
return {
|
|
60
|
-
// This setting (richEditingEnabled) should not live in the block editor's setting.
|
|
61
|
-
isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
|
|
62
|
-
isInserterOpened: select(editPostStore).isInserterOpened(),
|
|
63
|
-
isTextModeEnabled: getEditorMode() === 'text',
|
|
64
|
-
showIconLabels: isFeatureActive('showIconLabels'),
|
|
65
|
-
isListViewOpen: isListViewOpened(),
|
|
66
|
-
listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
const isLargeViewport = useViewportMatch('medium');
|
|
70
|
-
const isWideViewport = useViewportMatch('wide');
|
|
71
|
-
const {
|
|
72
|
-
shouldShowContextualToolbar,
|
|
73
|
-
canFocusHiddenToolbar,
|
|
74
|
-
fixedToolbarCanBeFocused
|
|
75
|
-
} = useShouldContextualToolbarShow();
|
|
76
|
-
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
77
|
-
// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
|
|
78
|
-
const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || fixedToolbarCanBeFocused;
|
|
79
|
-
/* translators: accessibility text for the editor toolbar */
|
|
80
|
-
const toolbarAriaLabel = __('Document tools');
|
|
81
|
-
const toggleListView = useCallback(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
|
|
82
|
-
const overflowItems = createElement(Fragment, null, createElement(ToolbarItem, {
|
|
83
|
-
as: Button,
|
|
84
|
-
className: "edit-post-header-toolbar__document-overview-toggle",
|
|
85
|
-
icon: listView,
|
|
86
|
-
disabled: isTextModeEnabled,
|
|
87
|
-
isPressed: isListViewOpen
|
|
88
|
-
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
89
|
-
label: __('Document Overview'),
|
|
90
|
-
onClick: toggleListView,
|
|
91
|
-
shortcut: listViewShortcut,
|
|
92
|
-
showTooltip: !showIconLabels,
|
|
93
|
-
variant: showIconLabels ? 'tertiary' : undefined,
|
|
94
|
-
"aria-expanded": isListViewOpen,
|
|
95
|
-
ref: setListViewToggleElement
|
|
96
|
-
}));
|
|
97
|
-
const toggleInserter = useCallback(() => {
|
|
98
|
-
if (isInserterOpened) {
|
|
99
|
-
// Focusing the inserter button should close the inserter popover.
|
|
100
|
-
// However, there are some cases it won't close when the focus is lost.
|
|
101
|
-
// See https://github.com/WordPress/gutenberg/issues/43090 for more details.
|
|
102
|
-
inserterButton.current.focus();
|
|
103
|
-
setIsInserterOpened(false);
|
|
104
|
-
} else {
|
|
105
|
-
setIsInserterOpened(true);
|
|
106
|
-
}
|
|
107
|
-
}, [isInserterOpened, setIsInserterOpened]);
|
|
108
|
-
|
|
109
|
-
/* translators: button label text should, if possible, be under 16 characters. */
|
|
110
|
-
const longLabel = _x('Toggle block inserter', 'Generic label for block inserter button');
|
|
111
|
-
const shortLabel = !isInserterOpened ? __('Add') : __('Close');
|
|
112
|
-
return createElement(NavigableToolbar, {
|
|
113
|
-
className: "edit-post-header-toolbar",
|
|
114
|
-
"aria-label": toolbarAriaLabel,
|
|
115
|
-
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused,
|
|
116
|
-
variant: "unstyled"
|
|
117
|
-
}, createElement("div", {
|
|
118
|
-
className: "edit-post-header-toolbar__left"
|
|
119
|
-
}, createElement(ToolbarItem, {
|
|
120
|
-
ref: inserterButton,
|
|
121
|
-
as: Button,
|
|
122
|
-
className: "edit-post-header-toolbar__inserter-toggle",
|
|
123
|
-
variant: "primary",
|
|
124
|
-
isPressed: isInserterOpened,
|
|
125
|
-
onMouseDown: preventDefault,
|
|
126
|
-
onClick: toggleInserter,
|
|
127
|
-
disabled: !isInserterEnabled,
|
|
128
|
-
icon: plus,
|
|
129
|
-
label: showIconLabels ? shortLabel : longLabel,
|
|
130
|
-
showTooltip: !showIconLabels,
|
|
131
|
-
"aria-expanded": isInserterOpened
|
|
132
|
-
}), (isWideViewport || !showIconLabels) && createElement(Fragment, null, isLargeViewport && !hasFixedToolbar && createElement(ToolbarItem, {
|
|
133
|
-
as: ToolSelector,
|
|
134
|
-
showTooltip: !showIconLabels,
|
|
135
|
-
variant: showIconLabels ? 'tertiary' : undefined,
|
|
136
|
-
disabled: isTextModeEnabled
|
|
137
|
-
}), createElement(ToolbarItem, {
|
|
138
|
-
as: EditorHistoryUndo,
|
|
139
|
-
showTooltip: !showIconLabels,
|
|
140
|
-
variant: showIconLabels ? 'tertiary' : undefined
|
|
141
|
-
}), createElement(ToolbarItem, {
|
|
142
|
-
as: EditorHistoryRedo,
|
|
143
|
-
showTooltip: !showIconLabels,
|
|
144
|
-
variant: showIconLabels ? 'tertiary' : undefined
|
|
145
|
-
}), overflowItems)));
|
|
146
|
-
}
|
|
147
|
-
export default HeaderToolbar;
|
|
148
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","privateApis","blockEditorPrivateApis","EditorHistoryRedo","EditorHistoryUndo","editorStore","Button","ToolbarItem","listView","plus","useRef","useCallback","keyboardShortcutsStore","editPostStore","unlock","useShouldContextualToolbarShow","preventDefault","event","HeaderToolbar","hasFixedToolbar","setListViewToggleElement","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","createElement","Fragment","as","className","icon","disabled","isPressed","label","onClick","shortcut","showTooltip","variant","undefined","ref","toggleInserter","current","focus","longLabel","shortLabel","shouldUseKeyboardFocusShortcut","onMouseDown"],"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tEditorHistoryRedo,\n\tEditorHistoryUndo,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction HeaderToolbar( { hasFixedToolbar, setListViewToggleElement } ) {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editPostStore );\n\tconst {\n\t\tisInserterEnabled,\n\t\tisInserterOpened,\n\t\tisTextModeEnabled,\n\t\tshowIconLabels,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t} = useSelect( ( select ) => {\n\t\tconst { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getEditorMode, isFeatureActive, isListViewOpened } =\n\t\t\tselect( editPostStore );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\treturn {\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tisInserterEnabled:\n\t\t\t\tgetEditorMode() === 'visual' &&\n\t\t\t\tgetEditorSettings().richEditingEnabled &&\n\t\t\t\thasInserterItems(\n\t\t\t\t\tgetBlockRootClientId( getBlockSelectionEnd() )\n\t\t\t\t),\n\t\t\tisInserterOpened: select( editPostStore ).isInserterOpened(),\n\t\t\tisTextModeEnabled: getEditorMode() === 'text',\n\t\t\tshowIconLabels: isFeatureActive( 'showIconLabels' ),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-post/toggle-list-view'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\tconst overflowItems = (\n\t\t<>\n\t\t\t<ToolbarItem\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-post-header-toolbar__document-overview-toggle\"\n\t\t\t\ticon={ listView }\n\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\tonClick={ toggleListView }\n\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\tref={ setListViewToggleElement }\n\t\t\t/>\n\t\t</>\n\t);\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-post-header-toolbar\"\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"edit-post-header-toolbar__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"edit-post-header-toolbar__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ ! isInserterEnabled }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ overflowItems }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default HeaderToolbar;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SACCC,gBAAgB,EAChBC,YAAY,EACZC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SACCC,iBAAiB,EACjBC,iBAAiB,EACjBL,KAAK,IAAIM,WAAW,QACd,mBAAmB;AAC1B,SAASC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AAC3D,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,MAAM,EAAEC,WAAW,QAAQ,oBAAoB;AACxD,SAASZ,KAAK,IAAIa,sBAAsB,QAAQ,+BAA+B;;AAE/E;AACA;AACA;AACA,SAASb,KAAK,IAAIc,aAAa,QAAQ,gBAAgB;AACvD,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,MAAM;EAAEC;AAA+B,CAAC,GAAGD,MAAM,CAAEZ,sBAAuB,CAAC;AAE3E,MAAMc,cAAc,GAAKC,KAAK,IAAM;EACnCA,KAAK,CAACD,cAAc,CAAC,CAAC;AACvB,CAAC;AAED,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,iBAAmB;IACxBwD,WAAW,EAAG,CAAEhC,cAAgB;IAChCiC,OAAO,EAAGjC,cAAc,GAAG,UAAU,GAAGkC;EAAW,CACnD,CAAC,EACAb,aACD,CAEC,CACY,CAAC;AAErB;AAEA,eAAe9B,aAAa"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
7
|
-
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
8
|
-
import { close } from '@wordpress/icons';
|
|
9
|
-
import { useViewportMatch, __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { store as editPostStore } from '../../store';
|
|
17
|
-
export default function InserterSidebar() {
|
|
18
|
-
const {
|
|
19
|
-
insertionPoint,
|
|
20
|
-
showMostUsedBlocks
|
|
21
|
-
} = useSelect(select => {
|
|
22
|
-
const {
|
|
23
|
-
isFeatureActive,
|
|
24
|
-
__experimentalGetInsertionPoint
|
|
25
|
-
} = select(editPostStore);
|
|
26
|
-
return {
|
|
27
|
-
insertionPoint: __experimentalGetInsertionPoint(),
|
|
28
|
-
showMostUsedBlocks: isFeatureActive('mostUsedBlocks')
|
|
29
|
-
};
|
|
30
|
-
}, []);
|
|
31
|
-
const {
|
|
32
|
-
setIsInserterOpened
|
|
33
|
-
} = useDispatch(editPostStore);
|
|
34
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
35
|
-
const TagName = !isMobileViewport ? VisuallyHidden : 'div';
|
|
36
|
-
const [inserterDialogRef, inserterDialogProps] = useDialog({
|
|
37
|
-
onClose: () => setIsInserterOpened(false),
|
|
38
|
-
focusOnMount: null
|
|
39
|
-
});
|
|
40
|
-
const libraryRef = useRef();
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
libraryRef.current.focusSearch();
|
|
43
|
-
}, []);
|
|
44
|
-
return createElement("div", {
|
|
45
|
-
ref: inserterDialogRef,
|
|
46
|
-
...inserterDialogProps,
|
|
47
|
-
className: "edit-post-editor__inserter-panel"
|
|
48
|
-
}, createElement(TagName, {
|
|
49
|
-
className: "edit-post-editor__inserter-panel-header"
|
|
50
|
-
}, createElement(Button, {
|
|
51
|
-
icon: close,
|
|
52
|
-
label: __('Close block inserter'),
|
|
53
|
-
onClick: () => setIsInserterOpened(false)
|
|
54
|
-
})), createElement("div", {
|
|
55
|
-
className: "edit-post-editor__inserter-panel-content"
|
|
56
|
-
}, createElement(Library, {
|
|
57
|
-
showMostUsedBlocks: showMostUsedBlocks,
|
|
58
|
-
showInserterHelpPanel: true,
|
|
59
|
-
shouldFocusBlock: isMobileViewport,
|
|
60
|
-
rootClientId: insertionPoint.rootClientId,
|
|
61
|
-
__experimentalInsertionIndex: insertionPoint.insertionIndex,
|
|
62
|
-
__experimentalFilterValue: insertionPoint.filterValue,
|
|
63
|
-
ref: libraryRef
|
|
64
|
-
})));
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=inserter-sidebar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useSelect","Button","VisuallyHidden","__experimentalLibrary","Library","close","useViewportMatch","__experimentalUseDialog","useDialog","__","useEffect","useRef","store","editPostStore","InserterSidebar","insertionPoint","showMostUsedBlocks","select","isFeatureActive","__experimentalGetInsertionPoint","setIsInserterOpened","isMobileViewport","TagName","inserterDialogRef","inserterDialogProps","onClose","focusOnMount","libraryRef","current","focusSearch","createElement","ref","className","icon","label","onClick","showInserterHelpPanel","shouldFocusBlock","rootClientId","__experimentalInsertionIndex","insertionIndex","__experimentalFilterValue","filterValue"],"sources":["@wordpress/edit-post/src/components/secondary-sidebar/inserter-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { close } from '@wordpress/icons';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst { insertionPoint, showMostUsedBlocks } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive, __experimentalGetInsertionPoint } =\n\t\t\tselect( editPostStore );\n\t\treturn {\n\t\t\tinsertionPoint: __experimentalGetInsertionPoint(),\n\t\t\tshowMostUsedBlocks: isFeatureActive( 'mostUsedBlocks' ),\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editPostStore );\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst TagName = ! isMobileViewport ? VisuallyHidden : 'div';\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: () => setIsInserterOpened( false ),\n\t\tfocusOnMount: null,\n\t} );\n\n\tconst libraryRef = useRef();\n\tuseEffect( () => {\n\t\tlibraryRef.current.focusSearch();\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-post-editor__inserter-panel\"\n\t\t>\n\t\t\t<TagName className=\"edit-post-editor__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close block inserter' ) }\n\t\t\t\t\tonClick={ () => setIsInserterOpened( false ) }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t\t<div className=\"edit-post-editor__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobileViewport }\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFilterValue={ insertionPoint.filterValue }\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,MAAM,EAAEC,cAAc,QAAQ,uBAAuB;AAC9D,SAASC,qBAAqB,IAAIC,OAAO,QAAQ,yBAAyB;AAC1E,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SACCC,gBAAgB,EAChBC,uBAAuB,IAAIC,SAAS,QAC9B,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,eAAeA,CAAA,EAAG;EACzC,MAAM;IAAEC,cAAc;IAAEC;EAAmB,CAAC,GAAGhB,SAAS,CAAIiB,MAAM,IAAM;IACvE,MAAM;MAAEC,eAAe;MAAEC;IAAgC,CAAC,GACzDF,MAAM,CAAEJ,aAAc,CAAC;IACxB,OAAO;MACNE,cAAc,EAAEI,+BAA+B,CAAC,CAAC;MACjDH,kBAAkB,EAAEE,eAAe,CAAE,gBAAiB;IACvD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEE;EAAoB,CAAC,GAAGrB,WAAW,CAAEc,aAAc,CAAC;EAE5D,MAAMQ,gBAAgB,GAAGf,gBAAgB,CAAE,QAAQ,EAAE,GAAI,C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