PluginProbe
Gutenberg / 20.0.1
Gutenberg v20.0.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 20.0.1, at build/edit-post/index.js

3,494 lines 119.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ // The require scope
4 /******/ var __webpack_require__ = {};
5 /******/
6 /************************************************************************/
7 /******/ /* webpack/runtime/compat get default export */
8 /******/ (() => {
9 /******/ // getDefaultExport function for compatibility with non-harmony modules
10 /******/ __webpack_require__.n = (module) => {
11 /******/ var getter = module && module.__esModule ?
12 /******/ () => (module['default']) :
13 /******/ () => (module);
14 /******/ __webpack_require__.d(getter, { a: getter });
15 /******/ return getter;
16 /******/ };
17 /******/ })();
18 /******/
19 /******/ /* webpack/runtime/define property getters */
20 /******/ (() => {
21 /******/ // define getter functions for harmony exports
22 /******/ __webpack_require__.d = (exports, definition) => {
23 /******/ for(var key in definition) {
24 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
26 /******/ }
27 /******/ }
28 /******/ };
29 /******/ })();
30 /******/
31 /******/ /* webpack/runtime/hasOwnProperty shorthand */
32 /******/ (() => {
33 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
34 /******/ })();
35 /******/
36 /******/ /* webpack/runtime/make namespace object */
37 /******/ (() => {
38 /******/ // define __esModule on exports
39 /******/ __webpack_require__.r = (exports) => {
40 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
41 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
42 /******/ }
43 /******/ Object.defineProperty(exports, '__esModule', { value: true });
44 /******/ };
45 /******/ })();
46 /******/
47 /************************************************************************/
48 var __webpack_exports__ = {};
49 // ESM COMPAT FLAG
50 __webpack_require__.r(__webpack_exports__);
51
52 // EXPORTS
53 __webpack_require__.d(__webpack_exports__, {
54 PluginBlockSettingsMenuItem: () => (/* reexport */ PluginBlockSettingsMenuItem),
55 PluginDocumentSettingPanel: () => (/* reexport */ PluginDocumentSettingPanel),
56 PluginMoreMenuItem: () => (/* reexport */ PluginMoreMenuItem),
57 PluginPostPublishPanel: () => (/* reexport */ PluginPostPublishPanel),
58 PluginPostStatusInfo: () => (/* reexport */ PluginPostStatusInfo),
59 PluginPrePublishPanel: () => (/* reexport */ PluginPrePublishPanel),
60 PluginSidebar: () => (/* reexport */ PluginSidebar),
61 PluginSidebarMoreMenuItem: () => (/* reexport */ PluginSidebarMoreMenuItem),
62 __experimentalFullscreenModeClose: () => (/* reexport */ fullscreen_mode_close),
63 __experimentalMainDashboardButton: () => (/* binding */ __experimentalMainDashboardButton),
64 __experimentalPluginPostExcerpt: () => (/* reexport */ __experimentalPluginPostExcerpt),
65 initializeEditor: () => (/* binding */ initializeEditor),
66 reinitializeEditor: () => (/* binding */ reinitializeEditor),
67 store: () => (/* reexport */ store)
68 });
69
70 // NAMESPACE OBJECT: ./packages/edit-post/build-module/store/actions.js
71 var actions_namespaceObject = {};
72 __webpack_require__.r(actions_namespaceObject);
73 __webpack_require__.d(actions_namespaceObject, {
74 __experimentalSetPreviewDeviceType: () => (__experimentalSetPreviewDeviceType),
75 __unstableCreateTemplate: () => (__unstableCreateTemplate),
76 closeGeneralSidebar: () => (closeGeneralSidebar),
77 closeModal: () => (closeModal),
78 closePublishSidebar: () => (closePublishSidebar),
79 hideBlockTypes: () => (hideBlockTypes),
80 initializeMetaBoxes: () => (initializeMetaBoxes),
81 metaBoxUpdatesFailure: () => (metaBoxUpdatesFailure),
82 metaBoxUpdatesSuccess: () => (metaBoxUpdatesSuccess),
83 openGeneralSidebar: () => (openGeneralSidebar),
84 openModal: () => (openModal),
85 openPublishSidebar: () => (openPublishSidebar),
86 removeEditorPanel: () => (removeEditorPanel),
87 requestMetaBoxUpdates: () => (requestMetaBoxUpdates),
88 setAvailableMetaBoxesPerLocation: () => (setAvailableMetaBoxesPerLocation),
89 setIsEditingTemplate: () => (setIsEditingTemplate),
90 setIsInserterOpened: () => (setIsInserterOpened),
91 setIsListViewOpened: () => (setIsListViewOpened),
92 showBlockTypes: () => (showBlockTypes),
93 switchEditorMode: () => (switchEditorMode),
94 toggleDistractionFree: () => (toggleDistractionFree),
95 toggleEditorPanelEnabled: () => (toggleEditorPanelEnabled),
96 toggleEditorPanelOpened: () => (toggleEditorPanelOpened),
97 toggleFeature: () => (toggleFeature),
98 toggleFullscreenMode: () => (toggleFullscreenMode),
99 togglePinnedPluginItem: () => (togglePinnedPluginItem),
100 togglePublishSidebar: () => (togglePublishSidebar),
101 updatePreferredStyleVariations: () => (updatePreferredStyleVariations)
102 });
103
104 // NAMESPACE OBJECT: ./packages/edit-post/build-module/store/selectors.js
105 var selectors_namespaceObject = {};
106 __webpack_require__.r(selectors_namespaceObject);
107 __webpack_require__.d(selectors_namespaceObject, {
108 __experimentalGetInsertionPoint: () => (__experimentalGetInsertionPoint),
109 __experimentalGetPreviewDeviceType: () => (__experimentalGetPreviewDeviceType),
110 areMetaBoxesInitialized: () => (areMetaBoxesInitialized),
111 getActiveGeneralSidebarName: () => (getActiveGeneralSidebarName),
112 getActiveMetaBoxLocations: () => (getActiveMetaBoxLocations),
113 getAllMetaBoxes: () => (getAllMetaBoxes),
114 getEditedPostTemplate: () => (getEditedPostTemplate),
115 getEditorMode: () => (getEditorMode),
116 getHiddenBlockTypes: () => (getHiddenBlockTypes),
117 getMetaBoxesPerLocation: () => (getMetaBoxesPerLocation),
118 getPreference: () => (getPreference),
119 getPreferences: () => (getPreferences),
120 hasMetaBoxes: () => (hasMetaBoxes),
121 isEditingTemplate: () => (isEditingTemplate),
122 isEditorPanelEnabled: () => (isEditorPanelEnabled),
123 isEditorPanelOpened: () => (isEditorPanelOpened),
124 isEditorPanelRemoved: () => (isEditorPanelRemoved),
125 isEditorSidebarOpened: () => (isEditorSidebarOpened),
126 isFeatureActive: () => (isFeatureActive),
127 isInserterOpened: () => (isInserterOpened),
128 isListViewOpened: () => (isListViewOpened),
129 isMetaBoxLocationActive: () => (isMetaBoxLocationActive),
130 isMetaBoxLocationVisible: () => (isMetaBoxLocationVisible),
131 isModalActive: () => (isModalActive),
132 isPluginItemPinned: () => (isPluginItemPinned),
133 isPluginSidebarOpened: () => (isPluginSidebarOpened),
134 isPublishSidebarOpened: () => (isPublishSidebarOpened),
135 isSavingMetaBoxes: () => (selectors_isSavingMetaBoxes)
136 });
137
138 ;// external ["wp","blocks"]
139 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
140 ;// external ["wp","blockLibrary"]
141 const external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
142 ;// external ["wp","deprecated"]
143 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
144 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
145 ;// external ["wp","element"]
146 const external_wp_element_namespaceObject = window["wp"]["element"];
147 ;// external ["wp","data"]
148 const external_wp_data_namespaceObject = window["wp"]["data"];
149 ;// external ["wp","preferences"]
150 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
151 ;// external ["wp","widgets"]
152 const external_wp_widgets_namespaceObject = window["wp"]["widgets"];
153 ;// external ["wp","editor"]
154 const external_wp_editor_namespaceObject = window["wp"]["editor"];
155 ;// ./node_modules/clsx/dist/clsx.mjs
156 function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
157 ;// external ["wp","blockEditor"]
158 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
159 ;// external ["wp","plugins"]
160 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
161 ;// external ["wp","i18n"]
162 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
163 ;// external ["wp","primitives"]
164 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
165 ;// external "ReactJSXRuntime"
166 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
167 ;// ./packages/icons/build-module/library/chevron-up.js
168 /**
169 * WordPress dependencies
170 */
171
172
173 const chevronUp = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
174 viewBox: "0 0 24 24",
175 xmlns: "http://www.w3.org/2000/svg",
176 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
177 d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
178 })
179 });
180 /* harmony default export */ const chevron_up = (chevronUp);
181
182 ;// ./packages/icons/build-module/library/chevron-down.js
183 /**
184 * WordPress dependencies
185 */
186
187
188 const chevronDown = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
189 viewBox: "0 0 24 24",
190 xmlns: "http://www.w3.org/2000/svg",
191 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
192 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
193 })
194 });
195 /* harmony default export */ const chevron_down = (chevronDown);
196
197 ;// external ["wp","notices"]
198 const external_wp_notices_namespaceObject = window["wp"]["notices"];
199 ;// external ["wp","commands"]
200 const external_wp_commands_namespaceObject = window["wp"]["commands"];
201 ;// external ["wp","coreCommands"]
202 const external_wp_coreCommands_namespaceObject = window["wp"]["coreCommands"];
203 ;// external ["wp","url"]
204 const external_wp_url_namespaceObject = window["wp"]["url"];
205 ;// external ["wp","htmlEntities"]
206 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
207 ;// external ["wp","coreData"]
208 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
209 ;// external ["wp","components"]
210 const external_wp_components_namespaceObject = window["wp"]["components"];
211 ;// external ["wp","compose"]
212 const external_wp_compose_namespaceObject = window["wp"]["compose"];
213 ;// ./packages/icons/build-module/library/wordpress.js
214 /**
215 * WordPress dependencies
216 */
217
218
219 const wordpress = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
220 xmlns: "http://www.w3.org/2000/svg",
221 viewBox: "-2 -2 24 24",
222 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
223 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"
224 })
225 });
226 /* harmony default export */ const library_wordpress = (wordpress);
227
228 ;// ./packages/edit-post/build-module/components/back-button/fullscreen-mode-close.js
229 /**
230 * External dependencies
231 */
232
233
234 /**
235 * WordPress dependencies
236 */
237
238
239
240
241
242
243
244
245
246 function FullscreenModeClose({
247 showTooltip,
248 icon,
249 href,
250 initialPost
251 }) {
252 var _postType$labels$view;
253 const {
254 isRequestingSiteIcon,
255 postType,
256 siteIconUrl
257 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
258 const {
259 getCurrentPostType
260 } = select(external_wp_editor_namespaceObject.store);
261 const {
262 getEntityRecord,
263 getPostType,
264 isResolving
265 } = select(external_wp_coreData_namespaceObject.store);
266 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
267 const _postType = initialPost?.type || getCurrentPostType();
268 return {
269 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
270 postType: getPostType(_postType),
271 siteIconUrl: siteData.site_icon_url
272 };
273 }, []);
274 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
275 if (!postType) {
276 return null;
277 }
278 let buttonIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
279 size: "36px",
280 icon: library_wordpress
281 });
282 const effect = {
283 expand: {
284 scale: 1.25,
285 transition: {
286 type: 'tween',
287 duration: '0.3'
288 }
289 }
290 };
291 if (siteIconUrl) {
292 buttonIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.img, {
293 variants: !disableMotion && effect,
294 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
295 className: "edit-post-fullscreen-mode-close_site-icon",
296 src: siteIconUrl
297 });
298 }
299 if (isRequestingSiteIcon) {
300 buttonIcon = null;
301 }
302
303 // Override default icon if custom icon is provided via props.
304 if (icon) {
305 buttonIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
306 size: "36px",
307 icon: icon
308 });
309 }
310 const classes = dist_clsx('edit-post-fullscreen-mode-close', {
311 'has-icon': siteIconUrl
312 });
313 const buttonHref = href !== null && href !== void 0 ? href : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
314 post_type: postType.slug
315 });
316 const buttonLabel = (_postType$labels$view = postType?.labels?.view_items) !== null && _postType$labels$view !== void 0 ? _postType$labels$view : (0,external_wp_i18n_namespaceObject.__)('Back');
317 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
318 whileHover: "expand",
319 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
320 __next40pxDefaultSize: true,
321 className: classes,
322 href: buttonHref,
323 label: buttonLabel,
324 showTooltip: showTooltip,
325 children: buttonIcon
326 })
327 });
328 }
329 /* harmony default export */ const fullscreen_mode_close = (FullscreenModeClose);
330
331 ;// external ["wp","privateApis"]
332 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
333 ;// ./packages/edit-post/build-module/lock-unlock.js
334 /**
335 * WordPress dependencies
336 */
337
338 const {
339 lock,
340 unlock
341 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/edit-post');
342
343 ;// ./packages/edit-post/build-module/components/back-button/index.js
344 /**
345 * WordPress dependencies
346 */
347
348
349
350 /**
351 * Internal dependencies
352 */
353
354
355
356 const {
357 BackButton: BackButtonFill
358 } = unlock(external_wp_editor_namespaceObject.privateApis);
359 const slideX = {
360 hidden: {
361 x: '-100%'
362 },
363 distractionFreeInactive: {
364 x: 0
365 },
366 hover: {
367 x: 0,
368 transition: {
369 type: 'tween',
370 delay: 0.2
371 }
372 }
373 };
374 function BackButton({
375 initialPost
376 }) {
377 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BackButtonFill, {
378 children: ({
379 length
380 }) => length <= 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
381 variants: slideX,
382 transition: {
383 type: 'tween',
384 delay: 0.8
385 },
386 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(fullscreen_mode_close, {
387 showTooltip: true,
388 initialPost: initialPost
389 })
390 })
391 });
392 }
393 /* harmony default export */ const back_button = (BackButton);
394
395 ;// ./packages/edit-post/build-module/store/constants.js
396 /**
397 * The identifier for the data store.
398 *
399 * @type {string}
400 */
401 const STORE_NAME = 'core/edit-post';
402
403 /**
404 * CSS selector string for the admin bar view post link anchor tag.
405 *
406 * @type {string}
407 */
408 const VIEW_AS_LINK_SELECTOR = '#wp-admin-bar-view a';
409
410 /**
411 * CSS selector string for the admin bar preview post link anchor tag.
412 *
413 * @type {string}
414 */
415 const VIEW_AS_PREVIEW_LINK_SELECTOR = '#wp-admin-bar-preview a';
416
417 ;// ./packages/edit-post/build-module/components/editor-initialization/listener-hooks.js
418 /**
419 * WordPress dependencies
420 */
421
422
423
424
425 /**
426 * Internal dependencies
427 */
428
429
430 /**
431 * This listener hook monitors any change in permalink and updates the view
432 * post link in the admin bar.
433 */
434 const useUpdatePostLinkListener = () => {
435 const {
436 newPermalink
437 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
438 newPermalink: select(external_wp_editor_namespaceObject.store).getCurrentPost().link
439 }), []);
440 const nodeToUpdateRef = (0,external_wp_element_namespaceObject.useRef)();
441 (0,external_wp_element_namespaceObject.useEffect)(() => {
442 nodeToUpdateRef.current = document.querySelector(VIEW_AS_PREVIEW_LINK_SELECTOR) || document.querySelector(VIEW_AS_LINK_SELECTOR);
443 }, []);
444 (0,external_wp_element_namespaceObject.useEffect)(() => {
445 if (!newPermalink || !nodeToUpdateRef.current) {
446 return;
447 }
448 nodeToUpdateRef.current.setAttribute('href', newPermalink);
449 }, [newPermalink]);
450 };
451
452 ;// ./packages/edit-post/build-module/components/editor-initialization/index.js
453 /**
454 * Internal dependencies
455 */
456
457
458 /**
459 * Data component used for initializing the editor and re-initializes
460 * when postId changes or on unmount.
461 *
462 * @return {null} This is a data component so does not render any ui.
463 */
464 function EditorInitialization() {
465 useUpdatePostLinkListener();
466 return null;
467 }
468
469 ;// external ["wp","keyboardShortcuts"]
470 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
471 ;// ./packages/edit-post/build-module/store/reducer.js
472 /**
473 * WordPress dependencies
474 */
475
476
477 /**
478 * Reducer keeping track of the meta boxes isSaving state.
479 * A "true" value means the meta boxes saving request is in-flight.
480 *
481 *
482 * @param {boolean} state Previous state.
483 * @param {Object} action Action Object.
484 *
485 * @return {Object} Updated state.
486 */
487 function isSavingMetaBoxes(state = false, action) {
488 switch (action.type) {
489 case 'REQUEST_META_BOX_UPDATES':
490 return true;
491 case 'META_BOX_UPDATES_SUCCESS':
492 case 'META_BOX_UPDATES_FAILURE':
493 return false;
494 default:
495 return state;
496 }
497 }
498 function mergeMetaboxes(metaboxes = [], newMetaboxes) {
499 const mergedMetaboxes = [...metaboxes];
500 for (const metabox of newMetaboxes) {
501 const existing = mergedMetaboxes.findIndex(box => box.id === metabox.id);
502 if (existing !== -1) {
503 mergedMetaboxes[existing] = metabox;
504 } else {
505 mergedMetaboxes.push(metabox);
506 }
507 }
508 return mergedMetaboxes;
509 }
510
511 /**
512 * Reducer keeping track of the meta boxes per location.
513 *
514 * @param {boolean} state Previous state.
515 * @param {Object} action Action Object.
516 *
517 * @return {Object} Updated state.
518 */
519 function metaBoxLocations(state = {}, action) {
520 switch (action.type) {
521 case 'SET_META_BOXES_PER_LOCATIONS':
522 {
523 const newState = {
524 ...state
525 };
526 for (const [location, metaboxes] of Object.entries(action.metaBoxesPerLocation)) {
527 newState[location] = mergeMetaboxes(newState[location], metaboxes);
528 }
529 return newState;
530 }
531 }
532 return state;
533 }
534
535 /**
536 * Reducer tracking whether meta boxes are initialized.
537 *
538 * @param {boolean} state
539 * @param {Object} action
540 *
541 * @return {boolean} Updated state.
542 */
543 function metaBoxesInitialized(state = false, action) {
544 switch (action.type) {
545 case 'META_BOXES_INITIALIZED':
546 return true;
547 }
548 return state;
549 }
550 const metaBoxes = (0,external_wp_data_namespaceObject.combineReducers)({
551 isSaving: isSavingMetaBoxes,
552 locations: metaBoxLocations,
553 initialized: metaBoxesInitialized
554 });
555 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
556 metaBoxes
557 }));
558
559 ;// external ["wp","apiFetch"]
560 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
561 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
562 ;// external ["wp","hooks"]
563 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
564 ;// ./packages/edit-post/build-module/utils/meta-boxes.js
565 /**
566 * Function returning the current Meta Boxes DOM Node in the editor
567 * whether the meta box area is opened or not.
568 * If the MetaBox Area is visible returns it, and returns the original container instead.
569 *
570 * @param {string} location Meta Box location.
571 *
572 * @return {string} HTML content.
573 */
574 const getMetaBoxContainer = location => {
575 const area = document.querySelector(`.edit-post-meta-boxes-area.is-${location} .metabox-location-${location}`);
576 if (area) {
577 return area;
578 }
579 return document.querySelector('#metaboxes .metabox-location-' + location);
580 };
581
582 ;// ./packages/edit-post/build-module/store/actions.js
583 /* wp:polyfill */
584 /**
585 * WordPress dependencies
586 */
587
588
589
590
591
592
593
594
595
596 /**
597 * Internal dependencies
598 */
599
600
601 const {
602 interfaceStore
603 } = unlock(external_wp_editor_namespaceObject.privateApis);
604
605 /**
606 * Returns an action object used in signalling that the user opened an editor sidebar.
607 *
608 * @param {?string} name Sidebar name to be opened.
609 */
610 const openGeneralSidebar = name => ({
611 registry
612 }) => {
613 registry.dispatch(interfaceStore).enableComplementaryArea('core', name);
614 };
615
616 /**
617 * Returns an action object signalling that the user closed the sidebar.
618 */
619 const closeGeneralSidebar = () => ({
620 registry
621 }) => registry.dispatch(interfaceStore).disableComplementaryArea('core');
622
623 /**
624 * Returns an action object used in signalling that the user opened a modal.
625 *
626 * @deprecated since WP 6.3 use `core/interface` store's action with the same name instead.
627 *
628 *
629 * @param {string} name A string that uniquely identifies the modal.
630 *
631 * @return {Object} Action object.
632 */
633 const openModal = name => ({
634 registry
635 }) => {
636 external_wp_deprecated_default()("select( 'core/edit-post' ).openModal( name )", {
637 since: '6.3',
638 alternative: "select( 'core/interface').openModal( name )"
639 });
640 return registry.dispatch(interfaceStore).openModal(name);
641 };
642
643 /**
644 * Returns an action object signalling that the user closed a modal.
645 *
646 * @deprecated since WP 6.3 use `core/interface` store's action with the same name instead.
647 *
648 * @return {Object} Action object.
649 */
650 const closeModal = () => ({
651 registry
652 }) => {
653 external_wp_deprecated_default()("select( 'core/edit-post' ).closeModal()", {
654 since: '6.3',
655 alternative: "select( 'core/interface').closeModal()"
656 });
657 return registry.dispatch(interfaceStore).closeModal();
658 };
659
660 /**
661 * Returns an action object used in signalling that the user opened the publish
662 * sidebar.
663 * @deprecated
664 *
665 * @return {Object} Action object
666 */
667 const openPublishSidebar = () => ({
668 registry
669 }) => {
670 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).openPublishSidebar", {
671 since: '6.6',
672 alternative: "dispatch( 'core/editor').openPublishSidebar"
673 });
674 registry.dispatch(external_wp_editor_namespaceObject.store).openPublishSidebar();
675 };
676
677 /**
678 * Returns an action object used in signalling that the user closed the
679 * publish sidebar.
680 * @deprecated
681 *
682 * @return {Object} Action object.
683 */
684 const closePublishSidebar = () => ({
685 registry
686 }) => {
687 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).closePublishSidebar", {
688 since: '6.6',
689 alternative: "dispatch( 'core/editor').closePublishSidebar"
690 });
691 registry.dispatch(external_wp_editor_namespaceObject.store).closePublishSidebar();
692 };
693
694 /**
695 * Returns an action object used in signalling that the user toggles the publish sidebar.
696 * @deprecated
697 *
698 * @return {Object} Action object
699 */
700 const togglePublishSidebar = () => ({
701 registry
702 }) => {
703 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).togglePublishSidebar", {
704 since: '6.6',
705 alternative: "dispatch( 'core/editor').togglePublishSidebar"
706 });
707 registry.dispatch(external_wp_editor_namespaceObject.store).togglePublishSidebar();
708 };
709
710 /**
711 * Returns an action object used to enable or disable a panel in the editor.
712 *
713 * @deprecated
714 *
715 * @param {string} panelName A string that identifies the panel to enable or disable.
716 *
717 * @return {Object} Action object.
718 */
719 const toggleEditorPanelEnabled = panelName => ({
720 registry
721 }) => {
722 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).toggleEditorPanelEnabled", {
723 since: '6.5',
724 alternative: "dispatch( 'core/editor').toggleEditorPanelEnabled"
725 });
726 registry.dispatch(external_wp_editor_namespaceObject.store).toggleEditorPanelEnabled(panelName);
727 };
728
729 /**
730 * Opens a closed panel and closes an open panel.
731 *
732 * @deprecated
733 *
734 * @param {string} panelName A string that identifies the panel to open or close.
735 */
736 const toggleEditorPanelOpened = panelName => ({
737 registry
738 }) => {
739 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).toggleEditorPanelOpened", {
740 since: '6.5',
741 alternative: "dispatch( 'core/editor').toggleEditorPanelOpened"
742 });
743 registry.dispatch(external_wp_editor_namespaceObject.store).toggleEditorPanelOpened(panelName);
744 };
745
746 /**
747 * Returns an action object used to remove a panel from the editor.
748 *
749 * @deprecated
750 *
751 * @param {string} panelName A string that identifies the panel to remove.
752 *
753 * @return {Object} Action object.
754 */
755 const removeEditorPanel = panelName => ({
756 registry
757 }) => {
758 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).removeEditorPanel", {
759 since: '6.5',
760 alternative: "dispatch( 'core/editor').removeEditorPanel"
761 });
762 registry.dispatch(external_wp_editor_namespaceObject.store).removeEditorPanel(panelName);
763 };
764
765 /**
766 * Triggers an action used to toggle a feature flag.
767 *
768 * @param {string} feature Feature name.
769 */
770 const toggleFeature = feature => ({
771 registry
772 }) => registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-post', feature);
773
774 /**
775 * Triggers an action used to switch editor mode.
776 *
777 * @deprecated
778 *
779 * @param {string} mode The editor mode.
780 */
781 const switchEditorMode = mode => ({
782 registry
783 }) => {
784 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).switchEditorMode", {
785 since: '6.6',
786 alternative: "dispatch( 'core/editor').switchEditorMode"
787 });
788 registry.dispatch(external_wp_editor_namespaceObject.store).switchEditorMode(mode);
789 };
790
791 /**
792 * Triggers an action object used to toggle a plugin name flag.
793 *
794 * @param {string} pluginName Plugin name.
795 */
796 const togglePinnedPluginItem = pluginName => ({
797 registry
798 }) => {
799 const isPinned = registry.select(interfaceStore).isItemPinned('core', pluginName);
800 registry.dispatch(interfaceStore)[isPinned ? 'unpinItem' : 'pinItem']('core', pluginName);
801 };
802
803 /**
804 * Returns an action object used in signaling that a style should be auto-applied when a block is created.
805 *
806 * @deprecated
807 */
808 function updatePreferredStyleVariations() {
809 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).updatePreferredStyleVariations", {
810 since: '6.6',
811 hint: 'Preferred Style Variations are not supported anymore.'
812 });
813 return {
814 type: 'NOTHING'
815 };
816 }
817
818 /**
819 * Update the provided block types to be visible.
820 *
821 * @param {string[]} blockNames Names of block types to show.
822 */
823 const showBlockTypes = blockNames => ({
824 registry
825 }) => {
826 unlock(registry.dispatch(external_wp_editor_namespaceObject.store)).showBlockTypes(blockNames);
827 };
828
829 /**
830 * Update the provided block types to be hidden.
831 *
832 * @param {string[]} blockNames Names of block types to hide.
833 */
834 const hideBlockTypes = blockNames => ({
835 registry
836 }) => {
837 unlock(registry.dispatch(external_wp_editor_namespaceObject.store)).hideBlockTypes(blockNames);
838 };
839
840 /**
841 * Stores info about which Meta boxes are available in which location.
842 *
843 * @param {Object} metaBoxesPerLocation Meta boxes per location.
844 */
845 function setAvailableMetaBoxesPerLocation(metaBoxesPerLocation) {
846 return {
847 type: 'SET_META_BOXES_PER_LOCATIONS',
848 metaBoxesPerLocation
849 };
850 }
851
852 /**
853 * Update a metabox.
854 */
855 const requestMetaBoxUpdates = () => async ({
856 registry,
857 select,
858 dispatch
859 }) => {
860 dispatch({
861 type: 'REQUEST_META_BOX_UPDATES'
862 });
863
864 // Saves the wp_editor fields.
865 if (window.tinyMCE) {
866 window.tinyMCE.triggerSave();
867 }
868
869 // We gather the base form data.
870 const baseFormData = new window.FormData(document.querySelector('.metabox-base-form'));
871 const postId = baseFormData.get('post_ID');
872 const postType = baseFormData.get('post_type');
873
874 // Additional data needed for backward compatibility.
875 // If we do not provide this data, the post will be overridden with the default values.
876 // We cannot rely on getCurrentPost because right now on the editor we may be editing a pattern or a template.
877 // We need to retrieve the post that the base form data is referring to.
878 const post = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
879 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);
880
881 // We gather all the metaboxes locations.
882 const activeMetaBoxLocations = select.getActiveMetaBoxLocations();
883 const formDataToMerge = [baseFormData, ...activeMetaBoxLocations.map(location => new window.FormData(getMetaBoxContainer(location)))];
884
885 // Merge all form data objects into a single one.
886 const formData = formDataToMerge.reduce((memo, currentFormData) => {
887 for (const [key, value] of currentFormData) {
888 memo.append(key, value);
889 }
890 return memo;
891 }, new window.FormData());
892 additionalData.forEach(([key, value]) => formData.append(key, value));
893 try {
894 // Save the metaboxes.
895 await external_wp_apiFetch_default()({
896 url: window._wpMetaBoxUrl,
897 method: 'POST',
898 body: formData,
899 parse: false
900 });
901 dispatch.metaBoxUpdatesSuccess();
902 } catch {
903 dispatch.metaBoxUpdatesFailure();
904 }
905 };
906
907 /**
908 * Returns an action object used to signal a successful meta box update.
909 *
910 * @return {Object} Action object.
911 */
912 function metaBoxUpdatesSuccess() {
913 return {
914 type: 'META_BOX_UPDATES_SUCCESS'
915 };
916 }
917
918 /**
919 * Returns an action object used to signal a failed meta box update.
920 *
921 * @return {Object} Action object.
922 */
923 function metaBoxUpdatesFailure() {
924 return {
925 type: 'META_BOX_UPDATES_FAILURE'
926 };
927 }
928
929 /**
930 * Action that changes the width of the editing canvas.
931 *
932 * @deprecated
933 *
934 * @param {string} deviceType
935 */
936 const __experimentalSetPreviewDeviceType = deviceType => ({
937 registry
938 }) => {
939 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).__experimentalSetPreviewDeviceType", {
940 since: '6.5',
941 version: '6.7',
942 hint: 'registry.dispatch( editorStore ).setDeviceType'
943 });
944 registry.dispatch(external_wp_editor_namespaceObject.store).setDeviceType(deviceType);
945 };
946
947 /**
948 * Returns an action object used to open/close the inserter.
949 *
950 * @deprecated
951 *
952 * @param {boolean|Object} value Whether the inserter should be opened (true) or closed (false).
953 */
954 const setIsInserterOpened = value => ({
955 registry
956 }) => {
957 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).setIsInserterOpened", {
958 since: '6.5',
959 alternative: "dispatch( 'core/editor').setIsInserterOpened"
960 });
961 registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(value);
962 };
963
964 /**
965 * Returns an action object used to open/close the list view.
966 *
967 * @deprecated
968 *
969 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
970 */
971 const setIsListViewOpened = isOpen => ({
972 registry
973 }) => {
974 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).setIsListViewOpened", {
975 since: '6.5',
976 alternative: "dispatch( 'core/editor').setIsListViewOpened"
977 });
978 registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(isOpen);
979 };
980
981 /**
982 * Returns an action object used to switch to template editing.
983 *
984 * @deprecated
985 */
986 function setIsEditingTemplate() {
987 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).setIsEditingTemplate", {
988 since: '6.5',
989 alternative: "dispatch( 'core/editor').setRenderingMode"
990 });
991 return {
992 type: 'NOTHING'
993 };
994 }
995
996 /**
997 * Create a block based template.
998 *
999 * @deprecated
1000 */
1001 function __unstableCreateTemplate() {
1002 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).__unstableCreateTemplate", {
1003 since: '6.5'
1004 });
1005 return {
1006 type: 'NOTHING'
1007 };
1008 }
1009 let actions_metaBoxesInitialized = false;
1010
1011 /**
1012 * Initializes WordPress `postboxes` script and the logic for saving meta boxes.
1013 */
1014 const initializeMetaBoxes = () => ({
1015 registry,
1016 select,
1017 dispatch
1018 }) => {
1019 const isEditorReady = registry.select(external_wp_editor_namespaceObject.store).__unstableIsEditorReady();
1020 if (!isEditorReady) {
1021 return;
1022 }
1023 // Only initialize once.
1024 if (actions_metaBoxesInitialized) {
1025 return;
1026 }
1027 const postType = registry.select(external_wp_editor_namespaceObject.store).getCurrentPostType();
1028 if (window.postboxes.page !== postType) {
1029 window.postboxes.add_postbox_toggles(postType);
1030 }
1031 actions_metaBoxesInitialized = true;
1032
1033 // Save metaboxes on save completion, except for autosaves.
1034 (0,external_wp_hooks_namespaceObject.addAction)('editor.savePost', 'core/edit-post/save-metaboxes', async (post, options) => {
1035 if (!options.isAutosave && select.hasMetaBoxes()) {
1036 await dispatch.requestMetaBoxUpdates();
1037 }
1038 });
1039 dispatch({
1040 type: 'META_BOXES_INITIALIZED'
1041 });
1042 };
1043
1044 /**
1045 * Action that toggles Distraction free mode.
1046 * Distraction free mode expects there are no sidebars, as due to the
1047 * z-index values set, you can't close sidebars.
1048 *
1049 * @deprecated
1050 */
1051 const toggleDistractionFree = () => ({
1052 registry
1053 }) => {
1054 external_wp_deprecated_default()("dispatch( 'core/edit-post' ).toggleDistractionFree", {
1055 since: '6.6',
1056 alternative: "dispatch( 'core/editor').toggleDistractionFree"
1057 });
1058 registry.dispatch(external_wp_editor_namespaceObject.store).toggleDistractionFree();
1059 };
1060
1061 /**
1062 * Action that toggles the Fullscreen Mode view option.
1063 */
1064 const toggleFullscreenMode = () => ({
1065 registry
1066 }) => {
1067 const isFullscreen = registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-post', 'fullscreenMode');
1068 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-post', 'fullscreenMode');
1069 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isFullscreen ? (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode activated.') : (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode deactivated.'), {
1070 id: 'core/edit-post/toggle-fullscreen-mode/notice',
1071 type: 'snackbar',
1072 actions: [{
1073 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
1074 onClick: () => {
1075 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-post', 'fullscreenMode');
1076 }
1077 }]
1078 });
1079 };
1080
1081 ;// ./packages/edit-post/build-module/store/selectors.js
1082 /* wp:polyfill */
1083 /**
1084 * WordPress dependencies
1085 */
1086
1087
1088
1089
1090
1091
1092 /**
1093 * Internal dependencies
1094 */
1095
1096 const {
1097 interfaceStore: selectors_interfaceStore
1098 } = unlock(external_wp_editor_namespaceObject.privateApis);
1099 const EMPTY_ARRAY = [];
1100 const EMPTY_OBJECT = {};
1101
1102 /**
1103 * Returns the current editing mode.
1104 *
1105 * @param {Object} state Global application state.
1106 *
1107 * @return {string} Editing mode.
1108 */
1109 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1110 var _select$get;
1111 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
1112 });
1113
1114 /**
1115 * Returns true if the editor sidebar is opened.
1116 *
1117 * @param {Object} state Global application state
1118 *
1119 * @return {boolean} Whether the editor sidebar is opened.
1120 */
1121 const isEditorSidebarOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1122 const activeGeneralSidebar = select(selectors_interfaceStore).getActiveComplementaryArea('core');
1123 return ['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
1124 });
1125
1126 /**
1127 * Returns true if the plugin sidebar is opened.
1128 *
1129 * @param {Object} state Global application state.
1130 *
1131 * @return {boolean} Whether the plugin sidebar is opened.
1132 */
1133 const isPluginSidebarOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1134 const activeGeneralSidebar = select(selectors_interfaceStore).getActiveComplementaryArea('core');
1135 return !!activeGeneralSidebar && !['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
1136 });
1137
1138 /**
1139 * Returns the current active general sidebar name, or null if there is no
1140 * general sidebar active. The active general sidebar is a unique name to
1141 * identify either an editor or plugin sidebar.
1142 *
1143 * Examples:
1144 *
1145 * - `edit-post/document`
1146 * - `my-plugin/insert-image-sidebar`
1147 *
1148 * @param {Object} state Global application state.
1149 *
1150 * @return {?string} Active general sidebar name.
1151 */
1152 const getActiveGeneralSidebarName = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1153 return select(selectors_interfaceStore).getActiveComplementaryArea('core');
1154 });
1155
1156 /**
1157 * Converts panels from the new preferences store format to the old format
1158 * that the post editor previously used.
1159 *
1160 * The resultant converted data should look like this:
1161 * {
1162 * panelName: {
1163 * enabled: false,
1164 * opened: true,
1165 * },
1166 * anotherPanelName: {
1167 * opened: true
1168 * },
1169 * }
1170 *
1171 * @param {string[] | undefined} inactivePanels An array of inactive panel names.
1172 * @param {string[] | undefined} openPanels An array of open panel names.
1173 *
1174 * @return {Object} The converted panel data.
1175 */
1176 function convertPanelsToOldFormat(inactivePanels, openPanels) {
1177 var _ref;
1178 // First reduce the inactive panels.
1179 const panelsWithEnabledState = inactivePanels?.reduce((accumulatedPanels, panelName) => ({
1180 ...accumulatedPanels,
1181 [panelName]: {
1182 enabled: false
1183 }
1184 }), {});
1185
1186 // Then reduce the open panels, passing in the result of the previous
1187 // reduction as the initial value so that both open and inactive
1188 // panel state is combined.
1189 const panels = openPanels?.reduce((accumulatedPanels, panelName) => {
1190 const currentPanelState = accumulatedPanels?.[panelName];
1191 return {
1192 ...accumulatedPanels,
1193 [panelName]: {
1194 ...currentPanelState,
1195 opened: true
1196 }
1197 };
1198 }, panelsWithEnabledState !== null && panelsWithEnabledState !== void 0 ? panelsWithEnabledState : {});
1199
1200 // The panels variable will only be set if openPanels wasn't `undefined`.
1201 // If it isn't set just return `panelsWithEnabledState`, and if that isn't
1202 // set return an empty object.
1203 return (_ref = panels !== null && panels !== void 0 ? panels : panelsWithEnabledState) !== null && _ref !== void 0 ? _ref : EMPTY_OBJECT;
1204 }
1205
1206 /**
1207 * Returns the preferences (these preferences are persisted locally).
1208 *
1209 * @param {Object} state Global application state.
1210 *
1211 * @return {Object} Preferences Object.
1212 */
1213 const getPreferences = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1214 external_wp_deprecated_default()(`select( 'core/edit-post' ).getPreferences`, {
1215 since: '6.0',
1216 alternative: `select( 'core/preferences' ).get`
1217 });
1218 const corePreferences = ['editorMode', 'hiddenBlockTypes'].reduce((accumulatedPrefs, preferenceKey) => {
1219 const value = select(external_wp_preferences_namespaceObject.store).get('core', preferenceKey);
1220 return {
1221 ...accumulatedPrefs,
1222 [preferenceKey]: value
1223 };
1224 }, {});
1225
1226 // Panels were a preference, but the data structure changed when the state
1227 // was migrated to the preferences store. They need to be converted from
1228 // the new preferences store format to old format to ensure no breaking
1229 // changes for plugins.
1230 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels');
1231 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels');
1232 const panels = convertPanelsToOldFormat(inactivePanels, openPanels);
1233 return {
1234 ...corePreferences,
1235 panels
1236 };
1237 });
1238
1239 /**
1240 *
1241 * @param {Object} state Global application state.
1242 * @param {string} preferenceKey Preference Key.
1243 * @param {*} defaultValue Default Value.
1244 *
1245 * @return {*} Preference Value.
1246 */
1247 function getPreference(state, preferenceKey, defaultValue) {
1248 external_wp_deprecated_default()(`select( 'core/edit-post' ).getPreference`, {
1249 since: '6.0',
1250 alternative: `select( 'core/preferences' ).get`
1251 });
1252
1253 // Avoid using the `getPreferences` registry selector where possible.
1254 const preferences = getPreferences(state);
1255 const value = preferences[preferenceKey];
1256 return value === undefined ? defaultValue : value;
1257 }
1258
1259 /**
1260 * Returns an array of blocks that are hidden.
1261 *
1262 * @return {Array} A list of the hidden block types
1263 */
1264 const getHiddenBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1265 var _select$get2;
1266 return (_select$get2 = select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _select$get2 !== void 0 ? _select$get2 : EMPTY_ARRAY;
1267 });
1268
1269 /**
1270 * Returns true if the publish sidebar is opened.
1271 *
1272 * @deprecated
1273 *
1274 * @param {Object} state Global application state
1275 *
1276 * @return {boolean} Whether the publish sidebar is open.
1277 */
1278 const isPublishSidebarOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1279 external_wp_deprecated_default()(`select( 'core/edit-post' ).isPublishSidebarOpened`, {
1280 since: '6.6',
1281 alternative: `select( 'core/editor' ).isPublishSidebarOpened`
1282 });
1283 return select(external_wp_editor_namespaceObject.store).isPublishSidebarOpened();
1284 });
1285
1286 /**
1287 * Returns true if the given panel was programmatically removed, or false otherwise.
1288 * All panels are not removed by default.
1289 *
1290 * @deprecated
1291 *
1292 * @param {Object} state Global application state.
1293 * @param {string} panelName A string that identifies the panel.
1294 *
1295 * @return {boolean} Whether or not the panel is removed.
1296 */
1297 const isEditorPanelRemoved = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
1298 external_wp_deprecated_default()(`select( 'core/edit-post' ).isEditorPanelRemoved`, {
1299 since: '6.5',
1300 alternative: `select( 'core/editor' ).isEditorPanelRemoved`
1301 });
1302 return select(external_wp_editor_namespaceObject.store).isEditorPanelRemoved(panelName);
1303 });
1304
1305 /**
1306 * Returns true if the given panel is enabled, or false otherwise. Panels are
1307 * enabled by default.
1308 *
1309 * @deprecated
1310 *
1311 * @param {Object} state Global application state.
1312 * @param {string} panelName A string that identifies the panel.
1313 *
1314 * @return {boolean} Whether or not the panel is enabled.
1315 */
1316 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
1317 external_wp_deprecated_default()(`select( 'core/edit-post' ).isEditorPanelEnabled`, {
1318 since: '6.5',
1319 alternative: `select( 'core/editor' ).isEditorPanelEnabled`
1320 });
1321 return select(external_wp_editor_namespaceObject.store).isEditorPanelEnabled(panelName);
1322 });
1323
1324 /**
1325 * Returns true if the given panel is open, or false otherwise. Panels are
1326 * closed by default.
1327 *
1328 * @deprecated
1329 *
1330 * @param {Object} state Global application state.
1331 * @param {string} panelName A string that identifies the panel.
1332 *
1333 * @return {boolean} Whether or not the panel is open.
1334 */
1335 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
1336 external_wp_deprecated_default()(`select( 'core/edit-post' ).isEditorPanelOpened`, {
1337 since: '6.5',
1338 alternative: `select( 'core/editor' ).isEditorPanelOpened`
1339 });
1340 return select(external_wp_editor_namespaceObject.store).isEditorPanelOpened(panelName);
1341 });
1342
1343 /**
1344 * Returns true if a modal is active, or false otherwise.
1345 *
1346 * @deprecated since WP 6.3 use `core/interface` store's selector with the same name instead.
1347 *
1348 * @param {Object} state Global application state.
1349 * @param {string} modalName A string that uniquely identifies the modal.
1350 *
1351 * @return {boolean} Whether the modal is active.
1352 */
1353 const isModalActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, modalName) => {
1354 external_wp_deprecated_default()(`select( 'core/edit-post' ).isModalActive`, {
1355 since: '6.3',
1356 alternative: `select( 'core/interface' ).isModalActive`
1357 });
1358 return !!select(selectors_interfaceStore).isModalActive(modalName);
1359 });
1360
1361 /**
1362 * Returns whether the given feature is enabled or not.
1363 *
1364 * @param {Object} state Global application state.
1365 * @param {string} feature Feature slug.
1366 *
1367 * @return {boolean} Is active.
1368 */
1369 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, feature) => {
1370 return !!select(external_wp_preferences_namespaceObject.store).get('core/edit-post', feature);
1371 });
1372
1373 /**
1374 * Returns true if the plugin item is pinned to the header.
1375 * When the value is not set it defaults to true.
1376 *
1377 * @param {Object} state Global application state.
1378 * @param {string} pluginName Plugin item name.
1379 *
1380 * @return {boolean} Whether the plugin item is pinned.
1381 */
1382 const isPluginItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, pluginName) => {
1383 return select(selectors_interfaceStore).isItemPinned('core', pluginName);
1384 });
1385
1386 /**
1387 * Returns an array of active meta box locations.
1388 *
1389 * @param {Object} state Post editor state.
1390 *
1391 * @return {string[]} Active meta box locations.
1392 */
1393 const getActiveMetaBoxLocations = (0,external_wp_data_namespaceObject.createSelector)(state => {
1394 return Object.keys(state.metaBoxes.locations).filter(location => isMetaBoxLocationActive(state, location));
1395 }, state => [state.metaBoxes.locations]);
1396
1397 /**
1398 * Returns true if a metabox location is active and visible
1399 *
1400 * @param {Object} state Post editor state.
1401 * @param {string} location Meta box location to test.
1402 *
1403 * @return {boolean} Whether the meta box location is active and visible.
1404 */
1405 const isMetaBoxLocationVisible = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, location) => {
1406 return isMetaBoxLocationActive(state, location) && getMetaBoxesPerLocation(state, location)?.some(({
1407 id
1408 }) => {
1409 return select(external_wp_editor_namespaceObject.store).isEditorPanelEnabled(`meta-box-${id}`);
1410 });
1411 });
1412
1413 /**
1414 * Returns true if there is an active meta box in the given location, or false
1415 * otherwise.
1416 *
1417 * @param {Object} state Post editor state.
1418 * @param {string} location Meta box location to test.
1419 *
1420 * @return {boolean} Whether the meta box location is active.
1421 */
1422 function isMetaBoxLocationActive(state, location) {
1423 const metaBoxes = getMetaBoxesPerLocation(state, location);
1424 return !!metaBoxes && metaBoxes.length !== 0;
1425 }
1426
1427 /**
1428 * Returns the list of all the available meta boxes for a given location.
1429 *
1430 * @param {Object} state Global application state.
1431 * @param {string} location Meta box location to test.
1432 *
1433 * @return {?Array} List of meta boxes.
1434 */
1435 function getMetaBoxesPerLocation(state, location) {
1436 return state.metaBoxes.locations[location];
1437 }
1438
1439 /**
1440 * Returns the list of all the available meta boxes.
1441 *
1442 * @param {Object} state Global application state.
1443 *
1444 * @return {Array} List of meta boxes.
1445 */
1446 const getAllMetaBoxes = (0,external_wp_data_namespaceObject.createSelector)(state => {
1447 return Object.values(state.metaBoxes.locations).flat();
1448 }, state => [state.metaBoxes.locations]);
1449
1450 /**
1451 * Returns true if the post is using Meta Boxes
1452 *
1453 * @param {Object} state Global application state
1454 *
1455 * @return {boolean} Whether there are metaboxes or not.
1456 */
1457 function hasMetaBoxes(state) {
1458 return getActiveMetaBoxLocations(state).length > 0;
1459 }
1460
1461 /**
1462 * Returns true if the Meta Boxes are being saved.
1463 *
1464 * @param {Object} state Global application state.
1465 *
1466 * @return {boolean} Whether the metaboxes are being saved.
1467 */
1468 function selectors_isSavingMetaBoxes(state) {
1469 return state.metaBoxes.isSaving;
1470 }
1471
1472 /**
1473 * Returns the current editing canvas device type.
1474 *
1475 * @deprecated
1476 *
1477 * @param {Object} state Global application state.
1478 *
1479 * @return {string} Device type.
1480 */
1481 const __experimentalGetPreviewDeviceType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1482 external_wp_deprecated_default()(`select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`, {
1483 since: '6.5',
1484 version: '6.7',
1485 alternative: `select( 'core/editor' ).getDeviceType`
1486 });
1487 return select(external_wp_editor_namespaceObject.store).getDeviceType();
1488 });
1489
1490 /**
1491 * Returns true if the inserter is opened.
1492 *
1493 * @deprecated
1494 *
1495 * @param {Object} state Global application state.
1496 *
1497 * @return {boolean} Whether the inserter is opened.
1498 */
1499 const isInserterOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1500 external_wp_deprecated_default()(`select( 'core/edit-post' ).isInserterOpened`, {
1501 since: '6.5',
1502 alternative: `select( 'core/editor' ).isInserterOpened`
1503 });
1504 return select(external_wp_editor_namespaceObject.store).isInserterOpened();
1505 });
1506
1507 /**
1508 * Get the insertion point for the inserter.
1509 *
1510 * @deprecated
1511 *
1512 * @param {Object} state Global application state.
1513 *
1514 * @return {Object} The root client ID, index to insert at and starting filter value.
1515 */
1516 const __experimentalGetInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1517 external_wp_deprecated_default()(`select( 'core/edit-post' ).__experimentalGetInsertionPoint`, {
1518 since: '6.5',
1519 version: '6.7'
1520 });
1521 return unlock(select(external_wp_editor_namespaceObject.store)).getInserter();
1522 });
1523
1524 /**
1525 * Returns true if the list view is opened.
1526 *
1527 * @param {Object} state Global application state.
1528 *
1529 * @return {boolean} Whether the list view is opened.
1530 */
1531 const isListViewOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1532 external_wp_deprecated_default()(`select( 'core/edit-post' ).isListViewOpened`, {
1533 since: '6.5',
1534 alternative: `select( 'core/editor' ).isListViewOpened`
1535 });
1536 return select(external_wp_editor_namespaceObject.store).isListViewOpened();
1537 });
1538
1539 /**
1540 * Returns true if the template editing mode is enabled.
1541 *
1542 * @deprecated
1543 */
1544 const isEditingTemplate = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1545 external_wp_deprecated_default()(`select( 'core/edit-post' ).isEditingTemplate`, {
1546 since: '6.5',
1547 alternative: `select( 'core/editor' ).getRenderingMode`
1548 });
1549 return select(external_wp_editor_namespaceObject.store).getCurrentPostType() === 'wp_template';
1550 });
1551
1552 /**
1553 * Returns true if meta boxes are initialized.
1554 *
1555 * @param {Object} state Global application state.
1556 *
1557 * @return {boolean} Whether meta boxes are initialized.
1558 */
1559 function areMetaBoxesInitialized(state) {
1560 return state.metaBoxes.initialized;
1561 }
1562
1563 /**
1564 * Retrieves the template of the currently edited post.
1565 *
1566 * @return {?Object} Post Template.
1567 */
1568 const getEditedPostTemplate = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1569 const {
1570 id: postId,
1571 type: postType
1572 } = select(external_wp_editor_namespaceObject.store).getCurrentPost();
1573 const templateId = unlock(select(external_wp_coreData_namespaceObject.store)).getTemplateId(postType, postId);
1574 if (!templateId) {
1575 return undefined;
1576 }
1577 return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', 'wp_template', templateId);
1578 });
1579
1580 ;// ./packages/edit-post/build-module/store/index.js
1581 /**
1582 * WordPress dependencies
1583 */
1584
1585
1586 /**
1587 * Internal dependencies
1588 */
1589
1590
1591
1592
1593
1594 /**
1595 * Store definition for the edit post namespace.
1596 *
1597 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
1598 *
1599 * @type {Object}
1600 */
1601 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
1602 reducer: reducer,
1603 actions: actions_namespaceObject,
1604 selectors: selectors_namespaceObject
1605 });
1606 (0,external_wp_data_namespaceObject.register)(store);
1607
1608 ;// ./packages/edit-post/build-module/components/keyboard-shortcuts/index.js
1609 /**
1610 * WordPress dependencies
1611 */
1612
1613
1614
1615
1616
1617 /**
1618 * Internal dependencies
1619 */
1620
1621 function KeyboardShortcuts() {
1622 const {
1623 toggleFullscreenMode
1624 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1625 const {
1626 registerShortcut
1627 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
1628 (0,external_wp_element_namespaceObject.useEffect)(() => {
1629 registerShortcut({
1630 name: 'core/edit-post/toggle-fullscreen',
1631 category: 'global',
1632 description: (0,external_wp_i18n_namespaceObject.__)('Enable or disable fullscreen mode.'),
1633 keyCombination: {
1634 modifier: 'secondary',
1635 character: 'f'
1636 }
1637 });
1638 }, []);
1639 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-post/toggle-fullscreen', () => {
1640 toggleFullscreenMode();
1641 });
1642 return null;
1643 }
1644 /* harmony default export */ const keyboard_shortcuts = (KeyboardShortcuts);
1645
1646 ;// ./packages/edit-post/build-module/components/init-pattern-modal/index.js
1647 /**
1648 * WordPress dependencies
1649 */
1650
1651
1652
1653
1654
1655
1656 function InitPatternModal() {
1657 const {
1658 editPost
1659 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store);
1660 const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined);
1661 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
1662 const {
1663 postType,
1664 isNewPost
1665 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1666 const {
1667 getEditedPostAttribute,
1668 isCleanNewPost
1669 } = select(external_wp_editor_namespaceObject.store);
1670 return {
1671 postType: getEditedPostAttribute('type'),
1672 isNewPost: isCleanNewPost()
1673 };
1674 }, []);
1675 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(() => isNewPost && postType === 'wp_block');
1676 if (postType !== 'wp_block' || !isNewPost) {
1677 return null;
1678 }
1679 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
1680 children: isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
1681 title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'),
1682 onRequestClose: () => {
1683 setIsModalOpen(false);
1684 },
1685 overlayClassName: "reusable-blocks-menu-items__convert-modal",
1686 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
1687 onSubmit: event => {
1688 event.preventDefault();
1689 setIsModalOpen(false);
1690 editPost({
1691 title,
1692 meta: {
1693 wp_pattern_sync_status: syncType
1694 }
1695 });
1696 },
1697 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
1698 spacing: "5",
1699 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
1700 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
1701 value: title,
1702 onChange: setTitle,
1703 placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern'),
1704 className: "patterns-create-modal__name-input",
1705 __nextHasNoMarginBottom: true,
1706 __next40pxDefaultSize: true
1707 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
1708 __nextHasNoMarginBottom: true,
1709 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'),
1710 help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'),
1711 checked: !syncType,
1712 onChange: () => {
1713 setSyncType(!syncType ? 'unsynced' : undefined);
1714 }
1715 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHStack, {
1716 justify: "right",
1717 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
1718 __next40pxDefaultSize: true,
1719 variant: "primary",
1720 type: "submit",
1721 disabled: !title,
1722 accessibleWhenDisabled: true,
1723 children: (0,external_wp_i18n_namespaceObject.__)('Create')
1724 })
1725 })]
1726 })
1727 })
1728 })
1729 });
1730 }
1731
1732 ;// ./packages/edit-post/build-module/components/browser-url/index.js
1733 /**
1734 * WordPress dependencies
1735 */
1736
1737
1738
1739
1740
1741 /**
1742 * Returns the Post's Edit URL.
1743 *
1744 * @param {number} postId Post ID.
1745 *
1746 * @return {string} Post edit URL.
1747 */
1748 function getPostEditURL(postId) {
1749 return (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
1750 post: postId,
1751 action: 'edit'
1752 });
1753 }
1754 class BrowserURL extends external_wp_element_namespaceObject.Component {
1755 constructor() {
1756 super(...arguments);
1757 this.state = {
1758 historyId: null
1759 };
1760 }
1761 componentDidUpdate(prevProps) {
1762 const {
1763 postId,
1764 postStatus
1765 } = this.props;
1766 const {
1767 historyId
1768 } = this.state;
1769 if ((postId !== prevProps.postId || postId !== historyId) && postStatus !== 'auto-draft' && postId) {
1770 this.setBrowserURL(postId);
1771 }
1772 }
1773
1774 /**
1775 * Replaces the browser URL with a post editor link for the given post ID.
1776 *
1777 * Note it is important that, since this function may be called when the
1778 * editor first loads, the result generated `getPostEditURL` matches that
1779 * produced by the server. Otherwise, the URL will change unexpectedly.
1780 *
1781 * @param {number} postId Post ID for which to generate post editor URL.
1782 */
1783 setBrowserURL(postId) {
1784 window.history.replaceState({
1785 id: postId
1786 }, 'Post ' + postId, getPostEditURL(postId));
1787 this.setState(() => ({
1788 historyId: postId
1789 }));
1790 }
1791 render() {
1792 return null;
1793 }
1794 }
1795 /* harmony default export */ const browser_url = ((0,external_wp_data_namespaceObject.withSelect)(select => {
1796 const {
1797 getCurrentPost
1798 } = select(external_wp_editor_namespaceObject.store);
1799 const post = getCurrentPost();
1800 let {
1801 id,
1802 status,
1803 type
1804 } = post;
1805 const isTemplate = ['wp_template', 'wp_template_part'].includes(type);
1806 if (isTemplate) {
1807 id = post.wp_id;
1808 }
1809 return {
1810 postId: id,
1811 postStatus: status
1812 };
1813 })(BrowserURL));
1814
1815 ;// ./packages/edit-post/build-module/components/meta-boxes/meta-boxes-area/index.js
1816 /**
1817 * External dependencies
1818 */
1819
1820
1821 /**
1822 * WordPress dependencies
1823 */
1824
1825
1826
1827
1828 /**
1829 * Internal dependencies
1830 */
1831
1832
1833 /**
1834 * Render metabox area.
1835 *
1836 * @param {Object} props Component props.
1837 * @param {string} props.location metabox location.
1838 * @return {Component} The component to be rendered.
1839 */
1840
1841 function MetaBoxesArea({
1842 location
1843 }) {
1844 const container = (0,external_wp_element_namespaceObject.useRef)(null);
1845 const formRef = (0,external_wp_element_namespaceObject.useRef)(null);
1846 (0,external_wp_element_namespaceObject.useEffect)(() => {
1847 formRef.current = document.querySelector('.metabox-location-' + location);
1848 if (formRef.current) {
1849 container.current.appendChild(formRef.current);
1850 }
1851 return () => {
1852 if (formRef.current) {
1853 document.querySelector('#metaboxes').appendChild(formRef.current);
1854 }
1855 };
1856 }, [location]);
1857 const isSaving = (0,external_wp_data_namespaceObject.useSelect)(select => {
1858 return select(store).isSavingMetaBoxes();
1859 }, []);
1860 const classes = dist_clsx('edit-post-meta-boxes-area', `is-${location}`, {
1861 'is-loading': isSaving
1862 });
1863 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
1864 className: classes,
1865 children: [isSaving && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
1866 className: "edit-post-meta-boxes-area__container",
1867 ref: container
1868 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
1869 className: "edit-post-meta-boxes-area__clear"
1870 })]
1871 });
1872 }
1873 /* harmony default export */ const meta_boxes_area = (MetaBoxesArea);
1874
1875 ;// ./packages/edit-post/build-module/components/meta-boxes/meta-box-visibility.js
1876 /**
1877 * WordPress dependencies
1878 */
1879
1880
1881
1882 function MetaBoxVisibility({
1883 id
1884 }) {
1885 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
1886 return select(external_wp_editor_namespaceObject.store).isEditorPanelEnabled(`meta-box-${id}`);
1887 }, [id]);
1888 (0,external_wp_element_namespaceObject.useEffect)(() => {
1889 const element = document.getElementById(id);
1890 if (!element) {
1891 return;
1892 }
1893 if (isVisible) {
1894 element.classList.remove('is-hidden');
1895 } else {
1896 element.classList.add('is-hidden');
1897 }
1898 }, [id, isVisible]);
1899 return null;
1900 }
1901
1902 ;// ./packages/edit-post/build-module/components/meta-boxes/index.js
1903 /* wp:polyfill */
1904 /**
1905 * WordPress dependencies
1906 */
1907
1908
1909 /**
1910 * Internal dependencies
1911 */
1912
1913
1914
1915
1916 function MetaBoxes({
1917 location
1918 }) {
1919 const metaBoxes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getMetaBoxesPerLocation(location), [location]);
1920 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
1921 children: [(metaBoxes !== null && metaBoxes !== void 0 ? metaBoxes : []).map(({
1922 id
1923 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MetaBoxVisibility, {
1924 id: id
1925 }, id)), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(meta_boxes_area, {
1926 location: location
1927 })]
1928 });
1929 }
1930
1931 ;// external ["wp","keycodes"]
1932 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
1933 ;// ./packages/edit-post/build-module/components/more-menu/manage-patterns-menu-item.js
1934 /**
1935 * WordPress dependencies
1936 */
1937
1938
1939
1940
1941
1942
1943 function ManagePatternsMenuItem() {
1944 const url = (0,external_wp_data_namespaceObject.useSelect)(select => {
1945 const {
1946 canUser
1947 } = select(external_wp_coreData_namespaceObject.store);
1948 const defaultUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
1949 post_type: 'wp_block'
1950 });
1951 const patternsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', {
1952 path: '/patterns'
1953 });
1954
1955 // The site editor and templates both check whether the user has
1956 // edit_theme_options capabilities. We can leverage that here and not
1957 // display the manage patterns link if the user can't access it.
1958 return canUser('create', {
1959 kind: 'postType',
1960 name: 'wp_template'
1961 }) ? patternsUrl : defaultUrl;
1962 }, []);
1963 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
1964 role: "menuitem",
1965 href: url,
1966 children: (0,external_wp_i18n_namespaceObject.__)('Manage patterns')
1967 });
1968 }
1969 /* harmony default export */ const manage_patterns_menu_item = (ManagePatternsMenuItem);
1970
1971 ;// ./packages/edit-post/build-module/components/more-menu/welcome-guide-menu-item.js
1972 /**
1973 * WordPress dependencies
1974 */
1975
1976
1977
1978
1979
1980 function WelcomeGuideMenuItem() {
1981 const isEditingTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).getCurrentPostType() === 'wp_template', []);
1982 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
1983 scope: "core/edit-post",
1984 name: isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide',
1985 label: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')
1986 });
1987 }
1988
1989 ;// ./packages/edit-post/build-module/components/preferences-modal/enable-custom-fields.js
1990 /**
1991 * WordPress dependencies
1992 */
1993
1994
1995
1996
1997
1998
1999
2000
2001 /**
2002 * Internal dependencies
2003 */
2004
2005
2006 const {
2007 PreferenceBaseOption
2008 } = unlock(external_wp_preferences_namespaceObject.privateApis);
2009 function submitCustomFieldsForm() {
2010 const customFieldsForm = document.getElementById('toggle-custom-fields-form');
2011
2012 // Ensure the referrer values is up to update with any
2013 customFieldsForm.querySelector('[name="_wp_http_referer"]').setAttribute('value', (0,external_wp_url_namespaceObject.getPathAndQueryString)(window.location.href));
2014 customFieldsForm.submit();
2015 }
2016 function CustomFieldsConfirmation({
2017 willEnable
2018 }) {
2019 const [isReloading, setIsReloading] = (0,external_wp_element_namespaceObject.useState)(false);
2020 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2021 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
2022 className: "edit-post-preferences-modal__custom-fields-confirmation-message",
2023 children: (0,external_wp_i18n_namespaceObject.__)('A page reload is required for this change. Make sure your content is saved before reloading.')
2024 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
2025 __next40pxDefaultSize: true,
2026 variant: "secondary",
2027 isBusy: isReloading,
2028 accessibleWhenDisabled: true,
2029 disabled: isReloading,
2030 onClick: () => {
2031 setIsReloading(true);
2032 submitCustomFieldsForm();
2033 },
2034 children: willEnable ? (0,external_wp_i18n_namespaceObject.__)('Show & Reload Page') : (0,external_wp_i18n_namespaceObject.__)('Hide & Reload Page')
2035 })]
2036 });
2037 }
2038 function EnableCustomFieldsOption({
2039 label
2040 }) {
2041 const areCustomFieldsEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
2042 return !!select(external_wp_editor_namespaceObject.store).getEditorSettings().enableCustomFields;
2043 }, []);
2044 const [isChecked, setIsChecked] = (0,external_wp_element_namespaceObject.useState)(areCustomFieldsEnabled);
2045 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceBaseOption, {
2046 label: label,
2047 isChecked: isChecked,
2048 onChange: setIsChecked,
2049 children: isChecked !== areCustomFieldsEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CustomFieldsConfirmation, {
2050 willEnable: isChecked
2051 })
2052 });
2053 }
2054
2055 ;// ./packages/edit-post/build-module/components/preferences-modal/enable-panel.js
2056 /**
2057 * WordPress dependencies
2058 */
2059
2060
2061
2062
2063 /**
2064 * Internal dependencies
2065 */
2066
2067
2068 const {
2069 PreferenceBaseOption: enable_panel_PreferenceBaseOption
2070 } = unlock(external_wp_preferences_namespaceObject.privateApis);
2071 function EnablePanelOption(props) {
2072 const {
2073 toggleEditorPanelEnabled
2074 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store);
2075 const {
2076 isChecked,
2077 isRemoved
2078 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2079 const {
2080 isEditorPanelEnabled,
2081 isEditorPanelRemoved
2082 } = select(external_wp_editor_namespaceObject.store);
2083 return {
2084 isChecked: isEditorPanelEnabled(props.panelName),
2085 isRemoved: isEditorPanelRemoved(props.panelName)
2086 };
2087 }, [props.panelName]);
2088 if (isRemoved) {
2089 return null;
2090 }
2091 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel_PreferenceBaseOption, {
2092 isChecked: isChecked,
2093 onChange: () => toggleEditorPanelEnabled(props.panelName),
2094 ...props
2095 });
2096 }
2097
2098 ;// ./packages/edit-post/build-module/components/preferences-modal/meta-boxes-section.js
2099 /* wp:polyfill */
2100 /**
2101 * WordPress dependencies
2102 */
2103
2104
2105
2106
2107
2108 /**
2109 * Internal dependencies
2110 */
2111
2112
2113
2114
2115
2116 const {
2117 PreferencesModalSection
2118 } = unlock(external_wp_preferences_namespaceObject.privateApis);
2119 function MetaBoxesSection({
2120 areCustomFieldsRegistered,
2121 metaBoxes,
2122 ...sectionProps
2123 }) {
2124 // The 'Custom Fields' meta box is a special case that we handle separately.
2125 const thirdPartyMetaBoxes = metaBoxes.filter(({
2126 id
2127 }) => id !== 'postcustom');
2128 if (!areCustomFieldsRegistered && thirdPartyMetaBoxes.length === 0) {
2129 return null;
2130 }
2131 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
2132 ...sectionProps,
2133 children: [areCustomFieldsRegistered && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnableCustomFieldsOption, {
2134 label: (0,external_wp_i18n_namespaceObject.__)('Custom fields')
2135 }), thirdPartyMetaBoxes.map(({
2136 id,
2137 title
2138 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EnablePanelOption, {
2139 label: title,
2140 panelName: `meta-box-${id}`
2141 }, id))]
2142 });
2143 }
2144 /* harmony default export */ const meta_boxes_section = ((0,external_wp_data_namespaceObject.withSelect)(select => {
2145 const {
2146 getEditorSettings
2147 } = select(external_wp_editor_namespaceObject.store);
2148 const {
2149 getAllMetaBoxes
2150 } = select(store);
2151 return {
2152 // This setting should not live in the block editor's store.
2153 areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== undefined,
2154 metaBoxes: getAllMetaBoxes()
2155 };
2156 })(MetaBoxesSection));
2157
2158 ;// ./packages/edit-post/build-module/components/preferences-modal/index.js
2159 /**
2160 * WordPress dependencies
2161 */
2162
2163
2164
2165
2166
2167 /**
2168 * Internal dependencies
2169 */
2170
2171
2172
2173 const {
2174 PreferenceToggleControl
2175 } = unlock(external_wp_preferences_namespaceObject.privateApis);
2176 const {
2177 PreferencesModal
2178 } = unlock(external_wp_editor_namespaceObject.privateApis);
2179 function EditPostPreferencesModal() {
2180 const extraSections = {
2181 general: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(meta_boxes_section, {
2182 title: (0,external_wp_i18n_namespaceObject.__)('Advanced')
2183 }),
2184 appearance: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
2185 scope: "core/edit-post",
2186 featureName: "themeStyles",
2187 help: (0,external_wp_i18n_namespaceObject.__)('Make the editor look like your theme.'),
2188 label: (0,external_wp_i18n_namespaceObject.__)('Use theme styles')
2189 })
2190 };
2191 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModal, {
2192 extraSections: extraSections
2193 });
2194 }
2195
2196 ;// ./packages/edit-post/build-module/components/more-menu/index.js
2197 /**
2198 * WordPress dependencies
2199 */
2200
2201
2202
2203
2204
2205
2206 /**
2207 * Internal dependencies
2208 */
2209
2210
2211
2212
2213
2214 const {
2215 ToolsMoreMenuGroup,
2216 ViewMoreMenuGroup
2217 } = unlock(external_wp_editor_namespaceObject.privateApis);
2218 const MoreMenu = () => {
2219 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
2220 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2221 children: [isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ViewMoreMenuGroup, {
2222 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
2223 scope: "core/edit-post",
2224 name: "fullscreenMode",
2225 label: (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode'),
2226 info: (0,external_wp_i18n_namespaceObject.__)('Show and hide the admin user interface'),
2227 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode activated.'),
2228 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Fullscreen mode deactivated.'),
2229 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.secondary('f')
2230 })
2231 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ToolsMoreMenuGroup, {
2232 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(manage_patterns_menu_item, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideMenuItem, {})]
2233 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditPostPreferencesModal, {})]
2234 });
2235 };
2236 /* harmony default export */ const more_menu = (MoreMenu);
2237
2238 ;// ./packages/edit-post/build-module/components/welcome-guide/image.js
2239
2240 function WelcomeGuideImage({
2241 nonAnimatedSrc,
2242 animatedSrc
2243 }) {
2244 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("picture", {
2245 className: "edit-post-welcome-guide__image",
2246 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("source", {
2247 srcSet: nonAnimatedSrc,
2248 media: "(prefers-reduced-motion: reduce)"
2249 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
2250 src: animatedSrc,
2251 width: "312",
2252 height: "240",
2253 alt: ""
2254 })]
2255 });
2256 }
2257
2258 ;// ./packages/edit-post/build-module/components/welcome-guide/default.js
2259 /**
2260 * WordPress dependencies
2261 */
2262
2263
2264
2265
2266
2267 /**
2268 * Internal dependencies
2269 */
2270
2271
2272
2273 function WelcomeGuideDefault() {
2274 const {
2275 toggleFeature
2276 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
2277 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Guide, {
2278 className: "edit-post-welcome-guide",
2279 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the editor'),
2280 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'),
2281 onFinish: () => toggleFeature('welcomeGuide'),
2282 pages: [{
2283 image: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideImage, {
2284 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
2285 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
2286 }),
2287 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2288 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
2289 className: "edit-post-welcome-guide__heading",
2290 children: (0,external_wp_i18n_namespaceObject.__)('Welcome to the editor')
2291 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
2292 className: "edit-post-welcome-guide__text",
2293 children: (0,external_wp_i18n_namespaceObject.__)('In the WordPress editor, each paragraph, image, or video is presented as a distinct “block” of content.')
2294 })]
2295 })
2296 }, {
2297 image: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideImage, {
2298 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
2299 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
2300 }),
2301 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2302 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
2303 className: "edit-post-welcome-guide__heading",
2304 children: (0,external_wp_i18n_namespaceObject.__)('Customize each block')
2305 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
2306 className: "edit-post-welcome-guide__text",
2307 children: (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.')
2308 })]
2309 })
2310 }, {
2311 image: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideImage, {
2312 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
2313 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
2314 }),
2315 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2316 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
2317 className: "edit-post-welcome-guide__heading",
2318 children: (0,external_wp_i18n_namespaceObject.__)('Explore all blocks')
2319 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
2320 className: "edit-post-welcome-guide__text",
2321 children: (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.'), {
2322 InserterIconImage: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
2323 alt: (0,external_wp_i18n_namespaceObject.__)('inserter'),
2324 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"
2325 })
2326 })
2327 })]
2328 })
2329 }, {
2330 image: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideImage, {
2331 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
2332 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
2333 }),
2334 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2335 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
2336 className: "edit-post-welcome-guide__heading",
2337 children: (0,external_wp_i18n_namespaceObject.__)('Learn more')
2338 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
2339 className: "edit-post-welcome-guide__text",
2340 children: (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)("New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"), {
2341 a: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
2342 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/')
2343 })
2344 })
2345 })]
2346 })
2347 }]
2348 });
2349 }
2350
2351 ;// ./packages/edit-post/build-module/components/welcome-guide/template.js
2352 /**
2353 * WordPress dependencies
2354 */
2355
2356
2357
2358
2359 /**
2360 * Internal dependencies
2361 */
2362
2363
2364
2365 function WelcomeGuideTemplate() {
2366 const {
2367 toggleFeature
2368 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
2369 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Guide, {
2370 className: "edit-template-welcome-guide",
2371 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the template editor'),
2372 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'),
2373 onFinish: () => toggleFeature('welcomeGuideTemplate'),
2374 pages: [{
2375 image: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideImage, {
2376 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.svg",
2377 animatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.gif"
2378 }),
2379 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2380 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
2381 className: "edit-post-welcome-guide__heading",
2382 children: (0,external_wp_i18n_namespaceObject.__)('Welcome to the template editor')
2383 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
2384 className: "edit-post-welcome-guide__text",
2385 children: (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.')
2386 })]
2387 })
2388 }]
2389 });
2390 }
2391
2392 ;// ./packages/edit-post/build-module/components/welcome-guide/index.js
2393 /**
2394 * WordPress dependencies
2395 */
2396
2397
2398 /**
2399 * Internal dependencies
2400 */
2401
2402
2403
2404
2405 function WelcomeGuide({
2406 postType
2407 }) {
2408 const {
2409 isActive,
2410 isEditingTemplate
2411 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2412 const {
2413 isFeatureActive
2414 } = select(store);
2415 const _isEditingTemplate = postType === 'wp_template';
2416 const feature = _isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide';
2417 return {
2418 isActive: isFeatureActive(feature),
2419 isEditingTemplate: _isEditingTemplate
2420 };
2421 }, [postType]);
2422 if (!isActive) {
2423 return null;
2424 }
2425 return isEditingTemplate ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideTemplate, {}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuideDefault, {});
2426 }
2427
2428 ;// ./packages/icons/build-module/library/fullscreen.js
2429 /**
2430 * WordPress dependencies
2431 */
2432
2433
2434 const fullscreen = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2435 xmlns: "http://www.w3.org/2000/svg",
2436 viewBox: "0 0 24 24",
2437 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2438 d: "M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z"
2439 })
2440 });
2441 /* harmony default export */ const library_fullscreen = (fullscreen);
2442
2443 ;// ./packages/edit-post/build-module/commands/use-commands.js
2444 /**
2445 * WordPress dependencies
2446 */
2447
2448
2449
2450
2451
2452
2453 function useCommands() {
2454 const {
2455 isFullscreen
2456 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2457 const {
2458 get
2459 } = select(external_wp_preferences_namespaceObject.store);
2460 return {
2461 isFullscreen: get('core/edit-post', 'fullscreenMode')
2462 };
2463 }, []);
2464 const {
2465 toggle
2466 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
2467 const {
2468 createInfoNotice
2469 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
2470 (0,external_wp_commands_namespaceObject.useCommand)({
2471 name: 'core/toggle-fullscreen-mode',
2472 label: isFullscreen ? (0,external_wp_i18n_namespaceObject.__)('Exit fullscreen') : (0,external_wp_i18n_namespaceObject.__)('Enter fullscreen'),
2473 icon: library_fullscreen,
2474 callback: ({
2475 close
2476 }) => {
2477 toggle('core/edit-post', 'fullscreenMode');
2478 close();
2479 createInfoNotice(isFullscreen ? (0,external_wp_i18n_namespaceObject.__)('Fullscreen off.') : (0,external_wp_i18n_namespaceObject.__)('Fullscreen on.'), {
2480 id: 'core/edit-post/toggle-fullscreen-mode/notice',
2481 type: 'snackbar',
2482 actions: [{
2483 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
2484 onClick: () => {
2485 toggle('core/edit-post', 'fullscreenMode');
2486 }
2487 }]
2488 });
2489 }
2490 });
2491 }
2492
2493 ;// ./packages/edit-post/build-module/components/layout/use-padding-appender.js
2494 /**
2495 * WordPress dependencies
2496 */
2497
2498
2499
2500
2501
2502 // Ruleset to add space for the typewriter effect. When typing in the last
2503 // block, there needs to be room to scroll up.
2504 const CSS = ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}';
2505 function usePaddingAppender(enabled) {
2506 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
2507 const effect = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
2508 function onMouseDown(event) {
2509 if (event.target !== node &&
2510 // Tests for the parent element because in the iframed editor if the click is
2511 // below the padding the target will be the parent element (html) and should
2512 // still be treated as intent to append.
2513 event.target !== node.parentElement) {
2514 return;
2515 }
2516
2517 // Only handle clicks under the last child.
2518 const lastChild = node.lastElementChild;
2519 if (!lastChild) {
2520 return;
2521 }
2522 const lastChildRect = lastChild.getBoundingClientRect();
2523 if (event.clientY < lastChildRect.bottom) {
2524 return;
2525 }
2526 event.preventDefault();
2527 const blockOrder = registry.select(external_wp_blockEditor_namespaceObject.store).getBlockOrder('');
2528 const lastBlockClientId = blockOrder[blockOrder.length - 1];
2529 const lastBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(lastBlockClientId);
2530 const {
2531 selectBlock,
2532 insertDefaultBlock
2533 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
2534 if (lastBlock && (0,external_wp_blocks_namespaceObject.isUnmodifiedDefaultBlock)(lastBlock)) {
2535 selectBlock(lastBlockClientId);
2536 } else {
2537 insertDefaultBlock();
2538 }
2539 }
2540 const {
2541 ownerDocument
2542 } = node;
2543 // Adds the listener on the document so that in the iframed editor clicks below the
2544 // padding can be handled as they too should be treated as intent to append.
2545 ownerDocument.addEventListener('mousedown', onMouseDown);
2546 return () => {
2547 ownerDocument.removeEventListener('mousedown', onMouseDown);
2548 };
2549 }, [registry]);
2550 return enabled ? [effect, CSS] : [];
2551 }
2552
2553 ;// ./packages/edit-post/build-module/components/layout/use-should-iframe.js
2554 /* wp:polyfill */
2555 /**
2556 * WordPress dependencies
2557 */
2558
2559
2560
2561
2562
2563 /**
2564 * Internal dependencies
2565 */
2566
2567 function useShouldIframe() {
2568 return (0,external_wp_data_namespaceObject.useSelect)(select => {
2569 const {
2570 getEditorSettings,
2571 getCurrentPostType,
2572 getDeviceType
2573 } = select(external_wp_editor_namespaceObject.store);
2574 return (
2575 // If the theme is block based, we ALWAYS use the iframe for
2576 // consistency across the post and site editor. The iframe was
2577 // introduced long before the sited editor and block themes, so
2578 // these themes are expecting it.
2579 getEditorSettings().__unstableIsBlockBasedTheme ||
2580 // For classic themes, we also still want to iframe all the special
2581 // editor features and modes such as device previews, zoom out, and
2582 // template/pattern editing.
2583 getDeviceType() !== 'Desktop' || ['wp_template', 'wp_block'].includes(getCurrentPostType()) || unlock(select(external_wp_blockEditor_namespaceObject.store)).isZoomOut() ||
2584 // Finally, still iframe the editor for classic themes if all blocks
2585 // are v3 (which means they are marked as iframe-compatible).
2586 select(external_wp_blocks_namespaceObject.store).getBlockTypes().every(type => type.apiVersion >= 3)
2587 );
2588 }, []);
2589 }
2590
2591 ;// ./packages/edit-post/build-module/hooks/use-navigate-to-entity-record.js
2592 /**
2593 * WordPress dependencies
2594 */
2595
2596
2597
2598
2599 /**
2600 * A hook that records the 'entity' history in the post editor as a user
2601 * navigates between editing a post and editing the post template or patterns.
2602 *
2603 * Implemented as a stack, so a little similar to the browser history API.
2604 *
2605 * Used to control displaying UI elements like the back button.
2606 *
2607 * @param {number} initialPostId The post id of the post when the editor loaded.
2608 * @param {string} initialPostType The post type of the post when the editor loaded.
2609 * @param {string} defaultRenderingMode The rendering mode to switch to when navigating.
2610 *
2611 * @return {Object} An object containing the `currentPost` variable and
2612 * `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.
2613 */
2614 function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRenderingMode) {
2615 const [postHistory, dispatch] = (0,external_wp_element_namespaceObject.useReducer)((historyState, {
2616 type,
2617 post,
2618 previousRenderingMode
2619 }) => {
2620 if (type === 'push') {
2621 return [...historyState, {
2622 post,
2623 previousRenderingMode
2624 }];
2625 }
2626 if (type === 'pop') {
2627 // Try to leave one item in the history.
2628 if (historyState.length > 1) {
2629 return historyState.slice(0, -1);
2630 }
2631 }
2632 return historyState;
2633 }, [{
2634 post: {
2635 postId: initialPostId,
2636 postType: initialPostType
2637 }
2638 }]);
2639 const {
2640 post,
2641 previousRenderingMode
2642 } = postHistory[postHistory.length - 1];
2643 const {
2644 getRenderingMode
2645 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_editor_namespaceObject.store);
2646 const {
2647 setRenderingMode
2648 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store);
2649 const onNavigateToEntityRecord = (0,external_wp_element_namespaceObject.useCallback)(params => {
2650 dispatch({
2651 type: 'push',
2652 post: {
2653 postId: params.postId,
2654 postType: params.postType
2655 },
2656 // Save the current rendering mode so we can restore it when navigating back.
2657 previousRenderingMode: getRenderingMode()
2658 });
2659 setRenderingMode(defaultRenderingMode);
2660 }, [getRenderingMode, setRenderingMode, defaultRenderingMode]);
2661 const onNavigateToPreviousEntityRecord = (0,external_wp_element_namespaceObject.useCallback)(() => {
2662 dispatch({
2663 type: 'pop'
2664 });
2665 if (previousRenderingMode) {
2666 setRenderingMode(previousRenderingMode);
2667 }
2668 }, [setRenderingMode, previousRenderingMode]);
2669 return {
2670 currentPost: post,
2671 onNavigateToEntityRecord,
2672 onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : undefined
2673 };
2674 }
2675
2676 ;// ./packages/edit-post/build-module/components/meta-boxes/use-meta-box-initialization.js
2677 /**
2678 * WordPress dependencies
2679 */
2680
2681
2682
2683
2684 /**
2685 * Internal dependencies
2686 */
2687
2688
2689 /**
2690 * Initializes WordPress `postboxes` script and the logic for saving meta boxes.
2691 *
2692 * @param { boolean } enabled
2693 */
2694 const useMetaBoxInitialization = enabled => {
2695 const isEnabledAndEditorReady = (0,external_wp_data_namespaceObject.useSelect)(select => enabled && select(external_wp_editor_namespaceObject.store).__unstableIsEditorReady(), [enabled]);
2696 const {
2697 initializeMetaBoxes
2698 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
2699 // The effect has to rerun when the editor is ready because initializeMetaBoxes
2700 // will noop until then.
2701 (0,external_wp_element_namespaceObject.useEffect)(() => {
2702 if (isEnabledAndEditorReady) {
2703 initializeMetaBoxes();
2704 }
2705 }, [isEnabledAndEditorReady, initializeMetaBoxes]);
2706 };
2707
2708 ;// ./packages/edit-post/build-module/components/layout/index.js
2709 /**
2710 * External dependencies
2711 */
2712
2713
2714 /**
2715 * WordPress dependencies
2716 */
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735 /**
2736 * Internal dependencies
2737 */
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754 const {
2755 getLayoutStyles
2756 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
2757 const {
2758 useCommands: layout_useCommands
2759 } = unlock(external_wp_coreCommands_namespaceObject.privateApis);
2760 const {
2761 useCommandContext
2762 } = unlock(external_wp_commands_namespaceObject.privateApis);
2763 const {
2764 Editor,
2765 FullscreenMode,
2766 NavigableRegion
2767 } = unlock(external_wp_editor_namespaceObject.privateApis);
2768 const {
2769 BlockKeyboardShortcuts
2770 } = unlock(external_wp_blockLibrary_namespaceObject.privateApis);
2771 const DESIGN_POST_TYPES = ['wp_template', 'wp_template_part', 'wp_block', 'wp_navigation'];
2772 function useEditorStyles(...additionalStyles) {
2773 const {
2774 hasThemeStyleSupport,
2775 editorSettings
2776 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2777 return {
2778 hasThemeStyleSupport: select(store).isFeatureActive('themeStyles'),
2779 editorSettings: select(external_wp_editor_namespaceObject.store).getEditorSettings()
2780 };
2781 }, []);
2782 const addedStyles = additionalStyles.join('\n');
2783
2784 // Compute the default styles.
2785 return (0,external_wp_element_namespaceObject.useMemo)(() => {
2786 var _editorSettings$style, _editorSettings$defau, _editorSettings$style2, _editorSettings$style3;
2787 const presetStyles = (_editorSettings$style = editorSettings.styles?.filter(style => style.__unstableType && style.__unstableType !== 'theme')) !== null && _editorSettings$style !== void 0 ? _editorSettings$style : [];
2788 const defaultEditorStyles = [...((_editorSettings$defau = editorSettings?.defaultEditorStyles) !== null && _editorSettings$defau !== void 0 ? _editorSettings$defau : []), ...presetStyles];
2789
2790 // Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).
2791 const hasThemeStyles = hasThemeStyleSupport && presetStyles.length !== ((_editorSettings$style2 = editorSettings.styles?.length) !== null && _editorSettings$style2 !== void 0 ? _editorSettings$style2 : 0);
2792
2793 // If theme styles are not present or displayed, ensure that
2794 // base layout styles are still present in the editor.
2795 if (!editorSettings.disableLayoutStyles && !hasThemeStyles) {
2796 defaultEditorStyles.push({
2797 css: getLayoutStyles({
2798 style: {},
2799 selector: 'body',
2800 hasBlockGapSupport: false,
2801 hasFallbackGapSupport: true,
2802 fallbackGapValue: '0.5em'
2803 })
2804 });
2805 }
2806 const baseStyles = hasThemeStyles ? (_editorSettings$style3 = editorSettings.styles) !== null && _editorSettings$style3 !== void 0 ? _editorSettings$style3 : [] : defaultEditorStyles;
2807 if (addedStyles) {
2808 return [...baseStyles, {
2809 css: addedStyles
2810 }];
2811 }
2812 return baseStyles;
2813 }, [editorSettings.defaultEditorStyles, editorSettings.disableLayoutStyles, editorSettings.styles, hasThemeStyleSupport, addedStyles]);
2814 }
2815 function MetaBoxesMain() {
2816 const [isOpen, openHeight, hasAnyVisible] = (0,external_wp_data_namespaceObject.useSelect)(select => {
2817 const {
2818 get
2819 } = select(external_wp_preferences_namespaceObject.store);
2820 const {
2821 isMetaBoxLocationVisible
2822 } = select(store);
2823 return [get('core/edit-post', 'metaBoxesMainIsOpen'), get('core/edit-post', 'metaBoxesMainOpenHeight'), isMetaBoxLocationVisible('normal') || isMetaBoxLocationVisible('advanced') || isMetaBoxLocationVisible('side')];
2824 }, []);
2825 const {
2826 set: setPreference
2827 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
2828 const metaBoxesMainRef = (0,external_wp_element_namespaceObject.useRef)();
2829 const isShort = (0,external_wp_compose_namespaceObject.useMediaQuery)('(max-height: 549px)');
2830 const [{
2831 min,
2832 max
2833 }, setHeightConstraints] = (0,external_wp_element_namespaceObject.useState)(() => ({}));
2834 // Keeps the resizable area’s size constraints updated taking into account
2835 // editor notices. The constraints are also used to derive the value for the
2836 // aria-valuenow attribute on the seperator.
2837 const effectSizeConstraints = (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
2838 const container = node.closest('.interface-interface-skeleton__content');
2839 const noticeLists = container.querySelectorAll(':scope > .components-notice-list');
2840 const resizeHandle = container.querySelector('.edit-post-meta-boxes-main__presenter');
2841 const deriveConstraints = () => {
2842 const fullHeight = container.offsetHeight;
2843 let nextMax = fullHeight;
2844 for (const element of noticeLists) {
2845 nextMax -= element.offsetHeight;
2846 }
2847 const nextMin = resizeHandle.offsetHeight;
2848 setHeightConstraints({
2849 min: nextMin,
2850 max: nextMax
2851 });
2852 };
2853 const observer = new window.ResizeObserver(deriveConstraints);
2854 observer.observe(container);
2855 for (const element of noticeLists) {
2856 observer.observe(element);
2857 }
2858 return () => observer.disconnect();
2859 }, []);
2860 const separatorRef = (0,external_wp_element_namespaceObject.useRef)();
2861 const separatorHelpId = (0,external_wp_element_namespaceObject.useId)();
2862 const [isUntouched, setIsUntouched] = (0,external_wp_element_namespaceObject.useState)(true);
2863 const applyHeight = (candidateHeight, isPersistent, isInstant) => {
2864 const nextHeight = Math.min(max, Math.max(min, candidateHeight));
2865 if (isPersistent) {
2866 setPreference('core/edit-post', 'metaBoxesMainOpenHeight', nextHeight);
2867 } else {
2868 separatorRef.current.ariaValueNow = getAriaValueNow(nextHeight);
2869 }
2870 if (isInstant) {
2871 metaBoxesMainRef.current.updateSize({
2872 height: nextHeight,
2873 // Oddly, when the event that triggered this was not from the mouse (e.g. keydown),
2874 // if `width` is left unspecified a subsequent drag gesture applies a fixed
2875 // width and the pane fails to widen/narrow with parent width changes from
2876 // sidebars opening/closing or window resizes.
2877 width: 'auto'
2878 });
2879 }
2880 };
2881 if (!hasAnyVisible) {
2882 return;
2883 }
2884 const contents = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
2885 // The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.
2886 className: "edit-post-layout__metaboxes edit-post-meta-boxes-main__liner",
2887 hidden: isShort && !isOpen,
2888 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MetaBoxes, {
2889 location: "normal"
2890 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MetaBoxes, {
2891 location: "advanced"
2892 })]
2893 });
2894 const isAutoHeight = openHeight === undefined;
2895 let usedMax = '50%'; // Approximation before max has a value.
2896 if (max !== undefined) {
2897 // Halves the available max height until a user height is set.
2898 usedMax = isAutoHeight && isUntouched ? max / 2 : max;
2899 }
2900 const getAriaValueNow = height => Math.round((height - min) / (max - min) * 100);
2901 const usedAriaValueNow = max === undefined || isAutoHeight ? 50 : getAriaValueNow(openHeight);
2902 const toggle = () => setPreference('core/edit-post', 'metaBoxesMainIsOpen', !isOpen);
2903
2904 // TODO: Support more/all keyboard interactions from the window splitter pattern:
2905 // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
2906 const onSeparatorKeyDown = event => {
2907 const delta = {
2908 ArrowUp: 20,
2909 ArrowDown: -20
2910 }[event.key];
2911 if (delta) {
2912 const pane = metaBoxesMainRef.current.resizable;
2913 const fromHeight = isAutoHeight ? pane.offsetHeight : openHeight;
2914 const nextHeight = delta + fromHeight;
2915 applyHeight(nextHeight, true, true);
2916 event.preventDefault();
2917 }
2918 };
2919 const className = 'edit-post-meta-boxes-main';
2920 const paneLabel = (0,external_wp_i18n_namespaceObject.__)('Meta Boxes');
2921 let Pane, paneProps;
2922 if (isShort) {
2923 Pane = NavigableRegion;
2924 paneProps = {
2925 className: dist_clsx(className, 'is-toggle-only')
2926 };
2927 } else {
2928 Pane = external_wp_components_namespaceObject.ResizableBox;
2929 paneProps = /** @type {Parameters<typeof ResizableBox>[0]} */{
2930 as: NavigableRegion,
2931 ref: metaBoxesMainRef,
2932 className: dist_clsx(className, 'is-resizable'),
2933 defaultSize: {
2934 height: openHeight
2935 },
2936 minHeight: min,
2937 maxHeight: usedMax,
2938 enable: {
2939 top: true,
2940 right: false,
2941 bottom: false,
2942 left: false,
2943 topLeft: false,
2944 topRight: false,
2945 bottomRight: false,
2946 bottomLeft: false
2947 },
2948 handleClasses: {
2949 top: 'edit-post-meta-boxes-main__presenter'
2950 },
2951 handleComponent: {
2952 top: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
2953 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
2954 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
2955 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("button", {
2956 // eslint-disable-line jsx-a11y/role-supports-aria-props
2957 ref: separatorRef,
2958 role: "separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
2959 ,
2960 "aria-valuenow": usedAriaValueNow,
2961 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
2962 "aria-describedby": separatorHelpId,
2963 onKeyDown: onSeparatorKeyDown
2964 })
2965 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
2966 id: separatorHelpId,
2967 children: (0,external_wp_i18n_namespaceObject.__)('Use up and down arrow keys to resize the meta box panel.')
2968 })]
2969 })
2970 },
2971 // Avoids hiccups while dragging over objects like iframes and ensures that
2972 // the event to end the drag is captured by the target (resize handle)
2973 // whether or not it’s under the pointer.
2974 onPointerDown: ({
2975 pointerId,
2976 target
2977 }) => {
2978 if (separatorRef.current.parentElement.contains(target)) {
2979 target.setPointerCapture(pointerId);
2980 }
2981 },
2982 onResizeStart: (event, direction, elementRef) => {
2983 if (isAutoHeight) {
2984 // Sets the starting height to avoid visual jumps in height and
2985 // aria-valuenow being `NaN` for the first (few) resize events.
2986 applyHeight(elementRef.offsetHeight, false, true);
2987 setIsUntouched(false);
2988 }
2989 },
2990 onResize: () => applyHeight(metaBoxesMainRef.current.state.height),
2991 onResizeStop: () => applyHeight(metaBoxesMainRef.current.state.height, true)
2992 };
2993 }
2994 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Pane, {
2995 "aria-label": paneLabel,
2996 ...paneProps,
2997 children: [isShort ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("button", {
2998 "aria-expanded": isOpen,
2999 className: "edit-post-meta-boxes-main__presenter",
3000 onClick: toggle,
3001 children: [paneLabel, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
3002 icon: isOpen ? chevron_up : chevron_down
3003 })]
3004 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("meta", {
3005 ref: effectSizeConstraints
3006 }), contents]
3007 });
3008 }
3009 function Layout({
3010 postId: initialPostId,
3011 postType: initialPostType,
3012 settings,
3013 initialEdits
3014 }) {
3015 layout_useCommands();
3016 useCommands();
3017 const shouldIframe = useShouldIframe();
3018 const {
3019 createErrorNotice
3020 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
3021 const {
3022 currentPost: {
3023 postId: currentPostId,
3024 postType: currentPostType
3025 },
3026 onNavigateToEntityRecord,
3027 onNavigateToPreviousEntityRecord
3028 } = useNavigateToEntityRecord(initialPostId, initialPostType, 'post-only');
3029 const isEditingTemplate = currentPostType === 'wp_template';
3030 const {
3031 mode,
3032 isFullscreenActive,
3033 hasActiveMetaboxes,
3034 hasBlockSelected,
3035 showIconLabels,
3036 isDistractionFree,
3037 showMetaBoxes,
3038 isWelcomeGuideVisible,
3039 templateId,
3040 enablePaddingAppender
3041 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
3042 var _getPostType$viewable;
3043 const {
3044 get
3045 } = select(external_wp_preferences_namespaceObject.store);
3046 const {
3047 isFeatureActive
3048 } = select(store);
3049 const {
3050 canUser,
3051 getPostType,
3052 getTemplateId
3053 } = unlock(select(external_wp_coreData_namespaceObject.store));
3054 const supportsTemplateMode = settings.supportsTemplateMode;
3055 const isViewable = (_getPostType$viewable = getPostType(currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
3056 const canViewTemplate = canUser('read', {
3057 kind: 'postType',
3058 name: 'wp_template'
3059 });
3060 const {
3061 isZoomOut
3062 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
3063 const {
3064 getEditorMode,
3065 getRenderingMode
3066 } = select(external_wp_editor_namespaceObject.store);
3067 const isRenderingPostOnly = getRenderingMode() === 'post-only';
3068 const isNotDesignPostType = !DESIGN_POST_TYPES.includes(currentPostType);
3069 const isDirectlyEditingPattern = currentPostType === 'wp_block' && !onNavigateToPreviousEntityRecord;
3070 return {
3071 mode: getEditorMode(),
3072 isFullscreenActive: select(store).isFeatureActive('fullscreenMode'),
3073 hasActiveMetaboxes: select(store).hasMetaBoxes(),
3074 hasBlockSelected: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(),
3075 showIconLabels: get('core', 'showIconLabels'),
3076 isDistractionFree: get('core', 'distractionFree'),
3077 showMetaBoxes: isNotDesignPostType && !isZoomOut() || isDirectlyEditingPattern,
3078 isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
3079 templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? getTemplateId(currentPostType, currentPostId) : null,
3080 enablePaddingAppender: !isZoomOut() && isRenderingPostOnly && isNotDesignPostType
3081 };
3082 }, [currentPostType, currentPostId, isEditingTemplate, settings.supportsTemplateMode, onNavigateToPreviousEntityRecord]);
3083 useMetaBoxInitialization(hasActiveMetaboxes);
3084 const [paddingAppenderRef, paddingStyle] = usePaddingAppender(enablePaddingAppender);
3085
3086 // Set the right context for the command palette
3087 const commandContext = hasBlockSelected ? 'block-selection-edit' : 'entity-edit';
3088 useCommandContext(commandContext);
3089 const editorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => ({
3090 ...settings,
3091 onNavigateToEntityRecord,
3092 onNavigateToPreviousEntityRecord,
3093 defaultRenderingMode: 'post-only'
3094 }), [settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]);
3095 const styles = useEditorStyles(paddingStyle);
3096
3097 // We need to add the show-icon-labels class to the body element so it is applied to modals.
3098 if (showIconLabels) {
3099 document.body.classList.add('show-icon-labels');
3100 } else {
3101 document.body.classList.remove('show-icon-labels');
3102 }
3103 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)();
3104 const className = dist_clsx('edit-post-layout', 'is-mode-' + mode, {
3105 'has-metaboxes': hasActiveMetaboxes
3106 });
3107 function onPluginAreaError(name) {
3108 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: plugin name */
3109 (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
3110 }
3111 const {
3112 createSuccessNotice
3113 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
3114 const onActionPerformed = (0,external_wp_element_namespaceObject.useCallback)((actionId, items) => {
3115 switch (actionId) {
3116 case 'move-to-trash':
3117 {
3118 document.location.href = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
3119 trashed: 1,
3120 post_type: items[0].type,
3121 ids: items[0].id
3122 });
3123 }
3124 break;
3125 case 'duplicate-post':
3126 {
3127 const newItem = items[0];
3128 const title = typeof newItem.title === 'string' ? newItem.title : newItem.title?.rendered;
3129 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
3130 // translators: %s: Title of the created post or template, e.g: "Hello world".
3131 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), {
3132 type: 'snackbar',
3133 id: 'duplicate-post-action',
3134 actions: [{
3135 label: (0,external_wp_i18n_namespaceObject.__)('Edit'),
3136 onClick: () => {
3137 const postId = newItem.id;
3138 document.location.href = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
3139 post: postId,
3140 action: 'edit'
3141 });
3142 }
3143 }]
3144 });
3145 }
3146 break;
3147 }
3148 }, [createSuccessNotice]);
3149 const initialPost = (0,external_wp_element_namespaceObject.useMemo)(() => {
3150 return {
3151 type: initialPostType,
3152 id: initialPostId
3153 };
3154 }, [initialPostType, initialPostId]);
3155 const backButton = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium') && isFullscreenActive ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button, {
3156 initialPost: initialPost
3157 }) : null;
3158 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SlotFillProvider, {
3159 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_editor_namespaceObject.ErrorBoundary, {
3160 canCopyContent: true,
3161 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_commands_namespaceObject.CommandMenu, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WelcomeGuide, {
3162 postType: currentPostType
3163 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
3164 className: navigateRegionsProps.className,
3165 ...navigateRegionsProps,
3166 ref: navigateRegionsProps.ref,
3167 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Editor, {
3168 settings: editorSettings,
3169 initialEdits: initialEdits,
3170 postType: currentPostType,
3171 postId: currentPostId,
3172 templateId: templateId,
3173 className: className,
3174 styles: styles,
3175 forceIsDirty: hasActiveMetaboxes,
3176 contentRef: paddingAppenderRef,
3177 disableIframe: !shouldIframe
3178 // We should auto-focus the canvas (title) on load.
3179 // eslint-disable-next-line jsx-a11y/no-autofocus
3180 ,
3181 autoFocus: !isWelcomeGuideVisible,
3182 onActionPerformed: onActionPerformed,
3183 extraSidebarPanels: showMetaBoxes && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MetaBoxes, {
3184 location: "side"
3185 }),
3186 extraContent: !isDistractionFree && showMetaBoxes && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MetaBoxesMain, {}),
3187 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PostLockedModal, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorInitialization, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(FullscreenMode, {
3188 isActive: isFullscreenActive
3189 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(browser_url, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.UnsavedChangesWarning, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.AutosaveMonitor, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.LocalAutosaveMonitor, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcuts, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.EditorKeyboardShortcutsRegister, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockKeyboardShortcuts, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InitPatternModal, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_plugins_namespaceObject.PluginArea, {
3190 onError: onPluginAreaError
3191 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(more_menu, {}), backButton, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.EditorSnackbars, {})]
3192 })
3193 })]
3194 })
3195 });
3196 }
3197 /* harmony default export */ const layout = (Layout);
3198
3199 ;// ./packages/edit-post/build-module/deprecated.js
3200 /**
3201 * WordPress dependencies
3202 */
3203
3204
3205
3206
3207 /**
3208 * Internal dependencies
3209 */
3210
3211
3212 const {
3213 PluginPostExcerpt
3214 } = unlock(external_wp_editor_namespaceObject.privateApis);
3215 const isSiteEditor = (0,external_wp_url_namespaceObject.getPath)(window.location.href)?.includes('site-editor.php');
3216 const deprecateSlot = name => {
3217 external_wp_deprecated_default()(`wp.editPost.${name}`, {
3218 since: '6.6',
3219 alternative: `wp.editor.${name}`
3220 });
3221 };
3222
3223 /* eslint-disable jsdoc/require-param */
3224 /**
3225 * @see PluginBlockSettingsMenuItem in @wordpress/editor package.
3226 */
3227 function PluginBlockSettingsMenuItem(props) {
3228 if (isSiteEditor) {
3229 return null;
3230 }
3231 deprecateSlot('PluginBlockSettingsMenuItem');
3232 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginBlockSettingsMenuItem, {
3233 ...props
3234 });
3235 }
3236
3237 /**
3238 * @see PluginDocumentSettingPanel in @wordpress/editor package.
3239 */
3240 function PluginDocumentSettingPanel(props) {
3241 if (isSiteEditor) {
3242 return null;
3243 }
3244 deprecateSlot('PluginDocumentSettingPanel');
3245 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginDocumentSettingPanel, {
3246 ...props
3247 });
3248 }
3249
3250 /**
3251 * @see PluginMoreMenuItem in @wordpress/editor package.
3252 */
3253 function PluginMoreMenuItem(props) {
3254 if (isSiteEditor) {
3255 return null;
3256 }
3257 deprecateSlot('PluginMoreMenuItem');
3258 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginMoreMenuItem, {
3259 ...props
3260 });
3261 }
3262
3263 /**
3264 * @see PluginPrePublishPanel in @wordpress/editor package.
3265 */
3266 function PluginPrePublishPanel(props) {
3267 if (isSiteEditor) {
3268 return null;
3269 }
3270 deprecateSlot('PluginPrePublishPanel');
3271 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginPrePublishPanel, {
3272 ...props
3273 });
3274 }
3275
3276 /**
3277 * @see PluginPostPublishPanel in @wordpress/editor package.
3278 */
3279 function PluginPostPublishPanel(props) {
3280 if (isSiteEditor) {
3281 return null;
3282 }
3283 deprecateSlot('PluginPostPublishPanel');
3284 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginPostPublishPanel, {
3285 ...props
3286 });
3287 }
3288
3289 /**
3290 * @see PluginPostStatusInfo in @wordpress/editor package.
3291 */
3292 function PluginPostStatusInfo(props) {
3293 if (isSiteEditor) {
3294 return null;
3295 }
3296 deprecateSlot('PluginPostStatusInfo');
3297 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginPostStatusInfo, {
3298 ...props
3299 });
3300 }
3301
3302 /**
3303 * @see PluginSidebar in @wordpress/editor package.
3304 */
3305 function PluginSidebar(props) {
3306 if (isSiteEditor) {
3307 return null;
3308 }
3309 deprecateSlot('PluginSidebar');
3310 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginSidebar, {
3311 ...props
3312 });
3313 }
3314
3315 /**
3316 * @see PluginSidebarMoreMenuItem in @wordpress/editor package.
3317 */
3318 function PluginSidebarMoreMenuItem(props) {
3319 if (isSiteEditor) {
3320 return null;
3321 }
3322 deprecateSlot('PluginSidebarMoreMenuItem');
3323 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_editor_namespaceObject.PluginSidebarMoreMenuItem, {
3324 ...props
3325 });
3326 }
3327
3328 /**
3329 * @see PluginPostExcerpt in @wordpress/editor package.
3330 */
3331 function __experimentalPluginPostExcerpt() {
3332 if (isSiteEditor) {
3333 return null;
3334 }
3335 external_wp_deprecated_default()('wp.editPost.__experimentalPluginPostExcerpt', {
3336 since: '6.6',
3337 hint: 'Core and custom panels can be access programmatically using their panel name.',
3338 link: 'https://developer.wordpress.org/block-editor/reference-guides/slotfills/plugin-document-setting-panel/#accessing-a-panel-programmatically'
3339 });
3340 return PluginPostExcerpt;
3341 }
3342
3343 /* eslint-enable jsdoc/require-param */
3344
3345 ;// ./packages/edit-post/build-module/index.js
3346 /**
3347 * WordPress dependencies
3348 */
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358 /**
3359 * Internal dependencies
3360 */
3361
3362
3363
3364 const {
3365 BackButton: __experimentalMainDashboardButton,
3366 registerCoreBlockBindingsSources
3367 } = unlock(external_wp_editor_namespaceObject.privateApis);
3368
3369 /**
3370 * Initializes and returns an instance of Editor.
3371 *
3372 * @param {string} id Unique identifier for editor instance.
3373 * @param {string} postType Post type of the post to edit.
3374 * @param {Object} postId ID of the post to edit.
3375 * @param {?Object} settings Editor settings object.
3376 * @param {Object} initialEdits Programmatic edits to apply initially, to be
3377 * considered as non-user-initiated (bypass for
3378 * unsaved changes prompt).
3379 */
3380 function initializeEditor(id, postType, postId, settings, initialEdits) {
3381 const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
3382 const target = document.getElementById(id);
3383 const root = (0,external_wp_element_namespaceObject.createRoot)(target);
3384 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-post', {
3385 fullscreenMode: true,
3386 themeStyles: true,
3387 welcomeGuide: true,
3388 welcomeGuideTemplate: true
3389 });
3390 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core', {
3391 allowRightClickOverrides: true,
3392 editorMode: 'visual',
3393 editorTool: 'edit',
3394 fixedToolbar: false,
3395 hiddenBlockTypes: [],
3396 inactivePanels: [],
3397 openPanels: ['post-status'],
3398 showBlockBreadcrumbs: true,
3399 showIconLabels: false,
3400 showListViewByDefault: false,
3401 enableChoosePatternModal: true,
3402 isPublishSidebarEnabled: true
3403 });
3404 if (window.__experimentalMediaProcessing) {
3405 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/media', {
3406 requireApproval: true,
3407 optimizeOnUpload: true
3408 });
3409 }
3410 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).reapplyBlockTypeFilters();
3411
3412 // Check if the block list view should be open by default.
3413 // If `distractionFree` mode is enabled, the block list view should not be open.
3414 // This behavior is disabled for small viewports.
3415 if (isMediumOrBigger && (0,external_wp_data_namespaceObject.select)(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault') && !(0,external_wp_data_namespaceObject.select)(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree')) {
3416 (0,external_wp_data_namespaceObject.dispatch)(external_wp_editor_namespaceObject.store).setIsListViewOpened(true);
3417 }
3418 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
3419 registerCoreBlockBindingsSources();
3420 (0,external_wp_widgets_namespaceObject.registerLegacyWidgetBlock)({
3421 inserter: false
3422 });
3423 (0,external_wp_widgets_namespaceObject.registerWidgetGroupBlock)({
3424 inserter: false
3425 });
3426 if (true) {
3427 (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)({
3428 enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks
3429 });
3430 }
3431
3432 // Show a console log warning if the browser is not in Standards rendering mode.
3433 const documentMode = document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
3434 if (documentMode !== 'Standards') {
3435 // eslint-disable-next-line no-console
3436 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.");
3437 }
3438
3439 // This is a temporary fix for a couple of issues specific to Webkit on iOS.
3440 // Without this hack the browser scrolls the mobile toolbar off-screen.
3441 // Once supported in Safari we can replace this in favor of preventScroll.
3442 // For details see issue #18632 and PR #18686
3443 // Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.
3444 // But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.
3445
3446 const isIphone = window.navigator.userAgent.indexOf('iPhone') !== -1;
3447 if (isIphone) {
3448 window.addEventListener('scroll', event => {
3449 const editorScrollContainer = document.getElementsByClassName('interface-interface-skeleton__body')[0];
3450 if (event.target === document) {
3451 // Scroll element into view by scrolling the editor container by the same amount
3452 // that Mobile Safari tried to scroll the html element upwards.
3453 if (window.scrollY > 100) {
3454 editorScrollContainer.scrollTop = editorScrollContainer.scrollTop + window.scrollY;
3455 }
3456 // Undo unwanted scroll on html element, but only in the visual editor.
3457 if (document.getElementsByClassName('is-mode-visual')[0]) {
3458 window.scrollTo(0, 0);
3459 }
3460 }
3461 });
3462 }
3463
3464 // Prevent the default browser action for files dropped outside of dropzones.
3465 window.addEventListener('dragover', e => e.preventDefault(), false);
3466 window.addEventListener('drop', e => e.preventDefault(), false);
3467 root.render(/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.StrictMode, {
3468 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(layout, {
3469 settings: settings,
3470 postId: postId,
3471 postType: postType,
3472 initialEdits: initialEdits
3473 })
3474 }));
3475 return root;
3476 }
3477
3478 /**
3479 * Used to reinitialize the editor after an error. Now it's a deprecated noop function.
3480 */
3481 function reinitializeEditor() {
3482 external_wp_deprecated_default()('wp.editPost.reinitializeEditor', {
3483 since: '6.2',
3484 version: '6.3'
3485 });
3486 }
3487
3488
3489
3490
3491
3492 (window.wp = window.wp || {}).editPost = __webpack_exports__;
3493 /******/ })()
3494 ;