@wordpress/core-commands 1.32.0 → 1.32.1-next.47f435fc9.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/build/admin-navigation-commands.js +59 -40
- package/build/admin-navigation-commands.js.map +7 -1
- package/build/index.js +45 -56
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/private-apis.js +33 -17
- package/build/private-apis.js.map +7 -1
- package/build/site-editor-navigation-commands.js +294 -266
- package/build/site-editor-navigation-commands.js.map +7 -1
- package/build/utils/order-entity-records-by-search.js +27 -7
- package/build/utils/order-entity-records-by-search.js.map +7 -1
- package/build-module/admin-navigation-commands.js +34 -31
- package/build-module/admin-navigation-commands.js.map +7 -1
- package/build-module/index.js +22 -44
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/private-apis.js +8 -8
- package/build-module/private-apis.js.map +7 -1
- package/build-module/site-editor-navigation-commands.js +256 -235
- package/build-module/site-editor-navigation-commands.js.map +7 -1
- package/build-module/utils/order-entity-records-by-search.js +5 -2
- package/build-module/utils/order-entity-records-by-search.js.map +7 -1
- package/package.json +22 -16
|
@@ -1,122 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var site_editor_navigation_commands_exports = {};
|
|
19
|
+
__export(site_editor_navigation_commands_exports, {
|
|
20
|
+
useSiteEditorNavigationCommands: () => useSiteEditorNavigationCommands
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
* WordPress dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
useHistory
|
|
29
|
-
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
22
|
+
module.exports = __toCommonJS(site_editor_navigation_commands_exports);
|
|
23
|
+
var import_commands = require("@wordpress/commands");
|
|
24
|
+
var import_i18n = require("@wordpress/i18n");
|
|
25
|
+
var import_element = require("@wordpress/element");
|
|
26
|
+
var import_data = require("@wordpress/data");
|
|
27
|
+
var import_core_data = require("@wordpress/core-data");
|
|
28
|
+
var import_icons = require("@wordpress/icons");
|
|
29
|
+
var import_router = require("@wordpress/router");
|
|
30
|
+
var import_url = require("@wordpress/url");
|
|
31
|
+
var import_compose = require("@wordpress/compose");
|
|
32
|
+
var import_html_entities = require("@wordpress/html-entities");
|
|
33
|
+
var import_lock_unlock = require("./lock-unlock");
|
|
34
|
+
var import_order_entity_records_by_search = require("./utils/order-entity-records-by-search");
|
|
35
|
+
const { useHistory } = (0, import_lock_unlock.unlock)(import_router.privateApis);
|
|
30
36
|
const icons = {
|
|
31
|
-
post:
|
|
32
|
-
page:
|
|
33
|
-
wp_template:
|
|
34
|
-
wp_registered_template:
|
|
35
|
-
wp_template_part:
|
|
37
|
+
post: import_icons.post,
|
|
38
|
+
page: import_icons.page,
|
|
39
|
+
wp_template: import_icons.layout,
|
|
40
|
+
wp_registered_template: import_icons.layout,
|
|
41
|
+
wp_template_part: import_icons.symbolFilled
|
|
36
42
|
};
|
|
37
43
|
function useDebouncedValue(value) {
|
|
38
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
39
|
-
const debounced = (0,
|
|
40
|
-
(0,
|
|
44
|
+
const [debouncedValue, setDebouncedValue] = (0, import_element.useState)("");
|
|
45
|
+
const debounced = (0, import_compose.useDebounce)(setDebouncedValue, 250);
|
|
46
|
+
(0, import_element.useEffect)(() => {
|
|
41
47
|
debounced(value);
|
|
42
48
|
return () => debounced.cancel();
|
|
43
49
|
}, [debounced, value]);
|
|
44
50
|
return debouncedValue;
|
|
45
51
|
}
|
|
46
|
-
const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({
|
|
47
|
-
search
|
|
48
|
-
}) {
|
|
52
|
+
const getNavigationCommandLoaderPerPostType = (postType) => function useNavigationCommandLoader({ search }) {
|
|
49
53
|
const history = useHistory();
|
|
50
|
-
const {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const { isBlockBasedTheme, canCreateTemplate } = (0, import_data.useSelect)(
|
|
55
|
+
(select) => {
|
|
56
|
+
return {
|
|
57
|
+
isBlockBasedTheme: select(import_core_data.store).getCurrentTheme()?.is_block_theme,
|
|
58
|
+
canCreateTemplate: select(import_core_data.store).canUser("create", {
|
|
59
|
+
kind: "postType",
|
|
60
|
+
name: "wp_template"
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
[]
|
|
65
|
+
);
|
|
62
66
|
const delayedSearch = useDebouncedValue(search);
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const { records, isLoading } = (0, import_data.useSelect)(
|
|
68
|
+
(select) => {
|
|
69
|
+
if (!delayedSearch) {
|
|
70
|
+
return {
|
|
71
|
+
isLoading: false
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const query = {
|
|
75
|
+
search: delayedSearch,
|
|
76
|
+
per_page: 10,
|
|
77
|
+
orderby: "relevance",
|
|
78
|
+
status: [
|
|
79
|
+
"publish",
|
|
80
|
+
"future",
|
|
81
|
+
"draft",
|
|
82
|
+
"pending",
|
|
83
|
+
"private"
|
|
84
|
+
]
|
|
85
|
+
};
|
|
68
86
|
return {
|
|
69
|
-
|
|
87
|
+
records: select(import_core_data.store).getEntityRecords(
|
|
88
|
+
"postType",
|
|
89
|
+
postType,
|
|
90
|
+
query
|
|
91
|
+
),
|
|
92
|
+
isLoading: !select(import_core_data.store).hasFinishedResolution(
|
|
93
|
+
"getEntityRecords",
|
|
94
|
+
["postType", postType, query]
|
|
95
|
+
)
|
|
70
96
|
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
status: ['publish', 'future', 'draft', 'pending', 'private']
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
records: select(_coreData.store).getEntityRecords('postType', postType, query),
|
|
80
|
-
isLoading: !select(_coreData.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
|
|
81
|
-
};
|
|
82
|
-
}, [delayedSearch]);
|
|
83
|
-
const commands = (0, _element.useMemo)(() => {
|
|
84
|
-
return (records !== null && records !== void 0 ? records : []).map(record => {
|
|
97
|
+
},
|
|
98
|
+
[delayedSearch]
|
|
99
|
+
);
|
|
100
|
+
const commands = (0, import_element.useMemo)(() => {
|
|
101
|
+
return (records ?? []).map((record) => {
|
|
85
102
|
const command = {
|
|
86
|
-
name: postType +
|
|
87
|
-
searchLabel: record.title?.rendered +
|
|
88
|
-
label: record.title?.rendered ? (0,
|
|
103
|
+
name: postType + "-" + record.id,
|
|
104
|
+
searchLabel: record.title?.rendered + " " + record.id,
|
|
105
|
+
label: record.title?.rendered ? (0, import_html_entities.decodeEntities)(record.title?.rendered) : (0, import_i18n.__)("(no title)"),
|
|
89
106
|
icon: icons[postType]
|
|
90
107
|
};
|
|
91
|
-
if (!canCreateTemplate || postType ===
|
|
108
|
+
if (!canCreateTemplate || postType === "post" || postType === "page" && !isBlockBasedTheme) {
|
|
92
109
|
return {
|
|
93
110
|
...command,
|
|
94
|
-
callback: ({
|
|
95
|
-
close
|
|
96
|
-
}) => {
|
|
111
|
+
callback: ({ close }) => {
|
|
97
112
|
const args = {
|
|
98
113
|
post: record.id,
|
|
99
|
-
action:
|
|
114
|
+
action: "edit"
|
|
100
115
|
};
|
|
101
|
-
const targetUrl = (0,
|
|
116
|
+
const targetUrl = (0, import_url.addQueryArgs)("post.php", args);
|
|
102
117
|
document.location = targetUrl;
|
|
103
118
|
close();
|
|
104
119
|
}
|
|
105
120
|
};
|
|
106
121
|
}
|
|
107
|
-
const isSiteEditor = (0,
|
|
122
|
+
const isSiteEditor = (0, import_url.getPath)(window.location.href)?.includes(
|
|
123
|
+
"site-editor.php"
|
|
124
|
+
);
|
|
108
125
|
return {
|
|
109
126
|
...command,
|
|
110
|
-
callback: ({
|
|
111
|
-
close
|
|
112
|
-
}) => {
|
|
127
|
+
callback: ({ close }) => {
|
|
113
128
|
if (isSiteEditor) {
|
|
114
|
-
history.navigate(
|
|
129
|
+
history.navigate(
|
|
130
|
+
`/${postType}/${record.id}?canvas=edit`
|
|
131
|
+
);
|
|
115
132
|
} else {
|
|
116
|
-
document.location = (0,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
133
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
134
|
+
"site-editor.php",
|
|
135
|
+
{
|
|
136
|
+
p: `/${postType}/${record.id}`,
|
|
137
|
+
canvas: "edit"
|
|
138
|
+
}
|
|
139
|
+
);
|
|
120
140
|
}
|
|
121
141
|
close();
|
|
122
142
|
}
|
|
@@ -128,89 +148,87 @@ const getNavigationCommandLoaderPerPostType = postType => function useNavigation
|
|
|
128
148
|
isLoading
|
|
129
149
|
};
|
|
130
150
|
};
|
|
131
|
-
const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({
|
|
132
|
-
search
|
|
133
|
-
}) {
|
|
151
|
+
const getNavigationCommandLoaderPerTemplate = (templateType) => function useNavigationCommandLoader({ search }) {
|
|
134
152
|
const history = useHistory();
|
|
135
|
-
const {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
} = (0, _data.useSelect)(select => {
|
|
151
|
-
const {
|
|
152
|
-
getEntityRecords
|
|
153
|
-
} = select(_coreData.store);
|
|
154
|
-
const query = {
|
|
155
|
-
per_page: -1
|
|
156
|
-
};
|
|
153
|
+
const { isBlockBasedTheme, canCreateTemplate } = (0, import_data.useSelect)(
|
|
154
|
+
(select) => {
|
|
155
|
+
return {
|
|
156
|
+
isBlockBasedTheme: select(import_core_data.store).getCurrentTheme()?.is_block_theme,
|
|
157
|
+
canCreateTemplate: select(import_core_data.store).canUser("read", {
|
|
158
|
+
kind: "postType",
|
|
159
|
+
name: templateType
|
|
160
|
+
})
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
[]
|
|
164
|
+
);
|
|
165
|
+
const { records, isLoading } = (0, import_data.useSelect)((select) => {
|
|
166
|
+
const { getEntityRecords } = select(import_core_data.store);
|
|
167
|
+
const query = { per_page: -1 };
|
|
157
168
|
return {
|
|
158
|
-
records: getEntityRecords(
|
|
159
|
-
isLoading: !select(
|
|
169
|
+
records: getEntityRecords("postType", templateType, query),
|
|
170
|
+
isLoading: !select(import_core_data.store).hasFinishedResolution(
|
|
171
|
+
"getEntityRecords",
|
|
172
|
+
["postType", templateType, query]
|
|
173
|
+
)
|
|
160
174
|
};
|
|
161
175
|
}, []);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* wp_template and wp_template_part endpoints do not support per_page or orderby parameters.
|
|
165
|
-
* We need to sort the results based on the search query to avoid removing relevant
|
|
166
|
-
* records below using .slice().
|
|
167
|
-
*/
|
|
168
|
-
const orderedRecords = (0, _element.useMemo)(() => {
|
|
169
|
-
return (0, _orderEntityRecordsBySearch.orderEntityRecordsBySearch)(records, search).slice(0, 10);
|
|
176
|
+
const orderedRecords = (0, import_element.useMemo)(() => {
|
|
177
|
+
return (0, import_order_entity_records_by_search.orderEntityRecordsBySearch)(records, search).slice(0, 10);
|
|
170
178
|
}, [records, search]);
|
|
171
|
-
const commands = (0,
|
|
172
|
-
if (!canCreateTemplate || !isBlockBasedTheme && !templateType ===
|
|
179
|
+
const commands = (0, import_element.useMemo)(() => {
|
|
180
|
+
if (!canCreateTemplate || !isBlockBasedTheme && !templateType === "wp_template_part") {
|
|
173
181
|
return [];
|
|
174
182
|
}
|
|
175
|
-
const isSiteEditor = (0,
|
|
183
|
+
const isSiteEditor = (0, import_url.getPath)(window.location.href)?.includes(
|
|
184
|
+
"site-editor.php"
|
|
185
|
+
);
|
|
176
186
|
const result = [];
|
|
177
|
-
result.push(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
close
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
result.push(
|
|
188
|
+
...orderedRecords.map((record) => {
|
|
189
|
+
return {
|
|
190
|
+
name: templateType + "-" + record.id,
|
|
191
|
+
searchLabel: record.title?.rendered + " " + record.id,
|
|
192
|
+
label: record.title?.rendered ? record.title?.rendered : (0, import_i18n.__)("(no title)"),
|
|
193
|
+
icon: icons[templateType],
|
|
194
|
+
callback: ({ close }) => {
|
|
195
|
+
if (isSiteEditor) {
|
|
196
|
+
history.navigate(
|
|
197
|
+
`/${templateType}/${record.id}?canvas=edit`
|
|
198
|
+
);
|
|
199
|
+
} else {
|
|
200
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
201
|
+
"site-editor.php",
|
|
202
|
+
{
|
|
203
|
+
p: `/${templateType}/${record.id}`,
|
|
204
|
+
canvas: "edit"
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
close();
|
|
193
209
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (orderedRecords?.length > 0 && templateType === 'wp_template_part') {
|
|
210
|
+
};
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
if (orderedRecords?.length > 0 && templateType === "wp_template_part") {
|
|
199
214
|
result.push({
|
|
200
|
-
name:
|
|
201
|
-
label: (0,
|
|
202
|
-
icon:
|
|
203
|
-
callback: ({
|
|
204
|
-
close
|
|
205
|
-
}) => {
|
|
215
|
+
name: "core/edit-site/open-template-parts",
|
|
216
|
+
label: (0, import_i18n.__)("Go to: Template parts"),
|
|
217
|
+
icon: import_icons.symbolFilled,
|
|
218
|
+
callback: ({ close }) => {
|
|
206
219
|
if (isSiteEditor) {
|
|
207
|
-
history.navigate(
|
|
220
|
+
history.navigate(
|
|
221
|
+
"/pattern?postType=wp_template_part&categoryId=all-parts"
|
|
222
|
+
);
|
|
208
223
|
} else {
|
|
209
|
-
document.location = (0,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
224
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
225
|
+
"site-editor.php",
|
|
226
|
+
{
|
|
227
|
+
p: "/pattern",
|
|
228
|
+
postType: "wp_template_part",
|
|
229
|
+
categoryId: "all-parts"
|
|
230
|
+
}
|
|
231
|
+
);
|
|
214
232
|
}
|
|
215
233
|
close();
|
|
216
234
|
}
|
|
@@ -225,75 +243,75 @@ const getNavigationCommandLoaderPerTemplate = templateType => function useNaviga
|
|
|
225
243
|
};
|
|
226
244
|
const getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNavigationCommands() {
|
|
227
245
|
const history = useHistory();
|
|
228
|
-
const isSiteEditor = (0,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
canCreatePatterns
|
|
233
|
-
} = (0, _data.useSelect)(select => {
|
|
246
|
+
const isSiteEditor = (0, import_url.getPath)(window.location.href)?.includes(
|
|
247
|
+
"site-editor.php"
|
|
248
|
+
);
|
|
249
|
+
const { isBlockBasedTheme, canCreateTemplate, canCreatePatterns } = (0, import_data.useSelect)((select) => {
|
|
234
250
|
return {
|
|
235
|
-
isBlockBasedTheme: select(
|
|
236
|
-
canCreateTemplate: select(
|
|
237
|
-
kind:
|
|
238
|
-
name:
|
|
251
|
+
isBlockBasedTheme: select(import_core_data.store).getCurrentTheme()?.is_block_theme,
|
|
252
|
+
canCreateTemplate: select(import_core_data.store).canUser("create", {
|
|
253
|
+
kind: "postType",
|
|
254
|
+
name: "wp_template"
|
|
239
255
|
}),
|
|
240
|
-
canCreatePatterns: select(
|
|
241
|
-
kind:
|
|
242
|
-
name:
|
|
256
|
+
canCreatePatterns: select(import_core_data.store).canUser("create", {
|
|
257
|
+
kind: "postType",
|
|
258
|
+
name: "wp_block"
|
|
243
259
|
})
|
|
244
260
|
};
|
|
245
261
|
}, []);
|
|
246
|
-
const commands = (0,
|
|
262
|
+
const commands = (0, import_element.useMemo)(() => {
|
|
247
263
|
const result = [];
|
|
248
264
|
if (canCreateTemplate && isBlockBasedTheme) {
|
|
249
|
-
// Go to Styles command
|
|
250
265
|
result.push({
|
|
251
|
-
name:
|
|
252
|
-
label: (0,
|
|
253
|
-
icon:
|
|
254
|
-
callback: ({
|
|
255
|
-
close
|
|
256
|
-
}) => {
|
|
266
|
+
name: "core/edit-site/open-styles",
|
|
267
|
+
label: (0, import_i18n.__)("Go to: Styles"),
|
|
268
|
+
icon: import_icons.styles,
|
|
269
|
+
callback: ({ close }) => {
|
|
257
270
|
if (isSiteEditor) {
|
|
258
|
-
history.navigate(
|
|
271
|
+
history.navigate("/styles");
|
|
259
272
|
} else {
|
|
260
|
-
document.location = (0,
|
|
261
|
-
|
|
262
|
-
|
|
273
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
274
|
+
"site-editor.php",
|
|
275
|
+
{
|
|
276
|
+
p: "/styles"
|
|
277
|
+
}
|
|
278
|
+
);
|
|
263
279
|
}
|
|
264
280
|
close();
|
|
265
281
|
}
|
|
266
282
|
});
|
|
267
283
|
result.push({
|
|
268
|
-
name:
|
|
269
|
-
label: (0,
|
|
270
|
-
icon:
|
|
271
|
-
callback: ({
|
|
272
|
-
close
|
|
273
|
-
}) => {
|
|
284
|
+
name: "core/edit-site/open-navigation",
|
|
285
|
+
label: (0, import_i18n.__)("Go to: Navigation"),
|
|
286
|
+
icon: import_icons.navigation,
|
|
287
|
+
callback: ({ close }) => {
|
|
274
288
|
if (isSiteEditor) {
|
|
275
|
-
history.navigate(
|
|
289
|
+
history.navigate("/navigation");
|
|
276
290
|
} else {
|
|
277
|
-
document.location = (0,
|
|
278
|
-
|
|
279
|
-
|
|
291
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
292
|
+
"site-editor.php",
|
|
293
|
+
{
|
|
294
|
+
p: "/navigation"
|
|
295
|
+
}
|
|
296
|
+
);
|
|
280
297
|
}
|
|
281
298
|
close();
|
|
282
299
|
}
|
|
283
300
|
});
|
|
284
301
|
result.push({
|
|
285
|
-
name:
|
|
286
|
-
label: (0,
|
|
287
|
-
icon:
|
|
288
|
-
callback: ({
|
|
289
|
-
close
|
|
290
|
-
}) => {
|
|
302
|
+
name: "core/edit-site/open-templates",
|
|
303
|
+
label: (0, import_i18n.__)("Go to: Templates"),
|
|
304
|
+
icon: import_icons.layout,
|
|
305
|
+
callback: ({ close }) => {
|
|
291
306
|
if (isSiteEditor) {
|
|
292
|
-
history.navigate(
|
|
307
|
+
history.navigate("/template");
|
|
293
308
|
} else {
|
|
294
|
-
document.location = (0,
|
|
295
|
-
|
|
296
|
-
|
|
309
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
310
|
+
"site-editor.php",
|
|
311
|
+
{
|
|
312
|
+
p: "/template"
|
|
313
|
+
}
|
|
314
|
+
);
|
|
297
315
|
}
|
|
298
316
|
close();
|
|
299
317
|
}
|
|
@@ -301,30 +319,36 @@ const getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNa
|
|
|
301
319
|
}
|
|
302
320
|
if (canCreatePatterns) {
|
|
303
321
|
result.push({
|
|
304
|
-
name:
|
|
305
|
-
label: (0,
|
|
306
|
-
icon:
|
|
307
|
-
callback: ({
|
|
308
|
-
close
|
|
309
|
-
}) => {
|
|
322
|
+
name: "core/edit-site/open-patterns",
|
|
323
|
+
label: (0, import_i18n.__)("Go to: Patterns"),
|
|
324
|
+
icon: import_icons.symbol,
|
|
325
|
+
callback: ({ close }) => {
|
|
310
326
|
if (canCreateTemplate) {
|
|
311
327
|
if (isSiteEditor) {
|
|
312
|
-
history.navigate(
|
|
328
|
+
history.navigate("/pattern");
|
|
313
329
|
} else {
|
|
314
|
-
document.location = (0,
|
|
315
|
-
|
|
316
|
-
|
|
330
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
331
|
+
"site-editor.php",
|
|
332
|
+
{
|
|
333
|
+
p: "/pattern"
|
|
334
|
+
}
|
|
335
|
+
);
|
|
317
336
|
}
|
|
318
337
|
close();
|
|
319
338
|
} else {
|
|
320
|
-
|
|
321
|
-
document.location.href = 'edit.php?post_type=wp_block';
|
|
339
|
+
document.location.href = "edit.php?post_type=wp_block";
|
|
322
340
|
}
|
|
323
341
|
}
|
|
324
342
|
});
|
|
325
343
|
}
|
|
326
344
|
return result;
|
|
327
|
-
}, [
|
|
345
|
+
}, [
|
|
346
|
+
history,
|
|
347
|
+
isSiteEditor,
|
|
348
|
+
canCreateTemplate,
|
|
349
|
+
canCreatePatterns,
|
|
350
|
+
isBlockBasedTheme
|
|
351
|
+
]);
|
|
328
352
|
return {
|
|
329
353
|
commands,
|
|
330
354
|
isLoading: false
|
|
@@ -332,42 +356,42 @@ const getSiteEditorBasicNavigationCommands = () => function useSiteEditorBasicNa
|
|
|
332
356
|
};
|
|
333
357
|
const getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssCommands() {
|
|
334
358
|
const history = useHistory();
|
|
335
|
-
const isSiteEditor = (0,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
} = (0,
|
|
339
|
-
const {
|
|
340
|
-
getEntityRecord,
|
|
341
|
-
__experimentalGetCurrentGlobalStylesId
|
|
342
|
-
} = select(_coreData.store);
|
|
359
|
+
const isSiteEditor = (0, import_url.getPath)(window.location.href)?.includes(
|
|
360
|
+
"site-editor.php"
|
|
361
|
+
);
|
|
362
|
+
const { canEditCSS } = (0, import_data.useSelect)((select) => {
|
|
363
|
+
const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = select(import_core_data.store);
|
|
343
364
|
const globalStylesId = __experimentalGetCurrentGlobalStylesId();
|
|
344
|
-
const globalStyles = globalStylesId ? getEntityRecord(
|
|
365
|
+
const globalStyles = globalStylesId ? getEntityRecord("root", "globalStyles", globalStylesId) : void 0;
|
|
345
366
|
return {
|
|
346
|
-
canEditCSS: !!globalStyles?._links?.[
|
|
367
|
+
canEditCSS: !!globalStyles?._links?.["wp:action-edit-css"]
|
|
347
368
|
};
|
|
348
369
|
}, []);
|
|
349
|
-
const commands = (0,
|
|
370
|
+
const commands = (0, import_element.useMemo)(() => {
|
|
350
371
|
if (!canEditCSS) {
|
|
351
372
|
return [];
|
|
352
373
|
}
|
|
353
|
-
return [
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
close
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
374
|
+
return [
|
|
375
|
+
{
|
|
376
|
+
name: "core/open-styles-css",
|
|
377
|
+
label: (0, import_i18n.__)("Open custom CSS"),
|
|
378
|
+
icon: import_icons.brush,
|
|
379
|
+
callback: ({ close }) => {
|
|
380
|
+
close();
|
|
381
|
+
if (isSiteEditor) {
|
|
382
|
+
history.navigate("/styles?section=/css");
|
|
383
|
+
} else {
|
|
384
|
+
document.location = (0, import_url.addQueryArgs)(
|
|
385
|
+
"site-editor.php",
|
|
386
|
+
{
|
|
387
|
+
p: "/styles",
|
|
388
|
+
section: "/css"
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
}
|
|
368
392
|
}
|
|
369
393
|
}
|
|
370
|
-
|
|
394
|
+
];
|
|
371
395
|
}, [history, canEditCSS, isSiteEditor]);
|
|
372
396
|
return {
|
|
373
397
|
isLoading: false,
|
|
@@ -375,34 +399,38 @@ const getGlobalStylesOpenCssCommands = () => function useGlobalStylesOpenCssComm
|
|
|
375
399
|
};
|
|
376
400
|
};
|
|
377
401
|
function useSiteEditorNavigationCommands() {
|
|
378
|
-
(0,
|
|
379
|
-
name:
|
|
380
|
-
hook: getNavigationCommandLoaderPerPostType(
|
|
402
|
+
(0, import_commands.useCommandLoader)({
|
|
403
|
+
name: "core/edit-site/navigate-pages",
|
|
404
|
+
hook: getNavigationCommandLoaderPerPostType("page")
|
|
381
405
|
});
|
|
382
|
-
(0,
|
|
383
|
-
name:
|
|
384
|
-
hook: getNavigationCommandLoaderPerPostType(
|
|
406
|
+
(0, import_commands.useCommandLoader)({
|
|
407
|
+
name: "core/edit-site/navigate-posts",
|
|
408
|
+
hook: getNavigationCommandLoaderPerPostType("post")
|
|
385
409
|
});
|
|
386
|
-
(0,
|
|
387
|
-
name:
|
|
388
|
-
hook: getNavigationCommandLoaderPerTemplate(
|
|
410
|
+
(0, import_commands.useCommandLoader)({
|
|
411
|
+
name: "core/edit-site/navigate-templates",
|
|
412
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_template")
|
|
389
413
|
});
|
|
390
|
-
(0,
|
|
391
|
-
name:
|
|
392
|
-
hook: getNavigationCommandLoaderPerTemplate(
|
|
414
|
+
(0, import_commands.useCommandLoader)({
|
|
415
|
+
name: "core/edit-site/navigate-templates",
|
|
416
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_registered_template")
|
|
393
417
|
});
|
|
394
|
-
(0,
|
|
395
|
-
name:
|
|
396
|
-
hook: getNavigationCommandLoaderPerTemplate(
|
|
418
|
+
(0, import_commands.useCommandLoader)({
|
|
419
|
+
name: "core/edit-site/navigate-template-parts",
|
|
420
|
+
hook: getNavigationCommandLoaderPerTemplate("wp_template_part")
|
|
397
421
|
});
|
|
398
|
-
(0,
|
|
399
|
-
name:
|
|
422
|
+
(0, import_commands.useCommandLoader)({
|
|
423
|
+
name: "core/edit-site/basic-navigation",
|
|
400
424
|
hook: getSiteEditorBasicNavigationCommands(),
|
|
401
|
-
context:
|
|
425
|
+
context: "site-editor"
|
|
402
426
|
});
|
|
403
|
-
(0,
|
|
404
|
-
name:
|
|
427
|
+
(0, import_commands.useCommandLoader)({
|
|
428
|
+
name: "core/edit-site/global-styles-css",
|
|
405
429
|
hook: getGlobalStylesOpenCssCommands()
|
|
406
430
|
});
|
|
407
431
|
}
|
|
408
|
-
|
|
432
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
433
|
+
0 && (module.exports = {
|
|
434
|
+
useSiteEditorNavigationCommands
|
|
435
|
+
});
|
|
436
|
+
//# sourceMappingURL=site-editor-navigation-commands.js.map
|