PluginProbe
Gutenberg / 12.7.1
Gutenberg v12.7.1
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 12.6.0 All 403 releases
gutenberg / build / edit-post / index.js

index.js in Gutenberg 12.7.1, at build/edit-post/index.js

9,574 lines 316.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 4403:
5 /***/ (function(module, exports) {
6
7 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
8 Copyright (c) 2018 Jed Watson.
9 Licensed under the MIT License (MIT), see
10 http://jedwatson.github.io/classnames
11 */
12 /* global define */
13
14 (function () {
15 'use strict';
16
17 var hasOwn = {}.hasOwnProperty;
18
19 function classNames() {
20 var classes = [];
21
22 for (var i = 0; i < arguments.length; i++) {
23 var arg = arguments[i];
24 if (!arg) continue;
25
26 var argType = typeof arg;
27
28 if (argType === 'string' || argType === 'number') {
29 classes.push(arg);
30 } else if (Array.isArray(arg)) {
31 if (arg.length) {
32 var inner = classNames.apply(null, arg);
33 if (inner) {
34 classes.push(inner);
35 }
36 }
37 } else if (argType === 'object') {
38 if (arg.toString === Object.prototype.toString) {
39 for (var key in arg) {
40 if (hasOwn.call(arg, key) && arg[key]) {
41 classes.push(key);
42 }
43 }
44 } else {
45 classes.push(arg.toString());
46 }
47 }
48 }
49
50 return classes.join(' ');
51 }
52
53 if ( true && module.exports) {
54 classNames.default = classNames;
55 module.exports = classNames;
56 } else if (true) {
57 // register as 'classnames', consistent with npm package name
58 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
59 return classNames;
60 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
61 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
62 } else {}
63 }());
64
65
66 /***/ })
67
68 /******/ });
69 /************************************************************************/
70 /******/ // The module cache
71 /******/ var __webpack_module_cache__ = {};
72 /******/
73 /******/ // The require function
74 /******/ function __webpack_require__(moduleId) {
75 /******/ // Check if module is in cache
76 /******/ var cachedModule = __webpack_module_cache__[moduleId];
77 /******/ if (cachedModule !== undefined) {
78 /******/ return cachedModule.exports;
79 /******/ }
80 /******/ // Create a new module (and put it into the cache)
81 /******/ var module = __webpack_module_cache__[moduleId] = {
82 /******/ // no module.id needed
83 /******/ // no module.loaded needed
84 /******/ exports: {}
85 /******/ };
86 /******/
87 /******/ // Execute the module function
88 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
89 /******/
90 /******/ // Return the exports of the module
91 /******/ return module.exports;
92 /******/ }
93 /******/
94 /************************************************************************/
95 /******/ /* webpack/runtime/compat get default export */
96 /******/ !function() {
97 /******/ // getDefaultExport function for compatibility with non-harmony modules
98 /******/ __webpack_require__.n = function(module) {
99 /******/ var getter = module && module.__esModule ?
100 /******/ function() { return module['default']; } :
101 /******/ function() { return module; };
102 /******/ __webpack_require__.d(getter, { a: getter });
103 /******/ return getter;
104 /******/ };
105 /******/ }();
106 /******/
107 /******/ /* webpack/runtime/define property getters */
108 /******/ !function() {
109 /******/ // define getter functions for harmony exports
110 /******/ __webpack_require__.d = function(exports, definition) {
111 /******/ for(var key in definition) {
112 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
113 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
114 /******/ }
115 /******/ }
116 /******/ };
117 /******/ }();
118 /******/
119 /******/ /* webpack/runtime/hasOwnProperty shorthand */
120 /******/ !function() {
121 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
122 /******/ }();
123 /******/
124 /******/ /* webpack/runtime/make namespace object */
125 /******/ !function() {
126 /******/ // define __esModule on exports
127 /******/ __webpack_require__.r = function(exports) {
128 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
129 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
130 /******/ }
131 /******/ Object.defineProperty(exports, '__esModule', { value: true });
132 /******/ };
133 /******/ }();
134 /******/
135 /************************************************************************/
136 var __webpack_exports__ = {};
137 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
138 !function() {
139 "use strict";
140 // ESM COMPAT FLAG
141 __webpack_require__.r(__webpack_exports__);
142
143 // EXPORTS
144 __webpack_require__.d(__webpack_exports__, {
145 "PluginBlockSettingsMenuItem": function() { return /* reexport */ plugin_block_settings_menu_item; },
146 "PluginDocumentSettingPanel": function() { return /* reexport */ plugin_document_setting_panel; },
147 "PluginMoreMenuItem": function() { return /* reexport */ plugin_more_menu_item; },
148 "PluginPostPublishPanel": function() { return /* reexport */ plugin_post_publish_panel; },
149 "PluginPostStatusInfo": function() { return /* reexport */ plugin_post_status_info; },
150 "PluginPrePublishPanel": function() { return /* reexport */ plugin_pre_publish_panel; },
151 "PluginSidebar": function() { return /* reexport */ PluginSidebarEditPost; },
152 "PluginSidebarMoreMenuItem": function() { return /* reexport */ PluginSidebarMoreMenuItem; },
153 "__experimentalFullscreenModeClose": function() { return /* reexport */ fullscreen_mode_close; },
154 "__experimentalMainDashboardButton": function() { return /* reexport */ main_dashboard_button; },
155 "initializeEditor": function() { return /* binding */ initializeEditor; },
156 "reinitializeEditor": function() { return /* binding */ reinitializeEditor; },
157 "store": function() { return /* reexport */ store_store; }
158 });
159
160 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
161 var actions_namespaceObject = {};
162 __webpack_require__.r(actions_namespaceObject);
163 __webpack_require__.d(actions_namespaceObject, {
164 "disableComplementaryArea": function() { return disableComplementaryArea; },
165 "enableComplementaryArea": function() { return enableComplementaryArea; },
166 "pinItem": function() { return pinItem; },
167 "setFeatureDefaults": function() { return setFeatureDefaults; },
168 "setFeatureValue": function() { return setFeatureValue; },
169 "toggleFeature": function() { return toggleFeature; },
170 "unpinItem": function() { return unpinItem; }
171 });
172
173 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
174 var selectors_namespaceObject = {};
175 __webpack_require__.r(selectors_namespaceObject);
176 __webpack_require__.d(selectors_namespaceObject, {
177 "getActiveComplementaryArea": function() { return getActiveComplementaryArea; },
178 "isFeatureActive": function() { return isFeatureActive; },
179 "isItemPinned": function() { return isItemPinned; }
180 });
181
182 // NAMESPACE OBJECT: ./packages/edit-post/build-module/store/actions.js
183 var store_actions_namespaceObject = {};
184 __webpack_require__.r(store_actions_namespaceObject);
185 __webpack_require__.d(store_actions_namespaceObject, {
186 "__experimentalSetPreviewDeviceType": function() { return __experimentalSetPreviewDeviceType; },
187 "__experimentalUpdateLocalAutosaveInterval": function() { return __experimentalUpdateLocalAutosaveInterval; },
188 "__unstableCreateTemplate": function() { return __unstableCreateTemplate; },
189 "__unstableSwitchToTemplateMode": function() { return __unstableSwitchToTemplateMode; },
190 "closeGeneralSidebar": function() { return closeGeneralSidebar; },
191 "closeModal": function() { return closeModal; },
192 "closePublishSidebar": function() { return closePublishSidebar; },
193 "hideBlockTypes": function() { return hideBlockTypes; },
194 "initializeMetaBoxes": function() { return initializeMetaBoxes; },
195 "metaBoxUpdatesFailure": function() { return metaBoxUpdatesFailure; },
196 "metaBoxUpdatesSuccess": function() { return metaBoxUpdatesSuccess; },
197 "openGeneralSidebar": function() { return openGeneralSidebar; },
198 "openModal": function() { return openModal; },
199 "openPublishSidebar": function() { return openPublishSidebar; },
200 "removeEditorPanel": function() { return removeEditorPanel; },
201 "requestMetaBoxUpdates": function() { return requestMetaBoxUpdates; },
202 "setAvailableMetaBoxesPerLocation": function() { return setAvailableMetaBoxesPerLocation; },
203 "setIsEditingTemplate": function() { return setIsEditingTemplate; },
204 "setIsInserterOpened": function() { return setIsInserterOpened; },
205 "setIsListViewOpened": function() { return setIsListViewOpened; },
206 "showBlockTypes": function() { return showBlockTypes; },
207 "switchEditorMode": function() { return switchEditorMode; },
208 "toggleEditorPanelEnabled": function() { return toggleEditorPanelEnabled; },
209 "toggleEditorPanelOpened": function() { return toggleEditorPanelOpened; },
210 "toggleFeature": function() { return actions_toggleFeature; },
211 "togglePinnedPluginItem": function() { return togglePinnedPluginItem; },
212 "togglePublishSidebar": function() { return togglePublishSidebar; },
213 "updatePreferredStyleVariations": function() { return updatePreferredStyleVariations; }
214 });
215
216 // NAMESPACE OBJECT: ./packages/edit-post/build-module/store/selectors.js
217 var store_selectors_namespaceObject = {};
218 __webpack_require__.r(store_selectors_namespaceObject);
219 __webpack_require__.d(store_selectors_namespaceObject, {
220 "__experimentalGetInsertionPoint": function() { return __experimentalGetInsertionPoint; },
221 "__experimentalGetPreviewDeviceType": function() { return __experimentalGetPreviewDeviceType; },
222 "areMetaBoxesInitialized": function() { return areMetaBoxesInitialized; },
223 "getActiveGeneralSidebarName": function() { return getActiveGeneralSidebarName; },
224 "getActiveMetaBoxLocations": function() { return getActiveMetaBoxLocations; },
225 "getAllMetaBoxes": function() { return getAllMetaBoxes; },
226 "getEditedPostTemplate": function() { return getEditedPostTemplate; },
227 "getEditorMode": function() { return getEditorMode; },
228 "getMetaBoxesPerLocation": function() { return getMetaBoxesPerLocation; },
229 "getPreference": function() { return getPreference; },
230 "getPreferences": function() { return getPreferences; },
231 "hasMetaBoxes": function() { return hasMetaBoxes; },
232 "isEditingTemplate": function() { return selectors_isEditingTemplate; },
233 "isEditorPanelEnabled": function() { return isEditorPanelEnabled; },
234 "isEditorPanelOpened": function() { return isEditorPanelOpened; },
235 "isEditorPanelRemoved": function() { return isEditorPanelRemoved; },
236 "isEditorSidebarOpened": function() { return isEditorSidebarOpened; },
237 "isFeatureActive": function() { return selectors_isFeatureActive; },
238 "isInserterOpened": function() { return isInserterOpened; },
239 "isListViewOpened": function() { return isListViewOpened; },
240 "isMetaBoxLocationActive": function() { return isMetaBoxLocationActive; },
241 "isMetaBoxLocationVisible": function() { return isMetaBoxLocationVisible; },
242 "isModalActive": function() { return isModalActive; },
243 "isPluginItemPinned": function() { return isPluginItemPinned; },
244 "isPluginSidebarOpened": function() { return isPluginSidebarOpened; },
245 "isPublishSidebarOpened": function() { return isPublishSidebarOpened; },
246 "isSavingMetaBoxes": function() { return selectors_isSavingMetaBoxes; }
247 });
248
249 ;// CONCATENATED MODULE: external ["wp","element"]
250 var external_wp_element_namespaceObject = window["wp"]["element"];
251 ;// CONCATENATED MODULE: external ["wp","blocks"]
252 var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
253 ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
254 var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
255 ;// CONCATENATED MODULE: external ["wp","data"]
256 var external_wp_data_namespaceObject = window["wp"]["data"];
257 ;// CONCATENATED MODULE: external ["wp","hooks"]
258 var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
259 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
260 function _extends() {
261 _extends = Object.assign || function (target) {
262 for (var i = 1; i < arguments.length; i++) {
263 var source = arguments[i];
264
265 for (var key in source) {
266 if (Object.prototype.hasOwnProperty.call(source, key)) {
267 target[key] = source[key];
268 }
269 }
270 }
271
272 return target;
273 };
274
275 return _extends.apply(this, arguments);
276 }
277 // EXTERNAL MODULE: ./node_modules/classnames/index.js
278 var classnames = __webpack_require__(4403);
279 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
280 ;// CONCATENATED MODULE: external ["wp","components"]
281 var external_wp_components_namespaceObject = window["wp"]["components"];
282 ;// CONCATENATED MODULE: external ["wp","i18n"]
283 var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
284 ;// CONCATENATED MODULE: external ["wp","primitives"]
285 var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
286 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
287
288
289 /**
290 * WordPress dependencies
291 */
292
293 const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
294 xmlns: "http://www.w3.org/2000/svg",
295 viewBox: "0 0 24 24"
296 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
297 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
298 }));
299 /* harmony default export */ var library_check = (check);
300
301 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
302
303
304 /**
305 * WordPress dependencies
306 */
307
308 const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
309 xmlns: "http://www.w3.org/2000/svg",
310 viewBox: "0 0 24 24"
311 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
312 d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
313 }));
314 /* harmony default export */ var star_filled = (starFilled);
315
316 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
317
318
319 /**
320 * WordPress dependencies
321 */
322
323 const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
324 xmlns: "http://www.w3.org/2000/svg",
325 viewBox: "0 0 24 24"
326 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
327 fillRule: "evenodd",
328 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
329 clipRule: "evenodd"
330 }));
331 /* harmony default export */ var star_empty = (starEmpty);
332
333 ;// CONCATENATED MODULE: external ["wp","viewport"]
334 var external_wp_viewport_namespaceObject = window["wp"]["viewport"];
335 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
336
337
338 /**
339 * WordPress dependencies
340 */
341
342 const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
343 xmlns: "http://www.w3.org/2000/svg",
344 viewBox: "0 0 24 24"
345 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
346 d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
347 }));
348 /* harmony default export */ var close_small = (closeSmall);
349
350 ;// CONCATENATED MODULE: external "lodash"
351 var external_lodash_namespaceObject = window["lodash"];
352 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
353 /**
354 * External dependencies
355 */
356
357 /**
358 * WordPress dependencies
359 */
360
361
362 /**
363 * Reducer to keep tract of the active area per scope.
364 *
365 * @param {boolean} state Previous state.
366 * @param {Object} action Action object.
367 * @param {string} action.type Action type.
368 * @param {string} action.itemType Type of item.
369 * @param {string} action.scope Item scope.
370 * @param {string} action.item Item name.
371 *
372 * @return {Object} Updated state.
373 */
374
375 function singleEnableItems() {
376 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
377 let {
378 type,
379 itemType,
380 scope,
381 item
382 } = arguments.length > 1 ? arguments[1] : undefined;
383
384 if (type !== 'SET_SINGLE_ENABLE_ITEM' || !itemType || !scope) {
385 return state;
386 }
387
388 return { ...state,
389 [itemType]: { ...state[itemType],
390 [scope]: item || null
391 }
392 };
393 }
394 /**
395 * Reducer keeping track of the "pinned" items per scope.
396 *
397 * @param {boolean} state Previous state.
398 * @param {Object} action Action object.
399 * @param {string} action.type Action type.
400 * @param {string} action.itemType Type of item.
401 * @param {string} action.scope Item scope.
402 * @param {string} action.item Item name.
403 * @param {boolean} action.isEnable Whether the item is pinned.
404 *
405 * @return {Object} Updated state.
406 */
407
408 function multipleEnableItems() {
409 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
410 let {
411 type,
412 itemType,
413 scope,
414 item,
415 isEnable
416 } = arguments.length > 1 ? arguments[1] : undefined;
417
418 if (type !== 'SET_MULTIPLE_ENABLE_ITEM' || !itemType || !scope || !item || (0,external_lodash_namespaceObject.get)(state, [itemType, scope, item]) === isEnable) {
419 return state;
420 }
421
422 const currentTypeState = state[itemType] || {};
423 const currentScopeState = currentTypeState[scope] || {};
424 return { ...state,
425 [itemType]: { ...currentTypeState,
426 [scope]: { ...currentScopeState,
427 [item]: isEnable || false
428 }
429 }
430 };
431 }
432 /**
433 * Reducer returning the defaults for user preferences.
434 *
435 * This is kept intentionally separate from the preferences
436 * themselves so that defaults are not persisted.
437 *
438 * @param {Object} state Current state.
439 * @param {Object} action Dispatched action.
440 *
441 * @return {Object} Updated state.
442 */
443
444 const preferenceDefaults = (0,external_wp_data_namespaceObject.combineReducers)({
445 features() {
446 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
447 let action = arguments.length > 1 ? arguments[1] : undefined;
448
449 if (action.type === 'SET_FEATURE_DEFAULTS') {
450 const {
451 scope,
452 defaults
453 } = action;
454 return { ...state,
455 [scope]: { ...state[scope],
456 ...defaults
457 }
458 };
459 }
460
461 return state;
462 }
463
464 });
465 /**
466 * Reducer returning the user preferences.
467 *
468 * @param {Object} state Current state.
469 * @param {Object} action Dispatched action.
470 *
471 * @return {Object} Updated state.
472 */
473
474 const preferences = (0,external_wp_data_namespaceObject.combineReducers)({
475 features() {
476 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
477 let action = arguments.length > 1 ? arguments[1] : undefined;
478
479 if (action.type === 'SET_FEATURE_VALUE') {
480 const {
481 scope,
482 featureName,
483 value
484 } = action;
485 return { ...state,
486 [scope]: { ...state[scope],
487 [featureName]: value
488 }
489 };
490 }
491
492 return state;
493 }
494
495 });
496 const enableItems = (0,external_wp_data_namespaceObject.combineReducers)({
497 singleEnableItems,
498 multipleEnableItems
499 });
500 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
501 enableItems,
502 preferenceDefaults,
503 preferences
504 }));
505
506 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
507 /**
508 * Returns an action object used in signalling that an active area should be changed.
509 *
510 * @param {string} itemType Type of item.
511 * @param {string} scope Item scope.
512 * @param {string} item Item identifier.
513 *
514 * @return {Object} Action object.
515 */
516 function setSingleEnableItem(itemType, scope, item) {
517 return {
518 type: 'SET_SINGLE_ENABLE_ITEM',
519 itemType,
520 scope,
521 item
522 };
523 }
524 /**
525 * Returns an action object used in signalling that a complementary item should be enabled.
526 *
527 * @param {string} scope Complementary area scope.
528 * @param {string} area Area identifier.
529 *
530 * @return {Object} Action object.
531 */
532
533
534 function enableComplementaryArea(scope, area) {
535 return setSingleEnableItem('complementaryArea', scope, area);
536 }
537 /**
538 * Returns an action object used in signalling that the complementary area of a given scope should be disabled.
539 *
540 * @param {string} scope Complementary area scope.
541 *
542 * @return {Object} Action object.
543 */
544
545 function disableComplementaryArea(scope) {
546 return setSingleEnableItem('complementaryArea', scope, undefined);
547 }
548 /**
549 * Returns an action object to make an area enabled/disabled.
550 *
551 * @param {string} itemType Type of item.
552 * @param {string} scope Item scope.
553 * @param {string} item Item identifier.
554 * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
555 *
556 * @return {Object} Action object.
557 */
558
559 function setMultipleEnableItem(itemType, scope, item, isEnable) {
560 return {
561 type: 'SET_MULTIPLE_ENABLE_ITEM',
562 itemType,
563 scope,
564 item,
565 isEnable
566 };
567 }
568 /**
569 * Returns an action object used in signalling that an item should be pinned.
570 *
571 * @param {string} scope Item scope.
572 * @param {string} itemId Item identifier.
573 *
574 * @return {Object} Action object.
575 */
576
577
578 function pinItem(scope, itemId) {
579 return setMultipleEnableItem('pinnedItems', scope, itemId, true);
580 }
581 /**
582 * Returns an action object used in signalling that an item should be unpinned.
583 *
584 * @param {string} scope Item scope.
585 * @param {string} itemId Item identifier.
586 *
587 * @return {Object} Action object.
588 */
589
590 function unpinItem(scope, itemId) {
591 return setMultipleEnableItem('pinnedItems', scope, itemId, false);
592 }
593 /**
594 * Returns an action object used in signalling that a feature should be toggled.
595 *
596 * @param {string} scope The feature scope (e.g. core/edit-post).
597 * @param {string} featureName The feature name.
598 */
599
600 function toggleFeature(scope, featureName) {
601 return function (_ref) {
602 let {
603 select,
604 dispatch
605 } = _ref;
606 const currentValue = select.isFeatureActive(scope, featureName);
607 dispatch.setFeatureValue(scope, featureName, !currentValue);
608 };
609 }
610 /**
611 * Returns an action object used in signalling that a feature should be set to
612 * a true or false value
613 *
614 * @param {string} scope The feature scope (e.g. core/edit-post).
615 * @param {string} featureName The feature name.
616 * @param {boolean} value The value to set.
617 *
618 * @return {Object} Action object.
619 */
620
621 function setFeatureValue(scope, featureName, value) {
622 return {
623 type: 'SET_FEATURE_VALUE',
624 scope,
625 featureName,
626 value: !!value
627 };
628 }
629 /**
630 * Returns an action object used in signalling that defaults should be set for features.
631 *
632 * @param {string} scope The feature scope (e.g. core/edit-post).
633 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
634 *
635 * @return {Object} Action object.
636 */
637
638 function setFeatureDefaults(scope, defaults) {
639 return {
640 type: 'SET_FEATURE_DEFAULTS',
641 scope,
642 defaults
643 };
644 }
645
646 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
647 /**
648 * External dependencies
649 */
650
651 /**
652 * Returns the item that is enabled in a given scope.
653 *
654 * @param {Object} state Global application state.
655 * @param {string} itemType Type of item.
656 * @param {string} scope Item scope.
657 *
658 * @return {?string|null} The item that is enabled in the passed scope and type.
659 */
660
661 function getSingleEnableItem(state, itemType, scope) {
662 return (0,external_lodash_namespaceObject.get)(state.enableItems.singleEnableItems, [itemType, scope]);
663 }
664 /**
665 * Returns the complementary area that is active in a given scope.
666 *
667 * @param {Object} state Global application state.
668 * @param {string} scope Item scope.
669 *
670 * @return {string} The complementary area that is active in the given scope.
671 */
672
673
674 function getActiveComplementaryArea(state, scope) {
675 return getSingleEnableItem(state, 'complementaryArea', scope);
676 }
677 /**
678 * Returns a boolean indicating if an item is enabled or not in a given scope.
679 *
680 * @param {Object} state Global application state.
681 * @param {string} itemType Type of item.
682 * @param {string} scope Scope.
683 * @param {string} item Item to check.
684 *
685 * @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.
686 */
687
688 function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
689 return (0,external_lodash_namespaceObject.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]);
690 }
691 /**
692 * Returns a boolean indicating if an item is pinned or not.
693 *
694 * @param {Object} state Global application state.
695 * @param {string} scope Scope.
696 * @param {string} item Item to check.
697 *
698 * @return {boolean} True if the item is pinned and false otherwise.
699 */
700
701
702 function isItemPinned(state, scope, item) {
703 return isMultipleEnabledItemEnabled(state, 'pinnedItems', scope, item) !== false;
704 }
705 /**
706 * Returns a boolean indicating whether a feature is active for a particular
707 * scope.
708 *
709 * @param {Object} state The store state.
710 * @param {string} scope The scope of the feature (e.g. core/edit-post).
711 * @param {string} featureName The name of the feature.
712 *
713 * @return {boolean} Is the feature enabled?
714 */
715
716 function isFeatureActive(state, scope, featureName) {
717 var _state$preferences$fe, _state$preferenceDefa;
718
719 const featureValue = (_state$preferences$fe = state.preferences.features[scope]) === null || _state$preferences$fe === void 0 ? void 0 : _state$preferences$fe[featureName];
720 const defaultedFeatureValue = featureValue !== undefined ? featureValue : (_state$preferenceDefa = state.preferenceDefaults.features[scope]) === null || _state$preferenceDefa === void 0 ? void 0 : _state$preferenceDefa[featureName];
721 return !!defaultedFeatureValue;
722 }
723
724 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
725 /**
726 * The identifier for the data store.
727 *
728 * @type {string}
729 */
730 const STORE_NAME = 'core/interface';
731
732 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
733 /**
734 * WordPress dependencies
735 */
736
737 /**
738 * Internal dependencies
739 */
740
741
742
743
744
745 const storeConfig = {
746 reducer: reducer,
747 actions: actions_namespaceObject,
748 selectors: selectors_namespaceObject,
749 persist: ['enableItems', 'preferences']
750 };
751 /**
752 * Store definition for the interface namespace.
753 *
754 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
755 *
756 * @type {Object}
757 */
758
759 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig); // Once we build a more generic persistence plugin that works across types of stores
760 // we'd be able to replace this with a register call.
761
762 (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, storeConfig);
763
764 ;// CONCATENATED MODULE: external ["wp","plugins"]
765 var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
766 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
767 /**
768 * WordPress dependencies
769 */
770
771 /* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
772 return {
773 icon: ownProps.icon || context.icon,
774 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
775 };
776 }));
777
778 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
779
780
781
782 /**
783 * External dependencies
784 */
785
786 /**
787 * WordPress dependencies
788 */
789
790
791
792 /**
793 * Internal dependencies
794 */
795
796
797
798
799 function ComplementaryAreaToggle(_ref) {
800 let {
801 as = external_wp_components_namespaceObject.Button,
802 scope,
803 identifier,
804 icon,
805 selectedIcon,
806 ...props
807 } = _ref;
808 const ComponentToUse = as;
809 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier]);
810 const {
811 enableComplementaryArea,
812 disableComplementaryArea
813 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
814 return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, _extends({
815 icon: selectedIcon && isSelected ? selectedIcon : icon,
816 onClick: () => {
817 if (isSelected) {
818 disableComplementaryArea(scope);
819 } else {
820 enableComplementaryArea(scope, identifier);
821 }
822 }
823 }, (0,external_lodash_namespaceObject.omit)(props, ['name'])));
824 }
825
826 /* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
827
828 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
829
830
831
832 /**
833 * External dependencies
834 */
835
836 /**
837 * WordPress dependencies
838 */
839
840
841 /**
842 * Internal dependencies
843 */
844
845
846
847 const ComplementaryAreaHeader = _ref => {
848 let {
849 smallScreenTitle,
850 children,
851 className,
852 toggleButtonProps
853 } = _ref;
854 const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
855 icon: close_small
856 }, toggleButtonProps));
857 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
858 className: "components-panel__header interface-complementary-area-header__small"
859 }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
860 className: "interface-complementary-area-header__small-title"
861 }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
862 className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
863 tabIndex: -1
864 }, children, toggleButton));
865 };
866
867 /* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader);
868
869 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
870
871
872
873 /**
874 * External dependencies
875 */
876
877 /**
878 * WordPress dependencies
879 */
880
881
882
883
884 function ActionItemSlot(_ref) {
885 let {
886 name,
887 as: Component = external_wp_components_namespaceObject.ButtonGroup,
888 fillProps = {},
889 bubblesVirtually,
890 ...props
891 } = _ref;
892 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
893 name: name,
894 bubblesVirtually: bubblesVirtually,
895 fillProps: fillProps
896 }, fills => {
897 if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) {
898 return null;
899 } // Special handling exists for backward compatibility.
900 // It ensures that menu items created by plugin authors aren't
901 // duplicated with automatically injected menu items coming
902 // from pinnable plugin sidebars.
903 // @see https://github.com/WordPress/gutenberg/issues/14457
904
905
906 const initializedByPlugins = [];
907 external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
908 let {
909 props: {
910 __unstableExplicitMenuItem,
911 __unstableTarget
912 }
913 } = _ref2;
914
915 if (__unstableTarget && __unstableExplicitMenuItem) {
916 initializedByPlugins.push(__unstableTarget);
917 }
918 });
919 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
920 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
921 return null;
922 }
923
924 return child;
925 });
926 return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
927 });
928 }
929
930 function ActionItem(_ref3) {
931 let {
932 name,
933 as: Component = external_wp_components_namespaceObject.Button,
934 onClick,
935 ...props
936 } = _ref3;
937 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
938 name: name
939 }, _ref4 => {
940 let {
941 onClick: fpOnClick
942 } = _ref4;
943 return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({
944 onClick: onClick || fpOnClick ? function () {
945 (onClick || external_lodash_namespaceObject.noop)(...arguments);
946 (fpOnClick || external_lodash_namespaceObject.noop)(...arguments);
947 } : undefined
948 }, props));
949 });
950 }
951
952 ActionItem.Slot = ActionItemSlot;
953 /* harmony default export */ var action_item = (ActionItem);
954
955 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
956
957
958
959 /**
960 * External dependencies
961 */
962
963 /**
964 * WordPress dependencies
965 */
966
967
968
969 /**
970 * Internal dependencies
971 */
972
973
974
975
976 const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility.
977 // They are removed so they don't leak to DOM elements.
978 // @see https://github.com/WordPress/gutenberg/issues/14457
979 (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget']));
980
981 function ComplementaryAreaMoreMenuItem(_ref) {
982 let {
983 scope,
984 target,
985 __unstableExplicitMenuItem,
986 ...props
987 } = _ref;
988 return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
989 as: toggleProps => {
990 return (0,external_wp_element_namespaceObject.createElement)(action_item, _extends({
991 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
992 __unstableTarget: `${scope}/${target}`,
993 as: PluginsMenuItem,
994 name: `${scope}/plugin-more-menu`
995 }, toggleProps));
996 },
997 role: "menuitemcheckbox",
998 selectedIcon: library_check,
999 name: target,
1000 scope: scope
1001 }, props));
1002 }
1003
1004 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
1005
1006
1007
1008 /**
1009 * External dependencies
1010 */
1011
1012
1013 /**
1014 * WordPress dependencies
1015 */
1016
1017
1018
1019 function PinnedItems(_ref) {
1020 let {
1021 scope,
1022 ...props
1023 } = _ref;
1024 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({
1025 name: `PinnedItems/${scope}`
1026 }, props));
1027 }
1028
1029 function PinnedItemsSlot(_ref2) {
1030 let {
1031 scope,
1032 className,
1033 ...props
1034 } = _ref2;
1035 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
1036 name: `PinnedItems/${scope}`
1037 }, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", {
1038 className: classnames_default()(className, 'interface-pinned-items')
1039 }, fills));
1040 }
1041
1042 PinnedItems.Slot = PinnedItemsSlot;
1043 /* harmony default export */ var pinned_items = (PinnedItems);
1044
1045 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
1046
1047
1048
1049 /**
1050 * External dependencies
1051 */
1052
1053 /**
1054 * WordPress dependencies
1055 */
1056
1057
1058
1059
1060
1061
1062
1063 /**
1064 * Internal dependencies
1065 */
1066
1067
1068
1069
1070
1071
1072
1073
1074 function ComplementaryAreaSlot(_ref) {
1075 let {
1076 scope,
1077 ...props
1078 } = _ref;
1079 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
1080 name: `ComplementaryArea/${scope}`
1081 }, props));
1082 }
1083
1084 function ComplementaryAreaFill(_ref2) {
1085 let {
1086 scope,
1087 children,
1088 className
1089 } = _ref2;
1090 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
1091 name: `ComplementaryArea/${scope}`
1092 }, (0,external_wp_element_namespaceObject.createElement)("div", {
1093 className: className
1094 }, children));
1095 }
1096
1097 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
1098 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
1099 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
1100 const {
1101 enableComplementaryArea,
1102 disableComplementaryArea
1103 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1104 (0,external_wp_element_namespaceObject.useEffect)(() => {
1105 // If the complementary area is active and the editor is switching from a big to a small window size.
1106 if (isActive && isSmall && !previousIsSmall.current) {
1107 // Disable the complementary area.
1108 disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
1109
1110 shouldOpenWhenNotSmall.current = true;
1111 } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
1112 // and we are going from a small to big window size.
1113 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
1114 // Remove the flag indicating the complementary area should be enabled.
1115 shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
1116
1117 enableComplementaryArea(scope, identifier);
1118 } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
1119 // remove the flag.
1120 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
1121 shouldOpenWhenNotSmall.current = false;
1122 }
1123
1124 if (isSmall !== previousIsSmall.current) {
1125 previousIsSmall.current = isSmall;
1126 }
1127 }, [isActive, isSmall, scope, identifier, activeArea]);
1128 }
1129
1130 function ComplementaryArea(_ref3) {
1131 let {
1132 children,
1133 className,
1134 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
1135 identifier,
1136 header,
1137 headerClassName,
1138 icon,
1139 isPinnable = true,
1140 panelClassName,
1141 scope,
1142 name,
1143 smallScreenTitle,
1144 title,
1145 toggleShortcut,
1146 isActiveByDefault,
1147 showIconLabels = false
1148 } = _ref3;
1149 const {
1150 isActive,
1151 isPinned,
1152 activeArea,
1153 isSmall,
1154 isLarge
1155 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1156 const {
1157 getActiveComplementaryArea,
1158 isItemPinned
1159 } = select(store);
1160
1161 const _activeArea = getActiveComplementaryArea(scope);
1162
1163 return {
1164 isActive: _activeArea === identifier,
1165 isPinned: isItemPinned(scope, identifier),
1166 activeArea: _activeArea,
1167 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
1168 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
1169 };
1170 }, [identifier, scope]);
1171 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
1172 const {
1173 enableComplementaryArea,
1174 disableComplementaryArea,
1175 pinItem,
1176 unpinItem
1177 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1178 (0,external_wp_element_namespaceObject.useEffect)(() => {
1179 if (isActiveByDefault && activeArea === undefined && !isSmall) {
1180 enableComplementaryArea(scope, identifier);
1181 }
1182 }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
1183 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
1184 scope: scope
1185 }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
1186 scope: scope,
1187 identifier: identifier,
1188 isPressed: isActive && (!showIconLabels || isLarge),
1189 "aria-expanded": isActive,
1190 label: title,
1191 icon: showIconLabels ? library_check : icon,
1192 showTooltip: !showIconLabels,
1193 variant: showIconLabels ? 'tertiary' : undefined
1194 })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
1195 target: name,
1196 scope: scope,
1197 icon: icon
1198 }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
1199 className: classnames_default()('interface-complementary-area', className),
1200 scope: scope
1201 }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
1202 className: headerClassName,
1203 closeLabel: closeLabel,
1204 onClose: () => disableComplementaryArea(scope),
1205 smallScreenTitle: smallScreenTitle,
1206 toggleButtonProps: {
1207 label: closeLabel,
1208 shortcut: toggleShortcut,
1209 scope,
1210 identifier
1211 }
1212 }, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1213 className: "interface-complementary-area__pin-unpin-item",
1214 icon: isPinned ? star_filled : star_empty,
1215 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
1216 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
1217 isPressed: isPinned,
1218 "aria-expanded": isPinned
1219 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
1220 className: panelClassName
1221 }, children)));
1222 }
1223
1224 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
1225 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
1226 /* harmony default export */ var complementary_area = (ComplementaryAreaWrapped);
1227
1228 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/fullscreen-mode/index.js
1229 /**
1230 * WordPress dependencies
1231 */
1232
1233
1234 const FullscreenMode = _ref => {
1235 let {
1236 isActive
1237 } = _ref;
1238 (0,external_wp_element_namespaceObject.useEffect)(() => {
1239 let isSticky = false; // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
1240 // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
1241 // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
1242 // a consequence of the FullscreenMode setup
1243
1244 if (document.body.classList.contains('sticky-menu')) {
1245 isSticky = true;
1246 document.body.classList.remove('sticky-menu');
1247 }
1248
1249 return () => {
1250 if (isSticky) {
1251 document.body.classList.add('sticky-menu');
1252 }
1253 };
1254 }, []);
1255 (0,external_wp_element_namespaceObject.useEffect)(() => {
1256 if (isActive) {
1257 document.body.classList.add('is-fullscreen-mode');
1258 } else {
1259 document.body.classList.remove('is-fullscreen-mode');
1260 }
1261
1262 return () => {
1263 if (isActive) {
1264 document.body.classList.remove('is-fullscreen-mode');
1265 }
1266 };
1267 }, [isActive]);
1268 return null;
1269 };
1270
1271 /* harmony default export */ var fullscreen_mode = (FullscreenMode);
1272
1273 ;// CONCATENATED MODULE: external ["wp","compose"]
1274 var external_wp_compose_namespaceObject = window["wp"]["compose"];
1275 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
1276
1277
1278
1279 /**
1280 * External dependencies
1281 */
1282
1283 /**
1284 * WordPress dependencies
1285 */
1286
1287 /**
1288 * WordPress dependencies
1289 */
1290
1291
1292
1293
1294
1295
1296 function useHTMLClass(className) {
1297 (0,external_wp_element_namespaceObject.useEffect)(() => {
1298 const element = document && document.querySelector(`html:not(.${className})`);
1299
1300 if (!element) {
1301 return;
1302 }
1303
1304 element.classList.toggle(className);
1305 return () => {
1306 element.classList.toggle(className);
1307 };
1308 }, [className]);
1309 }
1310
1311 function InterfaceSkeleton(_ref, ref) {
1312 let {
1313 footer,
1314 header,
1315 sidebar,
1316 secondarySidebar,
1317 notices,
1318 content,
1319 drawer,
1320 actions,
1321 labels,
1322 className,
1323 shortcuts
1324 } = _ref;
1325 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
1326 useHTMLClass('interface-interface-skeleton__html-container');
1327 const defaultLabels = {
1328 /* translators: accessibility text for the nav bar landmark region. */
1329 drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
1330
1331 /* translators: accessibility text for the top bar landmark region. */
1332 header: (0,external_wp_i18n_namespaceObject.__)('Header'),
1333
1334 /* translators: accessibility text for the content landmark region. */
1335 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
1336
1337 /* translators: accessibility text for the secondary sidebar landmark region. */
1338 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
1339
1340 /* translators: accessibility text for the settings landmark region. */
1341 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
1342
1343 /* translators: accessibility text for the publish landmark region. */
1344 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
1345
1346 /* translators: accessibility text for the footer landmark region. */
1347 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
1348 };
1349 const mergedLabels = { ...defaultLabels,
1350 ...labels
1351 };
1352 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, navigateRegionsProps, {
1353 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
1354 className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
1355 }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", {
1356 className: "interface-interface-skeleton__drawer",
1357 role: "region",
1358 "aria-label": mergedLabels.drawer,
1359 tabIndex: "-1"
1360 }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
1361 className: "interface-interface-skeleton__editor"
1362 }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", {
1363 className: "interface-interface-skeleton__header",
1364 role: "region",
1365 "aria-label": mergedLabels.header,
1366 tabIndex: "-1"
1367 }, header), (0,external_wp_element_namespaceObject.createElement)("div", {
1368 className: "interface-interface-skeleton__body"
1369 }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
1370 className: "interface-interface-skeleton__secondary-sidebar",
1371 role: "region",
1372 "aria-label": mergedLabels.secondarySidebar,
1373 tabIndex: "-1"
1374 }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
1375 className: "interface-interface-skeleton__notices"
1376 }, notices), (0,external_wp_element_namespaceObject.createElement)("div", {
1377 className: "interface-interface-skeleton__content",
1378 role: "region",
1379 "aria-label": mergedLabels.body,
1380 tabIndex: "-1"
1381 }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
1382 className: "interface-interface-skeleton__sidebar",
1383 role: "region",
1384 "aria-label": mergedLabels.sidebar,
1385 tabIndex: "-1"
1386 }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", {
1387 className: "interface-interface-skeleton__actions",
1388 role: "region",
1389 "aria-label": mergedLabels.actions,
1390 tabIndex: "-1"
1391 }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", {
1392 className: "interface-interface-skeleton__footer",
1393 role: "region",
1394 "aria-label": mergedLabels.footer,
1395 tabIndex: "-1"
1396 }, footer));
1397 }
1398
1399 /* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
1400
1401 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
1402
1403
1404 /**
1405 * WordPress dependencies
1406 */
1407
1408 const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1409 xmlns: "http://www.w3.org/2000/svg",
1410 viewBox: "0 0 24 24"
1411 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1412 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
1413 }));
1414 /* harmony default export */ var more_vertical = (moreVertical);
1415
1416 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js
1417
1418
1419 /**
1420 * External dependencies
1421 */
1422
1423 /**
1424 * WordPress dependencies
1425 */
1426
1427
1428
1429
1430 function MoreMenuDropdown(_ref) {
1431 let {
1432 as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
1433 className,
1434
1435 /* translators: button label text should, if possible, be under 16 characters. */
1436 label = (0,external_wp_i18n_namespaceObject.__)('Options'),
1437 popoverProps,
1438 toggleProps,
1439 children
1440 } = _ref;
1441 return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
1442 className: classnames_default()('interface-more-menu-dropdown', className),
1443 icon: more_vertical,
1444 label: label,
1445 popoverProps: {
1446 position: 'bottom left',
1447 ...popoverProps,
1448 className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
1449 },
1450 toggleProps: {
1451 tooltipPosition: 'bottom',
1452 ...toggleProps
1453 }
1454 }, onClose => children(onClose));
1455 }
1456
1457 ;// CONCATENATED MODULE: external ["wp","a11y"]
1458 var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
1459 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-feature-toggle/index.js
1460
1461
1462 /**
1463 * WordPress dependencies
1464 */
1465
1466
1467
1468
1469
1470 /**
1471 * Internal dependencies
1472 */
1473
1474
1475 function MoreMenuFeatureToggle(_ref) {
1476 let {
1477 scope,
1478 label,
1479 info,
1480 messageActivated,
1481 messageDeactivated,
1482 shortcut,
1483 feature
1484 } = _ref;
1485 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isFeatureActive(scope, feature), [feature]);
1486 const {
1487 toggleFeature
1488 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1489
1490 const speakMessage = () => {
1491 if (isActive) {
1492 (0,external_wp_a11y_namespaceObject.speak)(messageDeactivated || (0,external_wp_i18n_namespaceObject.__)('Feature deactivated'));
1493 } else {
1494 (0,external_wp_a11y_namespaceObject.speak)(messageActivated || (0,external_wp_i18n_namespaceObject.__)('Feature activated'));
1495 }
1496 };
1497
1498 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
1499 icon: isActive && library_check,
1500 isSelected: isActive,
1501 onClick: () => {
1502 toggleFeature(scope, feature);
1503 speakMessage();
1504 },
1505 role: "menuitemcheckbox",
1506 info: info,
1507 shortcut: shortcut
1508 }, label);
1509 }
1510
1511 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
1522
1523
1524
1525 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
1526 var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
1527 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/hooks/components/index.js
1528 /**
1529 * WordPress dependencies
1530 */
1531
1532
1533
1534 const replaceMediaUpload = () => external_wp_mediaUtils_namespaceObject.MediaUpload;
1535
1536 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-post/replace-media-upload', replaceMediaUpload);
1537
1538 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
1539 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1540 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/hooks/validate-multiple-use/index.js
1541
1542
1543
1544 /**
1545 * External dependencies
1546 */
1547
1548 /**
1549 * WordPress dependencies
1550 */
1551
1552
1553
1554
1555
1556
1557
1558
1559 const enhance = (0,external_wp_compose_namespaceObject.compose)(
1560 /**
1561 * For blocks whose block type doesn't support `multiple`, provides the
1562 * wrapped component with `originalBlockClientId` -- a reference to the
1563 * first block of the same type in the content -- if and only if that
1564 * "original" block is not the current one. Thus, an inexisting
1565 * `originalBlockClientId` prop signals that the block is valid.
1566 *
1567 * @param {WPComponent} WrappedBlockEdit A filtered BlockEdit instance.
1568 *
1569 * @return {WPComponent} Enhanced component with merged state data props.
1570 */
1571 (0,external_wp_data_namespaceObject.withSelect)((select, block) => {
1572 const multiple = (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'multiple', true); // For block types with `multiple` support, there is no "original
1573 // block" to be found in the content, as the block itself is valid.
1574
1575 if (multiple) {
1576 return {};
1577 } // Otherwise, only pass `originalBlockClientId` if it refers to a different
1578 // block from the current one.
1579
1580
1581 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
1582 const firstOfSameType = (0,external_lodash_namespaceObject.find)(blocks, _ref => {
1583 let {
1584 name
1585 } = _ref;
1586 return block.name === name;
1587 });
1588 const isInvalid = firstOfSameType && firstOfSameType.clientId !== block.clientId;
1589 return {
1590 originalBlockClientId: isInvalid && firstOfSameType.clientId
1591 };
1592 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref2) => {
1593 let {
1594 originalBlockClientId
1595 } = _ref2;
1596 return {
1597 selectFirst: () => dispatch(external_wp_blockEditor_namespaceObject.store).selectBlock(originalBlockClientId)
1598 };
1599 }));
1600 const withMultipleValidation = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => {
1601 return enhance(_ref3 => {
1602 let {
1603 originalBlockClientId,
1604 selectFirst,
1605 ...props
1606 } = _ref3;
1607
1608 if (!originalBlockClientId) {
1609 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
1610 }
1611
1612 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(props.name);
1613 const outboundType = getOutboundType(props.name);
1614 return [(0,external_wp_element_namespaceObject.createElement)("div", {
1615 key: "invalid-preview",
1616 style: {
1617 minHeight: '60px'
1618 }
1619 }, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
1620 key: "block-edit"
1621 }, props))), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
1622 key: "multiple-use-warning",
1623 actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1624 key: "find-original",
1625 variant: "secondary",
1626 onClick: selectFirst
1627 }, (0,external_wp_i18n_namespaceObject.__)('Find original')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1628 key: "remove",
1629 variant: "secondary",
1630 onClick: () => props.onReplace([])
1631 }, (0,external_wp_i18n_namespaceObject.__)('Remove')), outboundType && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1632 key: "transform",
1633 variant: "secondary",
1634 onClick: () => props.onReplace((0,external_wp_blocks_namespaceObject.createBlock)(outboundType.name, props.attributes))
1635 }, (0,external_wp_i18n_namespaceObject.__)('Transform into:'), " ", outboundType.title)]
1636 }, (0,external_wp_element_namespaceObject.createElement)("strong", null, blockType === null || blockType === void 0 ? void 0 : blockType.title, ": "), (0,external_wp_i18n_namespaceObject.__)('This block can only be used once.'))];
1637 });
1638 }, 'withMultipleValidation');
1639 /**
1640 * Given a base block name, returns the default block type to which to offer
1641 * transforms.
1642 *
1643 * @param {string} blockName Base block name.
1644 *
1645 * @return {?Object} The chosen default block type.
1646 */
1647
1648 function getOutboundType(blockName) {
1649 // Grab the first outbound transform
1650 const transform = (0,external_wp_blocks_namespaceObject.findTransform)((0,external_wp_blocks_namespaceObject.getBlockTransforms)('to', blockName), _ref4 => {
1651 let {
1652 type,
1653 blocks
1654 } = _ref4;
1655 return type === 'block' && blocks.length === 1;
1656 } // What about when .length > 1?
1657 );
1658
1659 if (!transform) {
1660 return null;
1661 }
1662
1663 return (0,external_wp_blocks_namespaceObject.getBlockType)(transform.blocks[0]);
1664 }
1665
1666 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-post/validate-multiple-use/with-multiple-validation', withMultipleValidation);
1667
1668 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/hooks/index.js
1669 /**
1670 * Internal dependencies
1671 */
1672
1673
1674
1675 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
1676
1677
1678 /**
1679 * WordPress dependencies
1680 */
1681
1682 const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1683 xmlns: "http://www.w3.org/2000/svg",
1684 viewBox: "0 0 24 24"
1685 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1686 d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
1687 }));
1688 /* harmony default export */ var library_external = (external);
1689
1690 ;// CONCATENATED MODULE: external ["wp","url"]
1691 var external_wp_url_namespaceObject = window["wp"]["url"];
1692 ;// CONCATENATED MODULE: external ["wp","notices"]
1693 var external_wp_notices_namespaceObject = window["wp"]["notices"];
1694 ;// CONCATENATED MODULE: external ["wp","editor"]
1695 var external_wp_editor_namespaceObject = window["wp"]["editor"];
1696 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/plugins/copy-content-menu-item/index.js
1697
1698
1699 /**
1700 * WordPress dependencies
1701 */
1702
1703
1704
1705
1706
1707
1708 function CopyContentMenuItem() {
1709 const {
1710 createNotice
1711 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
1712 const getText = (0,external_wp_data_namespaceObject.useSelect)(select => () => select(external_wp_editor_namespaceObject.store).getEditedPostAttribute('content'), []);
1713
1714 function onSuccess() {
1715 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
1716 isDismissible: true,
1717 type: 'snackbar'
1718 });
1719 }
1720
1721 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
1722 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
1723 ref: ref
1724 }, (0,external_wp_i18n_namespaceObject.__)('Copy all content'));
1725 }
1726
1727 ;// CONCATENATED MODULE: external ["wp","keycodes"]
1728 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
1729 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/store/defaults.js
1730 const PREFERENCES_DEFAULTS = {
1731 editorMode: 'visual',
1732 panels: {
1733 'post-status': {
1734 opened: true
1735 }
1736 },
1737 hiddenBlockTypes: [],
1738 preferredStyleVariations: {},
1739 localAutosaveInterval: 15
1740 };
1741
1742 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/store/reducer.js
1743 /**
1744 * External dependencies
1745 */
1746
1747 /**
1748 * WordPress dependencies
1749 */
1750
1751
1752 /**
1753 * Internal dependencies
1754 */
1755
1756
1757 /**
1758 * Higher-order reducer creator which provides the given initial state for the
1759 * original reducer.
1760 *
1761 * @param {*} initialState Initial state to provide to reducer.
1762 *
1763 * @return {Function} Higher-order reducer.
1764 */
1765
1766 const createWithInitialState = initialState => reducer => {
1767 return function () {
1768 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
1769 let action = arguments.length > 1 ? arguments[1] : undefined;
1770 return reducer(state, action);
1771 };
1772 };
1773 /**
1774 * Reducer returning the user preferences.
1775 *
1776 * @param {Object} state Current state.
1777 * @param {string} state.mode Current editor mode, either
1778 * "visual" or "text".
1779 * @param {boolean} state.isGeneralSidebarDismissed Whether general sidebar is
1780 * dismissed. False by default
1781 * or when closing general
1782 * sidebar, true when opening
1783 * sidebar.
1784 * @param {boolean} state.isSidebarOpened Whether the sidebar is
1785 * opened or closed.
1786 * @param {Object} state.panels The state of the different
1787 * sidebar panels.
1788 * @param {Object} action Dispatched action.
1789 *
1790 * @return {Object} Updated state.
1791 */
1792
1793
1794 const reducer_preferences = (0,external_lodash_namespaceObject.flow)([external_wp_data_namespaceObject.combineReducers, createWithInitialState(PREFERENCES_DEFAULTS)])({
1795 panels(state, action) {
1796 switch (action.type) {
1797 case 'TOGGLE_PANEL_ENABLED':
1798 {
1799 const {
1800 panelName
1801 } = action;
1802 return { ...state,
1803 [panelName]: { ...state[panelName],
1804 enabled: !(0,external_lodash_namespaceObject.get)(state, [panelName, 'enabled'], true)
1805 }
1806 };
1807 }
1808
1809 case 'TOGGLE_PANEL_OPENED':
1810 {
1811 const {
1812 panelName
1813 } = action;
1814 const isOpen = state[panelName] === true || (0,external_lodash_namespaceObject.get)(state, [panelName, 'opened'], false);
1815 return { ...state,
1816 [panelName]: { ...state[panelName],
1817 opened: !isOpen
1818 }
1819 };
1820 }
1821 }
1822
1823 return state;
1824 },
1825
1826 editorMode(state, action) {
1827 if (action.type === 'SWITCH_MODE') {
1828 return action.mode;
1829 }
1830
1831 return state;
1832 },
1833
1834 hiddenBlockTypes(state, action) {
1835 switch (action.type) {
1836 case 'SHOW_BLOCK_TYPES':
1837 return (0,external_lodash_namespaceObject.without)(state, ...action.blockNames);
1838
1839 case 'HIDE_BLOCK_TYPES':
1840 return (0,external_lodash_namespaceObject.union)(state, action.blockNames);
1841 }
1842
1843 return state;
1844 },
1845
1846 preferredStyleVariations(state, action) {
1847 switch (action.type) {
1848 case 'UPDATE_PREFERRED_STYLE_VARIATIONS':
1849 {
1850 if (!action.blockName) {
1851 return state;
1852 }
1853
1854 if (!action.blockStyle) {
1855 return (0,external_lodash_namespaceObject.omit)(state, [action.blockName]);
1856 }
1857
1858 return { ...state,
1859 [action.blockName]: action.blockStyle
1860 };
1861 }
1862 }
1863
1864 return state;
1865 },
1866
1867 localAutosaveInterval(state, action) {
1868 switch (action.type) {
1869 case 'UPDATE_LOCAL_AUTOSAVE_INTERVAL':
1870 return action.interval;
1871 }
1872
1873 return state;
1874 }
1875
1876 });
1877 /**
1878 * Reducer storing the list of all programmatically removed panels.
1879 *
1880 * @param {Array} state Current state.
1881 * @param {Object} action Action object.
1882 *
1883 * @return {Array} Updated state.
1884 */
1885
1886 function removedPanels() {
1887 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1888 let action = arguments.length > 1 ? arguments[1] : undefined;
1889
1890 switch (action.type) {
1891 case 'REMOVE_PANEL':
1892 if (!(0,external_lodash_namespaceObject.includes)(state, action.panelName)) {
1893 return [...state, action.panelName];
1894 }
1895
1896 }
1897
1898 return state;
1899 }
1900 /**
1901 * Reducer for storing the name of the open modal, or null if no modal is open.
1902 *
1903 * @param {Object} state Previous state.
1904 * @param {Object} action Action object containing the `name` of the modal
1905 *
1906 * @return {Object} Updated state
1907 */
1908
1909 function activeModal() {
1910 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1911 let action = arguments.length > 1 ? arguments[1] : undefined;
1912
1913 switch (action.type) {
1914 case 'OPEN_MODAL':
1915 return action.name;
1916
1917 case 'CLOSE_MODAL':
1918 return null;
1919 }
1920
1921 return state;
1922 }
1923 function publishSidebarActive() {
1924 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1925 let action = arguments.length > 1 ? arguments[1] : undefined;
1926
1927 switch (action.type) {
1928 case 'OPEN_PUBLISH_SIDEBAR':
1929 return true;
1930
1931 case 'CLOSE_PUBLISH_SIDEBAR':
1932 return false;
1933
1934 case 'TOGGLE_PUBLISH_SIDEBAR':
1935 return !state;
1936 }
1937
1938 return state;
1939 }
1940 /**
1941 * Reducer keeping track of the meta boxes isSaving state.
1942 * A "true" value means the meta boxes saving request is in-flight.
1943 *
1944 *
1945 * @param {boolean} state Previous state.
1946 * @param {Object} action Action Object.
1947 *
1948 * @return {Object} Updated state.
1949 */
1950
1951 function isSavingMetaBoxes() {
1952 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1953 let action = arguments.length > 1 ? arguments[1] : undefined;
1954
1955 switch (action.type) {
1956 case 'REQUEST_META_BOX_UPDATES':
1957 return true;
1958
1959 case 'META_BOX_UPDATES_SUCCESS':
1960 case 'META_BOX_UPDATES_FAILURE':
1961 return false;
1962
1963 default:
1964 return state;
1965 }
1966 }
1967 /**
1968 * Reducer keeping track of the meta boxes per location.
1969 *
1970 * @param {boolean} state Previous state.
1971 * @param {Object} action Action Object.
1972 *
1973 * @return {Object} Updated state.
1974 */
1975
1976 function metaBoxLocations() {
1977 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1978 let action = arguments.length > 1 ? arguments[1] : undefined;
1979
1980 switch (action.type) {
1981 case 'SET_META_BOXES_PER_LOCATIONS':
1982 return action.metaBoxesPerLocation;
1983 }
1984
1985 return state;
1986 }
1987 /**
1988 * Reducer returning the editing canvas device type.
1989 *
1990 * @param {Object} state Current state.
1991 * @param {Object} action Dispatched action.
1992 *
1993 * @return {Object} Updated state.
1994 */
1995
1996 function deviceType() {
1997 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Desktop';
1998 let action = arguments.length > 1 ? arguments[1] : undefined;
1999
2000 switch (action.type) {
2001 case 'SET_PREVIEW_DEVICE_TYPE':
2002 return action.deviceType;
2003 }
2004
2005 return state;
2006 }
2007 /**
2008 * Reducer to set the block inserter panel open or closed.
2009 *
2010 * Note: this reducer interacts with the list view panel reducer
2011 * to make sure that only one of the two panels is open at the same time.
2012 *
2013 * @param {Object} state Current state.
2014 * @param {Object} action Dispatched action.
2015 */
2016
2017 function blockInserterPanel() {
2018 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2019 let action = arguments.length > 1 ? arguments[1] : undefined;
2020
2021 switch (action.type) {
2022 case 'SET_IS_LIST_VIEW_OPENED':
2023 return action.isOpen ? false : state;
2024
2025 case 'SET_IS_INSERTER_OPENED':
2026 return action.value;
2027 }
2028
2029 return state;
2030 }
2031 /**
2032 * Reducer to set the list view panel open or closed.
2033 *
2034 * Note: this reducer interacts with the inserter panel reducer
2035 * to make sure that only one of the two panels is open at the same time.
2036 *
2037 * @param {Object} state Current state.
2038 * @param {Object} action Dispatched action.
2039 */
2040
2041 function listViewPanel() {
2042 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2043 let action = arguments.length > 1 ? arguments[1] : undefined;
2044
2045 switch (action.type) {
2046 case 'SET_IS_INSERTER_OPENED':
2047 return action.value ? false : state;
2048
2049 case 'SET_IS_LIST_VIEW_OPENED':
2050 return action.isOpen;
2051 }
2052
2053 return state;
2054 }
2055 /**
2056 * Reducer tracking whether the inserter is open.
2057 *
2058 * @param {boolean} state
2059 * @param {Object} action
2060 */
2061
2062 function isEditingTemplate() {
2063 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2064 let action = arguments.length > 1 ? arguments[1] : undefined;
2065
2066 switch (action.type) {
2067 case 'SET_IS_EDITING_TEMPLATE':
2068 return action.value;
2069 }
2070
2071 return state;
2072 }
2073 /**
2074 * Reducer tracking whether meta boxes are initialized.
2075 *
2076 * @param {boolean} state
2077 * @param {Object} action
2078 *
2079 * @return {boolean} Updated state.
2080 */
2081
2082
2083 function metaBoxesInitialized() {
2084 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2085 let action = arguments.length > 1 ? arguments[1] : undefined;
2086
2087 switch (action.type) {
2088 case 'META_BOXES_INITIALIZED':
2089 return true;
2090 }
2091
2092 return state;
2093 }
2094
2095 const metaBoxes = (0,external_wp_data_namespaceObject.combineReducers)({
2096 isSaving: isSavingMetaBoxes,
2097 locations: metaBoxLocations,
2098 initialized: metaBoxesInitialized
2099 });
2100 /* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2101 activeModal,
2102 metaBoxes,
2103 preferences: reducer_preferences,
2104 publishSidebarActive,
2105 removedPanels,
2106 deviceType,
2107 blockInserterPanel,
2108 listViewPanel,
2109 isEditingTemplate
2110 }));
2111
2112 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
2113 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
2114 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
2115 ;// CONCATENATED MODULE: external ["wp","coreData"]
2116 var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
2117 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/utils/meta-boxes.js
2118 /**
2119 * Function returning the current Meta Boxes DOM Node in the editor
2120 * whether the meta box area is opened or not.
2121 * If the MetaBox Area is visible returns it, and returns the original container instead.
2122 *
2123 * @param {string} location Meta Box location.
2124 *
2125 * @return {string} HTML content.
2126 */
2127 const getMetaBoxContainer = location => {
2128 const area = document.querySelector(`.edit-post-meta-boxes-area.is-${location} .metabox-location-${location}`);
2129
2130 if (area) {
2131 return area;
2132 }
2133
2134 return document.querySelector('#metaboxes .metabox-location-' + location);
2135 };
2136
2137 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/store/actions.js
2138 /**
2139 * External dependencies
2140 */
2141
2142 /**
2143 * WordPress dependencies
2144 */
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154 /**
2155 * Internal dependencies
2156 */
2157
2158
2159
2160 /**
2161 * Returns an action object used in signalling that the user opened an editor sidebar.
2162 *
2163 * @param {?string} name Sidebar name to be opened.
2164 */
2165
2166 const openGeneralSidebar = name => _ref => {
2167 let {
2168 registry
2169 } = _ref;
2170 return registry.dispatch(store).enableComplementaryArea(store_store.name, name);
2171 };
2172 /**
2173 * Returns an action object signalling that the user closed the sidebar.
2174 */
2175
2176 const closeGeneralSidebar = () => _ref2 => {
2177 let {
2178 registry
2179 } = _ref2;
2180 return registry.dispatch(store).disableComplementaryArea(store_store.name);
2181 };
2182 /**
2183 * Returns an action object used in signalling that the user opened a modal.
2184 *
2185 * @param {string} name A string that uniquely identifies the modal.
2186 *
2187 * @return {Object} Action object.
2188 */
2189
2190 function openModal(name) {
2191 return {
2192 type: 'OPEN_MODAL',
2193 name
2194 };
2195 }
2196 /**
2197 * Returns an action object signalling that the user closed a modal.
2198 *
2199 * @return {Object} Action object.
2200 */
2201
2202 function closeModal() {
2203 return {
2204 type: 'CLOSE_MODAL'
2205 };
2206 }
2207 /**
2208 * Returns an action object used in signalling that the user opened the publish
2209 * sidebar.
2210 *
2211 * @return {Object} Action object
2212 */
2213
2214 function openPublishSidebar() {
2215 return {
2216 type: 'OPEN_PUBLISH_SIDEBAR'
2217 };
2218 }
2219 /**
2220 * Returns an action object used in signalling that the user closed the
2221 * publish sidebar.
2222 *
2223 * @return {Object} Action object.
2224 */
2225
2226 function closePublishSidebar() {
2227 return {
2228 type: 'CLOSE_PUBLISH_SIDEBAR'
2229 };
2230 }
2231 /**
2232 * Returns an action object used in signalling that the user toggles the publish sidebar.
2233 *
2234 * @return {Object} Action object
2235 */
2236
2237 function togglePublishSidebar() {
2238 return {
2239 type: 'TOGGLE_PUBLISH_SIDEBAR'
2240 };
2241 }
2242 /**
2243 * Returns an action object used to enable or disable a panel in the editor.
2244 *
2245 * @param {string} panelName A string that identifies the panel to enable or disable.
2246 *
2247 * @return {Object} Action object.
2248 */
2249
2250 function toggleEditorPanelEnabled(panelName) {
2251 return {
2252 type: 'TOGGLE_PANEL_ENABLED',
2253 panelName
2254 };
2255 }
2256 /**
2257 * Returns an action object used to open or close a panel in the editor.
2258 *
2259 * @param {string} panelName A string that identifies the panel to open or close.
2260 *
2261 * @return {Object} Action object.
2262 */
2263
2264 function toggleEditorPanelOpened(panelName) {
2265 return {
2266 type: 'TOGGLE_PANEL_OPENED',
2267 panelName
2268 };
2269 }
2270 /**
2271 * Returns an action object used to remove a panel from the editor.
2272 *
2273 * @param {string} panelName A string that identifies the panel to remove.
2274 *
2275 * @return {Object} Action object.
2276 */
2277
2278 function removeEditorPanel(panelName) {
2279 return {
2280 type: 'REMOVE_PANEL',
2281 panelName
2282 };
2283 }
2284 /**
2285 * Triggers an action used to toggle a feature flag.
2286 *
2287 * @param {string} feature Feature name.
2288 */
2289
2290 const actions_toggleFeature = feature => _ref3 => {
2291 let {
2292 registry
2293 } = _ref3;
2294 return registry.dispatch(store).toggleFeature('core/edit-post', feature);
2295 };
2296 const switchEditorMode = mode => _ref4 => {
2297 let {
2298 dispatch,
2299 registry
2300 } = _ref4;
2301 dispatch({
2302 type: 'SWITCH_MODE',
2303 mode
2304 }); // Unselect blocks when we switch to the code editor.
2305
2306 if (mode !== 'visual') {
2307 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
2308 }
2309
2310 const message = mode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Visual editor selected') : (0,external_wp_i18n_namespaceObject.__)('Code editor selected');
2311 (0,external_wp_a11y_namespaceObject.speak)(message, 'assertive');
2312 };
2313 /**
2314 * Triggers an action object used to toggle a plugin name flag.
2315 *
2316 * @param {string} pluginName Plugin name.
2317 */
2318
2319 const togglePinnedPluginItem = pluginName => _ref5 => {
2320 let {
2321 registry
2322 } = _ref5;
2323 const isPinned = registry.select(store).isItemPinned('core/edit-post', pluginName);
2324 registry.dispatch(store)[isPinned ? 'unpinItem' : 'pinItem']('core/edit-post', pluginName);
2325 };
2326 /**
2327 * Returns an action object used in signalling that block types by the given
2328 * name(s) should be hidden.
2329 *
2330 * @param {string[]} blockNames Names of block types to hide.
2331 *
2332 * @return {Object} Action object.
2333 */
2334
2335 function hideBlockTypes(blockNames) {
2336 return {
2337 type: 'HIDE_BLOCK_TYPES',
2338 blockNames: (0,external_lodash_namespaceObject.castArray)(blockNames)
2339 };
2340 }
2341 /**
2342 * Returns an action object used in signaling that a style should be auto-applied when a block is created.
2343 *
2344 * @param {string} blockName Name of the block.
2345 * @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the "auto apply" setting of the block is removed.
2346 *
2347 * @return {Object} Action object.
2348 */
2349
2350 function updatePreferredStyleVariations(blockName, blockStyle) {
2351 return {
2352 type: 'UPDATE_PREFERRED_STYLE_VARIATIONS',
2353 blockName,
2354 blockStyle
2355 };
2356 }
2357 /**
2358 * Returns an action object used in signalling that the editor should attempt
2359 * to locally autosave the current post every `interval` seconds.
2360 *
2361 * @param {number} interval The new interval, in seconds.
2362 * @return {Object} Action object.
2363 */
2364
2365 function __experimentalUpdateLocalAutosaveInterval(interval) {
2366 return {
2367 type: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',
2368 interval
2369 };
2370 }
2371 /**
2372 * Returns an action object used in signalling that block types by the given
2373 * name(s) should be shown.
2374 *
2375 * @param {string[]} blockNames Names of block types to show.
2376 *
2377 * @return {Object} Action object.
2378 */
2379
2380 function showBlockTypes(blockNames) {
2381 return {
2382 type: 'SHOW_BLOCK_TYPES',
2383 blockNames: (0,external_lodash_namespaceObject.castArray)(blockNames)
2384 };
2385 }
2386 /**
2387 * Returns an action object used in signaling
2388 * what Meta boxes are available in which location.
2389 *
2390 * @param {Object} metaBoxesPerLocation Meta boxes per location.
2391 */
2392
2393 const setAvailableMetaBoxesPerLocation = metaBoxesPerLocation => _ref6 => {
2394 let {
2395 dispatch
2396 } = _ref6;
2397 return dispatch({
2398 type: 'SET_META_BOXES_PER_LOCATIONS',
2399 metaBoxesPerLocation
2400 });
2401 };
2402 /**
2403 * Update a metabox.
2404 */
2405
2406 const requestMetaBoxUpdates = () => async _ref7 => {
2407 let {
2408 registry,
2409 select,
2410 dispatch
2411 } = _ref7;
2412 dispatch({
2413 type: 'REQUEST_META_BOX_UPDATES'
2414 }); // Saves the wp_editor fields
2415
2416 if (window.tinyMCE) {
2417 window.tinyMCE.triggerSave();
2418 } // Additional data needed for backward compatibility.
2419 // If we do not provide this data, the post will be overridden with the default values.
2420
2421
2422 const post = registry.select(external_wp_editor_namespaceObject.store).getCurrentPost();
2423 const additionalData = [post.comment_status ? ['comment_status', post.comment_status] : false, post.ping_status ? ['ping_status', post.ping_status] : false, post.sticky ? ['sticky', post.sticky] : false, post.author ? ['post_author', post.author] : false].filter(Boolean); // We gather all the metaboxes locations data and the base form data
2424
2425 const baseFormData = new window.FormData(document.querySelector('.metabox-base-form'));
2426 const activeMetaBoxLocations = select.getActiveMetaBoxLocations();
2427 const formDataToMerge = [baseFormData, ...activeMetaBoxLocations.map(location => new window.FormData(getMetaBoxContainer(location)))]; // Merge all form data objects into a single one.
2428
2429 const formData = (0,external_lodash_namespaceObject.reduce)(formDataToMerge, (memo, currentFormData) => {
2430 for (const [key, value] of currentFormData) {
2431 memo.append(key, value);
2432 }
2433
2434 return memo;
2435 }, new window.FormData());
2436 additionalData.forEach(_ref8 => {
2437 let [key, value] = _ref8;
2438 return formData.append(key, value);
2439 });
2440
2441 try {
2442 // Save the metaboxes
2443 await external_wp_apiFetch_default()({
2444 url: window._wpMetaBoxUrl,
2445 method: 'POST',
2446 body: formData,
2447 parse: false
2448 });
2449 dispatch.metaBoxUpdatesSuccess();
2450 } catch {
2451 dispatch.metaBoxUpdatesFailure();
2452 }
2453 };
2454 /**
2455 * Returns an action object used to signal a successful meta box update.
2456 *
2457 * @return {Object} Action object.
2458 */
2459
2460 function metaBoxUpdatesSuccess() {
2461 return {
2462 type: 'META_BOX_UPDATES_SUCCESS'
2463 };
2464 }
2465 /**
2466 * Returns an action object used to signal a failed meta box update.
2467 *
2468 * @return {Object} Action object.
2469 */
2470
2471 function metaBoxUpdatesFailure() {
2472 return {
2473 type: 'META_BOX_UPDATES_FAILURE'
2474 };
2475 }
2476 /**
2477 * Returns an action object used to toggle the width of the editing canvas.
2478 *
2479 * @param {string} deviceType
2480 *
2481 * @return {Object} Action object.
2482 */
2483
2484 function __experimentalSetPreviewDeviceType(deviceType) {
2485 return {
2486 type: 'SET_PREVIEW_DEVICE_TYPE',
2487 deviceType
2488 };
2489 }
2490 /**
2491 * Returns an action object used to open/close the inserter.
2492 *
2493 * @param {boolean|Object} value Whether the inserter should be
2494 * opened (true) or closed (false).
2495 * To specify an insertion point,
2496 * use an object.
2497 * @param {string} value.rootClientId The root client ID to insert at.
2498 * @param {number} value.insertionIndex The index to insert at.
2499 *
2500 * @return {Object} Action object.
2501 */
2502
2503 function setIsInserterOpened(value) {
2504 return {
2505 type: 'SET_IS_INSERTER_OPENED',
2506 value
2507 };
2508 }
2509 /**
2510 * Returns an action object used to open/close the list view.
2511 *
2512 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
2513 * @return {Object} Action object.
2514 */
2515
2516 function setIsListViewOpened(isOpen) {
2517 return {
2518 type: 'SET_IS_LIST_VIEW_OPENED',
2519 isOpen
2520 };
2521 }
2522 /**
2523 * Returns an action object used to switch to template editing.
2524 *
2525 * @param {boolean} value Is editing template.
2526 * @return {Object} Action object.
2527 */
2528
2529 function setIsEditingTemplate(value) {
2530 return {
2531 type: 'SET_IS_EDITING_TEMPLATE',
2532 value
2533 };
2534 }
2535 /**
2536 * Switches to the template mode.
2537 *
2538 * @param {boolean} newTemplate Is new template.
2539 */
2540
2541 const __unstableSwitchToTemplateMode = function () {
2542 let newTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2543 return _ref9 => {
2544 let {
2545 registry,
2546 select,
2547 dispatch
2548 } = _ref9;
2549 dispatch(setIsEditingTemplate(true));
2550 const isWelcomeGuideActive = select.isFeatureActive('welcomeGuideTemplate');
2551
2552 if (!isWelcomeGuideActive) {
2553 const message = newTemplate ? (0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now.") : (0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.');
2554 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(message, {
2555 type: 'snackbar'
2556 });
2557 }
2558 };
2559 };
2560 /**
2561 * Create a block based template.
2562 *
2563 * @param {Object?} template Template to create and assign.
2564 */
2565
2566 const __unstableCreateTemplate = template => async _ref10 => {
2567 let {
2568 registry
2569 } = _ref10;
2570 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
2571 const post = registry.select(external_wp_editor_namespaceObject.store).getCurrentPost();
2572 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', post.type, post.id, {
2573 template: savedTemplate.slug
2574 });
2575 };
2576 let actions_metaBoxesInitialized = false;
2577 /**
2578 * Initializes WordPress `postboxes` script and the logic for saving meta boxes.
2579 */
2580
2581 const initializeMetaBoxes = () => _ref11 => {
2582 let {
2583 registry,
2584 select,
2585 dispatch
2586 } = _ref11;
2587
2588 const isEditorReady = registry.select(external_wp_editor_namespaceObject.store).__unstableIsEditorReady();
2589
2590 if (!isEditorReady) {
2591 return;
2592 } // Only initialize once.
2593
2594
2595 if (actions_metaBoxesInitialized) {
2596 return;
2597 }
2598
2599 const postType = registry.select(external_wp_editor_namespaceObject.store).getCurrentPostType();
2600
2601 if (window.postboxes.page !== postType) {
2602 window.postboxes.add_postbox_toggles(postType);
2603 }
2604
2605 actions_metaBoxesInitialized = true;
2606 let wasSavingPost = registry.select(external_wp_editor_namespaceObject.store).isSavingPost();
2607 let wasAutosavingPost = registry.select(external_wp_editor_namespaceObject.store).isAutosavingPost();
2608 const hasMetaBoxes = select.hasMetaBoxes(); // Save metaboxes when performing a full save on the post.
2609
2610 registry.subscribe(async () => {
2611 const isSavingPost = registry.select(external_wp_editor_namespaceObject.store).isSavingPost();
2612 const isAutosavingPost = registry.select(external_wp_editor_namespaceObject.store).isAutosavingPost(); // Save metaboxes on save completion, except for autosaves that are not a post preview.
2613 //
2614 // Meta boxes are initialized once at page load. It is not necessary to
2615 // account for updates on each state change.
2616 //
2617 // See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309
2618
2619 const shouldTriggerMetaboxesSave = hasMetaBoxes && wasSavingPost && !isSavingPost && !wasAutosavingPost; // Save current state for next inspection.
2620
2621 wasSavingPost = isSavingPost;
2622 wasAutosavingPost = isAutosavingPost;
2623
2624 if (shouldTriggerMetaboxesSave) {
2625 await dispatch.requestMetaBoxUpdates();
2626 }
2627 });
2628 dispatch({
2629 type: 'META_BOXES_INITIALIZED'
2630 });
2631 };
2632
2633 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
2634
2635
2636 var LEAF_KEY, hasWeakMap;
2637
2638 /**
2639 * Arbitrary value used as key for referencing cache object in WeakMap tree.
2640 *
2641 * @type {Object}
2642 */
2643 LEAF_KEY = {};
2644
2645 /**
2646 * Whether environment supports WeakMap.
2647 *
2648 * @type {boolean}
2649 */
2650 hasWeakMap = typeof WeakMap !== 'undefined';
2651
2652 /**
2653 * Returns the first argument as the sole entry in an array.
2654 *
2655 * @param {*} value Value to return.
2656 *
2657 * @return {Array} Value returned as entry in array.
2658 */
2659 function arrayOf( value ) {
2660 return [ value ];
2661 }
2662
2663 /**
2664 * Returns true if the value passed is object-like, or false otherwise. A value
2665 * is object-like if it can support property assignment, e.g. object or array.
2666 *
2667 * @param {*} value Value to test.
2668 *
2669 * @return {boolean} Whether value is object-like.
2670 */
2671 function isObjectLike( value ) {
2672 return !! value && 'object' === typeof value;
2673 }
2674
2675 /**
2676 * Creates and returns a new cache object.
2677 *
2678 * @return {Object} Cache object.
2679 */
2680 function createCache() {
2681 var cache = {
2682 clear: function() {
2683 cache.head = null;
2684 },
2685 };
2686
2687 return cache;
2688 }
2689
2690 /**
2691 * Returns true if entries within the two arrays are strictly equal by
2692 * reference from a starting index.
2693 *
2694 * @param {Array} a First array.
2695 * @param {Array} b Second array.
2696 * @param {number} fromIndex Index from which to start comparison.
2697 *
2698 * @return {boolean} Whether arrays are shallowly equal.
2699 */
2700 function isShallowEqual( a, b, fromIndex ) {
2701 var i;
2702
2703 if ( a.length !== b.length ) {
2704 return false;
2705 }
2706
2707 for ( i = fromIndex; i < a.length; i++ ) {
2708 if ( a[ i ] !== b[ i ] ) {
2709 return false;
2710 }
2711 }
2712
2713 return true;
2714 }
2715
2716 /**
2717 * Returns a memoized selector function. The getDependants function argument is
2718 * called before the memoized selector and is expected to return an immutable
2719 * reference or array of references on which the selector depends for computing
2720 * its own return value. The memoize cache is preserved only as long as those
2721 * dependant references remain the same. If getDependants returns a different
2722 * reference(s), the cache is cleared and the selector value regenerated.
2723 *
2724 * @param {Function} selector Selector function.
2725 * @param {Function} getDependants Dependant getter returning an immutable
2726 * reference or array of reference used in
2727 * cache bust consideration.
2728 *
2729 * @return {Function} Memoized selector.
2730 */
2731 /* harmony default export */ function rememo(selector, getDependants ) {
2732 var rootCache, getCache;
2733
2734 // Use object source as dependant if getter not provided
2735 if ( ! getDependants ) {
2736 getDependants = arrayOf;
2737 }
2738
2739 /**
2740 * Returns the root cache. If WeakMap is supported, this is assigned to the
2741 * root WeakMap cache set, otherwise it is a shared instance of the default
2742 * cache object.
2743 *
2744 * @return {(WeakMap|Object)} Root cache object.
2745 */
2746 function getRootCache() {
2747 return rootCache;
2748 }
2749
2750 /**
2751 * Returns the cache for a given dependants array. When possible, a WeakMap
2752 * will be used to create a unique cache for each set of dependants. This
2753 * is feasible due to the nature of WeakMap in allowing garbage collection
2754 * to occur on entries where the key object is no longer referenced. Since
2755 * WeakMap requires the key to be an object, this is only possible when the
2756 * dependant is object-like. The root cache is created as a hierarchy where
2757 * each top-level key is the first entry in a dependants set, the value a
2758 * WeakMap where each key is the next dependant, and so on. This continues
2759 * so long as the dependants are object-like. If no dependants are object-
2760 * like, then the cache is shared across all invocations.
2761 *
2762 * @see isObjectLike
2763 *
2764 * @param {Array} dependants Selector dependants.
2765 *
2766 * @return {Object} Cache object.
2767 */
2768 function getWeakMapCache( dependants ) {
2769 var caches = rootCache,
2770 isUniqueByDependants = true,
2771 i, dependant, map, cache;
2772
2773 for ( i = 0; i < dependants.length; i++ ) {
2774 dependant = dependants[ i ];
2775
2776 // Can only compose WeakMap from object-like key.
2777 if ( ! isObjectLike( dependant ) ) {
2778 isUniqueByDependants = false;
2779 break;
2780 }
2781
2782 // Does current segment of cache already have a WeakMap?
2783 if ( caches.has( dependant ) ) {
2784 // Traverse into nested WeakMap.
2785 caches = caches.get( dependant );
2786 } else {
2787 // Create, set, and traverse into a new one.
2788 map = new WeakMap();
2789 caches.set( dependant, map );
2790 caches = map;
2791 }
2792 }
2793
2794 // We use an arbitrary (but consistent) object as key for the last item
2795 // in the WeakMap to serve as our running cache.
2796 if ( ! caches.has( LEAF_KEY ) ) {
2797 cache = createCache();
2798 cache.isUniqueByDependants = isUniqueByDependants;
2799 caches.set( LEAF_KEY, cache );
2800 }
2801
2802 return caches.get( LEAF_KEY );
2803 }
2804
2805 // Assign cache handler by availability of WeakMap
2806 getCache = hasWeakMap ? getWeakMapCache : getRootCache;
2807
2808 /**
2809 * Resets root memoization cache.
2810 */
2811 function clear() {
2812 rootCache = hasWeakMap ? new WeakMap() : createCache();
2813 }
2814
2815 // eslint-disable-next-line jsdoc/check-param-names
2816 /**
2817 * The augmented selector call, considering first whether dependants have
2818 * changed before passing it to underlying memoize function.
2819 *
2820 * @param {Object} source Source object for derivation.
2821 * @param {...*} extraArgs Additional arguments to pass to selector.
2822 *
2823 * @return {*} Selector result.
2824 */
2825 function callSelector( /* source, ...extraArgs */ ) {
2826 var len = arguments.length,
2827 cache, node, i, args, dependants;
2828
2829 // Create copy of arguments (avoid leaking deoptimization).
2830 args = new Array( len );
2831 for ( i = 0; i < len; i++ ) {
2832 args[ i ] = arguments[ i ];
2833 }
2834
2835 dependants = getDependants.apply( null, args );
2836 cache = getCache( dependants );
2837
2838 // If not guaranteed uniqueness by dependants (primitive type or lack
2839 // of WeakMap support), shallow compare against last dependants and, if
2840 // references have changed, destroy cache to recalculate result.
2841 if ( ! cache.isUniqueByDependants ) {
2842 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
2843 cache.clear();
2844 }
2845
2846 cache.lastDependants = dependants;
2847 }
2848
2849 node = cache.head;
2850 while ( node ) {
2851 // Check whether node arguments match arguments
2852 if ( ! isShallowEqual( node.args, args, 1 ) ) {
2853 node = node.next;
2854 continue;
2855 }
2856
2857 // At this point we can assume we've found a match
2858
2859 // Surface matched node to head if not already
2860 if ( node !== cache.head ) {
2861 // Adjust siblings to point to each other.
2862 node.prev.next = node.next;
2863 if ( node.next ) {
2864 node.next.prev = node.prev;
2865 }
2866
2867 node.next = cache.head;
2868 node.prev = null;
2869 cache.head.prev = node;
2870 cache.head = node;
2871 }
2872
2873 // Return immediately
2874 return node.val;
2875 }
2876
2877 // No cached value found. Continue to insertion phase:
2878
2879 node = {
2880 // Generate the result from original function
2881 val: selector.apply( null, args ),
2882 };
2883
2884 // Avoid including the source object in the cache.
2885 args[ 0 ] = null;
2886 node.args = args;
2887
2888 // Don't need to check whether node is already head, since it would
2889 // have been returned above already if it was
2890
2891 // Shift existing head down list
2892 if ( cache.head ) {
2893 cache.head.prev = node;
2894 node.next = cache.head;
2895 }
2896
2897 cache.head = node;
2898
2899 return node.val;
2900 }
2901
2902 callSelector.getDependants = getDependants;
2903 callSelector.clear = clear;
2904 clear();
2905
2906 return callSelector;
2907 }
2908
2909 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/store/selectors.js
2910 /**
2911 * External dependencies
2912 */
2913
2914
2915 /**
2916 * WordPress dependencies
2917 */
2918
2919
2920
2921
2922
2923 /**
2924 * Returns the current editing mode.
2925 *
2926 * @param {Object} state Global application state.
2927 *
2928 * @return {string} Editing mode.
2929 */
2930
2931 function getEditorMode(state) {
2932 return getPreference(state, 'editorMode', 'visual');
2933 }
2934 /**
2935 * Returns true if the editor sidebar is opened.
2936 *
2937 * @param {Object} state Global application state
2938 *
2939 * @return {boolean} Whether the editor sidebar is opened.
2940 */
2941
2942 const isEditorSidebarOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2943 const activeGeneralSidebar = select(store).getActiveComplementaryArea('core/edit-post');
2944 return (0,external_lodash_namespaceObject.includes)(['edit-post/document', 'edit-post/block'], activeGeneralSidebar);
2945 });
2946 /**
2947 * Returns true if the plugin sidebar is opened.
2948 *
2949 * @param {Object} state Global application state.
2950 *
2951 * @return {boolean} Whether the plugin sidebar is opened.
2952 */
2953
2954 const isPluginSidebarOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2955 const activeGeneralSidebar = select(store).getActiveComplementaryArea('core/edit-post');
2956 return !!activeGeneralSidebar && !(0,external_lodash_namespaceObject.includes)(['edit-post/document', 'edit-post/block'], activeGeneralSidebar);
2957 });
2958 /**
2959 * Returns the current active general sidebar name, or null if there is no
2960 * general sidebar active. The active general sidebar is a unique name to
2961 * identify either an editor or plugin sidebar.
2962 *
2963 * Examples:
2964 *
2965 * - `edit-post/document`
2966 * - `my-plugin/insert-image-sidebar`
2967 *
2968 * @param {Object} state Global application state.
2969 *
2970 * @return {?string} Active general sidebar name.
2971 */
2972
2973 const getActiveGeneralSidebarName = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2974 return select(store).getActiveComplementaryArea('core/edit-post');
2975 });
2976 /**
2977 * Returns the preferences (these preferences are persisted locally).
2978 *
2979 * @param {Object} state Global application state.
2980 *
2981 * @return {Object} Preferences Object.
2982 */
2983
2984 function getPreferences(state) {
2985 return state.preferences;
2986 }
2987 /**
2988 *
2989 * @param {Object} state Global application state.
2990 * @param {string} preferenceKey Preference Key.
2991 * @param {*} defaultValue Default Value.
2992 *
2993 * @return {*} Preference Value.
2994 */
2995
2996 function getPreference(state, preferenceKey, defaultValue) {
2997 const preferences = getPreferences(state);
2998 const value = preferences[preferenceKey];
2999 return value === undefined ? defaultValue : value;
3000 }
3001 /**
3002 * Returns true if the publish sidebar is opened.
3003 *
3004 * @param {Object} state Global application state
3005 *
3006 * @return {boolean} Whether the publish sidebar is open.
3007 */
3008
3009 function isPublishSidebarOpened(state) {
3010 return state.publishSidebarActive;
3011 }
3012 /**
3013 * Returns true if the given panel was programmatically removed, or false otherwise.
3014 * All panels are not removed by default.
3015 *
3016 * @param {Object} state Global application state.
3017 * @param {string} panelName A string that identifies the panel.
3018 *
3019 * @return {boolean} Whether or not the panel is removed.
3020 */
3021
3022 function isEditorPanelRemoved(state, panelName) {
3023 return (0,external_lodash_namespaceObject.includes)(state.removedPanels, panelName);
3024 }
3025 /**
3026 * Returns true if the given panel is enabled, or false otherwise. Panels are
3027 * enabled by default.
3028 *
3029 * @param {Object} state Global application state.
3030 * @param {string} panelName A string that identifies the panel.
3031 *
3032 * @return {boolean} Whether or not the panel is enabled.
3033 */
3034
3035 function isEditorPanelEnabled(state, panelName) {
3036 const panels = getPreference(state, 'panels');
3037 return !isEditorPanelRemoved(state, panelName) && (0,external_lodash_namespaceObject.get)(panels, [panelName, 'enabled'], true);
3038 }
3039 /**
3040 * Returns true if the given panel is open, or false otherwise. Panels are
3041 * closed by default.
3042 *
3043 * @param {Object} state Global application state.
3044 * @param {string} panelName A string that identifies the panel.
3045 *
3046 * @return {boolean} Whether or not the panel is open.
3047 */
3048
3049 function isEditorPanelOpened(state, panelName) {
3050 const panels = getPreference(state, 'panels');
3051 return (0,external_lodash_namespaceObject.get)(panels, [panelName]) === true || (0,external_lodash_namespaceObject.get)(panels, [panelName, 'opened']) === true;
3052 }
3053 /**
3054 * Returns true if a modal is active, or false otherwise.
3055 *
3056 * @param {Object} state Global application state.
3057 * @param {string} modalName A string that uniquely identifies the modal.
3058 *
3059 * @return {boolean} Whether the modal is active.
3060 */
3061
3062 function isModalActive(state, modalName) {
3063 return state.activeModal === modalName;
3064 }
3065 /**
3066 * Returns whether the given feature is enabled or not.
3067 *
3068 * @param {Object} state Global application state.
3069 * @param {string} feature Feature slug.
3070 *
3071 * @return {boolean} Is active.
3072 */
3073
3074 const selectors_isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, feature) => {
3075 return select(store).isFeatureActive('core/edit-post', feature);
3076 });
3077 /**
3078 * Returns true if the plugin item is pinned to the header.
3079 * When the value is not set it defaults to true.
3080 *
3081 * @param {Object} state Global application state.
3082 * @param {string} pluginName Plugin item name.
3083 *
3084 * @return {boolean} Whether the plugin item is pinned.
3085 */
3086
3087 const isPluginItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, pluginName) => {
3088 return select(store).isItemPinned('core/edit-post', pluginName);
3089 });
3090 /**
3091 * Returns an array of active meta box locations.
3092 *
3093 * @param {Object} state Post editor state.
3094 *
3095 * @return {string[]} Active meta box locations.
3096 */
3097
3098 const getActiveMetaBoxLocations = rememo(state => {
3099 return Object.keys(state.metaBoxes.locations).filter(location => isMetaBoxLocationActive(state, location));
3100 }, state => [state.metaBoxes.locations]);
3101 /**
3102 * Returns true if a metabox location is active and visible
3103 *
3104 * @param {Object} state Post editor state.
3105 * @param {string} location Meta box location to test.
3106 *
3107 * @return {boolean} Whether the meta box location is active and visible.
3108 */
3109
3110 function isMetaBoxLocationVisible(state, location) {
3111 return isMetaBoxLocationActive(state, location) && (0,external_lodash_namespaceObject.some)(getMetaBoxesPerLocation(state, location), _ref => {
3112 let {
3113 id
3114 } = _ref;
3115 return isEditorPanelEnabled(state, `meta-box-${id}`);
3116 });
3117 }
3118 /**
3119 * Returns true if there is an active meta box in the given location, or false
3120 * otherwise.
3121 *
3122 * @param {Object} state Post editor state.
3123 * @param {string} location Meta box location to test.
3124 *
3125 * @return {boolean} Whether the meta box location is active.
3126 */
3127
3128 function isMetaBoxLocationActive(state, location) {
3129 const metaBoxes = getMetaBoxesPerLocation(state, location);
3130 return !!metaBoxes && metaBoxes.length !== 0;
3131 }
3132 /**
3133 * Returns the list of all the available meta boxes for a given location.
3134 *
3135 * @param {Object} state Global application state.
3136 * @param {string} location Meta box location to test.
3137 *
3138 * @return {?Array} List of meta boxes.
3139 */
3140
3141 function getMetaBoxesPerLocation(state, location) {
3142 return state.metaBoxes.locations[location];
3143 }
3144 /**
3145 * Returns the list of all the available meta boxes.
3146 *
3147 * @param {Object} state Global application state.
3148 *
3149 * @return {Array} List of meta boxes.
3150 */
3151
3152 const getAllMetaBoxes = rememo(state => {
3153 return (0,external_lodash_namespaceObject.flatten)((0,external_lodash_namespaceObject.values)(state.metaBoxes.locations));
3154 }, state => [state.metaBoxes.locations]);
3155 /**
3156 * Returns true if the post is using Meta Boxes
3157 *
3158 * @param {Object} state Global application state
3159 *
3160 * @return {boolean} Whether there are metaboxes or not.
3161 */
3162
3163 function hasMetaBoxes(state) {
3164 return getActiveMetaBoxLocations(state).length > 0;
3165 }
3166 /**
3167 * Returns true if the Meta Boxes are being saved.
3168 *
3169 * @param {Object} state Global application state.
3170 *
3171 * @return {boolean} Whether the metaboxes are being saved.
3172 */
3173
3174 function selectors_isSavingMetaBoxes(state) {
3175 return state.metaBoxes.isSaving;
3176 }
3177 /**
3178 * Returns the current editing canvas device type.
3179 *
3180 * @param {Object} state Global application state.
3181 *
3182 * @return {string} Device type.
3183 */
3184
3185 function __experimentalGetPreviewDeviceType(state) {
3186 return state.deviceType;
3187 }
3188 /**
3189 * Returns true if the inserter is opened.
3190 *
3191 * @param {Object} state Global application state.
3192 *
3193 * @return {boolean} Whether the inserter is opened.
3194 */
3195
3196 function isInserterOpened(state) {
3197 return !!state.blockInserterPanel;
3198 }
3199 /**
3200 * Get the insertion point for the inserter.
3201 *
3202 * @param {Object} state Global application state.
3203 *
3204 * @return {Object} The root client ID, index to insert at and starting filter value.
3205 */
3206
3207 function __experimentalGetInsertionPoint(state) {
3208 const {
3209 rootClientId,
3210 insertionIndex,
3211 filterValue
3212 } = state.blockInserterPanel;
3213 return {
3214 rootClientId,
3215 insertionIndex,
3216 filterValue
3217 };
3218 }
3219 /**
3220 * Returns true if the list view is opened.
3221 *
3222 * @param {Object} state Global application state.
3223 *
3224 * @return {boolean} Whether the list view is opened.
3225 */
3226
3227 function isListViewOpened(state) {
3228 return state.listViewPanel;
3229 }
3230 /**
3231 * Returns true if the template editing mode is enabled.
3232 *
3233 * @param {Object} state Global application state.
3234 *
3235 * @return {boolean} Whether we're editing the template.
3236 */
3237
3238 function selectors_isEditingTemplate(state) {
3239 return state.isEditingTemplate;
3240 }
3241 /**
3242 * Returns true if meta boxes are initialized.
3243 *
3244 * @param {Object} state Global application state.
3245 *
3246 * @return {boolean} Whether meta boxes are initialized.
3247 */
3248
3249 function areMetaBoxesInitialized(state) {
3250 return state.metaBoxes.initialized;
3251 }
3252 /**
3253 * Retrieves the template of the currently edited post.
3254 *
3255 * @return {Object?} Post Template.
3256 */
3257
3258 const getEditedPostTemplate = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3259 const currentTemplate = select(external_wp_editor_namespaceObject.store).getEditedPostAttribute('template');
3260
3261 if (currentTemplate) {
3262 var _select$getEntityReco;
3263
3264 const templateWithSameSlug = (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
3265 per_page: -1
3266 })) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.find(template => template.slug === currentTemplate);
3267
3268 if (!templateWithSameSlug) {
3269 return templateWithSameSlug;
3270 }
3271
3272 return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', 'wp_template', templateWithSameSlug.id);
3273 }
3274
3275 const post = select(external_wp_editor_namespaceObject.store).getCurrentPost();
3276
3277 if (post.link) {
3278 return select(external_wp_coreData_namespaceObject.store).__experimentalGetTemplateForLink(post.link);
3279 }
3280
3281 return null;
3282 });
3283
3284 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/store/constants.js
3285 /**
3286 * The identifier for the data store.
3287 *
3288 * @type {string}
3289 */
3290 const constants_STORE_NAME = 'core/edit-post';
3291 /**
3292 * CSS selector string for the admin bar view post link anchor tag.
3293 *
3294 * @type {string}
3295 */
3296
3297 const VIEW_AS_LINK_SELECTOR = '#wp-admin-bar-view a';
3298 /**
3299 * CSS selector string for the admin bar preview post link anchor tag.
3300 *
3301 * @type {string}
3302 */
3303
3304 const VIEW_AS_PREVIEW_LINK_SELECTOR = '#wp-admin-bar-preview a';
3305
3306 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/store/index.js
3307 /**
3308 * WordPress dependencies
3309 */
3310
3311 /**
3312 * Internal dependencies
3313 */
3314
3315
3316
3317
3318
3319 const store_storeConfig = {
3320 reducer: store_reducer,
3321 actions: store_actions_namespaceObject,
3322 selectors: store_selectors_namespaceObject,
3323 persist: ['preferences']
3324 };
3325 /**
3326 * Store definition for the edit post namespace.
3327 *
3328 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
3329 *
3330 * @type {Object}
3331 */
3332
3333 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, store_storeConfig); // Ideally we use register instead of register store.
3334
3335 (0,external_wp_data_namespaceObject.registerStore)(constants_STORE_NAME, store_storeConfig);
3336
3337 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js
3338
3339
3340 /**
3341 * WordPress dependencies
3342 */
3343
3344
3345
3346
3347 /**
3348 * Internal dependencies
3349 */
3350
3351
3352 function KeyboardShortcutsHelpMenuItem(_ref) {
3353 let {
3354 openModal
3355 } = _ref;
3356 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
3357 onClick: () => {
3358 openModal('edit-post/keyboard-shortcut-help');
3359 },
3360 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h')
3361 }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'));
3362 }
3363 /* harmony default export */ var keyboard_shortcuts_help_menu_item = ((0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
3364 const {
3365 openModal
3366 } = dispatch(store_store);
3367 return {
3368 openModal
3369 };
3370 })(KeyboardShortcutsHelpMenuItem));
3371
3372 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/tools-more-menu-group/index.js
3373
3374
3375 /**
3376 * External dependencies
3377 */
3378
3379 /**
3380 * WordPress dependencies
3381 */
3382
3383
3384
3385 const {
3386 Fill: ToolsMoreMenuGroup,
3387 Slot
3388 } = (0,external_wp_components_namespaceObject.createSlotFill)('ToolsMoreMenuGroup');
3389
3390 ToolsMoreMenuGroup.Slot = _ref => {
3391 let {
3392 fillProps
3393 } = _ref;
3394 return (0,external_wp_element_namespaceObject.createElement)(Slot, {
3395 fillProps: fillProps
3396 }, fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
3397 label: (0,external_wp_i18n_namespaceObject.__)('Tools')
3398 }, fills));
3399 };
3400
3401 /* harmony default export */ var tools_more_menu_group = (ToolsMoreMenuGroup);
3402
3403 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/plugins/welcome-guide-menu-item/index.js
3404
3405
3406 /**
3407 * WordPress dependencies
3408 */
3409
3410
3411
3412 /**
3413 * Internal dependencies
3414 */
3415
3416
3417 function WelcomeGuideMenuItem() {
3418 const isTemplateMode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isEditingTemplate(), []);
3419 return (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, {
3420 scope: "core/edit-post",
3421 feature: isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide',
3422 label: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')
3423 });
3424 }
3425
3426 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/plugins/index.js
3427
3428
3429 /**
3430 * WordPress dependencies
3431 */
3432
3433
3434
3435
3436
3437 /**
3438 * Internal dependencies
3439 */
3440
3441
3442
3443
3444
3445 (0,external_wp_plugins_namespaceObject.registerPlugin)('edit-post', {
3446 render() {
3447 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group, null, _ref => {
3448 let {
3449 onClose
3450 } = _ref;
3451 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
3452 role: "menuitem",
3453 href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
3454 post_type: 'wp_block'
3455 })
3456 }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks')), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts_help_menu_item, {
3457 onSelect: onClose
3458 }), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideMenuItem, null), (0,external_wp_element_namespaceObject.createElement)(CopyContentMenuItem, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
3459 role: "menuitem",
3460 icon: library_external,
3461 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/wordpress-editor/'),
3462 target: "_blank",
3463 rel: "noopener noreferrer"
3464 }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
3465 as: "span"
3466 },
3467 /* translators: accessibility text */
3468 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))));
3469 }));
3470 }
3471
3472 });
3473
3474 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
3475 var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
3476 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/text-editor/index.js
3477
3478
3479 /**
3480 * WordPress dependencies
3481 */
3482
3483
3484
3485
3486
3487
3488 /**
3489 * Internal dependencies
3490 */
3491
3492
3493
3494 function TextEditor(_ref) {
3495 let {
3496 onExit,
3497 isRichEditingEnabled
3498 } = _ref;
3499 return (0,external_wp_element_namespaceObject.createElement)("div", {
3500 className: "edit-post-text-editor"
3501 }, isRichEditingEnabled && (0,external_wp_element_namespaceObject.createElement)("div", {
3502 className: "edit-post-text-editor__toolbar"
3503 }, (0,external_wp_element_namespaceObject.createElement)("h2", null, (0,external_wp_i18n_namespaceObject.__)('Editing code')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3504 variant: "tertiary",
3505 onClick: onExit,
3506 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.secondary('m')
3507 }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor')), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.TextEditorGlobalKeyboardShortcuts, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
3508 className: "edit-post-text-editor__body"
3509 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTitle, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTextEditor, null)));
3510 }
3511
3512 /* harmony default export */ var text_editor = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
3513 isRichEditingEnabled: select(external_wp_editor_namespaceObject.store).getEditorSettings().richEditingEnabled
3514 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
3515 return {
3516 onExit() {
3517 dispatch(store_store).switchEditorMode('visual');
3518 }
3519
3520 };
3521 }))(TextEditor));
3522
3523 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/arrow-left.js
3524
3525
3526 /**
3527 * WordPress dependencies
3528 */
3529
3530 const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3531 xmlns: "http://www.w3.org/2000/svg",
3532 viewBox: "0 0 24 24"
3533 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3534 d: "M20 10.8H6.7l4.1-4.5-1.1-1.1-5.8 6.3 5.8 5.8 1.1-1.1-4-3.9H20z"
3535 }));
3536 /* harmony default export */ var arrow_left = (arrowLeft);
3537
3538 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/visual-editor/block-inspector-button.js
3539
3540
3541 /**
3542 * External dependencies
3543 */
3544
3545 /**
3546 * WordPress dependencies
3547 */
3548
3549
3550
3551
3552
3553
3554 /**
3555 * Internal dependencies
3556 */
3557
3558
3559 function BlockInspectorButton(_ref) {
3560 let {
3561 onClick = external_lodash_namespaceObject.noop,
3562 small = false
3563 } = _ref;
3564 const {
3565 shortcut,
3566 areAdvancedSettingsOpened
3567 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
3568 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-post/toggle-sidebar'),
3569 areAdvancedSettingsOpened: select(store_store).getActiveGeneralSidebarName() === 'edit-post/block'
3570 }), []);
3571 const {
3572 openGeneralSidebar,
3573 closeGeneralSidebar
3574 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3575 const label = areAdvancedSettingsOpened ? (0,external_wp_i18n_namespaceObject.__)('Hide more settings') : (0,external_wp_i18n_namespaceObject.__)('Show more settings');
3576 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
3577 onClick: () => {
3578 if (areAdvancedSettingsOpened) {
3579 closeGeneralSidebar();
3580 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Block settings closed'));
3581 } else {
3582 openGeneralSidebar('edit-post/block');
3583 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Additional settings are now available in the Editor block settings sidebar'));
3584 }
3585
3586 onClick();
3587 },
3588 shortcut: shortcut
3589 }, !small && label);
3590 }
3591 /* harmony default export */ var block_inspector_button = (BlockInspectorButton);
3592
3593 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/visual-editor/index.js
3594
3595
3596 /**
3597 * External dependencies
3598 */
3599
3600 /**
3601 * WordPress dependencies
3602 */
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612 /**
3613 * Internal dependencies
3614 */
3615
3616
3617
3618
3619 function MaybeIframe(_ref) {
3620 let {
3621 children,
3622 contentRef,
3623 shouldIframe,
3624 styles,
3625 assets,
3626 style
3627 } = _ref;
3628 const ref = (0,external_wp_blockEditor_namespaceObject.__unstableUseMouseMoveTypingReset)();
3629
3630 if (!shouldIframe) {
3631 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
3632 styles: styles
3633 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.WritingFlow, {
3634 ref: contentRef,
3635 className: "editor-styles-wrapper",
3636 style: {
3637 flex: '1',
3638 ...style
3639 },
3640 tabIndex: -1
3641 }, children));
3642 }
3643
3644 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, {
3645 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
3646 styles: styles
3647 }),
3648 assets: assets,
3649 ref: ref,
3650 contentRef: contentRef,
3651 style: {
3652 width: '100%',
3653 height: '100%',
3654 display: 'block'
3655 },
3656 name: "editor-canvas"
3657 }, children);
3658 }
3659
3660 function VisualEditor(_ref2) {
3661 let {
3662 styles
3663 } = _ref2;
3664 const {
3665 deviceType,
3666 isTemplateMode,
3667 wrapperBlockName,
3668 wrapperUniqueId
3669 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
3670 const {
3671 isEditingTemplate,
3672 __experimentalGetPreviewDeviceType
3673 } = select(store_store);
3674 const {
3675 getCurrentPostId,
3676 getCurrentPostType
3677 } = select(external_wp_editor_namespaceObject.store);
3678
3679 const _isTemplateMode = isEditingTemplate();
3680
3681 let _wrapperBlockName;
3682
3683 if (getCurrentPostType() === 'wp_block') {
3684 _wrapperBlockName = 'core/block';
3685 } else if (!_isTemplateMode) {
3686 _wrapperBlockName = 'core/post-content';
3687 }
3688
3689 return {
3690 deviceType: __experimentalGetPreviewDeviceType(),
3691 isTemplateMode: _isTemplateMode,
3692 wrapperBlockName: _wrapperBlockName,
3693 wrapperUniqueId: getCurrentPostId()
3694 };
3695 }, []);
3696 const hasMetaBoxes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasMetaBoxes(), []);
3697 const {
3698 themeSupportsLayout,
3699 assets
3700 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
3701 const _settings = select(external_wp_blockEditor_namespaceObject.store).getSettings();
3702
3703 return {
3704 themeSupportsLayout: _settings.supportsLayout,
3705 assets: _settings.__unstableResolvedAssets
3706 };
3707 }, []);
3708 const {
3709 clearSelectedBlock
3710 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
3711 const {
3712 setIsEditingTemplate
3713 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3714 const desktopCanvasStyles = {
3715 // We intentionally omit a 100% height here. The container is a flex item, so the 100% height is granted by default.
3716 // If a percentage height is present, older browsers such as Safari 13 apply that, but do so incorrectly as the inheritance is buggy.
3717 width: '100%',
3718 margin: 0,
3719 display: 'flex',
3720 flexFlow: 'column',
3721 // Default background color so that grey
3722 // .edit-post-editor-regions__content color doesn't show through.
3723 background: 'white'
3724 };
3725 const templateModeStyles = { ...desktopCanvasStyles,
3726 borderRadius: '2px 2px 0 0',
3727 border: '1px solid #ddd',
3728 borderBottom: 0
3729 };
3730 const resizedCanvasStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType, isTemplateMode);
3731 const defaultLayout = (0,external_wp_blockEditor_namespaceObject.useSetting)('layout');
3732 const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
3733 let animatedStyles = isTemplateMode ? templateModeStyles : desktopCanvasStyles;
3734
3735 if (resizedCanvasStyles) {
3736 animatedStyles = resizedCanvasStyles;
3737 }
3738
3739 let paddingBottom; // Add a constant padding for the typewritter effect. When typing at the
3740 // bottom, there needs to be room to scroll up.
3741
3742 if (!hasMetaBoxes && !resizedCanvasStyles && !isTemplateMode) {
3743 paddingBottom = '40vh';
3744 }
3745
3746 const ref = (0,external_wp_element_namespaceObject.useRef)();
3747 const contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, (0,external_wp_blockEditor_namespaceObject.__unstableUseClipboardHandler)(), (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)(), (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)(), (0,external_wp_blockEditor_namespaceObject.__unstableUseBlockSelectionClearer)()]);
3748 const blockSelectionClearerRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseBlockSelectionClearer)();
3749 const [, RecursionProvider] = (0,external_wp_blockEditor_namespaceObject.__experimentalUseNoRecursiveRenders)(wrapperUniqueId, wrapperBlockName);
3750 const layout = (0,external_wp_element_namespaceObject.useMemo)(() => {
3751 if (isTemplateMode) {
3752 return {
3753 type: 'default'
3754 };
3755 }
3756
3757 if (themeSupportsLayout) {
3758 return defaultLayout;
3759 }
3760
3761 return undefined;
3762 }, [isTemplateMode, themeSupportsLayout, defaultLayout]);
3763 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, {
3764 __unstableContentRef: ref,
3765 className: classnames_default()('edit-post-visual-editor', {
3766 'is-template-mode': isTemplateMode
3767 })
3768 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.VisualEditorGlobalKeyboardShortcuts, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
3769 className: "edit-post-visual-editor__content-area",
3770 animate: {
3771 padding: isTemplateMode ? '48px 48px 0' : '0'
3772 },
3773 ref: blockSelectionClearerRef
3774 }, isTemplateMode && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3775 className: "edit-post-visual-editor__exit-template-mode",
3776 icon: arrow_left,
3777 onClick: () => {
3778 clearSelectedBlock();
3779 setIsEditingTemplate(false);
3780 }
3781 }, (0,external_wp_i18n_namespaceObject.__)('Back')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
3782 animate: animatedStyles,
3783 initial: desktopCanvasStyles,
3784 className: previewMode
3785 }, (0,external_wp_element_namespaceObject.createElement)(MaybeIframe, {
3786 shouldIframe: isTemplateMode || deviceType === 'Tablet' || deviceType === 'Mobile',
3787 contentRef: contentRef,
3788 styles: styles,
3789 assets: assets,
3790 style: {
3791 paddingBottom
3792 }
3793 }, themeSupportsLayout && !isTemplateMode && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLayoutStyle, {
3794 selector: ".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container",
3795 layout: defaultLayout
3796 }), !isTemplateMode && (0,external_wp_element_namespaceObject.createElement)("div", {
3797 className: "edit-post-visual-editor__post-title-wrapper"
3798 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTitle, null)), (0,external_wp_element_namespaceObject.createElement)(RecursionProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, {
3799 className: isTemplateMode ? 'wp-site-blocks' : undefined,
3800 __experimentalLayout: layout
3801 }))))), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, null, _ref3 => {
3802 let {
3803 onClose
3804 } = _ref3;
3805 return (0,external_wp_element_namespaceObject.createElement)(block_inspector_button, {
3806 onClick: onClose
3807 });
3808 }));
3809 }
3810
3811 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/keyboard-shortcuts/index.js
3812 /**
3813 * WordPress dependencies
3814 */
3815
3816
3817
3818
3819
3820
3821 /**
3822 * Internal dependencies
3823 */
3824
3825
3826
3827 function KeyboardShortcuts() {
3828 const {
3829 getBlockSelectionStart
3830 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
3831 const {
3832 getEditorMode,
3833 isEditorSidebarOpened,
3834 isListViewOpened
3835 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
3836 const isModeToggleDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
3837 const {
3838 richEditingEnabled,
3839 codeEditingEnabled
3840 } = select(external_wp_editor_namespaceObject.store).getEditorSettings();
3841 return !richEditingEnabled || !codeEditingEnabled;
3842 }, []);
3843 const {
3844 switchEditorMode,
3845 openGeneralSidebar,
3846 closeGeneralSidebar,
3847 toggleFeature,
3848 setIsListViewOpened
3849 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3850 const {
3851 registerShortcut
3852 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
3853 (0,external_wp_element_namespaceObject.useEffect)(() => {
3854 registerShortcut({
3855 name: 'core/edit-post/toggle-mode',
3856 category: 'global',
3857 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
3858 keyCombination: {
3859 modifier: 'secondary',
3860 character: 'm'
3861 }
3862 });
3863 registerShortcut({
3864 name: 'core/edit-post/toggle-fullscreen',
3865 category: 'global',
3866 description: (0,external_wp_i18n_namespaceObject.__)('Toggle fullscreen mode.'),
3867 keyCombination: {
3868 modifier: 'secondary',
3869 character: 'f'
3870 }
3871 });
3872 registerShortcut({
3873 name: 'core/edit-post/toggle-list-view',
3874 category: 'global',
3875 description: (0,external_wp_i18n_namespaceObject.__)('Open the block list view.'),
3876 keyCombination: {
3877 modifier: 'access',
3878 character: 'o'
3879 }
3880 });
3881 registerShortcut({
3882 name: 'core/edit-post/toggle-sidebar',
3883 category: 'global',
3884 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the settings sidebar.'),
3885 keyCombination: {
3886 modifier: 'primaryShift',
3887 character: ','
3888 }
3889 });
3890 registerShortcut({
3891 name: 'core/edit-post/next-region',
3892 category: 'global',
3893 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
3894 keyCombination: {
3895 modifier: 'ctrl',
3896 character: '`'
3897 },
3898 aliases: [{
3899 modifier: 'access',
3900 character: 'n'
3901 }]
3902 });
3903 registerShortcut({
3904 name: 'core/edit-post/previous-region',
3905 category: 'global',
3906 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
3907 keyCombination: {
3908 modifier: 'ctrlShift',
3909 character: '`'
3910 },
3911 aliases: [{
3912 modifier: 'access',
3913 character: 'p'
3914 }]
3915 });
3916 registerShortcut({
3917 name: 'core/edit-post/keyboard-shortcuts',
3918 category: 'main',
3919 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
3920 keyCombination: {
3921 modifier: 'access',
3922 character: 'h'
3923 }
3924 });
3925 }, []);
3926 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-post/toggle-mode', () => {
3927 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
3928 }, {
3929 isDisabled: isModeToggleDisabled
3930 });
3931 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-post/toggle-fullscreen', () => {
3932 toggleFeature('fullscreenMode');
3933 });
3934 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-post/toggle-sidebar', event => {
3935 // This shortcut has no known clashes, but use preventDefault to prevent any
3936 // obscure shortcuts from triggering.
3937 event.preventDefault();
3938
3939 if (isEditorSidebarOpened()) {
3940 closeGeneralSidebar();
3941 } else {
3942 const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
3943 openGeneralSidebar(sidebarToOpen);
3944 }
3945 });
3946 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-post/toggle-list-view', () => setIsListViewOpened(!isListViewOpened()));
3947 return null;
3948 }
3949
3950 /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
3951
3952 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/keyboard-shortcut-help-modal/config.js
3953 /**
3954 * WordPress dependencies
3955 */
3956
3957 const textFormattingShortcuts = [{
3958 keyCombination: {
3959 modifier: 'primary',
3960 character: 'b'
3961 },
3962 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
3963 }, {
3964 keyCombination: {
3965 modifier: 'primary',
3966 character: 'i'
3967 },
3968 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
3969 }, {
3970 keyCombination: {
3971 modifier: 'primary',
3972 character: 'k'
3973 },
3974 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
3975 }, {
3976 keyCombination: {
3977 modifier: 'primaryShift',
3978 character: 'k'
3979 },
3980 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
3981 }, {
3982 keyCombination: {
3983 modifier: 'primary',
3984 character: 'u'
3985 },
3986 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
3987 }];
3988
3989 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/keyboard-shortcut-help-modal/shortcut.js
3990
3991
3992 /**
3993 * External dependencies
3994 */
3995
3996 /**
3997 * WordPress dependencies
3998 */
3999
4000
4001
4002
4003 function KeyCombination(_ref) {
4004 let {
4005 keyCombination,
4006 forceAriaLabel
4007 } = _ref;
4008 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4009 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4010 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4011 className: "edit-post-keyboard-shortcut-help-modal__shortcut-key-combination",
4012 "aria-label": forceAriaLabel || ariaLabel
4013 }, (0,external_lodash_namespaceObject.castArray)(shortcut).map((character, index) => {
4014 if (character === '+') {
4015 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
4016 key: index
4017 }, character);
4018 }
4019
4020 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4021 key: index,
4022 className: "edit-post-keyboard-shortcut-help-modal__shortcut-key"
4023 }, character);
4024 }));
4025 }
4026
4027 function Shortcut(_ref2) {
4028 let {
4029 description,
4030 keyCombination,
4031 aliases = [],
4032 ariaLabel
4033 } = _ref2;
4034 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
4035 className: "edit-post-keyboard-shortcut-help-modal__shortcut-description"
4036 }, description), (0,external_wp_element_namespaceObject.createElement)("div", {
4037 className: "edit-post-keyboard-shortcut-help-modal__shortcut-term"
4038 }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4039 keyCombination: keyCombination,
4040 forceAriaLabel: ariaLabel
4041 }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4042 keyCombination: alias,
4043 forceAriaLabel: ariaLabel,
4044 key: index
4045 }))));
4046 }
4047
4048 /* harmony default export */ var keyboard_shortcut_help_modal_shortcut = (Shortcut);
4049
4050 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
4051
4052
4053 /**
4054 * WordPress dependencies
4055 */
4056
4057
4058 /**
4059 * Internal dependencies
4060 */
4061
4062
4063
4064 function DynamicShortcut(_ref) {
4065 let {
4066 name
4067 } = _ref;
4068 const {
4069 keyCombination,
4070 description,
4071 aliases
4072 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4073 const {
4074 getShortcutKeyCombination,
4075 getShortcutDescription,
4076 getShortcutAliases
4077 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
4078 return {
4079 keyCombination: getShortcutKeyCombination(name),
4080 aliases: getShortcutAliases(name),
4081 description: getShortcutDescription(name)
4082 };
4083 }, [name]);
4084
4085 if (!keyCombination) {
4086 return null;
4087 }
4088
4089 return (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, {
4090 keyCombination: keyCombination,
4091 description: description,
4092 aliases: aliases
4093 });
4094 }
4095
4096 /* harmony default export */ var dynamic_shortcut = (DynamicShortcut);
4097
4098 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/keyboard-shortcut-help-modal/index.js
4099
4100
4101 /**
4102 * External dependencies
4103 */
4104
4105
4106 /**
4107 * WordPress dependencies
4108 */
4109
4110
4111
4112
4113
4114
4115 /**
4116 * Internal dependencies
4117 */
4118
4119
4120
4121
4122
4123 const MODAL_NAME = 'edit-post/keyboard-shortcut-help';
4124
4125 const ShortcutList = _ref => {
4126 let {
4127 shortcuts
4128 } = _ref;
4129 return (
4130 /*
4131 * Disable reason: The `list` ARIA role is redundant but
4132 * Safari+VoiceOver won't announce the list otherwise.
4133 */
4134
4135 /* eslint-disable jsx-a11y/no-redundant-roles */
4136 (0,external_wp_element_namespaceObject.createElement)("ul", {
4137 className: "edit-post-keyboard-shortcut-help-modal__shortcut-list",
4138 role: "list"
4139 }, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", {
4140 className: "edit-post-keyboard-shortcut-help-modal__shortcut",
4141 key: index
4142 }, (0,external_lodash_namespaceObject.isString)(shortcut) ? (0,external_wp_element_namespaceObject.createElement)(dynamic_shortcut, {
4143 name: shortcut
4144 }) : (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, shortcut))))
4145 /* eslint-enable jsx-a11y/no-redundant-roles */
4146
4147 );
4148 };
4149
4150 const ShortcutSection = _ref2 => {
4151 let {
4152 title,
4153 shortcuts,
4154 className
4155 } = _ref2;
4156 return (0,external_wp_element_namespaceObject.createElement)("section", {
4157 className: classnames_default()('edit-post-keyboard-shortcut-help-modal__section', className)
4158 }, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", {
4159 className: "edit-post-keyboard-shortcut-help-modal__section-title"
4160 }, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, {
4161 shortcuts: shortcuts
4162 }));
4163 };
4164
4165 const ShortcutCategorySection = _ref3 => {
4166 let {
4167 title,
4168 categoryName,
4169 additionalShortcuts = []
4170 } = _ref3;
4171 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
4172 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
4173 }, [categoryName]);
4174 return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4175 title: title,
4176 shortcuts: categoryShortcuts.concat(additionalShortcuts)
4177 });
4178 };
4179
4180 function KeyboardShortcutHelpModal(_ref4) {
4181 let {
4182 isModalActive,
4183 toggleModal
4184 } = _ref4;
4185 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-post/keyboard-shortcuts', toggleModal);
4186
4187 if (!isModalActive) {
4188 return null;
4189 }
4190
4191 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
4192 className: "edit-post-keyboard-shortcut-help-modal",
4193 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
4194 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
4195 onRequestClose: toggleModal
4196 }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4197 className: "edit-post-keyboard-shortcut-help-modal__main-shortcuts",
4198 shortcuts: ['core/edit-post/keyboard-shortcuts']
4199 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4200 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
4201 categoryName: "global"
4202 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4203 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
4204 categoryName: "selection"
4205 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4206 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
4207 categoryName: "block",
4208 additionalShortcuts: [{
4209 keyCombination: {
4210 character: '/'
4211 },
4212 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
4213
4214 /* translators: The forward-slash character. e.g. '/'. */
4215 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
4216 }]
4217 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4218 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
4219 shortcuts: textFormattingShortcuts
4220 }));
4221 }
4222 /* harmony default export */ var keyboard_shortcut_help_modal = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => ({
4223 isModalActive: select(store_store).isModalActive(MODAL_NAME)
4224 })), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref5) => {
4225 let {
4226 isModalActive
4227 } = _ref5;
4228 const {
4229 openModal,
4230 closeModal
4231 } = dispatch(store_store);
4232 return {
4233 toggleModal: () => isModalActive ? closeModal() : openModal(MODAL_NAME)
4234 };
4235 })])(KeyboardShortcutHelpModal));
4236
4237 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
4238 /**
4239 * WordPress dependencies
4240 */
4241
4242 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
4243
4244 /**
4245 * Return an SVG icon.
4246 *
4247 * @param {IconProps} props icon is the SVG component to render
4248 * size is a number specifiying the icon size in pixels
4249 * Other props will be passed to wrapped SVG component
4250 *
4251 * @return {JSX.Element} Icon component
4252 */
4253
4254 function Icon(_ref) {
4255 let {
4256 icon,
4257 size = 24,
4258 ...props
4259 } = _ref;
4260 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
4261 width: size,
4262 height: size,
4263 ...props
4264 });
4265 }
4266
4267 /* harmony default export */ var icon = (Icon);
4268
4269 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js
4270
4271
4272 /**
4273 * WordPress dependencies
4274 */
4275
4276 const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4277 xmlns: "http://www.w3.org/2000/svg",
4278 viewBox: "0 0 24 24"
4279 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4280 d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
4281 }));
4282 /* harmony default export */ var chevron_left = (chevronLeft);
4283
4284 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js
4285
4286
4287 /**
4288 * WordPress dependencies
4289 */
4290
4291 const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4292 xmlns: "http://www.w3.org/2000/svg",
4293 viewBox: "0 0 24 24"
4294 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4295 d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
4296 }));
4297 /* harmony default export */ var chevron_right = (chevronRight);
4298
4299 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/section.js
4300
4301
4302 const Section = _ref => {
4303 let {
4304 description,
4305 title,
4306 children
4307 } = _ref;
4308 return (0,external_wp_element_namespaceObject.createElement)("section", {
4309 className: "edit-post-preferences-modal__section"
4310 }, (0,external_wp_element_namespaceObject.createElement)("h2", {
4311 className: "edit-post-preferences-modal__section-title"
4312 }, title), description && (0,external_wp_element_namespaceObject.createElement)("p", {
4313 className: "edit-post-preferences-modal__section-description"
4314 }, description), children);
4315 };
4316
4317 /* harmony default export */ var section = (Section);
4318
4319 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/base.js
4320
4321
4322 /**
4323 * WordPress dependencies
4324 */
4325
4326
4327 function BaseOption(_ref) {
4328 let {
4329 help,
4330 label,
4331 isChecked,
4332 onChange,
4333 children
4334 } = _ref;
4335 return (0,external_wp_element_namespaceObject.createElement)("div", {
4336 className: "edit-post-preferences-modal__option"
4337 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
4338 help: help,
4339 label: label,
4340 checked: isChecked,
4341 onChange: onChange
4342 }), children);
4343 }
4344
4345 /* harmony default export */ var base = (BaseOption);
4346
4347 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/enable-custom-fields.js
4348
4349
4350 /**
4351 * WordPress dependencies
4352 */
4353
4354
4355
4356
4357
4358 /**
4359 * Internal dependencies
4360 */
4361
4362
4363 function CustomFieldsConfirmation(_ref) {
4364 let {
4365 willEnable
4366 } = _ref;
4367 const [isReloading, setIsReloading] = (0,external_wp_element_namespaceObject.useState)(false);
4368 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", {
4369 className: "edit-post-preferences-modal__custom-fields-confirmation-message"
4370 }, (0,external_wp_i18n_namespaceObject.__)('A page reload is required for this change. Make sure your content is saved before reloading.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4371 className: "edit-post-preferences-modal__custom-fields-confirmation-button",
4372 variant: "secondary",
4373 isBusy: isReloading,
4374 disabled: isReloading,
4375 onClick: () => {
4376 setIsReloading(true);
4377 document.getElementById('toggle-custom-fields-form').submit();
4378 }
4379 }, willEnable ? (0,external_wp_i18n_namespaceObject.__)('Enable & Reload') : (0,external_wp_i18n_namespaceObject.__)('Disable & Reload')));
4380 }
4381 function EnableCustomFieldsOption(_ref2) {
4382 let {
4383 label,
4384 areCustomFieldsEnabled
4385 } = _ref2;
4386 const [isChecked, setIsChecked] = (0,external_wp_element_namespaceObject.useState)(areCustomFieldsEnabled);
4387 return (0,external_wp_element_namespaceObject.createElement)(base, {
4388 label: label,
4389 isChecked: isChecked,
4390 onChange: setIsChecked
4391 }, isChecked !== areCustomFieldsEnabled && (0,external_wp_element_namespaceObject.createElement)(CustomFieldsConfirmation, {
4392 willEnable: isChecked
4393 }));
4394 }
4395 /* harmony default export */ var enable_custom_fields = ((0,external_wp_data_namespaceObject.withSelect)(select => ({
4396 areCustomFieldsEnabled: !!select(external_wp_editor_namespaceObject.store).getEditorSettings().enableCustomFields
4397 }))(EnableCustomFieldsOption));
4398
4399 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/enable-panel.js
4400 /**
4401 * WordPress dependencies
4402 */
4403
4404
4405 /**
4406 * Internal dependencies
4407 */
4408
4409
4410
4411 /* harmony default export */ var enable_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
4412 let {
4413 panelName
4414 } = _ref;
4415 const {
4416 isEditorPanelEnabled,
4417 isEditorPanelRemoved
4418 } = select(store_store);
4419 return {
4420 isRemoved: isEditorPanelRemoved(panelName),
4421 isChecked: isEditorPanelEnabled(panelName)
4422 };
4423 }), (0,external_wp_compose_namespaceObject.ifCondition)(_ref2 => {
4424 let {
4425 isRemoved
4426 } = _ref2;
4427 return !isRemoved;
4428 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref3) => {
4429 let {
4430 panelName
4431 } = _ref3;
4432 return {
4433 onChange: () => dispatch(store_store).toggleEditorPanelEnabled(panelName)
4434 };
4435 }))(base));
4436
4437 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/enable-plugin-document-setting-panel.js
4438
4439
4440 /**
4441 * WordPress dependencies
4442 */
4443
4444 /**
4445 * Internal dependencies
4446 */
4447
4448
4449 const {
4450 Fill,
4451 Slot: enable_plugin_document_setting_panel_Slot
4452 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption');
4453
4454 const EnablePluginDocumentSettingPanelOption = _ref => {
4455 let {
4456 label,
4457 panelName
4458 } = _ref;
4459 return (0,external_wp_element_namespaceObject.createElement)(Fill, null, (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4460 label: label,
4461 panelName: panelName
4462 }));
4463 };
4464
4465 EnablePluginDocumentSettingPanelOption.Slot = enable_plugin_document_setting_panel_Slot;
4466 /* harmony default export */ var enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption);
4467
4468 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/enable-publish-sidebar.js
4469 /**
4470 * WordPress dependencies
4471 */
4472
4473
4474
4475
4476 /**
4477 * Internal dependencies
4478 */
4479
4480
4481 /* harmony default export */ var enable_publish_sidebar = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
4482 isChecked: select(external_wp_editor_namespaceObject.store).isPublishSidebarEnabled()
4483 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
4484 const {
4485 enablePublishSidebar,
4486 disablePublishSidebar
4487 } = dispatch(external_wp_editor_namespaceObject.store);
4488 return {
4489 onChange: isEnabled => isEnabled ? enablePublishSidebar() : disablePublishSidebar()
4490 };
4491 }), // In < medium viewports we override this option and always show the publish sidebar.
4492 // See the edit-post's header component for the specific logic.
4493 (0,external_wp_viewport_namespaceObject.ifViewportMatches)('medium'))(base));
4494
4495 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/enable-feature.js
4496 /**
4497 * WordPress dependencies
4498 */
4499
4500
4501 /**
4502 * Internal dependencies
4503 */
4504
4505
4506
4507 /* harmony default export */ var enable_feature = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
4508 let {
4509 featureName
4510 } = _ref;
4511 const {
4512 isFeatureActive
4513 } = select(store_store);
4514 return {
4515 isChecked: isFeatureActive(featureName)
4516 };
4517 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref2) => {
4518 let {
4519 featureName
4520 } = _ref2;
4521 return {
4522 onChange: () => dispatch(store_store).toggleFeature(featureName)
4523 };
4524 }))(base));
4525
4526 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/options/index.js
4527
4528
4529
4530
4531
4532
4533 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/meta-boxes-section.js
4534
4535
4536 /**
4537 * External dependencies
4538 */
4539
4540 /**
4541 * WordPress dependencies
4542 */
4543
4544
4545
4546
4547 /**
4548 * Internal dependencies
4549 */
4550
4551
4552
4553
4554 function MetaBoxesSection(_ref) {
4555 let {
4556 areCustomFieldsRegistered,
4557 metaBoxes,
4558 ...sectionProps
4559 } = _ref;
4560 // The 'Custom Fields' meta box is a special case that we handle separately.
4561 const thirdPartyMetaBoxes = (0,external_lodash_namespaceObject.filter)(metaBoxes, _ref2 => {
4562 let {
4563 id
4564 } = _ref2;
4565 return id !== 'postcustom';
4566 });
4567
4568 if (!areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0) {
4569 return null;
4570 }
4571
4572 return (0,external_wp_element_namespaceObject.createElement)(section, sectionProps, areCustomFieldsRegistered && (0,external_wp_element_namespaceObject.createElement)(enable_custom_fields, {
4573 label: (0,external_wp_i18n_namespaceObject.__)('Custom fields')
4574 }), (0,external_lodash_namespaceObject.map)(thirdPartyMetaBoxes, _ref3 => {
4575 let {
4576 id,
4577 title
4578 } = _ref3;
4579 return (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4580 key: id,
4581 label: title,
4582 panelName: `meta-box-${id}`
4583 });
4584 }));
4585 }
4586 /* harmony default export */ var meta_boxes_section = ((0,external_wp_data_namespaceObject.withSelect)(select => {
4587 const {
4588 getEditorSettings
4589 } = select(external_wp_editor_namespaceObject.store);
4590 const {
4591 getAllMetaBoxes
4592 } = select(store_store);
4593 return {
4594 // This setting should not live in the block editor's store.
4595 areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== undefined,
4596 metaBoxes: getAllMetaBoxes()
4597 };
4598 })(MetaBoxesSection));
4599
4600 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/block-manager/checklist.js
4601
4602
4603 /**
4604 * External dependencies
4605 */
4606
4607 /**
4608 * WordPress dependencies
4609 */
4610
4611
4612
4613
4614 function BlockTypesChecklist(_ref) {
4615 let {
4616 blockTypes,
4617 value,
4618 onItemChange
4619 } = _ref;
4620 return (0,external_wp_element_namespaceObject.createElement)("ul", {
4621 className: "edit-post-block-manager__checklist"
4622 }, blockTypes.map(blockType => (0,external_wp_element_namespaceObject.createElement)("li", {
4623 key: blockType.name,
4624 className: "edit-post-block-manager__checklist-item"
4625 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
4626 label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, blockType.title, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
4627 icon: blockType.icon
4628 })),
4629 checked: value.includes(blockType.name),
4630 onChange: (0,external_lodash_namespaceObject.partial)(onItemChange, blockType.name)
4631 }))));
4632 }
4633
4634 /* harmony default export */ var checklist = (BlockTypesChecklist);
4635
4636 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/block-manager/category.js
4637
4638
4639 /**
4640 * External dependencies
4641 */
4642
4643 /**
4644 * WordPress dependencies
4645 */
4646
4647
4648
4649
4650
4651
4652 /**
4653 * Internal dependencies
4654 */
4655
4656
4657
4658
4659 function BlockManagerCategory(_ref) {
4660 let {
4661 title,
4662 blockTypes
4663 } = _ref;
4664 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockManagerCategory);
4665 const {
4666 defaultAllowedBlockTypes,
4667 hiddenBlockTypes
4668 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4669 const {
4670 getEditorSettings
4671 } = select(external_wp_editor_namespaceObject.store);
4672 const {
4673 getPreference
4674 } = select(store_store);
4675 return {
4676 defaultAllowedBlockTypes: getEditorSettings().defaultAllowedBlockTypes,
4677 hiddenBlockTypes: getPreference('hiddenBlockTypes')
4678 };
4679 }, []);
4680 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
4681 if (defaultAllowedBlockTypes === true) {
4682 return blockTypes;
4683 }
4684
4685 return blockTypes.filter(_ref2 => {
4686 let {
4687 name
4688 } = _ref2;
4689 return (0,external_lodash_namespaceObject.includes)(defaultAllowedBlockTypes || [], name);
4690 });
4691 }, [defaultAllowedBlockTypes, blockTypes]);
4692 const {
4693 showBlockTypes,
4694 hideBlockTypes
4695 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4696 const toggleVisible = (0,external_wp_element_namespaceObject.useCallback)((blockName, nextIsChecked) => {
4697 if (nextIsChecked) {
4698 showBlockTypes(blockName);
4699 } else {
4700 hideBlockTypes(blockName);
4701 }
4702 }, []);
4703 const toggleAllVisible = (0,external_wp_element_namespaceObject.useCallback)(nextIsChecked => {
4704 const blockNames = (0,external_lodash_namespaceObject.map)(blockTypes, 'name');
4705
4706 if (nextIsChecked) {
4707 showBlockTypes(blockNames);
4708 } else {
4709 hideBlockTypes(blockNames);
4710 }
4711 }, [blockTypes]);
4712
4713 if (!filteredBlockTypes.length) {
4714 return null;
4715 }
4716
4717 const checkedBlockNames = (0,external_lodash_namespaceObject.without)((0,external_lodash_namespaceObject.map)(filteredBlockTypes, 'name'), ...hiddenBlockTypes);
4718 const titleId = 'edit-post-block-manager__category-title-' + instanceId;
4719 const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
4720 let ariaChecked;
4721
4722 if (isAllChecked) {
4723 ariaChecked = 'true';
4724 } else if (checkedBlockNames.length > 0) {
4725 ariaChecked = 'mixed';
4726 } else {
4727 ariaChecked = 'false';
4728 }
4729
4730 return (0,external_wp_element_namespaceObject.createElement)("div", {
4731 role: "group",
4732 "aria-labelledby": titleId,
4733 className: "edit-post-block-manager__category"
4734 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
4735 checked: isAllChecked,
4736 onChange: toggleAllVisible,
4737 className: "edit-post-block-manager__category-title",
4738 "aria-checked": ariaChecked,
4739 label: (0,external_wp_element_namespaceObject.createElement)("span", {
4740 id: titleId
4741 }, title)
4742 }), (0,external_wp_element_namespaceObject.createElement)(checklist, {
4743 blockTypes: filteredBlockTypes,
4744 value: checkedBlockNames,
4745 onItemChange: toggleVisible
4746 }));
4747 }
4748
4749 /* harmony default export */ var block_manager_category = (BlockManagerCategory);
4750
4751 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/block-manager/index.js
4752
4753
4754 /**
4755 * External dependencies
4756 */
4757
4758 /**
4759 * WordPress dependencies
4760 */
4761
4762
4763
4764
4765
4766
4767
4768
4769 /**
4770 * Internal dependencies
4771 */
4772
4773
4774
4775
4776 function BlockManager(_ref) {
4777 let {
4778 blockTypes,
4779 categories,
4780 hasBlockSupport,
4781 isMatchingSearchTerm,
4782 numberOfHiddenBlocks
4783 } = _ref;
4784 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
4785 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)(''); // Filtering occurs here (as opposed to `withSelect`) to avoid
4786 // wasted renders by consequence of `Array#filter` producing
4787 // a new value reference on each call.
4788
4789 blockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || (0,external_lodash_namespaceObject.includes)(blockType.parent, 'core/post-content'))); // Announce search results on change
4790
4791 (0,external_wp_element_namespaceObject.useEffect)(() => {
4792 if (!search) {
4793 return;
4794 }
4795
4796 const count = blockTypes.length;
4797 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
4798 /* translators: %d: number of results. */
4799 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
4800 debouncedSpeak(resultsFoundMessage);
4801 }, [blockTypes.length, search, debouncedSpeak]);
4802 return (0,external_wp_element_namespaceObject.createElement)("div", {
4803 className: "edit-post-block-manager__content"
4804 }, !!numberOfHiddenBlocks && (0,external_wp_element_namespaceObject.createElement)("div", {
4805 className: "edit-post-block-manager__disabled-blocks-count"
4806 }, (0,external_wp_i18n_namespaceObject.sprintf)(
4807 /* translators: %d: number of blocks. */
4808 (0,external_wp_i18n_namespaceObject._n)('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
4809 label: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
4810 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
4811 value: search,
4812 onChange: nextSearch => setSearch(nextSearch),
4813 className: "edit-post-block-manager__search"
4814 }), (0,external_wp_element_namespaceObject.createElement)("div", {
4815 tabIndex: "0",
4816 role: "region",
4817 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Available block types'),
4818 className: "edit-post-block-manager__results"
4819 }, blockTypes.length === 0 && (0,external_wp_element_namespaceObject.createElement)("p", {
4820 className: "edit-post-block-manager__no-results"
4821 }, (0,external_wp_i18n_namespaceObject.__)('No blocks found.')), categories.map(category => (0,external_wp_element_namespaceObject.createElement)(block_manager_category, {
4822 key: category.slug,
4823 title: category.title,
4824 blockTypes: (0,external_lodash_namespaceObject.filter)(blockTypes, {
4825 category: category.slug
4826 })
4827 })), (0,external_wp_element_namespaceObject.createElement)(block_manager_category, {
4828 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized'),
4829 blockTypes: (0,external_lodash_namespaceObject.filter)(blockTypes, _ref2 => {
4830 let {
4831 category
4832 } = _ref2;
4833 return !category;
4834 })
4835 })));
4836 }
4837
4838 /* harmony default export */ var block_manager = ((0,external_wp_data_namespaceObject.withSelect)(select => {
4839 const {
4840 getBlockTypes,
4841 getCategories,
4842 hasBlockSupport,
4843 isMatchingSearchTerm
4844 } = select(external_wp_blocks_namespaceObject.store);
4845 const {
4846 getPreference
4847 } = select(store_store);
4848 const hiddenBlockTypes = getPreference('hiddenBlockTypes');
4849 const numberOfHiddenBlocks = (0,external_lodash_namespaceObject.isArray)(hiddenBlockTypes) && hiddenBlockTypes.length;
4850 return {
4851 blockTypes: getBlockTypes(),
4852 categories: getCategories(),
4853 hasBlockSupport,
4854 isMatchingSearchTerm,
4855 numberOfHiddenBlocks
4856 };
4857 })(BlockManager));
4858
4859 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/preferences-modal/index.js
4860
4861
4862 /**
4863 * External dependencies
4864 */
4865
4866 /**
4867 * WordPress dependencies
4868 */
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878 /**
4879 * Internal dependencies
4880 */
4881
4882
4883
4884
4885
4886
4887 const preferences_modal_MODAL_NAME = 'edit-post/preferences';
4888 const PREFERENCES_MENU = 'preferences-menu';
4889 function PreferencesModal() {
4890 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
4891 const {
4892 closeModal
4893 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4894 const {
4895 isModalActive,
4896 isViewable
4897 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4898 const {
4899 getEditedPostAttribute
4900 } = select(external_wp_editor_namespaceObject.store);
4901 const {
4902 getPostType
4903 } = select(external_wp_coreData_namespaceObject.store);
4904 const postType = getPostType(getEditedPostAttribute('type'));
4905 return {
4906 isModalActive: select(store_store).isModalActive(preferences_modal_MODAL_NAME),
4907 isViewable: (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false)
4908 };
4909 }, []);
4910 const showBlockBreadcrumbsOption = (0,external_wp_data_namespaceObject.useSelect)(select => {
4911 const {
4912 getEditorSettings
4913 } = select(external_wp_editor_namespaceObject.store);
4914 const {
4915 getEditorMode,
4916 isFeatureActive
4917 } = select(store_store);
4918 const mode = getEditorMode();
4919 const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
4920 const hasReducedUI = isFeatureActive('reducedUI');
4921 return !hasReducedUI && isLargeViewport && isRichEditingEnabled && mode === 'visual';
4922 }, [isLargeViewport]);
4923 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
4924 name: 'general',
4925 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
4926 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(section, {
4927 title: (0,external_wp_i18n_namespaceObject.__)('Publishing'),
4928 description: (0,external_wp_i18n_namespaceObject.__)('Change options related to publishing.')
4929 }, (0,external_wp_element_namespaceObject.createElement)(enable_publish_sidebar, {
4930 help: (0,external_wp_i18n_namespaceObject.__)('Review settings, such as visibility and tags.'),
4931 label: (0,external_wp_i18n_namespaceObject.__)('Include pre-publish checklist')
4932 })), (0,external_wp_element_namespaceObject.createElement)(section, {
4933 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
4934 description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the block editor interface and editing flow.')
4935 }, (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4936 featureName: "reducedUI",
4937 help: (0,external_wp_i18n_namespaceObject.__)('Compacts options and outlines in the toolbar.'),
4938 label: (0,external_wp_i18n_namespaceObject.__)('Reduce the interface')
4939 }), (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4940 featureName: "focusMode",
4941 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
4942 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
4943 }), (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4944 featureName: "showIconLabels",
4945 help: (0,external_wp_i18n_namespaceObject.__)('Shows text instead of icons.'),
4946 label: (0,external_wp_i18n_namespaceObject.__)('Display button labels')
4947 }), (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4948 featureName: "themeStyles",
4949 help: (0,external_wp_i18n_namespaceObject.__)('Make the editor look like your theme.'),
4950 label: (0,external_wp_i18n_namespaceObject.__)('Use theme styles')
4951 }), showBlockBreadcrumbsOption && (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4952 featureName: "showBlockBreadcrumbs",
4953 help: (0,external_wp_i18n_namespaceObject.__)('Shows block breadcrumbs at the bottom of the editor.'),
4954 label: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs')
4955 })))
4956 }, {
4957 name: 'blocks',
4958 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
4959 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(section, {
4960 title: (0,external_wp_i18n_namespaceObject.__)('Block interactions'),
4961 description: (0,external_wp_i18n_namespaceObject.__)('Customize how you interact with blocks in the block library and editing canvas.')
4962 }, (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4963 featureName: "mostUsedBlocks",
4964 help: (0,external_wp_i18n_namespaceObject.__)('Places the most frequent blocks in the block library.'),
4965 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks')
4966 }), (0,external_wp_element_namespaceObject.createElement)(enable_feature, {
4967 featureName: "keepCaretInsideBlock",
4968 help: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'),
4969 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
4970 })), (0,external_wp_element_namespaceObject.createElement)(section, {
4971 title: (0,external_wp_i18n_namespaceObject.__)('Visible blocks'),
4972 description: (0,external_wp_i18n_namespaceObject.__)("Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later.")
4973 }, (0,external_wp_element_namespaceObject.createElement)(block_manager, null)))
4974 }, {
4975 name: 'panels',
4976 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Panels'),
4977 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(section, {
4978 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'),
4979 description: (0,external_wp_i18n_namespaceObject.__)('Choose what displays in the panel.')
4980 }, (0,external_wp_element_namespaceObject.createElement)(enable_plugin_document_setting_panel.Slot, null), isViewable && (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4981 label: (0,external_wp_i18n_namespaceObject.__)('Permalink'),
4982 panelName: "post-link"
4983 }), isViewable && (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4984 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
4985 panelName: "template"
4986 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTaxonomies, {
4987 taxonomyWrapper: (content, taxonomy) => (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4988 label: (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'menu_name']),
4989 panelName: `taxonomy-panel-${taxonomy.slug}`
4990 })
4991 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostFeaturedImageCheck, null, (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4992 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'),
4993 panelName: "featured-image"
4994 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostExcerptCheck, null, (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
4995 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
4996 panelName: "post-excerpt"
4997 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTypeSupportCheck, {
4998 supportKeys: ['comments', 'trackbacks']
4999 }, (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
5000 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
5001 panelName: "discussion-panel"
5002 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PageAttributesCheck, null, (0,external_wp_element_namespaceObject.createElement)(enable_panel, {
5003 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'),
5004 panelName: "page-attributes"
5005 }))), (0,external_wp_element_namespaceObject.createElement)(meta_boxes_section, {
5006 title: (0,external_wp_i18n_namespaceObject.__)('Additional'),
5007 description: (0,external_wp_i18n_namespaceObject.__)('Add extra areas to the editor.')
5008 }))
5009 }], [isViewable, isLargeViewport, showBlockBreadcrumbsOption]); // This is also used to sync the two different rendered components
5010 // between small and large viewports.
5011
5012 const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU);
5013 /**
5014 * Create helper objects from `sections` for easier data handling.
5015 * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
5016 * is used for easier access to active tab's content.
5017 */
5018
5019 const {
5020 tabs,
5021 sectionsContentMap
5022 } = (0,external_wp_element_namespaceObject.useMemo)(() => sections.reduce((accumulator, _ref) => {
5023 let {
5024 name,
5025 tabLabel: title,
5026 content
5027 } = _ref;
5028 accumulator.tabs.push({
5029 name,
5030 title
5031 });
5032 accumulator.sectionsContentMap[name] = content;
5033 return accumulator;
5034 }, {
5035 tabs: [],
5036 sectionsContentMap: {}
5037 }), [sections]);
5038 const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
5039
5040 if (!isModalActive) {
5041 return null;
5042 }
5043
5044 let modalContent; // We render different components based on the viewport size.
5045
5046 if (isLargeViewport) {
5047 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
5048 className: "edit-post-preferences__tabs",
5049 tabs: tabs,
5050 initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
5051 onSelect: setActiveMenu,
5052 orientation: "vertical"
5053 }, getCurrentTab);
5054 } else {
5055 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
5056 initialPath: "/"
5057 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
5058 path: "/"
5059 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
5060 isBorderless: true,
5061 size: "small"
5062 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, tabs.map(tab => {
5063 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, {
5064 key: tab.name,
5065 path: tab.name,
5066 as: external_wp_components_namespaceObject.__experimentalItem,
5067 isAction: true
5068 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
5069 justify: "space-between"
5070 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, null, tab.title)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(icon, {
5071 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
5072 }))));
5073 }))))), sections.map(section => {
5074 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
5075 key: `${section.name}-menu`,
5076 path: section.name
5077 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
5078 isBorderless: true,
5079 size: "large"
5080 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardHeader, {
5081 isBorderless: false,
5082 justify: "left",
5083 size: "small",
5084 gap: "6"
5085 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
5086 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
5087 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
5088 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5089 size: "16"
5090 }, section.tabLabel)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, section.content)));
5091 }));
5092 }
5093
5094 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
5095 className: "edit-post-preferences-modal",
5096 title: (0,external_wp_i18n_namespaceObject.__)('Preferences'),
5097 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
5098 onRequestClose: closeModal
5099 }, modalContent);
5100 }
5101
5102 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/browser-url/index.js
5103 /**
5104 * WordPress dependencies
5105 */
5106
5107
5108
5109
5110 /**
5111 * Returns the Post's Edit URL.
5112 *
5113 * @param {number} postId Post ID.
5114 *
5115 * @return {string} Post edit URL.
5116 */
5117
5118 function getPostEditURL(postId) {
5119 return (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
5120 post: postId,
5121 action: 'edit'
5122 });
5123 }
5124 /**
5125 * Returns the Post's Trashed URL.
5126 *
5127 * @param {number} postId Post ID.
5128 * @param {string} postType Post Type.
5129 *
5130 * @return {string} Post trashed URL.
5131 */
5132
5133 function getPostTrashedURL(postId, postType) {
5134 return (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
5135 trashed: 1,
5136 post_type: postType,
5137 ids: postId
5138 });
5139 }
5140 class BrowserURL extends external_wp_element_namespaceObject.Component {
5141 constructor() {
5142 super(...arguments);
5143 this.state = {
5144 historyId: null
5145 };
5146 }
5147
5148 componentDidUpdate(prevProps) {
5149 const {
5150 postId,
5151 postStatus,
5152 postType,
5153 isSavingPost
5154 } = this.props;
5155 const {
5156 historyId
5157 } = this.state; // Posts are still dirty while saving so wait for saving to finish
5158 // to avoid the unsaved changes warning when trashing posts.
5159
5160 if (postStatus === 'trash' && !isSavingPost) {
5161 this.setTrashURL(postId, postType);
5162 return;
5163 }
5164
5165 if ((postId !== prevProps.postId || postId !== historyId) && postStatus !== 'auto-draft' && postId) {
5166 this.setBrowserURL(postId);
5167 }
5168 }
5169 /**
5170 * Navigates the browser to the post trashed URL to show a notice about the trashed post.
5171 *
5172 * @param {number} postId Post ID.
5173 * @param {string} postType Post Type.
5174 */
5175
5176
5177 setTrashURL(postId, postType) {
5178 window.location.href = getPostTrashedURL(postId, postType);
5179 }
5180 /**
5181 * Replaces the browser URL with a post editor link for the given post ID.
5182 *
5183 * Note it is important that, since this function may be called when the
5184 * editor first loads, the result generated `getPostEditURL` matches that
5185 * produced by the server. Otherwise, the URL will change unexpectedly.
5186 *
5187 * @param {number} postId Post ID for which to generate post editor URL.
5188 */
5189
5190
5191 setBrowserURL(postId) {
5192 window.history.replaceState({
5193 id: postId
5194 }, 'Post ' + postId, getPostEditURL(postId));
5195 this.setState(() => ({
5196 historyId: postId
5197 }));
5198 }
5199
5200 render() {
5201 return null;
5202 }
5203
5204 }
5205 /* harmony default export */ var browser_url = ((0,external_wp_data_namespaceObject.withSelect)(select => {
5206 const {
5207 getCurrentPost,
5208 isSavingPost
5209 } = select(external_wp_editor_namespaceObject.store);
5210 const post = getCurrentPost();
5211 let {
5212 id,
5213 status,
5214 type
5215 } = post;
5216 const isTemplate = ['wp_template', 'wp_template_part'].includes(type);
5217
5218 if (isTemplate) {
5219 id = post.wp_id;
5220 }
5221
5222 return {
5223 postId: id,
5224 postStatus: status,
5225 postType: type,
5226 isSavingPost: isSavingPost()
5227 };
5228 })(BrowserURL));
5229
5230 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
5231
5232
5233 /**
5234 * WordPress dependencies
5235 */
5236
5237 const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5238 xmlns: "http://www.w3.org/2000/svg",
5239 viewBox: "-2 -2 24 24"
5240 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5241 d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
5242 }));
5243 /* harmony default export */ var library_wordpress = (wordpress);
5244
5245 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/fullscreen-mode-close/index.js
5246
5247
5248 /**
5249 * External dependencies
5250 */
5251
5252
5253 /**
5254 * WordPress dependencies
5255 */
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265 /**
5266 * Internal dependencies
5267 */
5268
5269
5270
5271 function FullscreenModeClose(_ref) {
5272 let {
5273 showTooltip,
5274 icon,
5275 href
5276 } = _ref;
5277 const {
5278 isActive,
5279 isRequestingSiteIcon,
5280 postType,
5281 siteIconUrl
5282 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5283 const {
5284 getCurrentPostType
5285 } = select(external_wp_editor_namespaceObject.store);
5286 const {
5287 isFeatureActive
5288 } = select(store_store);
5289 const {
5290 getEntityRecord,
5291 getPostType,
5292 isResolving
5293 } = select(external_wp_coreData_namespaceObject.store);
5294 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
5295 return {
5296 isActive: isFeatureActive('fullscreenMode'),
5297 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
5298 postType: getPostType(getCurrentPostType()),
5299 siteIconUrl: siteData.site_icon_url
5300 };
5301 }, []);
5302 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
5303
5304 if (!isActive || !postType) {
5305 return null;
5306 }
5307
5308 let buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
5309 size: "36px",
5310 icon: library_wordpress
5311 });
5312 const effect = {
5313 expand: {
5314 scale: 1.25,
5315 transition: {
5316 type: 'tween',
5317 duration: '0.3'
5318 }
5319 }
5320 };
5321
5322 if (siteIconUrl) {
5323 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.img, {
5324 variants: !disableMotion && effect,
5325 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
5326 className: "edit-post-fullscreen-mode-close_site-icon",
5327 src: siteIconUrl
5328 });
5329 }
5330
5331 if (isRequestingSiteIcon) {
5332 buttonIcon = null;
5333 } // Override default icon if custom icon is provided via props.
5334
5335
5336 if (icon) {
5337 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
5338 size: "36px",
5339 icon: icon
5340 });
5341 }
5342
5343 const classes = classnames_default()({
5344 'edit-post-fullscreen-mode-close': true,
5345 'has-icon': siteIconUrl
5346 });
5347 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
5348 whileHover: "expand"
5349 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5350 className: classes,
5351 href: href !== null && href !== void 0 ? href : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
5352 post_type: postType.slug
5353 }),
5354 label: (0,external_lodash_namespaceObject.get)(postType, ['labels', 'view_items'], (0,external_wp_i18n_namespaceObject.__)('Back')),
5355 showTooltip: showTooltip
5356 }, buttonIcon));
5357 }
5358
5359 /* harmony default export */ var fullscreen_mode_close = (FullscreenModeClose);
5360
5361 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
5362
5363
5364 /**
5365 * WordPress dependencies
5366 */
5367
5368 const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5369 viewBox: "0 0 24 24",
5370 xmlns: "http://www.w3.org/2000/svg"
5371 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5372 d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
5373 }));
5374 /* harmony default export */ var list_view = (listView);
5375
5376 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
5377
5378
5379 /**
5380 * WordPress dependencies
5381 */
5382
5383 const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5384 xmlns: "http://www.w3.org/2000/svg",
5385 viewBox: "0 0 24 24"
5386 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5387 d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
5388 }));
5389 /* harmony default export */ var library_plus = (plus);
5390
5391 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/header-toolbar/index.js
5392
5393
5394 /**
5395 * WordPress dependencies
5396 */
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406 /**
5407 * Internal dependencies
5408 */
5409
5410
5411
5412 const preventDefault = event => {
5413 event.preventDefault();
5414 };
5415
5416 function HeaderToolbar() {
5417 const inserterButton = (0,external_wp_element_namespaceObject.useRef)();
5418 const {
5419 setIsInserterOpened,
5420 setIsListViewOpened
5421 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5422 const {
5423 isInserterEnabled,
5424 isInserterOpened,
5425 isTextModeEnabled,
5426 showIconLabels,
5427 isListViewOpen,
5428 listViewShortcut
5429 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5430 const {
5431 hasInserterItems,
5432 getBlockRootClientId,
5433 getBlockSelectionEnd
5434 } = select(external_wp_blockEditor_namespaceObject.store);
5435 const {
5436 getEditorSettings
5437 } = select(external_wp_editor_namespaceObject.store);
5438 const {
5439 getEditorMode,
5440 isFeatureActive,
5441 isListViewOpened
5442 } = select(store_store);
5443 const {
5444 getShortcutRepresentation
5445 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
5446 return {
5447 // This setting (richEditingEnabled) should not live in the block editor's setting.
5448 isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
5449 isInserterOpened: select(store_store).isInserterOpened(),
5450 isTextModeEnabled: getEditorMode() === 'text',
5451 showIconLabels: isFeatureActive('showIconLabels'),
5452 isListViewOpen: isListViewOpened(),
5453 listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
5454 };
5455 }, []);
5456 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
5457 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide');
5458 /* translators: accessibility text for the editor toolbar */
5459
5460 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools');
5461
5462 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
5463 const overflowItems = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5464 as: external_wp_editor_namespaceObject.TableOfContents,
5465 hasOutlineItemsDisabled: isTextModeEnabled,
5466 repositionDropdown: showIconLabels && !isWideViewport,
5467 showTooltip: !showIconLabels,
5468 variant: showIconLabels ? 'tertiary' : undefined
5469 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5470 as: external_wp_components_namespaceObject.Button,
5471 className: "edit-post-header-toolbar__list-view-toggle",
5472 icon: list_view,
5473 disabled: isTextModeEnabled,
5474 isPressed: isListViewOpen
5475 /* translators: button label text should, if possible, be under 16 characters. */
5476 ,
5477 label: (0,external_wp_i18n_namespaceObject.__)('List View'),
5478 onClick: toggleListView,
5479 shortcut: listViewShortcut,
5480 showTooltip: !showIconLabels
5481 }));
5482 const openInserter = (0,external_wp_element_namespaceObject.useCallback)(() => {
5483 if (isInserterOpened) {
5484 // Focusing the inserter button closes the inserter popover
5485 inserterButton.current.focus();
5486 } else {
5487 setIsInserterOpened(true);
5488 }
5489 }, [isInserterOpened, setIsInserterOpened]);
5490 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
5491 className: "edit-post-header-toolbar",
5492 "aria-label": toolbarAriaLabel
5493 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5494 className: "edit-post-header-toolbar__left"
5495 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5496 ref: inserterButton,
5497 as: external_wp_components_namespaceObject.Button,
5498 className: "edit-post-header-toolbar__inserter-toggle",
5499 variant: "primary",
5500 isPressed: isInserterOpened,
5501 onMouseDown: preventDefault,
5502 onClick: openInserter,
5503 disabled: !isInserterEnabled,
5504 icon: library_plus
5505 /* translators: button label text should, if possible, be under 16
5506 characters. */
5507 ,
5508 label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button'),
5509 showTooltip: !showIconLabels
5510 }, showIconLabels && (!isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close'))), (isWideViewport || !showIconLabels) && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5511 as: external_wp_blockEditor_namespaceObject.ToolSelector,
5512 showTooltip: !showIconLabels,
5513 variant: showIconLabels ? 'tertiary' : undefined,
5514 disabled: isTextModeEnabled
5515 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5516 as: external_wp_editor_namespaceObject.EditorHistoryUndo,
5517 showTooltip: !showIconLabels,
5518 variant: showIconLabels ? 'tertiary' : undefined
5519 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5520 as: external_wp_editor_namespaceObject.EditorHistoryRedo,
5521 showTooltip: !showIconLabels,
5522 variant: showIconLabels ? 'tertiary' : undefined
5523 }), overflowItems)));
5524 }
5525
5526 /* harmony default export */ var header_toolbar = (HeaderToolbar);
5527
5528 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/mode-switcher/index.js
5529
5530
5531 /**
5532 * WordPress dependencies
5533 */
5534
5535
5536
5537
5538
5539 /**
5540 * Internal dependencies
5541 */
5542
5543
5544 /**
5545 * Set of available mode options.
5546 *
5547 * @type {Array}
5548 */
5549
5550 const MODES = [{
5551 value: 'visual',
5552 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
5553 }, {
5554 value: 'text',
5555 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
5556 }];
5557
5558 function ModeSwitcher() {
5559 const {
5560 shortcut,
5561 isRichEditingEnabled,
5562 isCodeEditingEnabled,
5563 isEditingTemplate,
5564 mode
5565 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
5566 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-post/toggle-mode'),
5567 isRichEditingEnabled: select(external_wp_editor_namespaceObject.store).getEditorSettings().richEditingEnabled,
5568 isCodeEditingEnabled: select(external_wp_editor_namespaceObject.store).getEditorSettings().codeEditingEnabled,
5569 isEditingTemplate: select(store_store).isEditingTemplate(),
5570 mode: select(store_store).getEditorMode()
5571 }), []);
5572 const {
5573 switchEditorMode
5574 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5575
5576 if (isEditingTemplate) {
5577 return null;
5578 }
5579
5580 if (!isRichEditingEnabled || !isCodeEditingEnabled) {
5581 return null;
5582 }
5583
5584 const choices = MODES.map(choice => {
5585 if (choice.value !== mode) {
5586 return { ...choice,
5587 shortcut
5588 };
5589 }
5590
5591 return choice;
5592 });
5593 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5594 label: (0,external_wp_i18n_namespaceObject.__)('Editor')
5595 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
5596 choices: choices,
5597 value: mode,
5598 onSelect: switchEditorMode
5599 }));
5600 }
5601
5602 /* harmony default export */ var mode_switcher = (ModeSwitcher);
5603
5604 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/preferences-menu-item/index.js
5605
5606
5607 /**
5608 * WordPress dependencies
5609 */
5610
5611
5612
5613 /**
5614 * Internal dependencies
5615 */
5616
5617
5618 function PreferencesMenuItem() {
5619 const {
5620 openModal
5621 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5622 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5623 onClick: () => {
5624 openModal('edit-post/preferences');
5625 }
5626 }, (0,external_wp_i18n_namespaceObject.__)('Preferences'));
5627 }
5628
5629 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/writing-menu/index.js
5630
5631
5632 /**
5633 * WordPress dependencies
5634 */
5635
5636
5637
5638
5639
5640
5641 function WritingMenu() {
5642 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
5643
5644 if (!isLargeViewport) {
5645 return null;
5646 }
5647
5648 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5649 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun')
5650 }, (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, {
5651 scope: "core/edit-post",
5652 feature: "fixedToolbar",
5653 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
5654 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
5655 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
5656 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
5657 }), (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, {
5658 scope: "core/edit-post",
5659 feature: "focusMode",
5660 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
5661 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
5662 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
5663 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
5664 }), (0,external_wp_element_namespaceObject.createElement)(MoreMenuFeatureToggle, {
5665 scope: "core/edit-post",
5666 feature: "fullscreenMode",
5667 label: (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode'),
5668 info: (0,external_wp_i18n_namespaceObject.__)('Work without distraction'),
5669 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode activated'),
5670 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode deactivated'),
5671 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.secondary('f')
5672 }));
5673 }
5674
5675 /* harmony default export */ var writing_menu = (WritingMenu);
5676
5677 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/more-menu/index.js
5678
5679
5680 /**
5681 * WordPress dependencies
5682 */
5683
5684
5685
5686
5687 /**
5688 * Internal dependencies
5689 */
5690
5691
5692
5693
5694
5695 const POPOVER_PROPS = {
5696 className: 'edit-post-more-menu__content'
5697 };
5698
5699 const MoreMenu = _ref => {
5700 let {
5701 showIconLabels
5702 } = _ref;
5703 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
5704 return (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, {
5705 className: "edit-post-more-menu",
5706 popoverProps: POPOVER_PROPS,
5707 toggleProps: {
5708 showTooltip: !showIconLabels,
5709 ...(showIconLabels && {
5710 variant: 'tertiary'
5711 })
5712 }
5713 }, _ref2 => {
5714 let {
5715 onClose
5716 } = _ref2;
5717 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showIconLabels && !isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
5718 className: showIconLabels && 'show-icon-labels',
5719 scope: "core/edit-post"
5720 }), (0,external_wp_element_namespaceObject.createElement)(writing_menu, null), (0,external_wp_element_namespaceObject.createElement)(mode_switcher, null), (0,external_wp_element_namespaceObject.createElement)(action_item.Slot, {
5721 name: "core/edit-post/plugin-more-menu",
5722 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
5723 as: external_wp_components_namespaceObject.MenuGroup,
5724 fillProps: {
5725 onClick: onClose
5726 }
5727 }), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, {
5728 fillProps: {
5729 onClose
5730 }
5731 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(PreferencesMenuItem, null)));
5732 });
5733 };
5734
5735 /* harmony default export */ var more_menu = (MoreMenu);
5736
5737 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/post-publish-button-or-toggle.js
5738
5739
5740 /**
5741 * External dependencies
5742 */
5743
5744 /**
5745 * WordPress dependencies
5746 */
5747
5748
5749
5750
5751 /**
5752 * Internal dependencies
5753 */
5754
5755
5756 function PostPublishButtonOrToggle(_ref) {
5757 let {
5758 forceIsDirty,
5759 forceIsSaving,
5760 hasPublishAction,
5761 isBeingScheduled,
5762 isPending,
5763 isPublished,
5764 isPublishSidebarEnabled,
5765 isPublishSidebarOpened,
5766 isScheduled,
5767 togglePublishSidebar,
5768 setEntitiesSavedStatesCallback
5769 } = _ref;
5770 const IS_TOGGLE = 'toggle';
5771 const IS_BUTTON = 'button';
5772 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
5773 let component;
5774 /**
5775 * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
5776 *
5777 * 1) We want to show a BUTTON when the post status is at the _final stage_
5778 * for a particular role (see https://wordpress.org/support/article/post-status/):
5779 *
5780 * - is published
5781 * - is scheduled to be published
5782 * - is pending and can't be published (but only for viewports >= medium).
5783 * Originally, we considered showing a button for pending posts that couldn't be published
5784 * (for example, for an author with the contributor role). Some languages can have
5785 * long translations for "Submit for review", so given the lack of UI real estate available
5786 * we decided to take into account the viewport in that case.
5787 * See: https://github.com/WordPress/gutenberg/issues/10475
5788 *
5789 * 2) Then, in small viewports, we'll show a TOGGLE.
5790 *
5791 * 3) Finally, we'll use the publish sidebar status to decide:
5792 *
5793 * - if it is enabled, we show a TOGGLE
5794 * - if it is disabled, we show a BUTTON
5795 */
5796
5797 if (isPublished || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
5798 component = IS_BUTTON;
5799 } else if (isSmallerThanMediumViewport) {
5800 component = IS_TOGGLE;
5801 } else if (isPublishSidebarEnabled) {
5802 component = IS_TOGGLE;
5803 } else {
5804 component = IS_BUTTON;
5805 }
5806
5807 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPublishButton, {
5808 forceIsDirty: forceIsDirty,
5809 forceIsSaving: forceIsSaving,
5810 isOpen: isPublishSidebarOpened,
5811 isToggle: component === IS_TOGGLE,
5812 onToggle: togglePublishSidebar,
5813 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
5814 });
5815 }
5816 /* harmony default export */ var post_publish_button_or_toggle = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
5817 hasPublishAction: (0,external_lodash_namespaceObject.get)(select(external_wp_editor_namespaceObject.store).getCurrentPost(), ['_links', 'wp:action-publish'], false),
5818 isBeingScheduled: select(external_wp_editor_namespaceObject.store).isEditedPostBeingScheduled(),
5819 isPending: select(external_wp_editor_namespaceObject.store).isCurrentPostPending(),
5820 isPublished: select(external_wp_editor_namespaceObject.store).isCurrentPostPublished(),
5821 isPublishSidebarEnabled: select(external_wp_editor_namespaceObject.store).isPublishSidebarEnabled(),
5822 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
5823 isScheduled: select(external_wp_editor_namespaceObject.store).isCurrentPostScheduled()
5824 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
5825 const {
5826 togglePublishSidebar
5827 } = dispatch(store_store);
5828 return {
5829 togglePublishSidebar
5830 };
5831 }))(PostPublishButtonOrToggle));
5832
5833 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/device-preview/index.js
5834
5835
5836 /**
5837 * WordPress dependencies
5838 */
5839
5840
5841
5842
5843
5844
5845 /**
5846 * Internal dependencies
5847 */
5848
5849
5850 function DevicePreview() {
5851 const {
5852 hasActiveMetaboxes,
5853 isPostSaveable,
5854 isSaving,
5855 deviceType
5856 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
5857 hasActiveMetaboxes: select(store_store).hasMetaBoxes(),
5858 isSaving: select(store_store).isSavingMetaBoxes(),
5859 isPostSaveable: select(external_wp_editor_namespaceObject.store).isEditedPostSaveable(),
5860 deviceType: select(store_store).__experimentalGetPreviewDeviceType()
5861 }), []);
5862 const {
5863 __experimentalSetPreviewDeviceType: setPreviewDeviceType
5864 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5865 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPreviewOptions, {
5866 isEnabled: isPostSaveable,
5867 className: "edit-post-post-preview-dropdown",
5868 deviceType: deviceType,
5869 setDeviceType: setPreviewDeviceType
5870 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)("div", {
5871 className: "edit-post-header-preview__grouping-external"
5872 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPreviewButton, {
5873 className: 'edit-post-header-preview__button-external',
5874 role: "menuitem",
5875 forceIsAutosaveable: hasActiveMetaboxes,
5876 forcePreviewLink: isSaving ? null : undefined,
5877 textContent: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
5878 icon: library_external
5879 }))
5880 }))));
5881 }
5882
5883 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/main-dashboard-button/index.js
5884
5885
5886 /**
5887 * WordPress dependencies
5888 */
5889
5890 const slotName = '__experimentalMainDashboardButton';
5891 const {
5892 Fill: main_dashboard_button_Fill,
5893 Slot: MainDashboardButtonSlot
5894 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
5895 const MainDashboardButton = main_dashboard_button_Fill;
5896
5897 const main_dashboard_button_Slot = _ref => {
5898 let {
5899 children
5900 } = _ref;
5901 const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(slotName);
5902 const hasFills = Boolean(slot.fills && slot.fills.length);
5903
5904 if (!hasFills) {
5905 return children;
5906 }
5907
5908 return (0,external_wp_element_namespaceObject.createElement)(MainDashboardButtonSlot, {
5909 bubblesVirtually: true
5910 });
5911 };
5912
5913 MainDashboardButton.Slot = main_dashboard_button_Slot;
5914 /* harmony default export */ var main_dashboard_button = (MainDashboardButton);
5915
5916 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
5917
5918
5919 /**
5920 * WordPress dependencies
5921 */
5922
5923 const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5924 viewBox: "0 0 24 24",
5925 xmlns: "http://www.w3.org/2000/svg"
5926 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5927 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
5928 }));
5929 /* harmony default export */ var chevron_down = (chevronDown);
5930
5931 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/template-title/delete-template.js
5932
5933
5934 /**
5935 * External dependencies
5936 */
5937
5938 /**
5939 * WordPress dependencies
5940 */
5941
5942
5943
5944
5945
5946
5947
5948
5949 /**
5950 * Internal dependencies
5951 */
5952
5953
5954 function DeleteTemplate() {
5955 const {
5956 clearSelectedBlock
5957 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5958 const {
5959 setIsEditingTemplate
5960 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5961 const {
5962 getEditorSettings
5963 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_editor_namespaceObject.store);
5964 const {
5965 updateEditorSettings,
5966 editPost
5967 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store);
5968 const {
5969 deleteEntityRecord
5970 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
5971 const {
5972 template
5973 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5974 const {
5975 isEditingTemplate,
5976 getEditedPostTemplate
5977 } = select(store_store);
5978
5979 const _isEditing = isEditingTemplate();
5980
5981 return {
5982 template: _isEditing ? getEditedPostTemplate() : null
5983 };
5984 }, []);
5985 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
5986
5987 if (!template || !template.wp_id) {
5988 return null;
5989 }
5990
5991 let templateTitle = template.slug;
5992
5993 if (template !== null && template !== void 0 && template.title) {
5994 templateTitle = template.title;
5995 }
5996
5997 const onDelete = () => {
5998 clearSelectedBlock();
5999 setIsEditingTemplate(false);
6000 setShowConfirmDialog(false);
6001 editPost({
6002 template: ''
6003 });
6004 const settings = getEditorSettings();
6005 const newAvailableTemplates = (0,external_lodash_namespaceObject.pickBy)(settings.availableTemplates, (_title, id) => {
6006 return id !== template.slug;
6007 });
6008 updateEditorSettings({ ...settings,
6009 availableTemplates: newAvailableTemplates
6010 });
6011 deleteEntityRecord('postType', 'wp_template', template.id);
6012 };
6013
6014 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
6015 className: "edit-post-template-top-area__second-menu-group"
6016 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
6017 className: "edit-post-template-top-area__delete-template-button",
6018 isDestructive: true,
6019 variant: "secondary",
6020 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Delete template'),
6021 onClick: () => {
6022 setShowConfirmDialog(true);
6023 }
6024 }, (0,external_wp_i18n_namespaceObject.__)('Delete template')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
6025 isOpen: showConfirmDialog,
6026 onConfirm: onDelete,
6027 onCancel: () => {
6028 setShowConfirmDialog(false);
6029 }
6030 }, (0,external_wp_i18n_namespaceObject.sprintf)(
6031 /* translators: %s: template name */
6032 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete the %s template? It may be used by other pages or posts.'), templateTitle))));
6033 }
6034
6035 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/template-title/edit-template-title.js
6036
6037
6038 /**
6039 * External dependencies
6040 */
6041
6042 /**
6043 * WordPress dependencies
6044 */
6045
6046
6047
6048
6049
6050
6051 /**
6052 * Internal dependencies
6053 */
6054
6055
6056 function EditTemplateTitle() {
6057 const {
6058 template
6059 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6060 const {
6061 getEditedPostTemplate
6062 } = select(store_store);
6063 return {
6064 template: getEditedPostTemplate()
6065 };
6066 }, []);
6067 const {
6068 editEntityRecord
6069 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
6070 const {
6071 getEditorSettings
6072 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_editor_namespaceObject.store);
6073 const {
6074 updateEditorSettings
6075 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store);
6076
6077 if (template.has_theme_file) {
6078 return null;
6079 }
6080
6081 let templateTitle = (0,external_wp_i18n_namespaceObject.__)('Default');
6082
6083 if (template !== null && template !== void 0 && template.title) {
6084 templateTitle = template.title;
6085 } else if (!!template) {
6086 templateTitle = template.slug;
6087 }
6088
6089 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
6090 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
6091 value: templateTitle,
6092 help: (0,external_wp_i18n_namespaceObject.__)('Give the template a title that indicates its purpose, e.g. "Full Width".'),
6093 onChange: newTitle => {
6094 const settings = getEditorSettings();
6095 const newAvailableTemplates = (0,external_lodash_namespaceObject.mapValues)(settings.availableTemplates, (existingTitle, id) => {
6096 if (id !== template.slug) {
6097 return existingTitle;
6098 }
6099
6100 return newTitle;
6101 });
6102 updateEditorSettings({ ...settings,
6103 availableTemplates: newAvailableTemplates
6104 });
6105 editEntityRecord('postType', 'wp_template', template.id, {
6106 title: newTitle
6107 });
6108 }
6109 });
6110 }
6111
6112 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/template-title/template-description.js
6113
6114
6115 /**
6116 * WordPress dependencies
6117 */
6118
6119
6120 /**
6121 * Internal dependencies
6122 */
6123
6124
6125 function TemplateDescription() {
6126 const {
6127 description,
6128 title
6129 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6130 const {
6131 getEditedPostTemplate
6132 } = select(store_store);
6133 return {
6134 title: getEditedPostTemplate().title,
6135 description: getEditedPostTemplate().description
6136 };
6137 }, []);
6138
6139 if (!description) {
6140 return null;
6141 }
6142
6143 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
6144 level: 4,
6145 weight: 600
6146 }, title), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
6147 className: "edit-post-template-details__description",
6148 size: "body",
6149 as: "p",
6150 style: {
6151 marginTop: '12px'
6152 }
6153 }, description));
6154 }
6155
6156 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/template-title/index.js
6157
6158
6159 /**
6160 * WordPress dependencies
6161 */
6162
6163
6164
6165
6166 /**
6167 * Internal dependencies
6168 */
6169
6170
6171
6172
6173
6174
6175
6176
6177 function TemplateTitle() {
6178 const {
6179 template,
6180 isEditing,
6181 title
6182 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6183 const {
6184 isEditingTemplate,
6185 getEditedPostTemplate
6186 } = select(store_store);
6187 const {
6188 getEditedPostAttribute
6189 } = select(external_wp_editor_namespaceObject.store);
6190
6191 const _isEditing = isEditingTemplate();
6192
6193 return {
6194 template: _isEditing ? getEditedPostTemplate() : null,
6195 isEditing: _isEditing,
6196 title: getEditedPostAttribute('title') ? getEditedPostAttribute('title') : (0,external_wp_i18n_namespaceObject.__)('Untitled')
6197 };
6198 }, []);
6199 const {
6200 clearSelectedBlock
6201 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
6202 const {
6203 setIsEditingTemplate
6204 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6205
6206 if (!isEditing || !template) {
6207 return null;
6208 }
6209
6210 let templateTitle = (0,external_wp_i18n_namespaceObject.__)('Default');
6211
6212 if (template !== null && template !== void 0 && template.title) {
6213 templateTitle = template.title;
6214 } else if (!!template) {
6215 templateTitle = template.slug;
6216 }
6217
6218 const hasOptions = !!(template.custom || template.wp_id || template.description);
6219 return (0,external_wp_element_namespaceObject.createElement)("div", {
6220 className: "edit-post-template-top-area"
6221 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6222 className: "edit-post-template-post-title",
6223 isLink: true,
6224 showTooltip: true,
6225 label: (0,external_wp_i18n_namespaceObject.sprintf)(
6226 /* translators: %s: Title of the referring post, e.g: "Hello World!" */
6227 (0,external_wp_i18n_namespaceObject.__)('Edit %s'), title),
6228 onClick: () => {
6229 clearSelectedBlock();
6230 setIsEditingTemplate(false);
6231 }
6232 }, title), hasOptions ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
6233 position: "bottom center",
6234 contentClassName: "edit-post-template-top-area__popover",
6235 renderToggle: _ref => {
6236 let {
6237 onToggle
6238 } = _ref;
6239 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6240 className: "edit-post-template-title",
6241 isLink: true,
6242 icon: chevron_down,
6243 showTooltip: true,
6244 onClick: onToggle,
6245 label: (0,external_wp_i18n_namespaceObject.__)('Template Options')
6246 }, templateTitle);
6247 },
6248 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(EditTemplateTitle, null), (0,external_wp_element_namespaceObject.createElement)(TemplateDescription, null), (0,external_wp_element_namespaceObject.createElement)(DeleteTemplate, null))
6249 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
6250 className: "edit-post-template-title",
6251 size: "body",
6252 style: {
6253 lineHeight: '24px'
6254 }
6255 }, templateTitle));
6256 }
6257
6258 /* harmony default export */ var template_title = (TemplateTitle);
6259
6260 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/index.js
6261
6262
6263 /**
6264 * External dependencies
6265 */
6266
6267 /**
6268 * WordPress dependencies
6269 */
6270
6271
6272
6273
6274
6275 /**
6276 * Internal dependencies
6277 */
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288 function Header(_ref) {
6289 let {
6290 setEntitiesSavedStatesCallback
6291 } = _ref;
6292 const {
6293 hasActiveMetaboxes,
6294 isPublishSidebarOpened,
6295 isSaving,
6296 showIconLabels,
6297 hasReducedUI
6298 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
6299 hasActiveMetaboxes: select(store_store).hasMetaBoxes(),
6300 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
6301 isSaving: select(store_store).isSavingMetaBoxes(),
6302 showIconLabels: select(store_store).isFeatureActive('showIconLabels'),
6303 hasReducedUI: select(store_store).isFeatureActive('reducedUI')
6304 }), []);
6305 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
6306 const classes = classnames_default()('edit-post-header', {
6307 'has-reduced-ui': hasReducedUI
6308 });
6309 return (0,external_wp_element_namespaceObject.createElement)("div", {
6310 className: classes
6311 }, (0,external_wp_element_namespaceObject.createElement)(main_dashboard_button.Slot, null, (0,external_wp_element_namespaceObject.createElement)(fullscreen_mode_close, {
6312 showTooltip: true
6313 })), (0,external_wp_element_namespaceObject.createElement)("div", {
6314 className: "edit-post-header__toolbar"
6315 }, (0,external_wp_element_namespaceObject.createElement)(header_toolbar, null), (0,external_wp_element_namespaceObject.createElement)(template_title, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
6316 className: "edit-post-header__settings"
6317 }, !isPublishSidebarOpened && // This button isn't completely hidden by the publish sidebar.
6318 // We can't hide the whole toolbar when the publish sidebar is open because
6319 // we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
6320 // We track that DOM node to return focus to the PostPublishButtonOrToggle
6321 // when the publish sidebar has been closed.
6322 (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostSavedState, {
6323 forceIsDirty: hasActiveMetaboxes,
6324 forceIsSaving: isSaving,
6325 showIconLabels: showIconLabels
6326 }), (0,external_wp_element_namespaceObject.createElement)(DevicePreview, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPreviewButton, {
6327 forceIsAutosaveable: hasActiveMetaboxes,
6328 forcePreviewLink: isSaving ? null : undefined
6329 }), (0,external_wp_element_namespaceObject.createElement)(post_publish_button_or_toggle, {
6330 forceIsDirty: hasActiveMetaboxes,
6331 forceIsSaving: isSaving,
6332 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
6333 }), (isLargeViewport || !showIconLabels) && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
6334 scope: "core/edit-post"
6335 }), (0,external_wp_element_namespaceObject.createElement)(more_menu, {
6336 showIconLabels: showIconLabels
6337 })), showIconLabels && !isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(more_menu, {
6338 showIconLabels: showIconLabels
6339 })));
6340 }
6341
6342 /* harmony default export */ var header = (Header);
6343
6344 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js
6345
6346
6347 /**
6348 * WordPress dependencies
6349 */
6350
6351 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6352 xmlns: "http://www.w3.org/2000/svg",
6353 viewBox: "0 0 24 24"
6354 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6355 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
6356 }));
6357 /* harmony default export */ var library_close = (close_close);
6358
6359 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/secondary-sidebar/inserter-sidebar.js
6360
6361
6362
6363 /**
6364 * WordPress dependencies
6365 */
6366
6367
6368
6369
6370
6371
6372
6373 /**
6374 * Internal dependencies
6375 */
6376
6377
6378 function InserterSidebar() {
6379 const {
6380 insertionPoint,
6381 showMostUsedBlocks
6382 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6383 const {
6384 isFeatureActive,
6385 __experimentalGetInsertionPoint
6386 } = select(store_store);
6387 return {
6388 insertionPoint: __experimentalGetInsertionPoint(),
6389 showMostUsedBlocks: isFeatureActive('mostUsedBlocks')
6390 };
6391 }, []);
6392 const {
6393 setIsInserterOpened
6394 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6395 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
6396 const TagName = !isMobileViewport ? external_wp_components_namespaceObject.VisuallyHidden : 'div';
6397 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
6398 onClose: () => setIsInserterOpened(false),
6399 focusOnMount: null
6400 });
6401 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
6402 (0,external_wp_element_namespaceObject.useEffect)(() => {
6403 libraryRef.current.focusSearch();
6404 }, []);
6405 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
6406 ref: inserterDialogRef
6407 }, inserterDialogProps, {
6408 className: "edit-post-editor__inserter-panel"
6409 }), (0,external_wp_element_namespaceObject.createElement)(TagName, {
6410 className: "edit-post-editor__inserter-panel-header"
6411 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6412 icon: library_close,
6413 label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter'),
6414 onClick: () => setIsInserterOpened(false)
6415 })), (0,external_wp_element_namespaceObject.createElement)("div", {
6416 className: "edit-post-editor__inserter-panel-content"
6417 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, {
6418 showMostUsedBlocks: showMostUsedBlocks,
6419 showInserterHelpPanel: true,
6420 shouldFocusBlock: isMobileViewport,
6421 rootClientId: insertionPoint.rootClientId,
6422 __experimentalInsertionIndex: insertionPoint.insertionIndex,
6423 __experimentalFilterValue: insertionPoint.filterValue,
6424 ref: libraryRef
6425 })));
6426 }
6427
6428 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/secondary-sidebar/list-view-sidebar.js
6429
6430
6431 /**
6432 * WordPress dependencies
6433 */
6434
6435
6436
6437
6438
6439
6440
6441 /**
6442 * Internal dependencies
6443 */
6444
6445
6446 function ListViewSidebar() {
6447 const {
6448 setIsListViewOpened
6449 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6450 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
6451 const headerFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
6452 const contentFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
6453
6454 function closeOnEscape(event) {
6455 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
6456 event.preventDefault();
6457 setIsListViewOpened(false);
6458 }
6459 }
6460
6461 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewSidebar);
6462 const labelId = `edit-post-editor__list-view-panel-label-${instanceId}`;
6463 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
6464 (0,external_wp_element_namespaceObject.createElement)("div", {
6465 "aria-labelledby": labelId,
6466 className: "edit-post-editor__list-view-panel",
6467 onKeyDown: closeOnEscape
6468 }, (0,external_wp_element_namespaceObject.createElement)("div", {
6469 className: "edit-post-editor__list-view-panel-header",
6470 ref: headerFocusReturnRef
6471 }, (0,external_wp_element_namespaceObject.createElement)("strong", {
6472 id: labelId
6473 }, (0,external_wp_i18n_namespaceObject.__)('List View')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6474 icon: close_small,
6475 label: (0,external_wp_i18n_namespaceObject.__)('Close List View Sidebar'),
6476 onClick: () => setIsListViewOpened(false)
6477 })), (0,external_wp_element_namespaceObject.createElement)("div", {
6478 className: "edit-post-editor__list-view-panel-content",
6479 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([contentFocusReturnRef, focusOnMountRef])
6480 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
6481 showNestedBlocks: true,
6482 __experimentalFeatures: true,
6483 __experimentalPersistentListViewFeatures: true
6484 })))
6485 );
6486 }
6487
6488 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js
6489
6490
6491 /**
6492 * WordPress dependencies
6493 */
6494
6495 const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6496 xmlns: "http://www.w3.org/2000/svg",
6497 viewBox: "0 0 24 24"
6498 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6499 fillRule: "evenodd",
6500 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",
6501 clipRule: "evenodd"
6502 }));
6503 /* harmony default export */ var library_cog = (cog);
6504
6505 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/settings-header/index.js
6506
6507
6508 /**
6509 * WordPress dependencies
6510 */
6511
6512
6513
6514
6515 /**
6516 * Internal dependencies
6517 */
6518
6519
6520
6521 const SettingsHeader = _ref => {
6522 let {
6523 sidebarName
6524 } = _ref;
6525 const {
6526 openGeneralSidebar
6527 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6528
6529 const openDocumentSettings = () => openGeneralSidebar('edit-post/document');
6530
6531 const openBlockSettings = () => openGeneralSidebar('edit-post/block');
6532
6533 const {
6534 documentLabel,
6535 isTemplateMode
6536 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6537 const postTypeLabel = select(external_wp_editor_namespaceObject.store).getPostTypeLabel();
6538 return {
6539 // translators: Default label for the Document sidebar tab, not selected.
6540 documentLabel: postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun'),
6541 isTemplateMode: select(store_store).isEditingTemplate()
6542 };
6543 }, []);
6544 const [documentAriaLabel, documentActiveClass] = sidebarName === 'edit-post/document' ? // translators: ARIA label for the Document sidebar tab, selected. %s: Document label.
6545 [(0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('%s (selected)'), documentLabel), 'is-active'] : [documentLabel, ''];
6546 const [blockAriaLabel, blockActiveClass] = sidebarName === 'edit-post/block' ? // translators: ARIA label for the Block Settings Sidebar tab, selected.
6547 [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected.
6548 [(0,external_wp_i18n_namespaceObject.__)('Block'), ''];
6549 const [templateAriaLabel, templateActiveClass] = sidebarName === 'edit-post/document' ? [(0,external_wp_i18n_namespaceObject.__)('Template (selected)'), 'is-active'] : [(0,external_wp_i18n_namespaceObject.__)('Template'), ''];
6550 /* Use a list so screen readers will announce how many tabs there are. */
6551
6552 return (0,external_wp_element_namespaceObject.createElement)("ul", null, !isTemplateMode && (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6553 onClick: openDocumentSettings,
6554 className: `edit-post-sidebar__panel-tab ${documentActiveClass}`,
6555 "aria-label": documentAriaLabel,
6556 "data-label": documentLabel
6557 }, documentLabel)), isTemplateMode && (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6558 onClick: openDocumentSettings,
6559 className: `edit-post-sidebar__panel-tab ${templateActiveClass}`,
6560 "aria-label": templateAriaLabel,
6561 "data-label": (0,external_wp_i18n_namespaceObject.__)('Template')
6562 }, (0,external_wp_i18n_namespaceObject.__)('Template'))), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6563 onClick: openBlockSettings,
6564 className: `edit-post-sidebar__panel-tab ${blockActiveClass}`,
6565 "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab.
6566 ,
6567 "data-label": (0,external_wp_i18n_namespaceObject.__)('Block')
6568 }, // translators: Text label for the Block Settings Sidebar tab.
6569 (0,external_wp_i18n_namespaceObject.__)('Block'))));
6570 };
6571
6572 /* harmony default export */ var settings_header = (SettingsHeader);
6573
6574 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-visibility/index.js
6575
6576
6577 /**
6578 * WordPress dependencies
6579 */
6580
6581
6582
6583 function PostVisibility() {
6584 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostVisibilityCheck, {
6585 render: _ref => {
6586 let {
6587 canEdit
6588 } = _ref;
6589 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, {
6590 className: "edit-post-post-visibility"
6591 }, (0,external_wp_element_namespaceObject.createElement)("span", null, (0,external_wp_i18n_namespaceObject.__)('Visibility')), !canEdit && (0,external_wp_element_namespaceObject.createElement)("span", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostVisibilityLabel, null)), canEdit && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
6592 position: "bottom left",
6593 contentClassName: "edit-post-post-visibility__dialog",
6594 renderToggle: _ref2 => {
6595 let {
6596 isOpen,
6597 onToggle
6598 } = _ref2;
6599 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6600 "aria-expanded": isOpen,
6601 className: "edit-post-post-visibility__toggle",
6602 onClick: onToggle,
6603 variant: "tertiary"
6604 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostVisibilityLabel, null));
6605 },
6606 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostVisibility, null)
6607 }));
6608 }
6609 });
6610 }
6611 /* harmony default export */ var post_visibility = (PostVisibility);
6612
6613 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-trash/index.js
6614
6615
6616 /**
6617 * WordPress dependencies
6618 */
6619
6620
6621 function PostTrash() {
6622 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTrashCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTrash, null)));
6623 }
6624
6625 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-schedule/index.js
6626
6627
6628 /**
6629 * WordPress dependencies
6630 */
6631
6632
6633
6634
6635 function PostSchedule() {
6636 const anchorRef = (0,external_wp_element_namespaceObject.useRef)();
6637 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostScheduleCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, {
6638 className: "edit-post-post-schedule",
6639 ref: anchorRef
6640 }, (0,external_wp_element_namespaceObject.createElement)("span", null, (0,external_wp_i18n_namespaceObject.__)('Publish')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
6641 popoverProps: {
6642 anchorRef: anchorRef.current
6643 },
6644 position: "bottom left",
6645 contentClassName: "edit-post-post-schedule__dialog",
6646 renderToggle: _ref => {
6647 let {
6648 onToggle,
6649 isOpen
6650 } = _ref;
6651 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
6652 className: "edit-post-post-schedule__toggle",
6653 onClick: onToggle,
6654 "aria-expanded": isOpen,
6655 variant: "tertiary"
6656 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostScheduleLabel, null)));
6657 },
6658 renderContent: () => (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostSchedule, null)
6659 })));
6660 }
6661 /* harmony default export */ var post_schedule = (PostSchedule);
6662
6663 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-sticky/index.js
6664
6665
6666 /**
6667 * WordPress dependencies
6668 */
6669
6670
6671 function PostSticky() {
6672 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostStickyCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostSticky, null)));
6673 }
6674 /* harmony default export */ var post_sticky = (PostSticky);
6675
6676 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-author/index.js
6677
6678
6679 /**
6680 * WordPress dependencies
6681 */
6682
6683
6684 function PostAuthor() {
6685 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostAuthorCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, {
6686 className: "edit-post-post-author"
6687 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostAuthor, null)));
6688 }
6689 /* harmony default export */ var post_author = (PostAuthor);
6690
6691 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-slug/index.js
6692
6693
6694 /**
6695 * WordPress dependencies
6696 */
6697
6698
6699 function PostSlug() {
6700 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostSlugCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostSlug, null)));
6701 }
6702 /* harmony default export */ var post_slug = (PostSlug);
6703
6704 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-format/index.js
6705
6706
6707 /**
6708 * WordPress dependencies
6709 */
6710
6711
6712 function PostFormat() {
6713 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostFormatCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostFormat, null)));
6714 }
6715 /* harmony default export */ var post_format = (PostFormat);
6716
6717 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-pending-status/index.js
6718
6719
6720 /**
6721 * WordPress dependencies
6722 */
6723
6724
6725 function PostPendingStatus() {
6726 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPendingStatusCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPendingStatus, null)));
6727 }
6728 /* harmony default export */ var post_pending_status = (PostPendingStatus);
6729
6730 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/plugin-post-status-info/index.js
6731
6732
6733 /**
6734 * Defines as extensibility slot for the Status & visibility panel.
6735 */
6736
6737 /**
6738 * WordPress dependencies
6739 */
6740
6741 const {
6742 Fill: plugin_post_status_info_Fill,
6743 Slot: plugin_post_status_info_Slot
6744 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostStatusInfo');
6745 /**
6746 * Renders a row in the Status & visibility panel of the Document sidebar.
6747 * It should be noted that this is named and implemented around the function it serves
6748 * and not its location, which may change in future iterations.
6749 *
6750 * @param {Object} props Component properties.
6751 * @param {string} [props.className] An optional class name added to the row.
6752 * @param {WPElement} props.children Children to be rendered.
6753 *
6754 * @example
6755 * ```js
6756 * // Using ES5 syntax
6757 * var __ = wp.i18n.__;
6758 * var PluginPostStatusInfo = wp.editPost.PluginPostStatusInfo;
6759 *
6760 * function MyPluginPostStatusInfo() {
6761 * return wp.element.createElement(
6762 * PluginPostStatusInfo,
6763 * {
6764 * className: 'my-plugin-post-status-info',
6765 * },
6766 * __( 'My post status info' )
6767 * )
6768 * }
6769 * ```
6770 *
6771 * @example
6772 * ```jsx
6773 * // Using ESNext syntax
6774 * import { __ } from '@wordpress/i18n';
6775 * import { PluginPostStatusInfo } from '@wordpress/edit-post';
6776 *
6777 * const MyPluginPostStatusInfo = () => (
6778 * <PluginPostStatusInfo
6779 * className="my-plugin-post-status-info"
6780 * >
6781 * { __( 'My post status info' ) }
6782 * </PluginPostStatusInfo>
6783 * );
6784 * ```
6785 *
6786 * @return {WPComponent} The component to be rendered.
6787 */
6788
6789 const PluginPostStatusInfo = _ref => {
6790 let {
6791 children,
6792 className
6793 } = _ref;
6794 return (0,external_wp_element_namespaceObject.createElement)(plugin_post_status_info_Fill, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, {
6795 className: className
6796 }, children));
6797 };
6798
6799 PluginPostStatusInfo.Slot = plugin_post_status_info_Slot;
6800 /* harmony default export */ var plugin_post_status_info = (PluginPostStatusInfo);
6801
6802 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-status/index.js
6803
6804
6805 /**
6806 * WordPress dependencies
6807 */
6808
6809
6810
6811
6812 /**
6813 * Internal dependencies
6814 */
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826 /**
6827 * Module Constants
6828 */
6829
6830 const PANEL_NAME = 'post-status';
6831
6832 function PostStatus(_ref) {
6833 let {
6834 isOpened,
6835 onTogglePanel
6836 } = _ref;
6837 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
6838 className: "edit-post-post-status",
6839 title: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
6840 opened: isOpened,
6841 onToggle: onTogglePanel
6842 }, (0,external_wp_element_namespaceObject.createElement)(plugin_post_status_info.Slot, null, fills => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(post_visibility, null), (0,external_wp_element_namespaceObject.createElement)(post_schedule, null), (0,external_wp_element_namespaceObject.createElement)(post_format, null), (0,external_wp_element_namespaceObject.createElement)(post_sticky, null), (0,external_wp_element_namespaceObject.createElement)(post_pending_status, null), (0,external_wp_element_namespaceObject.createElement)(post_slug, null), (0,external_wp_element_namespaceObject.createElement)(post_author, null), fills, (0,external_wp_element_namespaceObject.createElement)(PostTrash, null))));
6843 }
6844
6845 /* harmony default export */ var post_status = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
6846 // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
6847 // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
6848 const {
6849 isEditorPanelRemoved,
6850 isEditorPanelOpened
6851 } = select(store_store);
6852 return {
6853 isRemoved: isEditorPanelRemoved(PANEL_NAME),
6854 isOpened: isEditorPanelOpened(PANEL_NAME)
6855 };
6856 }), (0,external_wp_compose_namespaceObject.ifCondition)(_ref2 => {
6857 let {
6858 isRemoved
6859 } = _ref2;
6860 return !isRemoved;
6861 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
6862 onTogglePanel() {
6863 return dispatch(store_store).toggleEditorPanelOpened(PANEL_NAME);
6864 }
6865
6866 }))])(PostStatus));
6867
6868 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/last-revision/index.js
6869
6870
6871 /**
6872 * WordPress dependencies
6873 */
6874
6875
6876
6877 function LastRevision() {
6878 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostLastRevisionCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
6879 className: "edit-post-last-revision__panel"
6880 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostLastRevision, null)));
6881 }
6882
6883 /* harmony default export */ var last_revision = (LastRevision);
6884
6885 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js
6886
6887
6888 /**
6889 * External dependencies
6890 */
6891
6892 /**
6893 * WordPress dependencies
6894 */
6895
6896
6897
6898
6899 /**
6900 * Internal dependencies
6901 */
6902
6903
6904
6905 function TaxonomyPanel(_ref) {
6906 let {
6907 isEnabled,
6908 taxonomy,
6909 isOpened,
6910 onTogglePanel,
6911 children
6912 } = _ref;
6913
6914 if (!isEnabled) {
6915 return null;
6916 }
6917
6918 const taxonomyMenuName = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'menu_name']);
6919
6920 if (!taxonomyMenuName) {
6921 return null;
6922 }
6923
6924 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
6925 title: taxonomyMenuName,
6926 opened: isOpened,
6927 onToggle: onTogglePanel
6928 }, children);
6929 }
6930
6931 /* harmony default export */ var taxonomy_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
6932 const slug = (0,external_lodash_namespaceObject.get)(ownProps.taxonomy, ['slug']);
6933 const panelName = slug ? `taxonomy-panel-${slug}` : '';
6934 return {
6935 panelName,
6936 isEnabled: slug ? select(store_store).isEditorPanelEnabled(panelName) : false,
6937 isOpened: slug ? select(store_store).isEditorPanelOpened(panelName) : false
6938 };
6939 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
6940 onTogglePanel: () => {
6941 dispatch(store_store).toggleEditorPanelOpened(ownProps.panelName);
6942 }
6943 })))(TaxonomyPanel));
6944
6945 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-taxonomies/index.js
6946
6947
6948 /**
6949 * WordPress dependencies
6950 */
6951
6952 /**
6953 * Internal dependencies
6954 */
6955
6956
6957
6958 function PostTaxonomies() {
6959 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTaxonomiesCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTaxonomies, {
6960 taxonomyWrapper: (content, taxonomy) => {
6961 return (0,external_wp_element_namespaceObject.createElement)(taxonomy_panel, {
6962 taxonomy: taxonomy
6963 }, content);
6964 }
6965 }));
6966 }
6967
6968 /* harmony default export */ var post_taxonomies = (PostTaxonomies);
6969
6970 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/featured-image/index.js
6971
6972
6973 /**
6974 * External dependencies
6975 */
6976
6977 /**
6978 * WordPress dependencies
6979 */
6980
6981
6982
6983
6984
6985
6986
6987 /**
6988 * Internal dependencies
6989 */
6990
6991
6992 /**
6993 * Module Constants
6994 */
6995
6996 const featured_image_PANEL_NAME = 'featured-image';
6997
6998 function FeaturedImage(_ref) {
6999 let {
7000 isEnabled,
7001 isOpened,
7002 postType,
7003 onTogglePanel
7004 } = _ref;
7005
7006 if (!isEnabled) {
7007 return null;
7008 }
7009
7010 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostFeaturedImageCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
7011 title: (0,external_lodash_namespaceObject.get)(postType, ['labels', 'featured_image'], (0,external_wp_i18n_namespaceObject.__)('Featured image')),
7012 opened: isOpened,
7013 onToggle: onTogglePanel
7014 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostFeaturedImage, null)));
7015 }
7016
7017 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
7018 const {
7019 getEditedPostAttribute
7020 } = select(external_wp_editor_namespaceObject.store);
7021 const {
7022 getPostType
7023 } = select(external_wp_coreData_namespaceObject.store);
7024 const {
7025 isEditorPanelEnabled,
7026 isEditorPanelOpened
7027 } = select(store_store);
7028 return {
7029 postType: getPostType(getEditedPostAttribute('type')),
7030 isEnabled: isEditorPanelEnabled(featured_image_PANEL_NAME),
7031 isOpened: isEditorPanelOpened(featured_image_PANEL_NAME)
7032 };
7033 });
7034 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
7035 const {
7036 toggleEditorPanelOpened
7037 } = dispatch(store_store);
7038 return {
7039 onTogglePanel: (0,external_lodash_namespaceObject.partial)(toggleEditorPanelOpened, featured_image_PANEL_NAME)
7040 };
7041 });
7042 /* harmony default export */ var featured_image = ((0,external_wp_compose_namespaceObject.compose)(applyWithSelect, applyWithDispatch)(FeaturedImage));
7043
7044 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-excerpt/index.js
7045
7046
7047 /**
7048 * WordPress dependencies
7049 */
7050
7051
7052
7053
7054
7055 /**
7056 * Internal dependencies
7057 */
7058
7059
7060 /**
7061 * Module Constants
7062 */
7063
7064 const post_excerpt_PANEL_NAME = 'post-excerpt';
7065
7066 function PostExcerpt(_ref) {
7067 let {
7068 isEnabled,
7069 isOpened,
7070 onTogglePanel
7071 } = _ref;
7072
7073 if (!isEnabled) {
7074 return null;
7075 }
7076
7077 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostExcerptCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
7078 title: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
7079 opened: isOpened,
7080 onToggle: onTogglePanel
7081 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostExcerpt, null)));
7082 }
7083
7084 /* harmony default export */ var post_excerpt = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
7085 return {
7086 isEnabled: select(store_store).isEditorPanelEnabled(post_excerpt_PANEL_NAME),
7087 isOpened: select(store_store).isEditorPanelOpened(post_excerpt_PANEL_NAME)
7088 };
7089 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
7090 onTogglePanel() {
7091 return dispatch(store_store).toggleEditorPanelOpened(post_excerpt_PANEL_NAME);
7092 }
7093
7094 }))])(PostExcerpt));
7095
7096 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/post-link/index.js
7097
7098
7099 /**
7100 * External dependencies
7101 */
7102
7103 /**
7104 * WordPress dependencies
7105 */
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115 /**
7116 * Internal dependencies
7117 */
7118
7119
7120 /**
7121 * Module Constants
7122 */
7123
7124 const post_link_PANEL_NAME = 'post-link';
7125
7126 function PostLink(_ref) {
7127 let {
7128 isOpened,
7129 onTogglePanel,
7130 isEditable,
7131 postLink,
7132 permalinkPrefix,
7133 permalinkSuffix,
7134 editPermalink,
7135 postSlug,
7136 postTypeLabel
7137 } = _ref;
7138 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
7139 let prefixElement, postNameElement, suffixElement;
7140
7141 if (isEditable) {
7142 prefixElement = permalinkPrefix && (0,external_wp_element_namespaceObject.createElement)("span", {
7143 className: "edit-post-post-link__link-prefix"
7144 }, permalinkPrefix);
7145 postNameElement = postSlug && (0,external_wp_element_namespaceObject.createElement)("span", {
7146 className: "edit-post-post-link__link-post-name"
7147 }, postSlug);
7148 suffixElement = permalinkSuffix && (0,external_wp_element_namespaceObject.createElement)("span", {
7149 className: "edit-post-post-link__link-suffix"
7150 }, permalinkSuffix);
7151 }
7152
7153 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
7154 title: (0,external_wp_i18n_namespaceObject.__)('Permalink'),
7155 opened: isOpened,
7156 onToggle: onTogglePanel
7157 }, isEditable && (0,external_wp_element_namespaceObject.createElement)("div", {
7158 className: "editor-post-link"
7159 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
7160 label: (0,external_wp_i18n_namespaceObject.__)('URL Slug'),
7161 value: forceEmptyField ? '' : postSlug,
7162 autoComplete: "off",
7163 spellCheck: "false",
7164 onChange: newValue => {
7165 editPermalink(newValue); // When we delete the field the permalink gets
7166 // reverted to the original value.
7167 // The forceEmptyField logic allows the user to have
7168 // the field temporarily empty while typing.
7169
7170 if (!newValue) {
7171 if (!forceEmptyField) {
7172 setForceEmptyField(true);
7173 }
7174
7175 return;
7176 }
7177
7178 if (forceEmptyField) {
7179 setForceEmptyField(false);
7180 }
7181 },
7182 onBlur: event => {
7183 editPermalink((0,external_wp_editor_namespaceObject.cleanForSlug)(event.target.value));
7184
7185 if (forceEmptyField) {
7186 setForceEmptyField(false);
7187 }
7188 }
7189 }), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('The last part of the URL.'), ' ', (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
7190 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/writing-posts/#post-field-descriptions')
7191 }, (0,external_wp_i18n_namespaceObject.__)('Read about permalinks')))), (0,external_wp_element_namespaceObject.createElement)("h3", {
7192 className: "edit-post-post-link__preview-label"
7193 }, postTypeLabel || (0,external_wp_i18n_namespaceObject.__)('View post')), (0,external_wp_element_namespaceObject.createElement)("div", {
7194 className: "edit-post-post-link__preview-link-container"
7195 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
7196 className: "edit-post-post-link__link",
7197 href: postLink,
7198 target: "_blank"
7199 }, isEditable ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, prefixElement, postNameElement, suffixElement) : postLink)));
7200 }
7201
7202 /* harmony default export */ var post_link = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
7203 const {
7204 isPermalinkEditable,
7205 getCurrentPost,
7206 isCurrentPostPublished,
7207 getPermalinkParts,
7208 getEditedPostAttribute,
7209 getEditedPostSlug
7210 } = select(external_wp_editor_namespaceObject.store);
7211 const {
7212 isEditorPanelEnabled,
7213 isEditorPanelOpened
7214 } = select(store_store);
7215 const {
7216 getPostType
7217 } = select(external_wp_coreData_namespaceObject.store);
7218 const {
7219 link
7220 } = getCurrentPost();
7221 const postTypeName = getEditedPostAttribute('type');
7222 const postType = getPostType(postTypeName);
7223 const permalinkParts = getPermalinkParts();
7224 return {
7225 postLink: link,
7226 isEditable: isPermalinkEditable(),
7227 isPublished: isCurrentPostPublished(),
7228 isOpened: isEditorPanelOpened(post_link_PANEL_NAME),
7229 isEnabled: isEditorPanelEnabled(post_link_PANEL_NAME),
7230 isViewable: (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false),
7231 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(getEditedPostSlug()),
7232 postTypeLabel: (0,external_lodash_namespaceObject.get)(postType, ['labels', 'view_item']),
7233 hasPermalinkParts: !!permalinkParts,
7234 permalinkPrefix: permalinkParts === null || permalinkParts === void 0 ? void 0 : permalinkParts.prefix,
7235 permalinkSuffix: permalinkParts === null || permalinkParts === void 0 ? void 0 : permalinkParts.suffix
7236 };
7237 }), (0,external_wp_compose_namespaceObject.ifCondition)(_ref2 => {
7238 let {
7239 isEnabled,
7240 postLink,
7241 isViewable,
7242 hasPermalinkParts
7243 } = _ref2;
7244 return isEnabled && postLink && isViewable && hasPermalinkParts;
7245 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
7246 const {
7247 toggleEditorPanelOpened
7248 } = dispatch(store_store);
7249 const {
7250 editPost
7251 } = dispatch(external_wp_editor_namespaceObject.store);
7252 return {
7253 onTogglePanel: () => toggleEditorPanelOpened(post_link_PANEL_NAME),
7254 editPermalink: newSlug => {
7255 editPost({
7256 slug: newSlug
7257 });
7258 }
7259 };
7260 })])(PostLink));
7261
7262 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/discussion-panel/index.js
7263
7264
7265 /**
7266 * WordPress dependencies
7267 */
7268
7269
7270
7271
7272
7273 /**
7274 * Internal dependencies
7275 */
7276
7277
7278 /**
7279 * Module Constants
7280 */
7281
7282 const discussion_panel_PANEL_NAME = 'discussion-panel';
7283
7284 function DiscussionPanel(_ref) {
7285 let {
7286 isEnabled,
7287 isOpened,
7288 onTogglePanel
7289 } = _ref;
7290
7291 if (!isEnabled) {
7292 return null;
7293 }
7294
7295 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTypeSupportCheck, {
7296 supportKeys: ['comments', 'trackbacks']
7297 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
7298 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
7299 opened: isOpened,
7300 onToggle: onTogglePanel
7301 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTypeSupportCheck, {
7302 supportKeys: "comments"
7303 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostComments, null))), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTypeSupportCheck, {
7304 supportKeys: "trackbacks"
7305 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPingbacks, null)))));
7306 }
7307
7308 /* harmony default export */ var discussion_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
7309 return {
7310 isEnabled: select(store_store).isEditorPanelEnabled(discussion_panel_PANEL_NAME),
7311 isOpened: select(store_store).isEditorPanelOpened(discussion_panel_PANEL_NAME)
7312 };
7313 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
7314 onTogglePanel() {
7315 return dispatch(store_store).toggleEditorPanelOpened(discussion_panel_PANEL_NAME);
7316 }
7317
7318 }))])(DiscussionPanel));
7319
7320 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/page-attributes/index.js
7321
7322
7323 /**
7324 * External dependencies
7325 */
7326
7327 /**
7328 * WordPress dependencies
7329 */
7330
7331
7332
7333
7334
7335
7336 /**
7337 * Internal dependencies
7338 */
7339
7340
7341 /**
7342 * Module Constants
7343 */
7344
7345 const page_attributes_PANEL_NAME = 'page-attributes';
7346 function PageAttributes() {
7347 const {
7348 isEnabled,
7349 isOpened,
7350 postType
7351 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7352 const {
7353 getEditedPostAttribute
7354 } = select(external_wp_editor_namespaceObject.store);
7355 const {
7356 isEditorPanelEnabled,
7357 isEditorPanelOpened
7358 } = select(store_store);
7359 const {
7360 getPostType
7361 } = select(external_wp_coreData_namespaceObject.store);
7362 return {
7363 isEnabled: isEditorPanelEnabled(page_attributes_PANEL_NAME),
7364 isOpened: isEditorPanelOpened(page_attributes_PANEL_NAME),
7365 postType: getPostType(getEditedPostAttribute('type'))
7366 };
7367 }, []);
7368 const {
7369 toggleEditorPanelOpened
7370 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7371
7372 if (!isEnabled || !postType) {
7373 return null;
7374 }
7375
7376 const onTogglePanel = (0,external_lodash_namespaceObject.partial)(toggleEditorPanelOpened, page_attributes_PANEL_NAME);
7377 return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PageAttributesCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
7378 title: (0,external_lodash_namespaceObject.get)(postType, ['labels', 'attributes'], (0,external_wp_i18n_namespaceObject.__)('Page attributes')),
7379 opened: isOpened,
7380 onToggle: onTogglePanel
7381 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PageAttributesParent, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PageAttributesOrder, null))));
7382 }
7383 /* harmony default export */ var page_attributes = (PageAttributes);
7384
7385 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/meta-boxes/meta-boxes-area/index.js
7386
7387
7388 /**
7389 * External dependencies
7390 */
7391
7392 /**
7393 * WordPress dependencies
7394 */
7395
7396
7397
7398
7399 /**
7400 * Internal dependencies
7401 */
7402
7403
7404 /**
7405 * Render metabox area.
7406 *
7407 * @param {Object} props Component props.
7408 * @param {string} props.location metabox location.
7409 * @return {WPComponent} The component to be rendered.
7410 */
7411
7412 function MetaBoxesArea(_ref) {
7413 let {
7414 location
7415 } = _ref;
7416 const container = (0,external_wp_element_namespaceObject.useRef)(null);
7417 const formRef = (0,external_wp_element_namespaceObject.useRef)(null);
7418 (0,external_wp_element_namespaceObject.useEffect)(() => {
7419 formRef.current = document.querySelector('.metabox-location-' + location);
7420
7421 if (formRef.current) {
7422 container.current.appendChild(formRef.current);
7423 }
7424
7425 return () => {
7426 if (formRef.current) {
7427 document.querySelector('#metaboxes').appendChild(formRef.current);
7428 }
7429 };
7430 }, [location]);
7431 const isSaving = (0,external_wp_data_namespaceObject.useSelect)(select => {
7432 return select(store_store).isSavingMetaBoxes();
7433 }, []);
7434 const classes = classnames_default()('edit-post-meta-boxes-area', `is-${location}`, {
7435 'is-loading': isSaving
7436 });
7437 return (0,external_wp_element_namespaceObject.createElement)("div", {
7438 className: classes
7439 }, isSaving && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), (0,external_wp_element_namespaceObject.createElement)("div", {
7440 className: "edit-post-meta-boxes-area__container",
7441 ref: container
7442 }), (0,external_wp_element_namespaceObject.createElement)("div", {
7443 className: "edit-post-meta-boxes-area__clear"
7444 }));
7445 }
7446
7447 /* harmony default export */ var meta_boxes_area = (MetaBoxesArea);
7448
7449 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/meta-boxes/meta-box-visibility.js
7450 /**
7451 * WordPress dependencies
7452 */
7453
7454
7455 /**
7456 * Internal dependencies
7457 */
7458
7459
7460
7461 class MetaBoxVisibility extends external_wp_element_namespaceObject.Component {
7462 componentDidMount() {
7463 this.updateDOM();
7464 }
7465
7466 componentDidUpdate(prevProps) {
7467 if (this.props.isVisible !== prevProps.isVisible) {
7468 this.updateDOM();
7469 }
7470 }
7471
7472 updateDOM() {
7473 const {
7474 id,
7475 isVisible
7476 } = this.props;
7477 const element = document.getElementById(id);
7478
7479 if (!element) {
7480 return;
7481 }
7482
7483 if (isVisible) {
7484 element.classList.remove('is-hidden');
7485 } else {
7486 element.classList.add('is-hidden');
7487 }
7488 }
7489
7490 render() {
7491 return null;
7492 }
7493
7494 }
7495
7496 /* harmony default export */ var meta_box_visibility = ((0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
7497 let {
7498 id
7499 } = _ref;
7500 return {
7501 isVisible: select(store_store).isEditorPanelEnabled(`meta-box-${id}`)
7502 };
7503 })(MetaBoxVisibility));
7504
7505 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/meta-boxes/index.js
7506
7507
7508 /**
7509 * External dependencies
7510 */
7511
7512 /**
7513 * WordPress dependencies
7514 */
7515
7516
7517
7518
7519 /**
7520 * Internal dependencies
7521 */
7522
7523
7524
7525
7526 function MetaBoxes(_ref) {
7527 let {
7528 location
7529 } = _ref;
7530 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
7531 const {
7532 metaBoxes,
7533 areMetaBoxesInitialized,
7534 isEditorReady
7535 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7536 const {
7537 __unstableIsEditorReady
7538 } = select(external_wp_editor_namespaceObject.store);
7539 const {
7540 getMetaBoxesPerLocation,
7541 areMetaBoxesInitialized: _areMetaBoxesInitialized
7542 } = select(store_store);
7543 return {
7544 metaBoxes: getMetaBoxesPerLocation(location),
7545 areMetaBoxesInitialized: _areMetaBoxesInitialized(),
7546 isEditorReady: __unstableIsEditorReady()
7547 };
7548 }, [location]); // When editor is ready, initialize postboxes (wp core script) and metabox
7549 // saving. This initializes all meta box locations, not just this specific
7550 // one.
7551
7552 (0,external_wp_element_namespaceObject.useEffect)(() => {
7553 if (isEditorReady && !areMetaBoxesInitialized) {
7554 registry.dispatch(store_store).initializeMetaBoxes();
7555 }
7556 }, [isEditorReady, areMetaBoxesInitialized]);
7557
7558 if (!areMetaBoxesInitialized) {
7559 return null;
7560 }
7561
7562 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_lodash_namespaceObject.map)(metaBoxes, _ref2 => {
7563 let {
7564 id
7565 } = _ref2;
7566 return (0,external_wp_element_namespaceObject.createElement)(meta_box_visibility, {
7567 key: id,
7568 id: id
7569 });
7570 }), (0,external_wp_element_namespaceObject.createElement)(meta_boxes_area, {
7571 location: location
7572 }));
7573 }
7574
7575 ;// CONCATENATED MODULE: external ["wp","warning"]
7576 var external_wp_warning_namespaceObject = window["wp"]["warning"];
7577 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/plugin-document-setting-panel/index.js
7578
7579
7580 /**
7581 * Defines as extensibility slot for the Settings sidebar
7582 */
7583
7584 /**
7585 * WordPress dependencies
7586 */
7587
7588
7589
7590
7591
7592 /**
7593 * Internal dependencies
7594 */
7595
7596
7597
7598 const {
7599 Fill: plugin_document_setting_panel_Fill,
7600 Slot: plugin_document_setting_panel_Slot
7601 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginDocumentSettingPanel');
7602
7603 const PluginDocumentSettingFill = _ref => {
7604 let {
7605 isEnabled,
7606 panelName,
7607 opened,
7608 onToggle,
7609 className,
7610 title,
7611 icon,
7612 children
7613 } = _ref;
7614 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(enable_plugin_document_setting_panel, {
7615 label: title,
7616 panelName: panelName
7617 }), (0,external_wp_element_namespaceObject.createElement)(plugin_document_setting_panel_Fill, null, isEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
7618 className: className,
7619 title: title,
7620 icon: icon,
7621 opened: opened,
7622 onToggle: onToggle
7623 }, children)));
7624 };
7625 /**
7626 * Renders items below the Status & Availability panel in the Document Sidebar.
7627 *
7628 * @param {Object} props Component properties.
7629 * @param {string} [props.name] The machine-friendly name for the panel.
7630 * @param {string} [props.className] An optional class name added to the row.
7631 * @param {string} [props.title] The title of the panel
7632 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
7633 *
7634 * @example
7635 * ```js
7636 * // Using ES5 syntax
7637 * var el = wp.element.createElement;
7638 * var __ = wp.i18n.__;
7639 * var registerPlugin = wp.plugins.registerPlugin;
7640 * var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
7641 *
7642 * function MyDocumentSettingPlugin() {
7643 * return el(
7644 * PluginDocumentSettingPanel,
7645 * {
7646 * className: 'my-document-setting-plugin',
7647 * title: 'My Panel',
7648 * },
7649 * __( 'My Document Setting Panel' )
7650 * );
7651 * }
7652 *
7653 * registerPlugin( 'my-document-setting-plugin', {
7654 * render: MyDocumentSettingPlugin
7655 * } );
7656 * ```
7657 *
7658 * @example
7659 * ```jsx
7660 * // Using ESNext syntax
7661 * import { registerPlugin } from '@wordpress/plugins';
7662 * import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
7663 *
7664 * const MyDocumentSettingTest = () => (
7665 * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel">
7666 * <p>My Document Setting Panel</p>
7667 * </PluginDocumentSettingPanel>
7668 * );
7669 *
7670 * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
7671 * ```
7672 *
7673 * @return {WPComponent} The component to be rendered.
7674 */
7675
7676
7677 const PluginDocumentSettingPanel = (0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
7678 if (undefined === ownProps.name) {
7679 typeof process !== "undefined" && process.env && "production" !== "production" ? 0 : void 0;
7680 }
7681
7682 return {
7683 icon: ownProps.icon || context.icon,
7684 panelName: `${context.name}/${ownProps.name}`
7685 };
7686 }), (0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
7687 let {
7688 panelName
7689 } = _ref2;
7690 return {
7691 opened: select(store_store).isEditorPanelOpened(panelName),
7692 isEnabled: select(store_store).isEditorPanelEnabled(panelName)
7693 };
7694 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref3) => {
7695 let {
7696 panelName
7697 } = _ref3;
7698 return {
7699 onToggle() {
7700 return dispatch(store_store).toggleEditorPanelOpened(panelName);
7701 }
7702
7703 };
7704 }))(PluginDocumentSettingFill);
7705 PluginDocumentSettingPanel.Slot = plugin_document_setting_panel_Slot;
7706 /* harmony default export */ var plugin_document_setting_panel = (PluginDocumentSettingPanel);
7707
7708 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/plugin-sidebar/index.js
7709
7710
7711
7712 /**
7713 * WordPress dependencies
7714 */
7715
7716
7717
7718
7719
7720 /**
7721 * Internal dependencies
7722 */
7723
7724
7725 /**
7726 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
7727 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
7728 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
7729 *
7730 * ```js
7731 * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
7732 * ```
7733 *
7734 * @see PluginSidebarMoreMenuItem
7735 *
7736 * @param {Object} props Element props.
7737 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
7738 * @param {string} [props.className] An optional class name added to the sidebar body.
7739 * @param {string} props.title Title displayed at the top of the sidebar.
7740 * @param {boolean} [props.isPinnable=true] Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item.
7741 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
7742 *
7743 * @example
7744 * ```js
7745 * // Using ES5 syntax
7746 * var __ = wp.i18n.__;
7747 * var el = wp.element.createElement;
7748 * var PanelBody = wp.components.PanelBody;
7749 * var PluginSidebar = wp.editPost.PluginSidebar;
7750 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
7751 *
7752 * function MyPluginSidebar() {
7753 * return el(
7754 * PluginSidebar,
7755 * {
7756 * name: 'my-sidebar',
7757 * title: 'My sidebar title',
7758 * icon: moreIcon,
7759 * },
7760 * el(
7761 * PanelBody,
7762 * {},
7763 * __( 'My sidebar content' )
7764 * )
7765 * );
7766 * }
7767 * ```
7768 *
7769 * @example
7770 * ```jsx
7771 * // Using ESNext syntax
7772 * import { __ } from '@wordpress/i18n';
7773 * import { PanelBody } from '@wordpress/components';
7774 * import { PluginSidebar } from '@wordpress/edit-post';
7775 * import { more } from '@wordpress/icons';
7776 *
7777 * const MyPluginSidebar = () => (
7778 * <PluginSidebar
7779 * name="my-sidebar"
7780 * title="My sidebar title"
7781 * icon={ more }
7782 * >
7783 * <PanelBody>
7784 * { __( 'My sidebar content' ) }
7785 * </PanelBody>
7786 * </PluginSidebar>
7787 * );
7788 * ```
7789 */
7790
7791 function PluginSidebarEditPost(_ref) {
7792 let {
7793 className,
7794 ...props
7795 } = _ref;
7796 const {
7797 postTitle,
7798 shortcut,
7799 showIconLabels
7800 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7801 return {
7802 postTitle: select(external_wp_editor_namespaceObject.store).getEditedPostAttribute('title'),
7803 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-post/toggle-sidebar'),
7804 showIconLabels: select(store_store).isFeatureActive('showIconLabels')
7805 };
7806 }, []);
7807 return (0,external_wp_element_namespaceObject.createElement)(complementary_area, _extends({
7808 panelClassName: className,
7809 className: "edit-post-sidebar",
7810 smallScreenTitle: postTitle || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
7811 scope: "core/edit-post",
7812 toggleShortcut: shortcut,
7813 showIconLabels: showIconLabels
7814 }, props));
7815 }
7816
7817 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/template/actions.js
7818
7819
7820 /**
7821 * External dependencies
7822 */
7823
7824 /**
7825 * WordPress dependencies
7826 */
7827
7828
7829
7830
7831
7832
7833
7834 /**
7835 * Internal dependencies
7836 */
7837
7838
7839
7840
7841 function PostTemplateActions(_ref) {
7842 let {
7843 isPostsPage
7844 } = _ref;
7845 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
7846 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
7847 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
7848 const {
7849 template,
7850 supportsTemplateMode,
7851 defaultTemplate
7852 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7853 var _getPostType$viewable, _getPostType;
7854
7855 const {
7856 getCurrentPostType,
7857 getEditorSettings
7858 } = select(external_wp_editor_namespaceObject.store);
7859 const {
7860 getPostType
7861 } = select(external_wp_coreData_namespaceObject.store);
7862 const {
7863 getEditedPostTemplate
7864 } = select(store_store);
7865 const isViewable = (_getPostType$viewable = (_getPostType = getPostType(getCurrentPostType())) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
7866
7867 const _supportsTemplateMode = getEditorSettings().supportsTemplateMode && isViewable;
7868
7869 return {
7870 template: _supportsTemplateMode && getEditedPostTemplate(),
7871 supportsTemplateMode: _supportsTemplateMode,
7872 defaultTemplate: getEditorSettings().defaultBlockTemplate
7873 };
7874 }, []);
7875 const {
7876 __unstableCreateTemplate,
7877 __unstableSwitchToTemplateMode
7878 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7879
7880 if (!supportsTemplateMode) {
7881 return null;
7882 }
7883
7884 const defaultTitle = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
7885
7886 async function onCreateTemplate(event) {
7887 event.preventDefault();
7888
7889 if (isBusy) {
7890 return;
7891 }
7892
7893 setIsBusy(true);
7894 const newTemplateContent = defaultTemplate !== null && defaultTemplate !== void 0 ? defaultTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
7895 tagName: 'header',
7896 layout: {
7897 inherit: true
7898 }
7899 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/site-title'), (0,external_wp_blocks_namespaceObject.createBlock)('core/site-tagline')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/separator'), (0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
7900 tagName: 'main'
7901 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
7902 layout: {
7903 inherit: true
7904 }
7905 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', {
7906 layout: {
7907 inherit: true
7908 }
7909 })])]);
7910 await __unstableCreateTemplate({
7911 slug: 'wp-custom-template-' + (0,external_lodash_namespaceObject.kebabCase)(title || defaultTitle),
7912 content: newTemplateContent,
7913 title: title || defaultTitle
7914 });
7915 setIsBusy(false);
7916 setIsModalOpen(false);
7917
7918 __unstableSwitchToTemplateMode(true);
7919 }
7920
7921 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
7922 className: "edit-post-template__actions"
7923 }, !!template && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7924 variant: "link",
7925 onClick: () => __unstableSwitchToTemplateMode()
7926 }, (0,external_wp_i18n_namespaceObject.__)('Edit')), !isPostsPage && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7927 variant: "link",
7928 onClick: () => setIsModalOpen(true)
7929 },
7930 /* translators: button to create a new template */
7931 (0,external_wp_i18n_namespaceObject._x)('New', 'action'))), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
7932 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
7933 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
7934 onRequestClose: () => {
7935 setIsModalOpen(false);
7936 setTitle('');
7937 },
7938 overlayClassName: "edit-post-template__modal"
7939 }, (0,external_wp_element_namespaceObject.createElement)("form", {
7940 onSubmit: onCreateTemplate
7941 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
7942 align: "flex-start",
7943 gap: 8
7944 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
7945 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
7946 value: title,
7947 onChange: setTitle,
7948 placeholder: defaultTitle,
7949 disabled: isBusy,
7950 help: (0,external_wp_i18n_namespaceObject.__)('Describe the purpose of the template, e.g. "Full Width". Custom templates can be applied to any post or page.')
7951 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
7952 className: "edit-post-template__modal-actions",
7953 justify: "flex-end",
7954 expanded: false
7955 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7956 variant: "tertiary",
7957 onClick: () => {
7958 setIsModalOpen(false);
7959 setTitle('');
7960 }
7961 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7962 variant: "primary",
7963 type: "submit",
7964 isBusy: isBusy,
7965 "aria-disabled": isBusy
7966 }, (0,external_wp_i18n_namespaceObject.__)('Create')))))));
7967 }
7968
7969 /* harmony default export */ var actions = (PostTemplateActions);
7970
7971 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/template/index.js
7972
7973
7974 /**
7975 * External dependencies
7976 */
7977
7978 /**
7979 * WordPress dependencies
7980 */
7981
7982
7983
7984
7985
7986
7987
7988 /**
7989 * Internal dependencies
7990 */
7991
7992
7993
7994 /**
7995 * Module Constants
7996 */
7997
7998 const template_PANEL_NAME = 'template';
7999 function TemplatePanel() {
8000 const {
8001 isEnabled,
8002 isOpened,
8003 isPostsPage,
8004 selectedTemplate,
8005 availableTemplates,
8006 fetchedTemplates,
8007 isViewable,
8008 template,
8009 supportsTemplateMode,
8010 canUserCreate
8011 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8012 var _getPostType$viewable, _getPostType;
8013
8014 const {
8015 isEditorPanelEnabled,
8016 isEditorPanelOpened,
8017 getEditedPostTemplate
8018 } = select(store_store);
8019 const {
8020 getEditedPostAttribute,
8021 getEditorSettings,
8022 getCurrentPostId,
8023 getCurrentPostType
8024 } = select(external_wp_editor_namespaceObject.store);
8025 const {
8026 getPostType,
8027 getEntityRecord,
8028 getEntityRecords,
8029 canUser
8030 } = select(external_wp_coreData_namespaceObject.store);
8031 const currentPostId = getCurrentPostId();
8032 const currentPostType = getCurrentPostType();
8033 const settings = getEntityRecord('root', 'site');
8034
8035 const _isViewable = (_getPostType$viewable = (_getPostType = getPostType(currentPostType)) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
8036
8037 const _supportsTemplateMode = select(external_wp_editor_namespaceObject.store).getEditorSettings().supportsTemplateMode && _isViewable;
8038
8039 const templateRecords = getEntityRecords('postType', 'wp_template', {
8040 post_type: currentPostType,
8041 per_page: -1
8042 });
8043 return {
8044 isEnabled: isEditorPanelEnabled(template_PANEL_NAME),
8045 isOpened: isEditorPanelOpened(template_PANEL_NAME),
8046 isPostsPage: currentPostId === (settings === null || settings === void 0 ? void 0 : settings.page_for_posts),
8047 selectedTemplate: getEditedPostAttribute('template'),
8048 availableTemplates: getEditorSettings().availableTemplates,
8049 fetchedTemplates: templateRecords,
8050 template: _supportsTemplateMode && getEditedPostTemplate(),
8051 isViewable: _isViewable,
8052 supportsTemplateMode: _supportsTemplateMode,
8053 canUserCreate: canUser('create', 'templates')
8054 };
8055 }, []);
8056 const templates = (0,external_wp_element_namespaceObject.useMemo)(() => {
8057 return { ...availableTemplates,
8058 ...(0,external_lodash_namespaceObject.fromPairs)((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(_ref => {
8059 let {
8060 slug,
8061 title
8062 } = _ref;
8063 return [slug, title.rendered];
8064 }))
8065 };
8066 }, [availableTemplates, fetchedTemplates]);
8067 const {
8068 toggleEditorPanelOpened
8069 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8070 const {
8071 editPost
8072 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store);
8073
8074 if (!isEnabled || !isViewable || (0,external_lodash_namespaceObject.isEmpty)(availableTemplates) && (!supportsTemplateMode || !canUserCreate)) {
8075 return null;
8076 }
8077
8078 const onTogglePanel = (0,external_lodash_namespaceObject.partial)(toggleEditorPanelOpened, template_PANEL_NAME);
8079
8080 let panelTitle = (0,external_wp_i18n_namespaceObject.__)('Template');
8081
8082 if (!!template) {
8083 var _template$title;
8084
8085 panelTitle = (0,external_wp_i18n_namespaceObject.sprintf)(
8086 /* translators: %s: template title */
8087 (0,external_wp_i18n_namespaceObject.__)('Template: %s'), (_template$title = template === null || template === void 0 ? void 0 : template.title) !== null && _template$title !== void 0 ? _template$title : template.slug);
8088 }
8089
8090 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
8091 title: panelTitle,
8092 opened: isOpened,
8093 onToggle: onTogglePanel
8094 }, isPostsPage ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
8095 className: "edit-post-template__notice",
8096 status: "warning",
8097 isDismissible: false
8098 }, (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
8099 hideLabelFromVision: true,
8100 label: (0,external_wp_i18n_namespaceObject.__)('Template:'),
8101 value: Object.keys(templates).includes(selectedTemplate) ? selectedTemplate : '',
8102 onChange: templateSlug => {
8103 editPost({
8104 template: templateSlug || ''
8105 });
8106 },
8107 options: (0,external_lodash_namespaceObject.map)(templates, (templateName, templateSlug) => ({
8108 value: templateSlug,
8109 label: templateName
8110 }))
8111 }), canUserCreate && (0,external_wp_element_namespaceObject.createElement)(actions, {
8112 isPostsPage: isPostsPage
8113 }));
8114 }
8115 /* harmony default export */ var template = (TemplatePanel);
8116
8117 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
8118
8119
8120 /**
8121 * WordPress dependencies
8122 */
8123
8124 const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
8125 xmlns: "http://www.w3.org/2000/svg",
8126 viewBox: "0 0 24 24"
8127 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
8128 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"
8129 }));
8130 /* harmony default export */ var library_layout = (layout);
8131
8132 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/template-summary/index.js
8133
8134
8135 /**
8136 * WordPress dependencies
8137 */
8138
8139
8140
8141 /**
8142 * Internal dependencies
8143 */
8144
8145
8146
8147 function TemplateSummary() {
8148 const template = (0,external_wp_data_namespaceObject.useSelect)(select => {
8149 const {
8150 getEditedPostTemplate
8151 } = select(store_store);
8152 return getEditedPostTemplate();
8153 }, []);
8154
8155 if (!template) {
8156 return null;
8157 }
8158
8159 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
8160 align: "flex-start",
8161 gap: "3"
8162 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(icon, {
8163 icon: library_layout
8164 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_wp_element_namespaceObject.createElement)("h2", {
8165 className: "edit-post-template-summary__title"
8166 }, (template === null || template === void 0 ? void 0 : template.title) || (template === null || template === void 0 ? void 0 : template.slug)), (0,external_wp_element_namespaceObject.createElement)("p", null, template === null || template === void 0 ? void 0 : template.description))));
8167 }
8168
8169 /* harmony default export */ var template_summary = (TemplateSummary);
8170
8171 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/settings-sidebar/index.js
8172
8173
8174 /**
8175 * WordPress dependencies
8176 */
8177
8178
8179
8180
8181
8182 /**
8183 * Internal dependencies
8184 */
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203 const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
8204 web: true,
8205 native: false
8206 });
8207
8208 const SettingsSidebar = () => {
8209 const {
8210 sidebarName,
8211 keyboardShortcut,
8212 isTemplateMode
8213 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8214 // The settings sidebar is used by the edit-post/document and edit-post/block sidebars.
8215 // sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.
8216 // If one of the two sidebars is active the component will contain the content of that sidebar.
8217 // When neither of the the two sidebars is active we can not simply return null, because the PluginSidebarEditPost
8218 // component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName
8219 // should contain the sidebar that will be active when the toggle button is pressed. If a block
8220 // is selected, that should be edit-post/block otherwise it's edit-post/document.
8221 let sidebar = select(store).getActiveComplementaryArea(store_store.name);
8222
8223 if (!['edit-post/document', 'edit-post/block'].includes(sidebar)) {
8224 if (select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()) {
8225 sidebar = 'edit-post/block';
8226 }
8227
8228 sidebar = 'edit-post/document';
8229 }
8230
8231 const shortcut = select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-post/toggle-sidebar');
8232 return {
8233 sidebarName: sidebar,
8234 keyboardShortcut: shortcut,
8235 isTemplateMode: select(store_store).isEditingTemplate()
8236 };
8237 }, []);
8238 return (0,external_wp_element_namespaceObject.createElement)(PluginSidebarEditPost, {
8239 identifier: sidebarName,
8240 header: (0,external_wp_element_namespaceObject.createElement)(settings_header, {
8241 sidebarName: sidebarName
8242 }),
8243 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings'),
8244 headerClassName: "edit-post-sidebar__panel-tabs"
8245 /* translators: button label text should, if possible, be under 16 characters. */
8246 ,
8247 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
8248 toggleShortcut: keyboardShortcut,
8249 icon: library_cog,
8250 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT
8251 }, !isTemplateMode && sidebarName === 'edit-post/document' && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(post_status, null), (0,external_wp_element_namespaceObject.createElement)(template, null), (0,external_wp_element_namespaceObject.createElement)(plugin_document_setting_panel.Slot, null), (0,external_wp_element_namespaceObject.createElement)(last_revision, null), (0,external_wp_element_namespaceObject.createElement)(post_link, null), (0,external_wp_element_namespaceObject.createElement)(post_taxonomies, null), (0,external_wp_element_namespaceObject.createElement)(featured_image, null), (0,external_wp_element_namespaceObject.createElement)(post_excerpt, null), (0,external_wp_element_namespaceObject.createElement)(discussion_panel, null), (0,external_wp_element_namespaceObject.createElement)(page_attributes, null), (0,external_wp_element_namespaceObject.createElement)(MetaBoxes, {
8252 location: "side"
8253 })), isTemplateMode && sidebarName === 'edit-post/document' && (0,external_wp_element_namespaceObject.createElement)(template_summary, null), sidebarName === 'edit-post/block' && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null));
8254 };
8255
8256 /* harmony default export */ var settings_sidebar = (SettingsSidebar);
8257
8258 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/welcome-guide/image.js
8259
8260 function WelcomeGuideImage(_ref) {
8261 let {
8262 nonAnimatedSrc,
8263 animatedSrc
8264 } = _ref;
8265 return (0,external_wp_element_namespaceObject.createElement)("picture", {
8266 className: "edit-post-welcome-guide__image"
8267 }, (0,external_wp_element_namespaceObject.createElement)("source", {
8268 srcSet: nonAnimatedSrc,
8269 media: "(prefers-reduced-motion: reduce)"
8270 }), (0,external_wp_element_namespaceObject.createElement)("img", {
8271 src: animatedSrc,
8272 width: "312",
8273 height: "240",
8274 alt: ""
8275 }));
8276 }
8277
8278 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/welcome-guide/default.js
8279
8280
8281 /**
8282 * WordPress dependencies
8283 */
8284
8285
8286
8287
8288 /**
8289 * Internal dependencies
8290 */
8291
8292
8293
8294 function WelcomeGuideDefault() {
8295 const {
8296 toggleFeature
8297 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8298 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
8299 className: "edit-post-welcome-guide",
8300 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the block editor'),
8301 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'),
8302 onFinish: () => toggleFeature('welcomeGuide'),
8303 pages: [{
8304 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
8305 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
8306 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
8307 }),
8308 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
8309 className: "edit-post-welcome-guide__heading"
8310 }, (0,external_wp_i18n_namespaceObject.__)('Welcome to the block editor')), (0,external_wp_element_namespaceObject.createElement)("p", {
8311 className: "edit-post-welcome-guide__text"
8312 }, (0,external_wp_i18n_namespaceObject.__)('In the WordPress editor, each paragraph, image, or video is presented as a distinct “block” of content.')))
8313 }, {
8314 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
8315 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
8316 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
8317 }),
8318 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
8319 className: "edit-post-welcome-guide__heading"
8320 }, (0,external_wp_i18n_namespaceObject.__)('Make each block your own')), (0,external_wp_element_namespaceObject.createElement)("p", {
8321 className: "edit-post-welcome-guide__text"
8322 }, (0,external_wp_i18n_namespaceObject.__)('Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.')))
8323 }, {
8324 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
8325 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
8326 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
8327 }),
8328 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
8329 className: "edit-post-welcome-guide__heading"
8330 }, (0,external_wp_i18n_namespaceObject.__)('Get to know the block library')), (0,external_wp_element_namespaceObject.createElement)("p", {
8331 className: "edit-post-welcome-guide__text"
8332 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'), {
8333 InserterIconImage: (0,external_wp_element_namespaceObject.createElement)("img", {
8334 alt: (0,external_wp_i18n_namespaceObject.__)('inserter'),
8335 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A"
8336 })
8337 })))
8338 }, {
8339 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
8340 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
8341 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
8342 }),
8343 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
8344 className: "edit-post-welcome-guide__heading"
8345 }, (0,external_wp_i18n_namespaceObject.__)('Learn how to use the block editor')), (0,external_wp_element_namespaceObject.createElement)("p", {
8346 className: "edit-post-welcome-guide__text"
8347 }, (0,external_wp_i18n_namespaceObject.__)('New to the block editor? Want to learn more about using it? '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
8348 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/wordpress-editor/')
8349 }, (0,external_wp_i18n_namespaceObject.__)("Here's a detailed guide."))))
8350 }]
8351 });
8352 }
8353
8354 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/welcome-guide/template.js
8355
8356
8357 /**
8358 * WordPress dependencies
8359 */
8360
8361
8362
8363 /**
8364 * Internal dependencies
8365 */
8366
8367
8368
8369 function WelcomeGuideTemplate() {
8370 const {
8371 toggleFeature
8372 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8373 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
8374 className: "edit-template-welcome-guide",
8375 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the template editor'),
8376 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'),
8377 onFinish: () => toggleFeature('welcomeGuideTemplate'),
8378 pages: [{
8379 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
8380 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.svg",
8381 animatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.gif"
8382 }),
8383 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
8384 className: "edit-post-welcome-guide__heading"
8385 }, (0,external_wp_i18n_namespaceObject.__)('Welcome to the template editor')), (0,external_wp_element_namespaceObject.createElement)("p", {
8386 className: "edit-post-welcome-guide__text"
8387 }, (0,external_wp_i18n_namespaceObject.__)('Templates help define the layout of the site. You can customize all aspects of your posts and pages using blocks and patterns in this editor.')))
8388 }]
8389 });
8390 }
8391
8392 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/welcome-guide/index.js
8393
8394
8395 /**
8396 * WordPress dependencies
8397 */
8398
8399 /**
8400 * Internal dependencies
8401 */
8402
8403
8404
8405
8406 function WelcomeGuide() {
8407 const {
8408 isActive,
8409 isTemplateMode
8410 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8411 const {
8412 isFeatureActive,
8413 isEditingTemplate
8414 } = select(store_store);
8415
8416 const _isTemplateMode = isEditingTemplate();
8417
8418 const feature = _isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide';
8419 return {
8420 isActive: isFeatureActive(feature),
8421 isTemplateMode: _isTemplateMode
8422 };
8423 }, []);
8424
8425 if (!isActive) {
8426 return null;
8427 }
8428
8429 return isTemplateMode ? (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideTemplate, null) : (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideDefault, null);
8430 }
8431
8432 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/plugin-post-publish-panel/index.js
8433
8434
8435 /**
8436 * WordPress dependencies
8437 */
8438
8439
8440
8441 const {
8442 Fill: plugin_post_publish_panel_Fill,
8443 Slot: plugin_post_publish_panel_Slot
8444 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostPublishPanel');
8445
8446 const PluginPostPublishPanelFill = _ref => {
8447 let {
8448 children,
8449 className,
8450 title,
8451 initialOpen = false,
8452 icon
8453 } = _ref;
8454 return (0,external_wp_element_namespaceObject.createElement)(plugin_post_publish_panel_Fill, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
8455 className: className,
8456 initialOpen: initialOpen || !title,
8457 title: title,
8458 icon: icon
8459 }, children));
8460 };
8461 /**
8462 * Renders provided content to the post-publish panel in the publish flow
8463 * (side panel that opens after a user publishes the post).
8464 *
8465 * @param {Object} props Component properties.
8466 * @param {string} [props.className] An optional class name added to the panel.
8467 * @param {string} [props.title] Title displayed at the top of the panel.
8468 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
8469 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
8470 *
8471 * @example
8472 * ```js
8473 * // Using ES5 syntax
8474 * var __ = wp.i18n.__;
8475 * var PluginPostPublishPanel = wp.editPost.PluginPostPublishPanel;
8476 *
8477 * function MyPluginPostPublishPanel() {
8478 * return wp.element.createElement(
8479 * PluginPostPublishPanel,
8480 * {
8481 * className: 'my-plugin-post-publish-panel',
8482 * title: __( 'My panel title' ),
8483 * initialOpen: true,
8484 * },
8485 * __( 'My panel content' )
8486 * );
8487 * }
8488 * ```
8489 *
8490 * @example
8491 * ```jsx
8492 * // Using ESNext syntax
8493 * import { __ } from '@wordpress/i18n';
8494 * import { PluginPostPublishPanel } from '@wordpress/edit-post';
8495 *
8496 * const MyPluginPostPublishPanel = () => (
8497 * <PluginPostPublishPanel
8498 * className="my-plugin-post-publish-panel"
8499 * title={ __( 'My panel title' ) }
8500 * initialOpen={ true }
8501 * >
8502 * { __( 'My panel content' ) }
8503 * </PluginPostPublishPanel>
8504 * );
8505 * ```
8506 *
8507 * @return {WPComponent} The component to be rendered.
8508 */
8509
8510
8511 const PluginPostPublishPanel = (0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
8512 return {
8513 icon: ownProps.icon || context.icon
8514 };
8515 }))(PluginPostPublishPanelFill);
8516 PluginPostPublishPanel.Slot = plugin_post_publish_panel_Slot;
8517 /* harmony default export */ var plugin_post_publish_panel = (PluginPostPublishPanel);
8518
8519 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/sidebar/plugin-pre-publish-panel/index.js
8520
8521
8522 /**
8523 * WordPress dependencies
8524 */
8525
8526
8527
8528 const {
8529 Fill: plugin_pre_publish_panel_Fill,
8530 Slot: plugin_pre_publish_panel_Slot
8531 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPrePublishPanel');
8532
8533 const PluginPrePublishPanelFill = _ref => {
8534 let {
8535 children,
8536 className,
8537 title,
8538 initialOpen = false,
8539 icon
8540 } = _ref;
8541 return (0,external_wp_element_namespaceObject.createElement)(plugin_pre_publish_panel_Fill, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
8542 className: className,
8543 initialOpen: initialOpen || !title,
8544 title: title,
8545 icon: icon
8546 }, children));
8547 };
8548 /**
8549 * Renders provided content to the pre-publish side panel in the publish flow
8550 * (side panel that opens when a user first pushes "Publish" from the main editor).
8551 *
8552 * @param {Object} props Component props.
8553 * @param {string} [props.className] An optional class name added to the panel.
8554 * @param {string} [props.title] Title displayed at the top of the panel.
8555 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
8556 * When no title is provided it is always opened.
8557 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
8558 * icon slug string, or an SVG WP element, to be rendered when
8559 * the sidebar is pinned to toolbar.
8560 *
8561 * @example
8562 * ```js
8563 * // Using ES5 syntax
8564 * var __ = wp.i18n.__;
8565 * var PluginPrePublishPanel = wp.editPost.PluginPrePublishPanel;
8566 *
8567 * function MyPluginPrePublishPanel() {
8568 * return wp.element.createElement(
8569 * PluginPrePublishPanel,
8570 * {
8571 * className: 'my-plugin-pre-publish-panel',
8572 * title: __( 'My panel title' ),
8573 * initialOpen: true,
8574 * },
8575 * __( 'My panel content' )
8576 * );
8577 * }
8578 * ```
8579 *
8580 * @example
8581 * ```jsx
8582 * // Using ESNext syntax
8583 * import { __ } from '@wordpress/i18n';
8584 * import { PluginPrePublishPanel } from '@wordpress/edit-post';
8585 *
8586 * const MyPluginPrePublishPanel = () => (
8587 * <PluginPrePublishPanel
8588 * className="my-plugin-pre-publish-panel"
8589 * title={ __( 'My panel title' ) }
8590 * initialOpen={ true }
8591 * >
8592 * { __( 'My panel content' ) }
8593 * </PluginPrePublishPanel>
8594 * );
8595 * ```
8596 *
8597 * @return {WPComponent} The component to be rendered.
8598 */
8599
8600
8601 const PluginPrePublishPanel = (0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
8602 return {
8603 icon: ownProps.icon || context.icon
8604 };
8605 }))(PluginPrePublishPanelFill);
8606 PluginPrePublishPanel.Slot = plugin_pre_publish_panel_Slot;
8607 /* harmony default export */ var plugin_pre_publish_panel = (PluginPrePublishPanel);
8608
8609 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/layout/actions-panel.js
8610
8611
8612 /**
8613 * WordPress dependencies
8614 */
8615
8616
8617
8618
8619
8620 /**
8621 * Internal dependencies
8622 */
8623
8624
8625
8626
8627 const {
8628 Fill: actions_panel_Fill,
8629 Slot: actions_panel_Slot
8630 } = (0,external_wp_components_namespaceObject.createSlotFill)('ActionsPanel');
8631 const ActionsPanelFill = (/* unused pure expression or super */ null && (actions_panel_Fill));
8632 function ActionsPanel(_ref) {
8633 let {
8634 setEntitiesSavedStatesCallback,
8635 closeEntitiesSavedStates,
8636 isEntitiesSavedStatesOpen
8637 } = _ref;
8638 const {
8639 closePublishSidebar,
8640 togglePublishSidebar
8641 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8642 const {
8643 publishSidebarOpened,
8644 hasActiveMetaboxes,
8645 isSavingMetaBoxes,
8646 hasNonPostEntityChanges
8647 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8648 return {
8649 publishSidebarOpened: select(store_store).isPublishSidebarOpened(),
8650 hasActiveMetaboxes: select(store_store).hasMetaBoxes(),
8651 isSavingMetaBoxes: select(store_store).isSavingMetaBoxes(),
8652 hasNonPostEntityChanges: select(external_wp_editor_namespaceObject.store).hasNonPostEntityChanges()
8653 };
8654 }, []);
8655 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setEntitiesSavedStatesCallback(true), []); // It is ok for these components to be unmounted when not in visual use.
8656 // We don't want more than one present at a time, decide which to render.
8657
8658 let unmountableContent;
8659
8660 if (publishSidebarOpened) {
8661 unmountableContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostPublishPanel, {
8662 onClose: closePublishSidebar,
8663 forceIsDirty: hasActiveMetaboxes,
8664 forceIsSaving: isSavingMetaBoxes,
8665 PrePublishExtension: plugin_pre_publish_panel.Slot,
8666 PostPublishExtension: plugin_post_publish_panel.Slot
8667 });
8668 } else if (hasNonPostEntityChanges) {
8669 unmountableContent = (0,external_wp_element_namespaceObject.createElement)("div", {
8670 className: "edit-post-layout__toggle-entities-saved-states-panel"
8671 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
8672 variant: "secondary",
8673 className: "edit-post-layout__toggle-entities-saved-states-panel-button",
8674 onClick: openEntitiesSavedStates,
8675 "aria-expanded": false
8676 }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')));
8677 } else {
8678 unmountableContent = (0,external_wp_element_namespaceObject.createElement)("div", {
8679 className: "edit-post-layout__toggle-publish-panel"
8680 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
8681 variant: "secondary",
8682 className: "edit-post-layout__toggle-publish-panel-button",
8683 onClick: togglePublishSidebar,
8684 "aria-expanded": false
8685 }, (0,external_wp_i18n_namespaceObject.__)('Open publish panel')));
8686 } // Since EntitiesSavedStates controls its own panel, we can keep it
8687 // always mounted to retain its own component state (such as checkboxes).
8688
8689
8690 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isEntitiesSavedStatesOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, {
8691 close: closeEntitiesSavedStates
8692 }), (0,external_wp_element_namespaceObject.createElement)(actions_panel_Slot, {
8693 bubblesVirtually: true
8694 }), !isEntitiesSavedStatesOpen && unmountableContent);
8695 }
8696
8697 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/layout/index.js
8698
8699
8700 /**
8701 * External dependencies
8702 */
8703
8704 /**
8705 * WordPress dependencies
8706 */
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719 /**
8720 * Internal dependencies
8721 */
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737 const interfaceLabels = {
8738 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block library'),
8739
8740 /* translators: accessibility text for the editor top bar landmark region. */
8741 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
8742
8743 /* translators: accessibility text for the editor content landmark region. */
8744 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
8745
8746 /* translators: accessibility text for the editor settings landmark region. */
8747 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
8748
8749 /* translators: accessibility text for the editor publish landmark region. */
8750 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
8751
8752 /* translators: accessibility text for the editor footer landmark region. */
8753 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer')
8754 };
8755
8756 function Layout(_ref) {
8757 let {
8758 styles
8759 } = _ref;
8760 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
8761 const isHugeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('huge', '>=');
8762 const {
8763 openGeneralSidebar,
8764 closeGeneralSidebar,
8765 setIsInserterOpened
8766 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8767 const {
8768 createErrorNotice
8769 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8770 const {
8771 mode,
8772 isFullscreenActive,
8773 isRichEditingEnabled,
8774 sidebarIsOpened,
8775 hasActiveMetaboxes,
8776 hasFixedToolbar,
8777 previousShortcut,
8778 nextShortcut,
8779 hasBlockSelected,
8780 isInserterOpened,
8781 isListViewOpened,
8782 showIconLabels,
8783 hasReducedUI,
8784 showBlockBreadcrumbs,
8785 isTemplateMode,
8786 documentLabel
8787 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8788 const {
8789 getEditorSettings,
8790 getPostTypeLabel
8791 } = select(external_wp_editor_namespaceObject.store);
8792 const editorSettings = getEditorSettings();
8793 const postTypeLabel = getPostTypeLabel();
8794 return {
8795 isTemplateMode: select(store_store).isEditingTemplate(),
8796 hasFixedToolbar: select(store_store).isFeatureActive('fixedToolbar'),
8797 sidebarIsOpened: !!(select(store).getActiveComplementaryArea(store_store.name) || select(store_store).isPublishSidebarOpened()),
8798 isFullscreenActive: select(store_store).isFeatureActive('fullscreenMode'),
8799 isInserterOpened: select(store_store).isInserterOpened(),
8800 isListViewOpened: select(store_store).isListViewOpened(),
8801 mode: select(store_store).getEditorMode(),
8802 isRichEditingEnabled: editorSettings.richEditingEnabled,
8803 hasActiveMetaboxes: select(store_store).hasMetaBoxes(),
8804 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-post/previous-region'),
8805 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-post/next-region'),
8806 showIconLabels: select(store_store).isFeatureActive('showIconLabels'),
8807 hasReducedUI: select(store_store).isFeatureActive('reducedUI'),
8808 showBlockBreadcrumbs: select(store_store).isFeatureActive('showBlockBreadcrumbs'),
8809 // translators: Default label for the Document in the Block Breadcrumb.
8810 documentLabel: postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun')
8811 };
8812 }, []);
8813 const className = classnames_default()('edit-post-layout', 'is-mode-' + mode, {
8814 'is-sidebar-opened': sidebarIsOpened,
8815 'has-fixed-toolbar': hasFixedToolbar,
8816 'has-metaboxes': hasActiveMetaboxes,
8817 'show-icon-labels': showIconLabels
8818 });
8819
8820 const openSidebarPanel = () => openGeneralSidebar(hasBlockSelected ? 'edit-post/block' : 'edit-post/document'); // Inserter and Sidebars are mutually exclusive
8821
8822
8823 (0,external_wp_element_namespaceObject.useEffect)(() => {
8824 if (sidebarIsOpened && !isHugeViewport) {
8825 setIsInserterOpened(false);
8826 }
8827 }, [sidebarIsOpened, isHugeViewport]);
8828 (0,external_wp_element_namespaceObject.useEffect)(() => {
8829 if (isInserterOpened && !isHugeViewport) {
8830 closeGeneralSidebar();
8831 }
8832 }, [isInserterOpened, isHugeViewport]); // Local state for save panel.
8833 // Note 'truthy' callback implies an open panel.
8834
8835 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0,external_wp_element_namespaceObject.useState)(false);
8836 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(arg => {
8837 if (typeof entitiesSavedStatesCallback === 'function') {
8838 entitiesSavedStatesCallback(arg);
8839 }
8840
8841 setEntitiesSavedStatesCallback(false);
8842 }, [entitiesSavedStatesCallback]);
8843
8844 const secondarySidebar = () => {
8845 if (mode === 'visual' && isInserterOpened) {
8846 return (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null);
8847 }
8848
8849 if (mode === 'visual' && isListViewOpened) {
8850 return (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, null);
8851 }
8852
8853 return null;
8854 };
8855
8856 function onPluginAreaError(name) {
8857 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
8858 /* translators: %s: plugin name */
8859 (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
8860 }
8861
8862 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(fullscreen_mode, {
8863 isActive: isFullscreenActive
8864 }), (0,external_wp_element_namespaceObject.createElement)(browser_url, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.UnsavedChangesWarning, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.AutosaveMonitor, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.LocalAutosaveMonitor, null), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorKeyboardShortcutsRegister, null), (0,external_wp_element_namespaceObject.createElement)(settings_sidebar, null), (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
8865 className: className,
8866 labels: interfaceLabels,
8867 header: (0,external_wp_element_namespaceObject.createElement)(header, {
8868 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
8869 }),
8870 secondarySidebar: secondarySidebar(),
8871 sidebar: (!isMobileViewport || sidebarIsOpened) && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !isMobileViewport && !sidebarIsOpened && (0,external_wp_element_namespaceObject.createElement)("div", {
8872 className: "edit-post-layout__toggle-sidebar-panel"
8873 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
8874 variant: "secondary",
8875 className: "edit-post-layout__toggle-sidebar-panel-button",
8876 onClick: openSidebarPanel,
8877 "aria-expanded": false
8878 }, hasBlockSelected ? (0,external_wp_i18n_namespaceObject.__)('Open block settings') : (0,external_wp_i18n_namespaceObject.__)('Open document settings'))), (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
8879 scope: "core/edit-post"
8880 })),
8881 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
8882 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorNotices, null), (mode === 'text' || !isRichEditingEnabled) && (0,external_wp_element_namespaceObject.createElement)(text_editor, null), isRichEditingEnabled && mode === 'visual' && (0,external_wp_element_namespaceObject.createElement)(VisualEditor, {
8883 styles: styles
8884 }), !isTemplateMode && (0,external_wp_element_namespaceObject.createElement)("div", {
8885 className: "edit-post-layout__metaboxes"
8886 }, (0,external_wp_element_namespaceObject.createElement)(MetaBoxes, {
8887 location: "normal"
8888 }), (0,external_wp_element_namespaceObject.createElement)(MetaBoxes, {
8889 location: "advanced"
8890 })), isMobileViewport && sidebarIsOpened && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ScrollLock, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockStyles.Slot, {
8891 scope: "core/block-inspector"
8892 })),
8893 footer: !hasReducedUI && showBlockBreadcrumbs && !isMobileViewport && isRichEditingEnabled && mode === 'visual' && (0,external_wp_element_namespaceObject.createElement)("div", {
8894 className: "edit-post-layout__footer"
8895 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
8896 rootLabelText: documentLabel
8897 })),
8898 actions: (0,external_wp_element_namespaceObject.createElement)(ActionsPanel, {
8899 closeEntitiesSavedStates: closeEntitiesSavedStates,
8900 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
8901 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
8902 }),
8903 shortcuts: {
8904 previous: previousShortcut,
8905 next: nextShortcut
8906 }
8907 }), (0,external_wp_element_namespaceObject.createElement)(PreferencesModal, null), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal, null), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, {
8908 onError: onPluginAreaError
8909 }));
8910 }
8911
8912 /* harmony default export */ var components_layout = (Layout);
8913
8914 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/editor-initialization/listener-hooks.js
8915 /**
8916 * WordPress dependencies
8917 */
8918
8919
8920
8921
8922 /**
8923 * Internal dependencies
8924 */
8925
8926
8927 /**
8928 * This listener hook monitors for block selection and triggers the appropriate
8929 * sidebar state.
8930 *
8931 * @param {number} postId The current post id.
8932 */
8933
8934 const useBlockSelectionListener = postId => {
8935 const {
8936 hasBlockSelection,
8937 isEditorSidebarOpened
8938 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8939 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(),
8940 isEditorSidebarOpened: select(constants_STORE_NAME).isEditorSidebarOpened()
8941 }), [postId]);
8942 const {
8943 openGeneralSidebar
8944 } = (0,external_wp_data_namespaceObject.useDispatch)(constants_STORE_NAME);
8945 (0,external_wp_element_namespaceObject.useEffect)(() => {
8946 if (!isEditorSidebarOpened) {
8947 return;
8948 }
8949
8950 if (hasBlockSelection) {
8951 openGeneralSidebar('edit-post/block');
8952 } else {
8953 openGeneralSidebar('edit-post/document');
8954 }
8955 }, [hasBlockSelection, isEditorSidebarOpened]);
8956 };
8957 /**
8958 * This listener hook monitors any change in permalink and updates the view
8959 * post link in the admin bar.
8960 *
8961 * @param {number} postId
8962 */
8963
8964 const useUpdatePostLinkListener = postId => {
8965 const {
8966 newPermalink
8967 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8968 newPermalink: select(external_wp_editor_namespaceObject.store).getCurrentPost().link
8969 }), [postId]);
8970 const nodeToUpdate = (0,external_wp_element_namespaceObject.useRef)();
8971 (0,external_wp_element_namespaceObject.useEffect)(() => {
8972 nodeToUpdate.current = document.querySelector(VIEW_AS_PREVIEW_LINK_SELECTOR) || document.querySelector(VIEW_AS_LINK_SELECTOR);
8973 }, [postId]);
8974 (0,external_wp_element_namespaceObject.useEffect)(() => {
8975 if (!newPermalink || !nodeToUpdate.current) {
8976 return;
8977 }
8978
8979 nodeToUpdate.current.setAttribute('href', newPermalink);
8980 }, [newPermalink]);
8981 };
8982
8983 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/editor-initialization/index.js
8984 /**
8985 * Internal dependencies
8986 */
8987
8988 /**
8989 * Data component used for initializing the editor and re-initializes
8990 * when postId changes or on unmount.
8991 *
8992 * @param {number} postId The id of the post.
8993 * @return {null} This is a data component so does not render any ui.
8994 */
8995
8996 function EditorInitialization(_ref) {
8997 let {
8998 postId
8999 } = _ref;
9000 useBlockSelectionListener(postId);
9001 useUpdatePostLinkListener(postId);
9002 return null;
9003 }
9004
9005 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/editor.js
9006
9007
9008
9009 /**
9010 * External dependencies
9011 */
9012
9013 /**
9014 * WordPress dependencies
9015 */
9016
9017
9018
9019
9020
9021
9022
9023
9024 /**
9025 * Internal dependencies
9026 */
9027
9028
9029
9030
9031
9032 function Editor(_ref) {
9033 let {
9034 postId,
9035 postType,
9036 settings,
9037 initialEdits,
9038 onError,
9039 ...props
9040 } = _ref;
9041 const {
9042 hasFixedToolbar,
9043 focusMode,
9044 hasReducedUI,
9045 hasThemeStyles,
9046 post,
9047 preferredStyleVariations,
9048 hiddenBlockTypes,
9049 blockTypes,
9050 __experimentalLocalAutosaveInterval,
9051 keepCaretInsideBlock,
9052 isTemplateMode,
9053 template
9054 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9055 var _getPostType$viewable, _getPostType;
9056
9057 const {
9058 isFeatureActive,
9059 getPreference,
9060 __experimentalGetPreviewDeviceType,
9061 isEditingTemplate,
9062 getEditedPostTemplate
9063 } = select(store_store);
9064 const {
9065 getEntityRecord,
9066 getPostType,
9067 getEntityRecords
9068 } = select(external_wp_coreData_namespaceObject.store);
9069 const {
9070 getEditorSettings
9071 } = select(external_wp_editor_namespaceObject.store);
9072 const {
9073 getBlockTypes
9074 } = select(external_wp_blocks_namespaceObject.store);
9075 const isTemplate = ['wp_template', 'wp_template_part'].includes(postType); // Ideally the initializeEditor function should be called using the ID of the REST endpoint.
9076 // to avoid the special case.
9077
9078 let postObject;
9079
9080 if (isTemplate) {
9081 const posts = getEntityRecords('postType', postType, {
9082 wp_id: postId
9083 });
9084 postObject = posts === null || posts === void 0 ? void 0 : posts[0];
9085 } else {
9086 postObject = getEntityRecord('postType', postType, postId);
9087 }
9088
9089 const supportsTemplateMode = getEditorSettings().supportsTemplateMode;
9090 const isViewable = (_getPostType$viewable = (_getPostType = getPostType(postType)) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
9091 return {
9092 hasFixedToolbar: isFeatureActive('fixedToolbar') || __experimentalGetPreviewDeviceType() !== 'Desktop',
9093 focusMode: isFeatureActive('focusMode'),
9094 hasReducedUI: isFeatureActive('reducedUI'),
9095 hasThemeStyles: isFeatureActive('themeStyles'),
9096 preferredStyleVariations: getPreference('preferredStyleVariations'),
9097 hiddenBlockTypes: getPreference('hiddenBlockTypes'),
9098 blockTypes: getBlockTypes(),
9099 __experimentalLocalAutosaveInterval: getPreference('localAutosaveInterval'),
9100 keepCaretInsideBlock: isFeatureActive('keepCaretInsideBlock'),
9101 isTemplateMode: isEditingTemplate(),
9102 template: supportsTemplateMode && isViewable ? getEditedPostTemplate() : null,
9103 post: postObject
9104 };
9105 }, [postType, postId]);
9106 const {
9107 updatePreferredStyleVariations,
9108 setIsInserterOpened
9109 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9110 const editorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => {
9111 const result = { ...settings,
9112 __experimentalPreferredStyleVariations: {
9113 value: preferredStyleVariations,
9114 onChange: updatePreferredStyleVariations
9115 },
9116 hasFixedToolbar,
9117 focusMode,
9118 hasReducedUI,
9119 __experimentalLocalAutosaveInterval,
9120 // This is marked as experimental to give time for the quick inserter to mature.
9121 __experimentalSetIsInserterOpened: setIsInserterOpened,
9122 keepCaretInsideBlock,
9123 // Keep a reference of the `allowedBlockTypes` from the server to handle use cases
9124 // where we need to differentiate if a block is disabled by the user or some plugin.
9125 defaultAllowedBlockTypes: settings.allowedBlockTypes
9126 }; // Omit hidden block types if exists and non-empty.
9127
9128 if ((0,external_lodash_namespaceObject.size)(hiddenBlockTypes) > 0) {
9129 // Defer to passed setting for `allowedBlockTypes` if provided as
9130 // anything other than `true` (where `true` is equivalent to allow
9131 // all block types).
9132 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? (0,external_lodash_namespaceObject.map)(blockTypes, 'name') : settings.allowedBlockTypes || [];
9133 result.allowedBlockTypes = (0,external_lodash_namespaceObject.without)(defaultAllowedBlockTypes, ...hiddenBlockTypes);
9134 }
9135
9136 return result;
9137 }, [settings, hasFixedToolbar, focusMode, hasReducedUI, hiddenBlockTypes, blockTypes, preferredStyleVariations, __experimentalLocalAutosaveInterval, setIsInserterOpened, updatePreferredStyleVariations, keepCaretInsideBlock]);
9138 const styles = (0,external_wp_element_namespaceObject.useMemo)(() => {
9139 const themeStyles = [];
9140 const presetStyles = [];
9141 settings.styles.forEach(style => {
9142 if (!style.__unstableType || style.__unstableType === 'theme') {
9143 themeStyles.push(style);
9144 } else {
9145 presetStyles.push(style);
9146 }
9147 });
9148 const defaultEditorStyles = [...settings.defaultEditorStyles, ...presetStyles];
9149 return hasThemeStyles && themeStyles.length ? settings.styles : defaultEditorStyles;
9150 }, [settings, hasThemeStyles]);
9151
9152 if (!post) {
9153 return null;
9154 }
9155
9156 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.StrictMode, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorProvider, _extends({
9157 settings: editorSettings,
9158 post: post,
9159 initialEdits: initialEdits,
9160 useSubRegistry: false,
9161 __unstableTemplate: isTemplateMode ? template : undefined
9162 }, props), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.ErrorBoundary, {
9163 onError: onError
9164 }, (0,external_wp_element_namespaceObject.createElement)(EditorInitialization, {
9165 postId: postId
9166 }), (0,external_wp_element_namespaceObject.createElement)(components_layout, {
9167 styles: styles
9168 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostLockedModal, null)))));
9169 }
9170
9171 /* harmony default export */ var editor = (Editor);
9172
9173 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js
9174
9175
9176 /**
9177 * External dependencies
9178 */
9179
9180 /**
9181 * WordPress dependencies
9182 */
9183
9184
9185
9186
9187
9188 const isEverySelectedBlockAllowed = (selected, allowed) => (0,external_lodash_namespaceObject.difference)(selected, allowed).length === 0;
9189 /**
9190 * Plugins may want to add an item to the menu either for every block
9191 * or only for the specific ones provided in the `allowedBlocks` component property.
9192 *
9193 * If there are multiple blocks selected the item will be rendered if every block
9194 * is of one allowed type (not necessarily the same).
9195 *
9196 * @param {string[]} selectedBlocks Array containing the names of the blocks selected
9197 * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
9198 * @return {boolean} Whether the item will be rendered or not.
9199 */
9200
9201
9202 const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
9203 /**
9204 * Renders a new item in the block settings menu.
9205 *
9206 * @param {Object} props Component props.
9207 * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
9208 * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
9209 * @param {string} props.label The menu item text.
9210 * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
9211 * @param {boolean} [props.small] Whether to render the label or not.
9212 * @param {string} [props.role] The ARIA role for the menu item.
9213 *
9214 * @example
9215 * ```js
9216 * // Using ES5 syntax
9217 * var __ = wp.i18n.__;
9218 * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
9219 *
9220 * function doOnClick(){
9221 * // To be called when the user clicks the menu item.
9222 * }
9223 *
9224 * function MyPluginBlockSettingsMenuItem() {
9225 * return wp.element.createElement(
9226 * PluginBlockSettingsMenuItem,
9227 * {
9228 * allowedBlocks: [ 'core/paragraph' ],
9229 * icon: 'dashicon-name',
9230 * label: __( 'Menu item text' ),
9231 * onClick: doOnClick,
9232 * }
9233 * );
9234 * }
9235 * ```
9236 *
9237 * @example
9238 * ```jsx
9239 * // Using ESNext syntax
9240 * import { __ } from '@wordpress/i18n';
9241 * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
9242 *
9243 * const doOnClick = ( ) => {
9244 * // To be called when the user clicks the menu item.
9245 * };
9246 *
9247 * const MyPluginBlockSettingsMenuItem = () => (
9248 * <PluginBlockSettingsMenuItem
9249 * allowedBlocks={ [ 'core/paragraph' ] }
9250 * icon='dashicon-name'
9251 * label={ __( 'Menu item text' ) }
9252 * onClick={ doOnClick } />
9253 * );
9254 * ```
9255 *
9256 * @return {WPComponent} The component to be rendered.
9257 */
9258
9259
9260 const PluginBlockSettingsMenuItem = _ref => {
9261 let {
9262 allowedBlocks,
9263 icon,
9264 label,
9265 onClick,
9266 small,
9267 role
9268 } = _ref;
9269 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref2 => {
9270 let {
9271 selectedBlocks,
9272 onClose
9273 } = _ref2;
9274
9275 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
9276 return null;
9277 }
9278
9279 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
9280 onClick: (0,external_wp_compose_namespaceObject.compose)(onClick, onClose),
9281 icon: icon,
9282 label: small ? label : undefined,
9283 role: role
9284 }, !small && label);
9285 });
9286 };
9287
9288 /* harmony default export */ var plugin_block_settings_menu_item = (PluginBlockSettingsMenuItem);
9289
9290 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/plugin-more-menu-item/index.js
9291 /**
9292 * WordPress dependencies
9293 */
9294
9295
9296
9297 /**
9298 * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
9299 * The text within the component appears as the menu item label.
9300 *
9301 * @param {Object} props Component properties.
9302 * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
9303 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
9304 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
9305 * @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/menu-item/README.md) component.
9306 *
9307 * @example
9308 * ```js
9309 * // Using ES5 syntax
9310 * var __ = wp.i18n.__;
9311 * var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;
9312 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
9313 *
9314 * function onButtonClick() {
9315 * alert( 'Button clicked.' );
9316 * }
9317 *
9318 * function MyButtonMoreMenuItem() {
9319 * return wp.element.createElement(
9320 * PluginMoreMenuItem,
9321 * {
9322 * icon: moreIcon,
9323 * onClick: onButtonClick,
9324 * },
9325 * __( 'My button title' )
9326 * );
9327 * }
9328 * ```
9329 *
9330 * @example
9331 * ```jsx
9332 * // Using ESNext syntax
9333 * import { __ } from '@wordpress/i18n';
9334 * import { PluginMoreMenuItem } from '@wordpress/edit-post';
9335 * import { more } from '@wordpress/icons';
9336 *
9337 * function onButtonClick() {
9338 * alert( 'Button clicked.' );
9339 * }
9340 *
9341 * const MyButtonMoreMenuItem = () => (
9342 * <PluginMoreMenuItem
9343 * icon={ more }
9344 * onClick={ onButtonClick }
9345 * >
9346 * { __( 'My button title' ) }
9347 * </PluginMoreMenuItem>
9348 * );
9349 * ```
9350 *
9351 * @return {WPComponent} The component to be rendered.
9352 */
9353
9354 /* harmony default export */ var plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
9355 return {
9356 icon: ownProps.icon || context.icon,
9357 name: 'core/edit-post/plugin-more-menu'
9358 };
9359 }))(action_item));
9360
9361 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/components/header/plugin-sidebar-more-menu-item/index.js
9362
9363
9364
9365 /**
9366 * WordPress dependencies
9367 */
9368
9369 /**
9370 * Renders a menu item in `Plugins` group in `More Menu` drop down,
9371 * and can be used to activate the corresponding `PluginSidebar` component.
9372 * The text within the component appears as the menu item label.
9373 *
9374 * @param {Object} props Component props.
9375 * @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar.
9376 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
9377 *
9378 * @example
9379 * ```js
9380 * // Using ES5 syntax
9381 * var __ = wp.i18n.__;
9382 * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
9383 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
9384 *
9385 * function MySidebarMoreMenuItem() {
9386 * return wp.element.createElement(
9387 * PluginSidebarMoreMenuItem,
9388 * {
9389 * target: 'my-sidebar',
9390 * icon: moreIcon,
9391 * },
9392 * __( 'My sidebar title' )
9393 * )
9394 * }
9395 * ```
9396 *
9397 * @example
9398 * ```jsx
9399 * // Using ESNext syntax
9400 * import { __ } from '@wordpress/i18n';
9401 * import { PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
9402 * import { more } from '@wordpress/icons';
9403 *
9404 * const MySidebarMoreMenuItem = () => (
9405 * <PluginSidebarMoreMenuItem
9406 * target="my-sidebar"
9407 * icon={ more }
9408 * >
9409 * { __( 'My sidebar title' ) }
9410 * </PluginSidebarMoreMenuItem>
9411 * );
9412 * ```
9413 *
9414 * @return {WPComponent} The component to be rendered.
9415 */
9416
9417 function PluginSidebarMoreMenuItem(props) {
9418 return (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem // Menu item is marked with unstable prop for backward compatibility.
9419 // @see https://github.com/WordPress/gutenberg/issues/14457
9420 , _extends({
9421 __unstableExplicitMenuItem: true,
9422 scope: "core/edit-post"
9423 }, props));
9424 }
9425
9426 ;// CONCATENATED MODULE: ./packages/edit-post/build-module/index.js
9427
9428
9429 /**
9430 * WordPress dependencies
9431 */
9432
9433
9434
9435
9436
9437
9438 /**
9439 * Internal dependencies
9440 */
9441
9442
9443
9444
9445
9446 /**
9447 * Reinitializes the editor after the user chooses to reboot the editor after
9448 * an unhandled error occurs, replacing previously mounted editor element using
9449 * an initial state from prior to the crash.
9450 *
9451 * @param {Object} postType Post type of the post to edit.
9452 * @param {Object} postId ID of the post to edit.
9453 * @param {Element} target DOM node in which editor is rendered.
9454 * @param {?Object} settings Editor settings object.
9455 * @param {Object} initialEdits Programmatic edits to apply initially, to be
9456 * considered as non-user-initiated (bypass for
9457 * unsaved changes prompt).
9458 */
9459
9460 function reinitializeEditor(postType, postId, target, settings, initialEdits) {
9461 (0,external_wp_element_namespaceObject.unmountComponentAtNode)(target);
9462 const reboot = reinitializeEditor.bind(null, postType, postId, target, settings, initialEdits);
9463 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(editor, {
9464 settings: settings,
9465 onError: reboot,
9466 postId: postId,
9467 postType: postType,
9468 initialEdits: initialEdits,
9469 recovery: true
9470 }), target);
9471 }
9472 /**
9473 * Initializes and returns an instance of Editor.
9474 *
9475 * @param {string} id Unique identifier for editor instance.
9476 * @param {string} postType Post type of the post to edit.
9477 * @param {Object} postId ID of the post to edit.
9478 * @param {?Object} settings Editor settings object.
9479 * @param {Object} initialEdits Programmatic edits to apply initially, to be
9480 * considered as non-user-initiated (bypass for
9481 * unsaved changes prompt).
9482 */
9483
9484 function initializeEditor(id, postType, postId, settings, initialEdits) {
9485 // Prevent adding template part in the post editor.
9486 // Only add the filter when the post editor is initialized, not imported.
9487 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (can, blockType) => {
9488 if (!(0,external_wp_data_namespaceObject.select)(store_store).isEditingTemplate() && blockType.name === 'core/template-part') {
9489 return false;
9490 }
9491
9492 return can;
9493 });
9494 const target = document.getElementById(id);
9495 const reboot = reinitializeEditor.bind(null, postType, postId, target, settings, initialEdits);
9496 (0,external_wp_data_namespaceObject.dispatch)(store).setFeatureDefaults('core/edit-post', {
9497 fixedToolbar: false,
9498 welcomeGuide: true,
9499 fullscreenMode: true,
9500 showIconLabels: false,
9501 themeStyles: true,
9502 showBlockBreadcrumbs: true,
9503 welcomeGuideTemplate: true
9504 });
9505
9506 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
9507
9508 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
9509
9510 if (true) {
9511 (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)({
9512 enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks
9513 });
9514 } // Show a console log warning if the browser is not in Standards rendering mode.
9515
9516
9517 const documentMode = document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
9518
9519 if (documentMode !== 'Standards') {
9520 // eslint-disable-next-line no-console
9521 console.warn("Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.");
9522 } // This is a temporary fix for a couple of issues specific to Webkit on iOS.
9523 // Without this hack the browser scrolls the mobile toolbar off-screen.
9524 // Once supported in Safari we can replace this in favor of preventScroll.
9525 // For details see issue #18632 and PR #18686
9526 // Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.
9527 // But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.
9528
9529
9530 const isIphone = window.navigator.userAgent.indexOf('iPhone') !== -1;
9531
9532 if (isIphone) {
9533 window.addEventListener('scroll', event => {
9534 const editorScrollContainer = document.getElementsByClassName('interface-interface-skeleton__body')[0];
9535
9536 if (event.target === document) {
9537 // Scroll element into view by scrolling the editor container by the same amount
9538 // that Mobile Safari tried to scroll the html element upwards.
9539 if (window.scrollY > 100) {
9540 editorScrollContainer.scrollTop = editorScrollContainer.scrollTop + window.scrollY;
9541 } // Undo unwanted scroll on html element, but only in the visual editor.
9542
9543
9544 if (document.getElementsByClassName('is-mode-visual')[0]) {
9545 window.scrollTo(0, 0);
9546 }
9547 }
9548 });
9549 }
9550
9551 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(editor, {
9552 settings: settings,
9553 onError: reboot,
9554 postId: postId,
9555 postType: postType,
9556 initialEdits: initialEdits
9557 }), target);
9558 }
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571 }();
9572 (window.wp = window.wp || {}).editPost = __webpack_exports__;
9573 /******/ })()
9574 ;