PluginProbe
Gutenberg / 18.9.0
Gutenberg v18.9.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
gutenberg / build / core-commands / index.js

index.js in Gutenberg 18.9.0, at build/core-commands/index.js

649 lines 22.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ // The require scope
4 /******/ var __webpack_require__ = {};
5 /******/
6 /************************************************************************/
7 /******/ /* webpack/runtime/define property getters */
8 /******/ (() => {
9 /******/ // define getter functions for harmony exports
10 /******/ __webpack_require__.d = (exports, definition) => {
11 /******/ for(var key in definition) {
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 /******/ }
15 /******/ }
16 /******/ };
17 /******/ })();
18 /******/
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */
20 /******/ (() => {
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22 /******/ })();
23 /******/
24 /******/ /* webpack/runtime/make namespace object */
25 /******/ (() => {
26 /******/ // define __esModule on exports
27 /******/ __webpack_require__.r = (exports) => {
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30 /******/ }
31 /******/ Object.defineProperty(exports, '__esModule', { value: true });
32 /******/ };
33 /******/ })();
34 /******/
35 /************************************************************************/
36 var __webpack_exports__ = {};
37 // ESM COMPAT FLAG
38 __webpack_require__.r(__webpack_exports__);
39
40 // EXPORTS
41 __webpack_require__.d(__webpack_exports__, {
42 privateApis: () => (/* reexport */ privateApis)
43 });
44
45 ;// CONCATENATED MODULE: external ["wp","commands"]
46 const external_wp_commands_namespaceObject = window["wp"]["commands"];
47 ;// CONCATENATED MODULE: external ["wp","i18n"]
48 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
49 ;// CONCATENATED MODULE: external ["wp","primitives"]
50 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
51 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
52 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
53 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
54 /**
55 * WordPress dependencies
56 */
57
58
59 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
60 xmlns: "http://www.w3.org/2000/svg",
61 viewBox: "0 0 24 24",
62 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
63 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
64 })
65 });
66 /* harmony default export */ const library_plus = (plus);
67
68 ;// CONCATENATED MODULE: ./packages/core-commands/build-module/admin-navigation-commands.js
69 /**
70 * WordPress dependencies
71 */
72
73
74
75 function useAdminNavigationCommands() {
76 (0,external_wp_commands_namespaceObject.useCommand)({
77 name: 'core/add-new-post',
78 label: (0,external_wp_i18n_namespaceObject.__)('Add new post'),
79 icon: library_plus,
80 callback: () => {
81 document.location.href = 'post-new.php';
82 }
83 });
84 (0,external_wp_commands_namespaceObject.useCommand)({
85 name: 'core/add-new-page',
86 label: (0,external_wp_i18n_namespaceObject.__)('Add new page'),
87 icon: library_plus,
88 callback: () => {
89 document.location.href = 'post-new.php?post_type=page';
90 }
91 });
92 }
93
94 ;// CONCATENATED MODULE: external ["wp","element"]
95 const external_wp_element_namespaceObject = window["wp"]["element"];
96 ;// CONCATENATED MODULE: external ["wp","data"]
97 const external_wp_data_namespaceObject = window["wp"]["data"];
98 ;// CONCATENATED MODULE: external ["wp","coreData"]
99 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
100 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post.js
101 /**
102 * WordPress dependencies
103 */
104
105
106 const post = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
107 xmlns: "http://www.w3.org/2000/svg",
108 viewBox: "0 0 24 24",
109 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
110 d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z"
111 })
112 });
113 /* harmony default export */ const library_post = (post);
114
115 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
116 /**
117 * WordPress dependencies
118 */
119
120
121
122 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
123 xmlns: "http://www.w3.org/2000/svg",
124 viewBox: "0 0 24 24",
125 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
126 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
127 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
128 d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"
129 })]
130 });
131 /* harmony default export */ const library_page = (page);
132
133 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
134 /**
135 * WordPress dependencies
136 */
137
138
139 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
140 xmlns: "http://www.w3.org/2000/svg",
141 viewBox: "0 0 24 24",
142 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
143 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
144 })
145 });
146 /* harmony default export */ const library_layout = (layout);
147
148 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
149 /**
150 * WordPress dependencies
151 */
152
153
154 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
155 xmlns: "http://www.w3.org/2000/svg",
156 viewBox: "0 0 24 24",
157 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
158 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
159 })
160 });
161 /* harmony default export */ const symbol_filled = (symbolFilled);
162
163 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
164 /**
165 * WordPress dependencies
166 */
167
168
169 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
170 viewBox: "0 0 24 24",
171 xmlns: "http://www.w3.org/2000/svg",
172 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
173 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"
174 })
175 });
176 /* harmony default export */ const library_navigation = (navigation);
177
178 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/styles.js
179 /**
180 * WordPress dependencies
181 */
182
183
184 const styles = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
185 viewBox: "0 0 24 24",
186 xmlns: "http://www.w3.org/2000/svg",
187 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
188 d: "M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"
189 })
190 });
191 /* harmony default export */ const library_styles = (styles);
192
193 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol.js
194 /**
195 * WordPress dependencies
196 */
197
198
199 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
200 xmlns: "http://www.w3.org/2000/svg",
201 viewBox: "0 0 24 24",
202 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
203 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
204 })
205 });
206 /* harmony default export */ const library_symbol = (symbol);
207
208 ;// CONCATENATED MODULE: external ["wp","router"]
209 const external_wp_router_namespaceObject = window["wp"]["router"];
210 ;// CONCATENATED MODULE: external ["wp","url"]
211 const external_wp_url_namespaceObject = window["wp"]["url"];
212 ;// CONCATENATED MODULE: external ["wp","compose"]
213 const external_wp_compose_namespaceObject = window["wp"]["compose"];
214 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
215 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
216 ;// CONCATENATED MODULE: external ["wp","privateApis"]
217 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
218 ;// CONCATENATED MODULE: ./packages/core-commands/build-module/lock-unlock.js
219 /**
220 * WordPress dependencies
221 */
222
223 const {
224 lock,
225 unlock
226 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-commands');
227
228 ;// CONCATENATED MODULE: ./packages/core-commands/build-module/utils/order-entity-records-by-search.js
229 function orderEntityRecordsBySearch(records = [], search = '') {
230 if (!Array.isArray(records) || !records.length) {
231 return [];
232 }
233 if (!search) {
234 return records;
235 }
236 const priority = [];
237 const nonPriority = [];
238 for (let i = 0; i < records.length; i++) {
239 const record = records[i];
240 if (record?.title?.raw?.toLowerCase()?.includes(search?.toLowerCase())) {
241 priority.push(record);
242 } else {
243 nonPriority.push(record);
244 }
245 }
246 return priority.concat(nonPriority);
247 }
248
249 ;// CONCATENATED MODULE: ./packages/core-commands/build-module/site-editor-navigation-commands.js
250 /**
251 * WordPress dependencies
252 */
253
254
255
256
257
258
259
260
261
262
263
264 /**
265 * Internal dependencies
266 */
267
268
269 const {
270 useHistory
271 } = unlock(external_wp_router_namespaceObject.privateApis);
272 const icons = {
273 post: library_post,
274 page: library_page,
275 wp_template: library_layout,
276 wp_template_part: symbol_filled
277 };
278 function useDebouncedValue(value) {
279 const [debouncedValue, setDebouncedValue] = (0,external_wp_element_namespaceObject.useState)('');
280 const debounced = (0,external_wp_compose_namespaceObject.useDebounce)(setDebouncedValue, 250);
281 (0,external_wp_element_namespaceObject.useEffect)(() => {
282 debounced(value);
283 return () => debounced.cancel();
284 }, [debounced, value]);
285 return debouncedValue;
286 }
287 const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader({
288 search
289 }) {
290 const history = useHistory();
291 const {
292 isBlockBasedTheme,
293 canCreateTemplate
294 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
295 return {
296 isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
297 canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
298 kind: 'postType',
299 name: 'wp_template'
300 })
301 };
302 }, []);
303 const delayedSearch = useDebouncedValue(search);
304 const {
305 records,
306 isLoading
307 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
308 if (!delayedSearch) {
309 return {
310 isLoading: false
311 };
312 }
313 const query = {
314 search: delayedSearch,
315 per_page: 10,
316 orderby: 'relevance',
317 status: ['publish', 'future', 'draft', 'pending', 'private']
318 };
319 return {
320 records: select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, query),
321 isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query])
322 };
323 }, [delayedSearch]);
324 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
325 return (records !== null && records !== void 0 ? records : []).map(record => {
326 const command = {
327 name: postType + '-' + record.id,
328 searchLabel: record.title?.rendered + ' ' + record.id,
329 label: record.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record.title?.rendered) : (0,external_wp_i18n_namespaceObject.__)('(no title)'),
330 icon: icons[postType]
331 };
332 if (!canCreateTemplate || postType === 'post' || postType === 'page' && !isBlockBasedTheme) {
333 return {
334 ...command,
335 callback: ({
336 close
337 }) => {
338 const args = {
339 post: record.id,
340 action: 'edit'
341 };
342 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', args);
343 document.location = targetUrl;
344 close();
345 }
346 };
347 }
348 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
349 return {
350 ...command,
351 callback: ({
352 close
353 }) => {
354 const args = {
355 postType,
356 postId: record.id,
357 canvas: 'edit'
358 };
359 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
360 if (isSiteEditor) {
361 history.push(args);
362 } else {
363 document.location = targetUrl;
364 }
365 close();
366 }
367 };
368 });
369 }, [canCreateTemplate, records, isBlockBasedTheme, history]);
370 return {
371 commands,
372 isLoading
373 };
374 };
375 const getNavigationCommandLoaderPerTemplate = templateType => function useNavigationCommandLoader({
376 search
377 }) {
378 const history = useHistory();
379 const {
380 isBlockBasedTheme,
381 canCreateTemplate
382 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
383 return {
384 isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
385 canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
386 kind: 'postType',
387 name: templateType
388 })
389 };
390 }, []);
391 const {
392 records,
393 isLoading
394 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
395 const {
396 getEntityRecords
397 } = select(external_wp_coreData_namespaceObject.store);
398 const query = {
399 per_page: -1
400 };
401 return {
402 records: getEntityRecords('postType', templateType, query),
403 isLoading: !select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecords', ['postType', templateType, query])
404 };
405 }, []);
406
407 /*
408 * wp_template and wp_template_part endpoints do not support per_page or orderby parameters.
409 * We need to sort the results based on the search query to avoid removing relevant
410 * records below using .slice().
411 */
412 const orderedRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
413 return orderEntityRecordsBySearch(records, search).slice(0, 10);
414 }, [records, search]);
415 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
416 if (!canCreateTemplate || !isBlockBasedTheme && !templateType === 'wp_template_part') {
417 return [];
418 }
419 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
420 const result = [];
421 result.push(...orderedRecords.map(record => {
422 return {
423 name: templateType + '-' + record.id,
424 searchLabel: record.title?.rendered + ' ' + record.id,
425 label: record.title?.rendered ? record.title?.rendered : (0,external_wp_i18n_namespaceObject.__)('(no title)'),
426 icon: icons[templateType],
427 callback: ({
428 close
429 }) => {
430 const args = {
431 postType: templateType,
432 postId: record.id,
433 canvas: 'edit'
434 };
435 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
436 if (isSiteEditor) {
437 history.push(args);
438 } else {
439 document.location = targetUrl;
440 }
441 close();
442 }
443 };
444 }));
445 if (orderedRecords?.length > 0 && templateType === 'wp_template_part') {
446 result.push({
447 name: 'core/edit-site/open-template-parts',
448 label: (0,external_wp_i18n_namespaceObject.__)('Template parts'),
449 icon: symbol_filled,
450 callback: ({
451 close
452 }) => {
453 const args = {
454 postType: 'wp_template_part',
455 categoryId: 'all-parts'
456 };
457 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
458 if (isSiteEditor) {
459 history.push(args);
460 } else {
461 document.location = targetUrl;
462 }
463 close();
464 }
465 });
466 }
467 return result;
468 }, [canCreateTemplate, isBlockBasedTheme, orderedRecords, history]);
469 return {
470 commands,
471 isLoading
472 };
473 };
474 const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('page');
475 const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post');
476 const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template');
477 const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerTemplate('wp_template_part');
478 function useSiteEditorBasicNavigationCommands() {
479 const history = useHistory();
480 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
481 const {
482 isBlockBasedTheme,
483 canCreateTemplate
484 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
485 return {
486 isBlockBasedTheme: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme,
487 canCreateTemplate: select(external_wp_coreData_namespaceObject.store).canUser('create', {
488 kind: 'postType',
489 name: 'wp_template'
490 })
491 };
492 }, []);
493 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => {
494 const result = [];
495 if (canCreateTemplate && isBlockBasedTheme) {
496 result.push({
497 name: 'core/edit-site/open-navigation',
498 label: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
499 icon: library_navigation,
500 callback: ({
501 close
502 }) => {
503 const args = {
504 postType: 'wp_navigation'
505 };
506 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
507 if (isSiteEditor) {
508 history.push(args);
509 } else {
510 document.location = targetUrl;
511 }
512 close();
513 }
514 });
515 result.push({
516 name: 'core/edit-site/open-styles',
517 label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
518 icon: library_styles,
519 callback: ({
520 close
521 }) => {
522 const args = {
523 path: '/wp_global_styles'
524 };
525 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
526 if (isSiteEditor) {
527 history.push(args);
528 } else {
529 document.location = targetUrl;
530 }
531 close();
532 }
533 });
534 result.push({
535 name: 'core/edit-site/open-pages',
536 label: (0,external_wp_i18n_namespaceObject.__)('Pages'),
537 icon: library_page,
538 callback: ({
539 close
540 }) => {
541 const args = {
542 postType: 'page'
543 };
544 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
545 if (isSiteEditor) {
546 history.push(args);
547 } else {
548 document.location = targetUrl;
549 }
550 close();
551 }
552 });
553 result.push({
554 name: 'core/edit-site/open-templates',
555 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
556 icon: library_layout,
557 callback: ({
558 close
559 }) => {
560 const args = {
561 postType: 'wp_template'
562 };
563 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
564 if (isSiteEditor) {
565 history.push(args);
566 } else {
567 document.location = targetUrl;
568 }
569 close();
570 }
571 });
572 }
573 result.push({
574 name: 'core/edit-site/open-patterns',
575 label: (0,external_wp_i18n_namespaceObject.__)('Patterns'),
576 icon: library_symbol,
577 callback: ({
578 close
579 }) => {
580 if (canCreateTemplate) {
581 const args = {
582 postType: 'wp_block'
583 };
584 const targetUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', args);
585 if (isSiteEditor) {
586 history.push(args);
587 } else {
588 document.location = targetUrl;
589 }
590 close();
591 } else {
592 // If a user cannot access the site editor
593 document.location.href = 'edit.php?post_type=wp_block';
594 }
595 }
596 });
597 return result;
598 }, [history, isSiteEditor, canCreateTemplate, isBlockBasedTheme]);
599 return {
600 commands,
601 isLoading: false
602 };
603 }
604 function useSiteEditorNavigationCommands() {
605 (0,external_wp_commands_namespaceObject.useCommandLoader)({
606 name: 'core/edit-site/navigate-pages',
607 hook: usePageNavigationCommandLoader
608 });
609 (0,external_wp_commands_namespaceObject.useCommandLoader)({
610 name: 'core/edit-site/navigate-posts',
611 hook: usePostNavigationCommandLoader
612 });
613 (0,external_wp_commands_namespaceObject.useCommandLoader)({
614 name: 'core/edit-site/navigate-templates',
615 hook: useTemplateNavigationCommandLoader
616 });
617 (0,external_wp_commands_namespaceObject.useCommandLoader)({
618 name: 'core/edit-site/navigate-template-parts',
619 hook: useTemplatePartNavigationCommandLoader
620 });
621 (0,external_wp_commands_namespaceObject.useCommandLoader)({
622 name: 'core/edit-site/basic-navigation',
623 hook: useSiteEditorBasicNavigationCommands,
624 context: 'site-editor'
625 });
626 }
627
628 ;// CONCATENATED MODULE: ./packages/core-commands/build-module/private-apis.js
629 /**
630 * Internal dependencies
631 */
632
633
634
635 function useCommands() {
636 useAdminNavigationCommands();
637 useSiteEditorNavigationCommands();
638 }
639 const privateApis = {};
640 lock(privateApis, {
641 useCommands
642 });
643
644 ;// CONCATENATED MODULE: ./packages/core-commands/build-module/index.js
645
646
647 (window.wp = window.wp || {}).coreCommands = __webpack_exports__;
648 /******/ })()
649 ;