@wordpress/editor 14.18.0 → 14.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +2 -0
- package/build/components/document-bar/index.js +3 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +37 -17
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js +32 -20
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +4 -3
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +2 -1
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +66 -42
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/post-actions/index.js +19 -28
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +5 -5
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +4 -2
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +68 -48
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +30 -18
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +3 -1
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/panel.js +3 -11
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/preferences-modal/block-visibility.js +2 -1
- package/build/components/preferences-modal/block-visibility.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +6 -3
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.js +19 -18
- package/build/components/provider/index.js.map +1 -1
- package/build/components/sidebar/header.js +1 -1
- package/build/components/sidebar/header.js.map +1 -1
- package/build/components/sidebar/index.js +1 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +148 -23
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/store/private-actions.js +29 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +45 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +8 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +5 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +3 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +38 -18
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +32 -20
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +4 -3
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +2 -1
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +67 -43
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/post-actions/index.js +19 -28
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +5 -5
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +4 -2
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +68 -48
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +30 -18
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +3 -1
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/panel.js +3 -11
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/preferences-modal/block-visibility.js +2 -1
- package/build-module/components/preferences-modal/block-visibility.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +1 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +6 -3
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.js +19 -18
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/sidebar/header.js +1 -1
- package/build-module/components/sidebar/header.js.map +1 -1
- package/build-module/components/sidebar/index.js +1 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +148 -24
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/store/private-actions.js +25 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +44 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +8 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +5 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +51 -9
- package/build-style/style.css +51 -9
- package/build-types/components/document-outline/index.d.ts.map +1 -1
- package/build-types/components/document-outline/item.d.ts +2 -1
- package/build-types/components/document-outline/item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts +6 -2
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/panel.d.ts.map +1 -1
- package/build-types/components/preferences-modal/block-visibility.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts +2 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +4 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +13 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts +3 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/index.js +49 -17
- package/src/components/document-outline/item.js +38 -23
- package/src/components/document-outline/style.scss +2 -0
- package/src/components/entities-saved-states/entity-record-item.js +2 -4
- package/src/components/entities-saved-states/entity-type-list.js +6 -2
- package/src/components/entities-saved-states/index.js +98 -58
- package/src/components/entities-saved-states/style.scss +40 -5
- package/src/components/post-actions/index.js +19 -37
- package/src/components/post-card-panel/index.js +9 -7
- package/src/components/post-featured-image/index.js +2 -0
- package/src/components/post-template/block-theme.js +76 -56
- package/src/components/post-template/classic-theme.js +31 -15
- package/src/components/post-template/create-new-template-modal.js +1 -0
- package/src/components/post-template/panel.js +2 -12
- package/src/components/post-text-editor/style.scss +0 -2
- package/src/components/preferences-modal/block-visibility.js +2 -1
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/preview-dropdown/index.js +8 -6
- package/src/components/provider/index.js +21 -30
- package/src/components/sidebar/header.js +1 -1
- package/src/components/sidebar/index.js +1 -1
- package/src/components/start-page-options/index.js +149 -23
- package/src/components/start-page-options/style.scss +27 -0
- package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/src/store/private-actions.js +33 -0
- package/src/store/private-selectors.js +59 -4
- package/src/store/selectors.js +9 -14
- package/src/utils/media-upload/index.js +3 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,11 +8,13 @@ exports.default = BlockThemeControl;
|
|
|
8
8
|
var _data = require("@wordpress/data");
|
|
9
9
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
|
+
var _element = require("@wordpress/element");
|
|
11
12
|
var _i18n = require("@wordpress/i18n");
|
|
12
13
|
var _coreData = require("@wordpress/core-data");
|
|
13
14
|
var _icons = require("@wordpress/icons");
|
|
14
15
|
var _notices = require("@wordpress/notices");
|
|
15
16
|
var _preferences = require("@wordpress/preferences");
|
|
17
|
+
var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
|
|
16
18
|
var _store = require("../../store");
|
|
17
19
|
var _swapTemplateButton = _interopRequireDefault(require("./swap-template-button"));
|
|
18
20
|
var _resetDefaultTemplate = _interopRequireDefault(require("./reset-default-template"));
|
|
@@ -27,10 +29,10 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
27
29
|
* Internal dependencies
|
|
28
30
|
*/
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Internal dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
34
36
|
function BlockThemeControl({
|
|
35
37
|
id
|
|
36
38
|
}) {
|
|
@@ -63,12 +65,24 @@ function BlockThemeControl({
|
|
|
63
65
|
createSuccessNotice
|
|
64
66
|
} = (0, _data.useDispatch)(_notices.store);
|
|
65
67
|
const {
|
|
66
|
-
setRenderingMode
|
|
67
|
-
|
|
68
|
+
setRenderingMode,
|
|
69
|
+
setDefaultRenderingMode
|
|
70
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
68
71
|
const canCreateTemplate = (0, _data.useSelect)(select => !!select(_coreData.store).canUser('create', {
|
|
69
72
|
kind: 'postType',
|
|
70
73
|
name: 'wp_template'
|
|
71
74
|
}), []);
|
|
75
|
+
const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
|
|
76
|
+
// Memoize popoverProps to avoid returning a new object every time.
|
|
77
|
+
const popoverProps = (0, _element.useMemo)(() => ({
|
|
78
|
+
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
79
|
+
// move around when the label changes.
|
|
80
|
+
anchor: popoverAnchor,
|
|
81
|
+
className: 'editor-post-template__dropdown',
|
|
82
|
+
placement: 'left-start',
|
|
83
|
+
offset: 36,
|
|
84
|
+
shift: true
|
|
85
|
+
}), [popoverAnchor]);
|
|
72
86
|
if (!hasResolved) {
|
|
73
87
|
return null;
|
|
74
88
|
}
|
|
@@ -87,49 +101,55 @@ function BlockThemeControl({
|
|
|
87
101
|
});
|
|
88
102
|
}
|
|
89
103
|
};
|
|
90
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
children:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
104
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPanelRow.default, {
|
|
105
|
+
label: (0, _i18n.__)('Template'),
|
|
106
|
+
ref: setPopoverAnchor,
|
|
107
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
|
|
108
|
+
popoverProps: popoverProps,
|
|
109
|
+
focusOnMount: true,
|
|
110
|
+
toggleProps: {
|
|
111
|
+
size: 'compact',
|
|
112
|
+
variant: 'tertiary',
|
|
113
|
+
tooltipPosition: 'middle left'
|
|
114
|
+
},
|
|
115
|
+
label: (0, _i18n.__)('Template options'),
|
|
116
|
+
text: (0, _htmlEntities.decodeEntities)(template.title),
|
|
117
|
+
icon: null,
|
|
118
|
+
children: ({
|
|
119
|
+
onClose
|
|
120
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
121
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.MenuGroup, {
|
|
122
|
+
children: [canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
|
|
123
|
+
onClick: () => {
|
|
124
|
+
onNavigateToEntityRecord({
|
|
125
|
+
postId: template.id,
|
|
126
|
+
postType: 'wp_template'
|
|
127
|
+
});
|
|
128
|
+
onClose();
|
|
129
|
+
mayShowTemplateEditNotice();
|
|
130
|
+
},
|
|
131
|
+
children: (0, _i18n.__)('Edit template')
|
|
132
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_swapTemplateButton.default, {
|
|
133
|
+
onClick: onClose
|
|
134
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_resetDefaultTemplate.default, {
|
|
135
|
+
onClick: onClose
|
|
136
|
+
}), canCreateTemplate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createNewTemplate.default, {
|
|
137
|
+
onClick: onClose
|
|
138
|
+
})]
|
|
139
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuGroup, {
|
|
140
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
|
|
141
|
+
icon: !isTemplateHidden ? _icons.check : undefined,
|
|
142
|
+
isSelected: !isTemplateHidden,
|
|
143
|
+
role: "menuitemcheckbox",
|
|
144
|
+
onClick: () => {
|
|
145
|
+
const newRenderingMode = isTemplateHidden ? 'template-locked' : 'post-only';
|
|
146
|
+
setRenderingMode(newRenderingMode);
|
|
147
|
+
setDefaultRenderingMode(newRenderingMode);
|
|
148
|
+
},
|
|
149
|
+
children: (0, _i18n.__)('Show template')
|
|
150
|
+
})
|
|
121
151
|
})]
|
|
122
|
-
})
|
|
123
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
|
|
124
|
-
icon: !isTemplateHidden ? _icons.check : undefined,
|
|
125
|
-
isSelected: !isTemplateHidden,
|
|
126
|
-
role: "menuitemcheckbox",
|
|
127
|
-
onClick: () => {
|
|
128
|
-
setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
|
|
129
|
-
},
|
|
130
|
-
children: (0, _i18n.__)('Show template')
|
|
131
|
-
})
|
|
132
|
-
})]
|
|
152
|
+
})
|
|
133
153
|
})
|
|
134
154
|
});
|
|
135
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_htmlEntities","_components","_i18n","_coreData","_icons","_notices","_preferences","_store","_swapTemplateButton","_interopRequireDefault","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","_jsxRuntime","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","useSelect","select","getRenderingMode","_getEditorSettings","unlock","editorStore","editorSettings","hasOwnProperty","get","getPreference","preferencesStore","editedRecord","template","hasResolved","useEntityRecord","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","canCreateTemplate","coreStore","canUser","kind","name","notificationAction","label","__","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","jsx","DropdownMenu","popoverProps","focusOnMount","toggleProps","size","variant","tooltipPosition","text","decodeEntities","title","icon","children","onClose","jsxs","Fragment","MenuGroup","MenuItem","postId","postType","default","check","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tsize: 'compact',\n\t\t\t\tvariant: 'tertiary',\n\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\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\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Show template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,mBAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,kBAAA,GAAAH,sBAAA,CAAAV,OAAA;AAAsD,IAAAc,WAAA,GAAAd,OAAA;AAnBtD;AACA;AACA;;AAUA;AACA;AACA;;AAOA,MAAMe,aAAa,GAAG;E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,CAAE,CAAC;YACHN,OAAO,CAAC,CAAC;YACThB,yBAAyB,CAAC,CAAC;UAC5B,CAAG;UAAAe,QAAA,EAED,IAAAnB,QAAE,EAAE,eAAgB;QAAC,CACd,CACV,eAED,IAAApC,WAAA,CAAA2C,GAAA,EAAChD,mBAAA,CAAAoE,OAAkB;UAAC1B,OAAO,EAAGmB;QAAS,CAAE,CAAC,eAC1C,IAAAxD,WAAA,CAAA2C,GAAA,EAAC9C,qBAAA,CAAAkE,OAAoB;UAAC1B,OAAO,EAAGmB;QAAS,CAAE,CAAC,EAC1C3B,iBAAiB,iBAClB,IAAA7B,WAAA,CAAA2C,GAAA,EAAC5C,kBAAA,CAAAgE,OAAiB;UAAC1B,OAAO,EAAGmB;QAAS,CAAE,CACxC;MAAA,CACS,CAAC,eACZ,IAAAxD,WAAA,CAAA2C,GAAA,EAACvD,WAAA,CAAAuE,SAAS;QAAAJ,QAAA,eACT,IAAAvD,WAAA,CAAA2C,GAAA,EAACvD,WAAA,CAAAwE,QAAQ;UACRN,IAAI,EAAG,CAAEhD,gBAAgB,GAAG0D,YAAK,GAAGzB,SAAW;UAC/C0B,UAAU,EAAG,CAAE3D,gBAAkB;UACjC4D,IAAI,EAAC,kBAAkB;UACvB7B,OAAO,EAAGA,CAAA,KAAM;YACfT,gBAAgB,CACftB,gBAAgB,GACb,iBAAiB,GACjB,WACJ,CAAC;UACF,CAAG;UAAAiD,QAAA,EAED,IAAAnB,QAAE,EAAE,eAAgB;QAAC,CACd;MAAC,CACD,CAAC;IAAA,CACX;EACF,CACY,CAAC;AAEjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_htmlEntities","_components","_element","_i18n","_coreData","_icons","_notices","_preferences","_postPanelRow","_interopRequireDefault","_store","_swapTemplateButton","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","_jsxRuntime","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","useSelect","select","getRenderingMode","_getEditorSettings","unlock","editorStore","editorSettings","hasOwnProperty","get","getPreference","preferencesStore","editedRecord","template","hasResolved","useEntityRecord","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","setDefaultRenderingMode","canCreateTemplate","coreStore","canUser","kind","name","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","className","placement","offset","shift","notificationAction","label","__","onClick","onNavigateToPreviousEntityRecord","undefined","mayShowTemplateEditNotice","type","actions","jsx","default","ref","children","DropdownMenu","focusOnMount","toggleProps","size","variant","tooltipPosition","text","decodeEntities","title","icon","onClose","jsxs","Fragment","MenuGroup","MenuItem","postId","postType","check","isSelected","role","newRenderingMode"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord, store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode, setDefaultRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst canCreateTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\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() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tclassName: 'editor-post-template__dropdown',\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\ttooltipPosition: 'middle left',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\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\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tconst newRenderingMode = isTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only';\n\t\t\t\t\t\t\t\t\tsetRenderingMode( newRenderingMode );\n\t\t\t\t\t\t\t\t\tsetDefaultRenderingMode( newRenderingMode );\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\t{ __( 'Show template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAKA,IAAAS,aAAA,GAAAC,sBAAA,CAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAF,sBAAA,CAAAV,OAAA;AACA,IAAAa,qBAAA,GAAAH,sBAAA,CAAAV,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AACA,IAAAe,kBAAA,GAAAL,sBAAA,CAAAV,OAAA;AAAsD,IAAAgB,WAA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/C0B,UAAU,EAAG,CAAEtE,gBAAkB;YACjCuE,IAAI,EAAC,kBAAkB;YACvB7B,OAAO,EAAGA,CAAA,KAAM;cACf,MAAM8B,gBAAgB,GAAGxE,gBAAgB,GACtC,iBAAiB,GACjB,WAAW;cACdsB,gBAAgB,CAAEkD,gBAAiB,CAAC;cACpCjD,uBAAuB,CAAEiD,gBAAiB,CAAC;YAC5C,CAAG;YAAArB,QAAA,EAED,IAAAV,QAAE,EAAE,eAAgB;UAAC,CACd;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACF,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@ var _notices = require("@wordpress/notices");
|
|
|
16
16
|
var _store = require("../../store");
|
|
17
17
|
var _createNewTemplateModal = _interopRequireDefault(require("./create-new-template-modal"));
|
|
18
18
|
var _hooks = require("./hooks");
|
|
19
|
+
var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
/**
|
|
21
22
|
* WordPress dependencies
|
|
@@ -25,10 +26,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
26
|
* Internal dependencies
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
|
-
const POPOVER_PROPS = {
|
|
29
|
-
className: 'editor-post-template__dropdown',
|
|
30
|
-
placement: 'bottom-start'
|
|
31
|
-
};
|
|
32
29
|
function PostTemplateToggle({
|
|
33
30
|
isOpen,
|
|
34
31
|
onClick
|
|
@@ -175,20 +172,35 @@ function PostTemplateDropdownContent({
|
|
|
175
172
|
});
|
|
176
173
|
}
|
|
177
174
|
function ClassicThemeControl() {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
175
|
+
const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
|
|
176
|
+
// Memoize popoverProps to avoid returning a new object every time.
|
|
177
|
+
const popoverProps = (0, _element.useMemo)(() => ({
|
|
178
|
+
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
179
|
+
// move around when the label changes.
|
|
180
|
+
anchor: popoverAnchor,
|
|
181
|
+
className: 'editor-post-template__dropdown',
|
|
182
|
+
placement: 'left-start',
|
|
183
|
+
offset: 36,
|
|
184
|
+
shift: true
|
|
185
|
+
}), [popoverAnchor]);
|
|
186
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPanelRow.default, {
|
|
187
|
+
label: (0, _i18n.__)('Template'),
|
|
188
|
+
ref: setPopoverAnchor,
|
|
189
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
|
|
190
|
+
popoverProps: popoverProps,
|
|
191
|
+
focusOnMount: true,
|
|
192
|
+
renderToggle: ({
|
|
193
|
+
isOpen,
|
|
194
|
+
onToggle
|
|
195
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTemplateToggle, {
|
|
196
|
+
isOpen: isOpen,
|
|
197
|
+
onClick: onToggle
|
|
198
|
+
}),
|
|
199
|
+
renderContent: ({
|
|
200
|
+
onClose
|
|
201
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(PostTemplateDropdownContent, {
|
|
202
|
+
onClose: onClose
|
|
203
|
+
})
|
|
192
204
|
})
|
|
193
205
|
});
|
|
194
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_data","_coreData","_blockEditor","_element","_icons","_notices","_store","_createNewTemplateModal","_interopRequireDefault","_hooks","_jsxRuntime","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","useSelect","select","templateSlug","editorStore","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","coreStore","canUser","kind","name","getCurrentTemplateId","title","slug","jsx","Button","__next40pxDefaultSize","variant","__","children","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","useAllowSwitchingTemplates","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","useMemo","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","useDispatch","createSuccessNotice","noticesStore","isCreateModalOpen","setIsCreateModalOpen","useState","jsxs","__experimentalInspectorPopoverHeader","help","actions","icon","addTemplate","Notice","status","isDismissible","SelectControl","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","default","ClassicThemeControl","Dropdown","popoverProps","focusOnMount","renderToggle","onToggle","renderContent","_default","exports"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\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', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) && select( editorStore ).getCurrentTemplateId();\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\t__next40pxDefaultSize\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the dropdown content for selecting a post template.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose The function to close the dropdown.\n *\n * @return {React.ReactNode} The rendered dropdown content.\n */\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\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\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\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} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\n/**\n * Provides a dropdown menu for selecting and managing post templates.\n *\n * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.\n *\n * @return {React.ReactNode} The rendered ClassicThemeControl component.\n */\nexport default ClassicThemeControl;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,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M,EAAGA,MAAQ;MAACC,OAAO,EAAGsF;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAE9D;IAAQ,CAAC,kBAC5B,IAAA/B,WAAA,CAAAwB,GAAA,EAACM,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAA+D,QAAA,GAAAC,OAAA,CAAAT,OAAA,GAOeC,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_coreData","_blockEditor","_element","_icons","_notices","_store","_createNewTemplateModal","_interopRequireDefault","_hooks","_postPanelRow","_jsxRuntime","PostTemplateToggle","isOpen","onClick","templateTitle","useSelect","select","templateSlug","editorStore","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","coreStore","canUser","kind","name","getCurrentTemplateId","title","slug","jsx","Button","__next40pxDefaultSize","variant","__","children","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","useAllowSwitchingTemplates","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","useMemo","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","useDispatch","createSuccessNotice","noticesStore","isCreateModalOpen","setIsCreateModalOpen","useState","jsxs","className","__experimentalInspectorPopoverHeader","help","actions","icon","addTemplate","Notice","status","isDismissible","SelectControl","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","default","ClassicThemeControl","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","ref","Dropdown","focusOnMount","renderToggle","onToggle","renderContent","_default","exports"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\nimport PostPanelRow from '../post-panel-row';\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', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) && select( editorStore ).getCurrentTemplateId();\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\t__next40pxDefaultSize\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the dropdown content for selecting a post template.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose The function to close the dropdown.\n *\n * @return {React.ReactNode} The rendered dropdown content.\n */\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\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\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\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} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\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() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tclassName: 'editor-post-template__dropdown',\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\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\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<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\n/**\n * Provides a dropdown menu for selecting and managing post templates.\n *\n * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.\n *\n * @return {React.ReactNode} The rendered ClassicThemeControl component.\n */\nexport default ClassicThemeControl;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,uBA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EAAGN,gBAAkB;IAAA7D,QAAA,eAChE,IAAA1B,WAAA,CAAAqB,GAAA,EAACjC,WAAA,CAAA0G,QAAQ;MACRN,YAAY,EAAGA,YAAc;MAC7BO,YAAY;MACZC,YAAY,EAAGA,CAAE;QAAE9F,MAAM;QAAE+F;MAAS,CAAC,kBACpC,IAAAjG,WAAA,CAAAqB,GAAA,EAACpB,kBAAkB;QAClBC,MAAM,EAAGA,MAAQ;QACjBC,OAAO,EAAG8F;MAAU,CACpB,CACC;MACHC,aAAa,EAAGA,CAAE;QAAEtE;MAAQ,CAAC,kBAC5B,IAAA5B,WAAA,CAAAqB,GAAA,EAACM,2BAA2B;QAACC,OAAO,EAAGA;MAAS,CAAE;IAChD,CACH;EAAC,CACW,CAAC;AAEjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAAuE,QAAA,GAAAC,OAAA,CAAAhB,OAAA,GAOeC,mBAAmB","ignoreList":[]}
|
|
@@ -100,7 +100,9 @@ function CreateNewTemplateModal({
|
|
|
100
100
|
onChange: setTitle,
|
|
101
101
|
placeholder: DEFAULT_TITLE,
|
|
102
102
|
disabled: isBusy,
|
|
103
|
-
help: (0, _i18n.__)(
|
|
103
|
+
help: (0, _i18n.__)(
|
|
104
|
+
// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
|
|
105
|
+
'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.')
|
|
104
106
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
105
107
|
justify: "right",
|
|
106
108
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_element","_blocks","_components","_i18n","_url","_lockUnlock","_store","_jsxRuntime","DEFAULT_TITLE","__","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","useSelect","select","getEditorSettings","getCurrentTemplateId","editorStore","getTemplateId","createTemplate","unlock","useDispatch","title","setTitle","useState","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","serialize","createBlock","tagName","layout","inherit","newTemplate","slug","cleanForSlug","content","postId","id","postType","jsx","Modal","onRequestClose","focusOnMount","size","children","className","onSubmit","jsxs","__experimentalVStack","spacing","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","__experimentalHStack","justify","Button","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAA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AAC,mCAAmC;MAC7CC,QAAQ,EAAGvB,MAAQ;MAAAqB,QAAA,eAEnB,IAAA3C,WAAA,CAAA8C,IAAA,EAACnD,WAAA,CAAAoD,oBAAM;QAACC,OAAO,EAAC,GAAG;QAAAL,QAAA,gBAClB,IAAA3C,WAAA,CAAAsC,GAAA,EAAC3C,WAAA,CAAAsD,WAAW;UACXC,qBAAqB;UACrBC,uBAAuB;UACvBC,KAAK,EAAG,IAAAlD,QAAE,EAAE,MAAO,CAAG;UACtBmD,KAAK,EAAGrC,KAAO;UACfsC,QAAQ,EAAGrC,QAAU;UACrBsC,WAAW,EAAGtD,aAAe;UAC7BuD,QAAQ,EAAGrC,MAAQ;UACnBsC,IAAI,EAAG,IAAAvD,QAAE,
|
|
1
|
+
{"version":3,"names":["_data","require","_element","_blocks","_components","_i18n","_url","_lockUnlock","_store","_jsxRuntime","DEFAULT_TITLE","__","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","useSelect","select","getEditorSettings","getCurrentTemplateId","editorStore","getTemplateId","createTemplate","unlock","useDispatch","title","setTitle","useState","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","serialize","createBlock","tagName","layout","inherit","newTemplate","slug","cleanForSlug","content","postId","id","postType","jsx","Modal","onRequestClose","focusOnMount","size","children","className","onSubmit","jsxs","__experimentalVStack","spacing","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","__experimentalHStack","justify","Button","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AApBnD;AACA;AACA;;AAcA;AACA;AACA;;AAIA,MAAMS,aAAa,GAAG,IAAAC,QAAE,EAAE,iBAAkB,CAAC;AAE9B,SAASC,sBAAsBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC7D,MAAM;IAAEC,oBAAoB;IAAEC;EAAyB,CAAC,GAAG,IAAAC,eAAS,EACjEC,MAAM,IAAM;IACb,MAAM;MAAEC,iBAAiB;MAAEC;IAAqB,CAAC,GAChDF,MAAM,CAAEG,YAAY,CAAC;IACtB,OAAO;MACNN,oBAAoB,EAAEI,iBAAiB,CAAC,CAAC,CAACJ,oBAAoB;MAC9DC,wBAAwB,EACvBG,iBAAi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AA,EAACnD,WAAA,CAAA+D,oBAAM;UAACC,OAAO,EAAC,OAAO;UAAAhB,QAAA,gBACtB,IAAA3C,WAAA,CAAAsC,GAAA,EAAC3C,WAAA,CAAAiE,MAAM;YACNV,qBAAqB;YACrBW,OAAO,EAAC,UAAU;YAClBC,OAAO,EAAGzC,MAAQ;YAAAsB,QAAA,EAEhB,IAAAzC,QAAE,EAAE,QAAS;UAAC,CACT,CAAC,eAET,IAAAF,WAAA,CAAAsC,GAAA,EAAC3C,WAAA,CAAAiE,MAAM;YACNV,qBAAqB;YACrBW,OAAO,EAAC,SAAS;YACjBE,IAAI,EAAC,QAAQ;YACb5C,MAAM,EAAGA,MAAQ;YACjB,iBAAgBA,MAAQ;YAAAwB,QAAA,EAEtB,IAAAzC,QAAE,EAAE,QAAS;UAAC,CACT,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
|
|
@@ -6,12 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = PostTemplatePanel;
|
|
8
8
|
var _data = require("@wordpress/data");
|
|
9
|
-
var _i18n = require("@wordpress/i18n");
|
|
10
9
|
var _coreData = require("@wordpress/core-data");
|
|
11
10
|
var _store = require("../../store");
|
|
12
11
|
var _classicTheme = _interopRequireDefault(require("./classic-theme"));
|
|
13
12
|
var _blockTheme = _interopRequireDefault(require("./block-theme"));
|
|
14
|
-
var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
|
|
15
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
14
|
/**
|
|
17
15
|
* WordPress dependencies
|
|
@@ -68,17 +66,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
68
66
|
})) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
|
|
69
67
|
}, []);
|
|
70
68
|
if ((!isBlockTheme || !canViewTemplates) && isVisible) {
|
|
71
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
72
|
-
label: (0, _i18n.__)('Template'),
|
|
73
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_classicTheme.default, {})
|
|
74
|
-
});
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_classicTheme.default, {});
|
|
75
70
|
}
|
|
76
71
|
if (isBlockTheme && !!templateId) {
|
|
77
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
78
|
-
|
|
79
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockTheme.default, {
|
|
80
|
-
id: templateId
|
|
81
|
-
})
|
|
72
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockTheme.default, {
|
|
73
|
+
id: templateId
|
|
82
74
|
});
|
|
83
75
|
}
|
|
84
76
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_store","_classicTheme","_interopRequireDefault","_blockTheme","_jsxRuntime","PostTemplatePanel","templateId","isBlockTheme","useSelect","select","getCurrentTemplateId","getEditorSettings","editorStore","__unstableIsBlockBasedTheme","isVisible","_select$canUser","postTypeSlug","getCurrentPostType","postType","coreStore","getPostType","viewable","settings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","kind","name","canViewTemplates","_select$canUser2","jsx","default","id"],"sources":["@wordpress/editor/src/components/post-template/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\n\n/**\n * Displays the template controls based on the current editor settings and user permissions.\n *\n * @return {React.ReactNode} The rendered PostTemplatePanel component.\n */\nexport default function PostTemplatePanel() {\n\tconst { templateId, isBlockTheme } = useSelect( ( select ) => {\n\t\tconst { getCurrentTemplateId, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tisBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme,\n\t\t};\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', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tconst canViewTemplates = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( coreStore ).canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) ?? false\n\t\t);\n\t}, [] );\n\n\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\treturn <ClassicThemeControl />;\n\t}\n\n\tif ( isBlockTheme && !! templateId ) {\n\t\treturn <BlockThemeControl id={ templateId } />;\n\t}\n\treturn null;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAA8C,IAAAM,WAAA,GAAAN,OAA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A,cAAAA,eAAA,GAAI,KAAK;IACb,OAAOc,kBAAkB;EAC1B,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMI,gBAAgB,GAAG,IAAAzB,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAyB,gBAAA;IACjD,QAAAA,gBAAA,GACCzB,MAAM,CAAEU,eAAU,CAAC,CAACW,OAAO,CAAE,MAAM,EAAE;MACpCC,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAE;IACP,CAAE,CAAC,cAAAE,gBAAA,cAAAA,gBAAA,GAAI,KAAK;EAEd,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAE,CAAE3B,YAAY,IAAI,CAAE0B,gBAAgB,KAAMnB,SAAS,EAAG;IAC5D,oBAAO,IAAAV,WAAA,CAAA+B,GAAA,EAAClC,aAAA,CAAAmC,OAAmB,IAAE,CAAC;EAC/B;EAEA,IAAK7B,YAAY,IAAI,CAAC,CAAED,UAAU,EAAG;IACpC,oBAAO,IAAAF,WAAA,CAAA+B,GAAA,EAAChC,WAAA,CAAAiC,OAAiB;MAACC,EAAE,EAAG/B;IAAY,CAAE,CAAC;EAC/C;EACA,OAAO,IAAI;AACZ","ignoreList":[]}
|
|
@@ -23,6 +23,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
23
23
|
const {
|
|
24
24
|
BlockManager
|
|
25
25
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
26
|
+
const EMPTY_ARRAY = [];
|
|
26
27
|
function BlockVisibility() {
|
|
27
28
|
const {
|
|
28
29
|
showBlockTypes,
|
|
@@ -37,7 +38,7 @@ function BlockVisibility() {
|
|
|
37
38
|
return {
|
|
38
39
|
blockTypes: select(_blocks.store).getBlockTypes(),
|
|
39
40
|
allowedBlockTypes: select(_store.store).getEditorSettings().allowedBlockTypes,
|
|
40
|
-
hiddenBlockTypes: (_select$get = select(_preferences.store).get('core', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get :
|
|
41
|
+
hiddenBlockTypes: (_select$get = select(_preferences.store).get('core', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get : EMPTY_ARRAY
|
|
41
42
|
};
|
|
42
43
|
}, []);
|
|
43
44
|
const allowedBlockTypes = (0, _element.useMemo)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_preferences","_blocks","_element","_blockEditor","_store","_lockUnlock","_jsxRuntime","BlockManager","unlock","blockEditorPrivateApis","BlockVisibility","showBlockTypes","hideBlockTypes","useDispatch","editorStore","blockTypes","allowedBlockTypes","_allowedBlockTypes","hiddenBlockTypes","_hiddenBlockTypes","useSelect","select","_select$get","blocksStore","getBlockTypes","getEditorSettings","preferencesStore","get","useMemo","filter","name","includes","filteredBlockTypes","blockType","hasBlockSupport","parent","hiddenBlock","some","registeredBlock","selectedBlockTypes","onChangeSelectedBlockTypes","newSelectedBlockTypes","length","blockTypesToHide","find","map","blockTypesToShow","jsx","onChange"],"sources":["@wordpress/editor/src/components/preferences-modal/block-visibility.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { BlockManager } = unlock( blockEditorPrivateApis );\n\nexport default function BlockVisibility() {\n\tconst { showBlockTypes, hideBlockTypes } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst {\n\t\tblockTypes,\n\t\tallowedBlockTypes: _allowedBlockTypes,\n\t\thiddenBlockTypes: _hiddenBlockTypes,\n\t} = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tblockTypes: select( blocksStore ).getBlockTypes(),\n\t\t\tallowedBlockTypes:\n\t\t\t\tselect( editorStore ).getEditorSettings().allowedBlockTypes,\n\t\t\thiddenBlockTypes:\n\t\t\t\tselect( preferencesStore ).get( 'core', 'hiddenBlockTypes' ) ??\n\t\t\t\
|
|
1
|
+
{"version":3,"names":["_data","require","_preferences","_blocks","_element","_blockEditor","_store","_lockUnlock","_jsxRuntime","BlockManager","unlock","blockEditorPrivateApis","EMPTY_ARRAY","BlockVisibility","showBlockTypes","hideBlockTypes","useDispatch","editorStore","blockTypes","allowedBlockTypes","_allowedBlockTypes","hiddenBlockTypes","_hiddenBlockTypes","useSelect","select","_select$get","blocksStore","getBlockTypes","getEditorSettings","preferencesStore","get","useMemo","filter","name","includes","filteredBlockTypes","blockType","hasBlockSupport","parent","hiddenBlock","some","registeredBlock","selectedBlockTypes","onChangeSelectedBlockTypes","newSelectedBlockTypes","length","blockTypesToHide","find","map","blockTypesToShow","jsx","onChange"],"sources":["@wordpress/editor/src/components/preferences-modal/block-visibility.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { BlockManager } = unlock( blockEditorPrivateApis );\nconst EMPTY_ARRAY = [];\n\nexport default function BlockVisibility() {\n\tconst { showBlockTypes, hideBlockTypes } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst {\n\t\tblockTypes,\n\t\tallowedBlockTypes: _allowedBlockTypes,\n\t\thiddenBlockTypes: _hiddenBlockTypes,\n\t} = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tblockTypes: select( blocksStore ).getBlockTypes(),\n\t\t\tallowedBlockTypes:\n\t\t\t\tselect( editorStore ).getEditorSettings().allowedBlockTypes,\n\t\t\thiddenBlockTypes:\n\t\t\t\tselect( preferencesStore ).get( 'core', 'hiddenBlockTypes' ) ??\n\t\t\t\tEMPTY_ARRAY,\n\t\t};\n\t}, [] );\n\n\tconst allowedBlockTypes = useMemo( () => {\n\t\tif ( _allowedBlockTypes === true ) {\n\t\t\treturn blockTypes;\n\t\t}\n\t\treturn blockTypes.filter( ( { name } ) => {\n\t\t\treturn _allowedBlockTypes?.includes( name );\n\t\t} );\n\t}, [ _allowedBlockTypes, blockTypes ] );\n\n\tconst filteredBlockTypes = allowedBlockTypes.filter(\n\t\t( blockType ) =>\n\t\t\thasBlockSupport( blockType, 'inserter', true ) &&\n\t\t\t( ! blockType.parent ||\n\t\t\t\tblockType.parent.includes( 'core/post-content' ) )\n\t);\n\n\t// Some hidden blocks become unregistered\n\t// by removing for instance the plugin that registered them, yet\n\t// they're still remain as hidden by the user's action.\n\t// We consider \"hidden\", blocks which were hidden and\n\t// are still registered.\n\tconst hiddenBlockTypes = _hiddenBlockTypes.filter( ( hiddenBlock ) => {\n\t\treturn filteredBlockTypes.some(\n\t\t\t( registeredBlock ) => registeredBlock.name === hiddenBlock\n\t\t);\n\t} );\n\n\tconst selectedBlockTypes = filteredBlockTypes.filter(\n\t\t( blockType ) => ! hiddenBlockTypes.includes( blockType.name )\n\t);\n\n\tconst onChangeSelectedBlockTypes = ( newSelectedBlockTypes ) => {\n\t\tif ( selectedBlockTypes.length > newSelectedBlockTypes.length ) {\n\t\t\tconst blockTypesToHide = selectedBlockTypes.filter(\n\t\t\t\t( blockType ) =>\n\t\t\t\t\t! newSelectedBlockTypes.find(\n\t\t\t\t\t\t( { name } ) => name === blockType.name\n\t\t\t\t\t)\n\t\t\t);\n\t\t\thideBlockTypes( blockTypesToHide.map( ( { name } ) => name ) );\n\t\t} else if ( selectedBlockTypes.length < newSelectedBlockTypes.length ) {\n\t\t\tconst blockTypesToShow = newSelectedBlockTypes.filter(\n\t\t\t\t( blockType ) =>\n\t\t\t\t\t! selectedBlockTypes.find(\n\t\t\t\t\t\t( { name } ) => name === blockType.name\n\t\t\t\t\t)\n\t\t\t);\n\t\t\tshowBlockTypes( blockTypesToShow.map( ( { name } ) => name ) );\n\t\t}\n\t};\n\n\treturn (\n\t\t<BlockManager\n\t\t\tblockTypes={ filteredBlockTypes }\n\t\t\tselectedBlockTypes={ selectedBlockTypes }\n\t\t\tonChange={ onChangeSelectedBlockTypes }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAA2C,IAAAO,WAAA,GAAAP,OAAA;AAb3C;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EAAEQ;AAAa,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AACzD,MAAMC,WAAW,GAAG,EAAE;AAEP,SAASC,eAAeA,CAAA,EAAG;EACzC,MAAM;IAAEC,cAAc;IAAEC;EAAe,CAAC,GAAG,IAAAL,kBAAM,EAChD,IAAAM,iBAAW,EAAEC,YAAY,CAC1B,CAAC;EAED,MAAM;IACLC,UAAU;IACVC,iBAAiB,EAAEC,kBAAkB;IACrCC,gBAAgB,EAAEC;EACnB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,WAAA;IAC5B,OAAO;MACNP,UAAU,EAAEM,MAAM,CAAEE,aAAY,CAAC,CAACC,aAAa,CAAC,CAAC;MACjDR,iBAAiB,EAChBK,MAAM,CAAEP,YAAY,CAAC,CAACW,iBAAiB,CAAC,CAAC,CAACT,iBAAiB;MAC5DE,gBAAgB,GAAAI,WAAA,GACfD,MAAM,CAAEK,kBAAiB,CAAC,CAACC,GAAG,CAAE,MAAM,EAAE,k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I,KAAKG,SAAS,CAACH,IACpC,CACF,CAAC;MACDlB,cAAc,CAAE+B,gBAAgB,CAACE,GAAG,CAAE,CAAE;QAAEf;MAAK,CAAC,KAAMA,IAAK,CAAE,CAAC;IAC/D,CAAC,MAAM,IAAKS,kBAAkB,CAACG,MAAM,GAAGD,qBAAqB,CAACC,MAAM,EAAG;MACtE,MAAMI,gBAAgB,GAAGL,qBAAqB,CAACZ,MAAM,CAClDI,SAAS,IACV,CAAEM,kBAAkB,CAACK,IAAI,CACxB,CAAE;QAAEd;MAAK,CAAC,KAAMA,IAAI,KAAKG,SAAS,CAACH,IACpC,CACF,CAAC;MACDnB,cAAc,CAAEmC,gBAAgB,CAACD,GAAG,CAAE,CAAE;QAAEf;MAAK,CAAC,KAAMA,IAAK,CAAE,CAAC;IAC/D;EACD,CAAC;EAED,oBACC,IAAAzB,WAAA,CAAA0C,GAAA,EAACzC,YAAY;IACZS,UAAU,EAAGiB,kBAAoB;IACjCO,kBAAkB,EAAGA,kBAAoB;IACzCS,QAAQ,EAAGR;EAA4B,CACvC,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -90,7 +90,7 @@ function PreferencesModalContents({
|
|
|
90
90
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PreferenceToggleControl, {
|
|
91
91
|
scope: "core",
|
|
92
92
|
featureName: "showListViewByDefault",
|
|
93
|
-
help: (0, _i18n.__)('Opens the List View
|
|
93
|
+
help: (0, _i18n.__)('Opens the List View panel by default.'),
|
|
94
94
|
label: (0, _i18n.__)('Always open List View')
|
|
95
95
|
}), showBlockBreadcrumbsOption && /*#__PURE__*/(0, _jsxRuntime.jsx)(PreferenceToggleControl, {
|
|
96
96
|
scope: "core",
|