| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var wp; 2 (wp ||= {}).editWidgets = (() => { 3 var __create = Object.create; 4 var __defProp = Object.defineProperty; 5 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 6 var __getOwnPropNames = Object.getOwnPropertyNames; 7 var __getProtoOf = Object.getPrototypeOf; 8 var __hasOwnProp = Object.prototype.hasOwnProperty; 9 var __commonJS = (cb, mod) => function __require() { 10 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 11 }; 12 var __export = (target, all) => { 13 for (var name2 in all) 14 __defProp(target, name2, { get: all[name2], enumerable: true }); 15 }; 16 var __copyProps = (to, from, except, desc) => { 17 if (from && typeof from === "object" || typeof from === "function") { 18 for (let key of __getOwnPropNames(from)) 19 if (!__hasOwnProp.call(to, key) && key !== except) 20 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 21 } 22 return to; 23 }; 24 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 25 // If the importer is in node compatibility mode or this is not an ESM 26 // file that has been converted to a CommonJS file using a Babel- 27 // compatible transform (i.e. "__esModule" has not been set), then set 28 // "default" to the CommonJS "module.exports" for node compatibility. 29 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 30 mod 31 )); 32 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 33 34 // package-external:@wordpress/blocks 35 var require_blocks = __commonJS({ 36 "package-external:@wordpress/blocks"(exports, module) { 37 module.exports = window.wp.blocks; 38 } 39 }); 40 41 // package-external:@wordpress/data 42 var require_data = __commonJS({ 43 "package-external:@wordpress/data"(exports, module) { 44 module.exports = window.wp.data; 45 } 46 }); 47 48 // package-external:@wordpress/deprecated 49 var require_deprecated = __commonJS({ 50 "package-external:@wordpress/deprecated"(exports, module) { 51 module.exports = window.wp.deprecated; 52 } 53 }); 54 55 // package-external:@wordpress/element 56 var require_element = __commonJS({ 57 "package-external:@wordpress/element"(exports, module) { 58 module.exports = window.wp.element; 59 } 60 }); 61 62 // package-external:@wordpress/block-library 63 var require_block_library = __commonJS({ 64 "package-external:@wordpress/block-library"(exports, module) { 65 module.exports = window.wp.blockLibrary; 66 } 67 }); 68 69 // package-external:@wordpress/core-data 70 var require_core_data = __commonJS({ 71 "package-external:@wordpress/core-data"(exports, module) { 72 module.exports = window.wp.coreData; 73 } 74 }); 75 76 // package-external:@wordpress/widgets 77 var require_widgets = __commonJS({ 78 "package-external:@wordpress/widgets"(exports, module) { 79 module.exports = window.wp.widgets; 80 } 81 }); 82 83 // package-external:@wordpress/preferences 84 var require_preferences = __commonJS({ 85 "package-external:@wordpress/preferences"(exports, module) { 86 module.exports = window.wp.preferences; 87 } 88 }); 89 90 // package-external:@wordpress/api-fetch 91 var require_api_fetch = __commonJS({ 92 "package-external:@wordpress/api-fetch"(exports, module) { 93 module.exports = window.wp.apiFetch; 94 } 95 }); 96 97 // package-external:@wordpress/i18n 98 var require_i18n = __commonJS({ 99 "package-external:@wordpress/i18n"(exports, module) { 100 module.exports = window.wp.i18n; 101 } 102 }); 103 104 // package-external:@wordpress/notices 105 var require_notices = __commonJS({ 106 "package-external:@wordpress/notices"(exports, module) { 107 module.exports = window.wp.notices; 108 } 109 }); 110 111 // package-external:@wordpress/components 112 var require_components = __commonJS({ 113 "package-external:@wordpress/components"(exports, module) { 114 module.exports = window.wp.components; 115 } 116 }); 117 118 // package-external:@wordpress/primitives 119 var require_primitives = __commonJS({ 120 "package-external:@wordpress/primitives"(exports, module) { 121 module.exports = window.wp.primitives; 122 } 123 }); 124 125 // vendor-external:react/jsx-runtime 126 var require_jsx_runtime = __commonJS({ 127 "vendor-external:react/jsx-runtime"(exports, module) { 128 module.exports = window.ReactJSXRuntime; 129 } 130 }); 131 132 // package-external:@wordpress/viewport 133 var require_viewport = __commonJS({ 134 "package-external:@wordpress/viewport"(exports, module) { 135 module.exports = window.wp.viewport; 136 } 137 }); 138 139 // package-external:@wordpress/compose 140 var require_compose = __commonJS({ 141 "package-external:@wordpress/compose"(exports, module) { 142 module.exports = window.wp.compose; 143 } 144 }); 145 146 // package-external:@wordpress/plugins 147 var require_plugins = __commonJS({ 148 "package-external:@wordpress/plugins"(exports, module) { 149 module.exports = window.wp.plugins; 150 } 151 }); 152 153 // package-external:@wordpress/private-apis 154 var require_private_apis = __commonJS({ 155 "package-external:@wordpress/private-apis"(exports, module) { 156 module.exports = window.wp.privateApis; 157 } 158 }); 159 160 // package-external:@wordpress/block-editor 161 var require_block_editor = __commonJS({ 162 "package-external:@wordpress/block-editor"(exports, module) { 163 module.exports = window.wp.blockEditor; 164 } 165 }); 166 167 // package-external:@wordpress/hooks 168 var require_hooks = __commonJS({ 169 "package-external:@wordpress/hooks"(exports, module) { 170 module.exports = window.wp.hooks; 171 } 172 }); 173 174 // package-external:@wordpress/media-utils 175 var require_media_utils = __commonJS({ 176 "package-external:@wordpress/media-utils"(exports, module) { 177 module.exports = window.wp.mediaUtils; 178 } 179 }); 180 181 // package-external:@wordpress/patterns 182 var require_patterns = __commonJS({ 183 "package-external:@wordpress/patterns"(exports, module) { 184 module.exports = window.wp.patterns; 185 } 186 }); 187 188 // package-external:@wordpress/keyboard-shortcuts 189 var require_keyboard_shortcuts = __commonJS({ 190 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 191 module.exports = window.wp.keyboardShortcuts; 192 } 193 }); 194 195 // package-external:@wordpress/keycodes 196 var require_keycodes = __commonJS({ 197 "package-external:@wordpress/keycodes"(exports, module) { 198 module.exports = window.wp.keycodes; 199 } 200 }); 201 202 // package-external:@wordpress/url 203 var require_url = __commonJS({ 204 "package-external:@wordpress/url"(exports, module) { 205 module.exports = window.wp.url; 206 } 207 }); 208 209 // package-external:@wordpress/dom 210 var require_dom = __commonJS({ 211 "package-external:@wordpress/dom"(exports, module) { 212 module.exports = window.wp.dom; 213 } 214 }); 215 216 // packages/edit-widgets/build-module/index.mjs 217 var index_exports = {}; 218 __export(index_exports, { 219 initialize: () => initialize, 220 initializeEditor: () => initializeEditor, 221 reinitializeEditor: () => reinitializeEditor, 222 store: () => store2 223 }); 224 var import_blocks3 = __toESM(require_blocks(), 1); 225 var import_data32 = __toESM(require_data(), 1); 226 var import_deprecated6 = __toESM(require_deprecated(), 1); 227 var import_element25 = __toESM(require_element(), 1); 228 var import_block_library2 = __toESM(require_block_library(), 1); 229 var import_core_data12 = __toESM(require_core_data(), 1); 230 var import_widgets5 = __toESM(require_widgets(), 1); 231 var import_preferences10 = __toESM(require_preferences(), 1); 232 233 // packages/edit-widgets/build-module/store/index.mjs 234 var import_api_fetch = __toESM(require_api_fetch(), 1); 235 var import_data8 = __toESM(require_data(), 1); 236 237 // packages/edit-widgets/build-module/store/reducer.mjs 238 var import_data = __toESM(require_data(), 1); 239 function widgetAreasOpenState(state = {}, action) { 240 const { type } = action; 241 switch (type) { 242 case "SET_WIDGET_AREAS_OPEN_STATE": { 243 return action.widgetAreasOpenState; 244 } 245 case "SET_IS_WIDGET_AREA_OPEN": { 246 const { clientId, isOpen } = action; 247 return { 248 ...state, 249 [clientId]: isOpen 250 }; 251 } 252 default: { 253 return state; 254 } 255 } 256 } 257 function blockInserterPanel(state = false, action) { 258 switch (action.type) { 259 case "SET_IS_LIST_VIEW_OPENED": 260 return action.isOpen ? false : state; 261 case "SET_IS_INSERTER_OPENED": 262 return action.value; 263 } 264 return state; 265 } 266 function listViewPanel(state = false, action) { 267 switch (action.type) { 268 case "SET_IS_INSERTER_OPENED": 269 return action.value ? false : state; 270 case "SET_IS_LIST_VIEW_OPENED": 271 return action.isOpen; 272 } 273 return state; 274 } 275 function listViewToggleRef(state = { current: null }) { 276 return state; 277 } 278 function inserterSidebarToggleRef(state = { current: null }) { 279 return state; 280 } 281 function widgetSavingLock(state = {}, action) { 282 switch (action.type) { 283 case "LOCK_WIDGET_SAVING": 284 return { ...state, [action.lockName]: true }; 285 case "UNLOCK_WIDGET_SAVING": { 286 const { [action.lockName]: removedLockName, ...restState } = state; 287 return restState; 288 } 289 } 290 return state; 291 } 292 var reducer_default = (0, import_data.combineReducers)({ 293 blockInserterPanel, 294 inserterSidebarToggleRef, 295 listViewPanel, 296 listViewToggleRef, 297 widgetAreasOpenState, 298 widgetSavingLock 299 }); 300 301 // packages/edit-widgets/build-module/store/resolvers.mjs 302 var resolvers_exports = {}; 303 __export(resolvers_exports, { 304 getWidgetAreas: () => getWidgetAreas, 305 getWidgets: () => getWidgets 306 }); 307 var import_blocks2 = __toESM(require_blocks(), 1); 308 var import_core_data2 = __toESM(require_core_data(), 1); 309 310 // packages/edit-widgets/build-module/store/actions.mjs 311 var actions_exports2 = {}; 312 __export(actions_exports2, { 313 closeGeneralSidebar: () => closeGeneralSidebar, 314 lockWidgetSaving: () => lockWidgetSaving, 315 moveBlockToWidgetArea: () => moveBlockToWidgetArea, 316 persistStubPost: () => persistStubPost, 317 saveEditedWidgetAreas: () => saveEditedWidgetAreas, 318 saveWidgetArea: () => saveWidgetArea, 319 saveWidgetAreas: () => saveWidgetAreas, 320 setIsInserterOpened: () => setIsInserterOpened, 321 setIsListViewOpened: () => setIsListViewOpened, 322 setIsWidgetAreaOpen: () => setIsWidgetAreaOpen, 323 setWidgetAreasOpenState: () => setWidgetAreasOpenState, 324 setWidgetIdForClientId: () => setWidgetIdForClientId, 325 unlockWidgetSaving: () => unlockWidgetSaving 326 }); 327 var import_i18n3 = __toESM(require_i18n(), 1); 328 var import_notices = __toESM(require_notices(), 1); 329 330 // node_modules/clsx/dist/clsx.mjs 331 function r(e) { 332 var t, f, n = ""; 333 if ("string" == typeof e || "number" == typeof e) n += e; 334 else if ("object" == typeof e) if (Array.isArray(e)) { 335 var o = e.length; 336 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f); 337 } else for (f in e) e[f] && (n && (n += " "), n += f); 338 return n; 339 } 340 function clsx() { 341 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t); 342 return n; 343 } 344 var clsx_default = clsx; 345 346 // packages/interface/build-module/components/complementary-area/index.mjs 347 var import_components5 = __toESM(require_components(), 1); 348 var import_data6 = __toESM(require_data(), 1); 349 var import_i18n = __toESM(require_i18n(), 1); 350 351 // packages/icons/build-module/library/block-default.mjs 352 var import_primitives = __toESM(require_primitives(), 1); 353 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 354 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) }); 355 356 // packages/icons/build-module/library/check.mjs 357 var import_primitives2 = __toESM(require_primitives(), 1); 358 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 359 var check_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 360 361 // packages/icons/build-module/library/close-small.mjs 362 var import_primitives3 = __toESM(require_primitives(), 1); 363 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 364 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) }); 365 366 // packages/icons/build-module/library/drawer-left.mjs 367 var import_primitives4 = __toESM(require_primitives(), 1); 368 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 369 var drawer_left_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" }) }); 370 371 // packages/icons/build-module/library/drawer-right.mjs 372 var import_primitives5 = __toESM(require_primitives(), 1); 373 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 374 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" }) }); 375 376 // packages/icons/build-module/library/external.mjs 377 var import_primitives6 = __toESM(require_primitives(), 1); 378 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 379 var external_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) }); 380 381 // packages/icons/build-module/library/list-view.mjs 382 var import_primitives7 = __toESM(require_primitives(), 1); 383 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 384 var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) }); 385 386 // packages/icons/build-module/library/more-vertical.mjs 387 var import_primitives8 = __toESM(require_primitives(), 1); 388 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 389 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 390 391 // packages/icons/build-module/library/plus.mjs 392 var import_primitives9 = __toESM(require_primitives(), 1); 393 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 394 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) }); 395 396 // packages/icons/build-module/library/redo.mjs 397 var import_primitives10 = __toESM(require_primitives(), 1); 398 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 399 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z" }) }); 400 401 // packages/icons/build-module/library/star-empty.mjs 402 var import_primitives11 = __toESM(require_primitives(), 1); 403 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 404 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z" }) }); 405 406 // packages/icons/build-module/library/star-filled.mjs 407 var import_primitives12 = __toESM(require_primitives(), 1); 408 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 409 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" }) }); 410 411 // packages/icons/build-module/library/undo.mjs 412 var import_primitives13 = __toESM(require_primitives(), 1); 413 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 414 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z" }) }); 415 416 // packages/interface/build-module/components/complementary-area/index.mjs 417 var import_element2 = __toESM(require_element(), 1); 418 var import_viewport = __toESM(require_viewport(), 1); 419 var import_preferences3 = __toESM(require_preferences(), 1); 420 var import_compose = __toESM(require_compose(), 1); 421 var import_plugins2 = __toESM(require_plugins(), 1); 422 423 // packages/interface/build-module/components/complementary-area-toggle/index.mjs 424 var import_components = __toESM(require_components(), 1); 425 var import_data5 = __toESM(require_data(), 1); 426 var import_plugins = __toESM(require_plugins(), 1); 427 428 // packages/interface/build-module/store/index.mjs 429 var import_data4 = __toESM(require_data(), 1); 430 431 // packages/interface/build-module/store/actions.mjs 432 var actions_exports = {}; 433 __export(actions_exports, { 434 closeModal: () => closeModal, 435 disableComplementaryArea: () => disableComplementaryArea, 436 enableComplementaryArea: () => enableComplementaryArea, 437 openModal: () => openModal, 438 pinItem: () => pinItem, 439 setDefaultComplementaryArea: () => setDefaultComplementaryArea, 440 setFeatureDefaults: () => setFeatureDefaults, 441 setFeatureValue: () => setFeatureValue, 442 toggleFeature: () => toggleFeature, 443 unpinItem: () => unpinItem 444 }); 445 var import_deprecated2 = __toESM(require_deprecated(), 1); 446 var import_preferences = __toESM(require_preferences(), 1); 447 448 // packages/interface/build-module/store/deprecated.mjs 449 var import_deprecated = __toESM(require_deprecated(), 1); 450 function normalizeComplementaryAreaScope(scope) { 451 if (["core/edit-post", "core/edit-site"].includes(scope)) { 452 (0, import_deprecated.default)(`$scope} interface scope`, { 453 alternative: "core interface scope", 454 hint: "core/edit-post and core/edit-site are merging.", 455 version: "6.6" 456 }); 457 return "core"; 458 } 459 return scope; 460 } 461 function normalizeComplementaryAreaName(scope, name2) { 462 if (scope === "core" && name2 === "edit-site/template") { 463 (0, import_deprecated.default)(`edit-site/template sidebar`, { 464 alternative: "edit-post/document", 465 version: "6.6" 466 }); 467 return "edit-post/document"; 468 } 469 if (scope === "core" && name2 === "edit-site/block-inspector") { 470 (0, import_deprecated.default)(`edit-site/block-inspector sidebar`, { 471 alternative: "edit-post/block", 472 version: "6.6" 473 }); 474 return "edit-post/block"; 475 } 476 return name2; 477 } 478 479 // packages/interface/build-module/store/actions.mjs 480 var setDefaultComplementaryArea = (scope, area) => { 481 scope = normalizeComplementaryAreaScope(scope); 482 area = normalizeComplementaryAreaName(scope, area); 483 return { 484 type: "SET_DEFAULT_COMPLEMENTARY_AREA", 485 scope, 486 area 487 }; 488 }; 489 var enableComplementaryArea = (scope, area) => ({ registry, dispatch: dispatch2 }) => { 490 if (!area) { 491 return; 492 } 493 scope = normalizeComplementaryAreaScope(scope); 494 area = normalizeComplementaryAreaName(scope, area); 495 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible"); 496 if (!isComplementaryAreaVisible) { 497 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", true); 498 } 499 dispatch2({ 500 type: "ENABLE_COMPLEMENTARY_AREA", 501 scope, 502 area 503 }); 504 }; 505 var disableComplementaryArea = (scope) => ({ registry }) => { 506 scope = normalizeComplementaryAreaScope(scope); 507 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible"); 508 if (isComplementaryAreaVisible) { 509 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", false); 510 } 511 }; 512 var pinItem = (scope, item) => ({ registry }) => { 513 if (!item) { 514 return; 515 } 516 scope = normalizeComplementaryAreaScope(scope); 517 item = normalizeComplementaryAreaName(scope, item); 518 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems"); 519 if (pinnedItems?.[item] === true) { 520 return; 521 } 522 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", { 523 ...pinnedItems, 524 [item]: true 525 }); 526 }; 527 var unpinItem = (scope, item) => ({ registry }) => { 528 if (!item) { 529 return; 530 } 531 scope = normalizeComplementaryAreaScope(scope); 532 item = normalizeComplementaryAreaName(scope, item); 533 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems"); 534 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", { 535 ...pinnedItems, 536 [item]: false 537 }); 538 }; 539 function toggleFeature(scope, featureName) { 540 return function({ registry }) { 541 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).toggleFeature`, { 542 since: "6.0", 543 alternative: `dispatch( 'core/preferences' ).toggle` 544 }); 545 registry.dispatch(import_preferences.store).toggle(scope, featureName); 546 }; 547 } 548 function setFeatureValue(scope, featureName, value) { 549 return function({ registry }) { 550 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureValue`, { 551 since: "6.0", 552 alternative: `dispatch( 'core/preferences' ).set` 553 }); 554 registry.dispatch(import_preferences.store).set(scope, featureName, !!value); 555 }; 556 } 557 function setFeatureDefaults(scope, defaults) { 558 return function({ registry }) { 559 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, { 560 since: "6.0", 561 alternative: `dispatch( 'core/preferences' ).setDefaults` 562 }); 563 registry.dispatch(import_preferences.store).setDefaults(scope, defaults); 564 }; 565 } 566 function openModal(name2) { 567 return { 568 type: "OPEN_MODAL", 569 name: name2 570 }; 571 } 572 function closeModal() { 573 return { 574 type: "CLOSE_MODAL" 575 }; 576 } 577 578 // packages/interface/build-module/store/selectors.mjs 579 var selectors_exports = {}; 580 __export(selectors_exports, { 581 getActiveComplementaryArea: () => getActiveComplementaryArea, 582 isComplementaryAreaLoading: () => isComplementaryAreaLoading, 583 isFeatureActive: () => isFeatureActive, 584 isItemPinned: () => isItemPinned, 585 isModalActive: () => isModalActive 586 }); 587 var import_data2 = __toESM(require_data(), 1); 588 var import_deprecated4 = __toESM(require_deprecated(), 1); 589 var import_preferences2 = __toESM(require_preferences(), 1); 590 var getActiveComplementaryArea = (0, import_data2.createRegistrySelector)( 591 (select) => (state, scope) => { 592 scope = normalizeComplementaryAreaScope(scope); 593 const isComplementaryAreaVisible = select(import_preferences2.store).get( 594 scope, 595 "isComplementaryAreaVisible" 596 ); 597 if (isComplementaryAreaVisible === void 0) { 598 return void 0; 599 } 600 if (isComplementaryAreaVisible === false) { 601 return null; 602 } 603 return state?.complementaryAreas?.[scope]; 604 } 605 ); 606 var isComplementaryAreaLoading = (0, import_data2.createRegistrySelector)( 607 (select) => (state, scope) => { 608 scope = normalizeComplementaryAreaScope(scope); 609 const isVisible = select(import_preferences2.store).get( 610 scope, 611 "isComplementaryAreaVisible" 612 ); 613 const identifier = state?.complementaryAreas?.[scope]; 614 return isVisible && identifier === void 0; 615 } 616 ); 617 var isItemPinned = (0, import_data2.createRegistrySelector)( 618 (select) => (state, scope, item) => { 619 scope = normalizeComplementaryAreaScope(scope); 620 item = normalizeComplementaryAreaName(scope, item); 621 const pinnedItems = select(import_preferences2.store).get( 622 scope, 623 "pinnedItems" 624 ); 625 return pinnedItems?.[item] ?? true; 626 } 627 ); 628 var isFeatureActive = (0, import_data2.createRegistrySelector)( 629 (select) => (state, scope, featureName) => { 630 (0, import_deprecated4.default)( 631 `select( 'core/interface' ).isFeatureActive( scope, featureName )`, 632 { 633 since: "6.0", 634 alternative: `select( 'core/preferences' ).get( scope, featureName )` 635 } 636 ); 637 return !!select(import_preferences2.store).get(scope, featureName); 638 } 639 ); 640 function isModalActive(state, modalName) { 641 return state.activeModal === modalName; 642 } 643 644 // packages/interface/build-module/store/reducer.mjs 645 var import_data3 = __toESM(require_data(), 1); 646 function complementaryAreas(state = {}, action) { 647 switch (action.type) { 648 case "SET_DEFAULT_COMPLEMENTARY_AREA": { 649 const { scope, area } = action; 650 if (state[scope]) { 651 return state; 652 } 653 return { 654 ...state, 655 [scope]: area 656 }; 657 } 658 case "ENABLE_COMPLEMENTARY_AREA": { 659 const { scope, area } = action; 660 return { 661 ...state, 662 [scope]: area 663 }; 664 } 665 } 666 return state; 667 } 668 function activeModal(state = null, action) { 669 switch (action.type) { 670 case "OPEN_MODAL": 671 return action.name; 672 case "CLOSE_MODAL": 673 return null; 674 } 675 return state; 676 } 677 var reducer_default2 = (0, import_data3.combineReducers)({ 678 complementaryAreas, 679 activeModal 680 }); 681 682 // packages/interface/build-module/store/constants.mjs 683 var STORE_NAME = "core/interface"; 684 685 // packages/interface/build-module/store/index.mjs 686 var store = (0, import_data4.createReduxStore)(STORE_NAME, { 687 reducer: reducer_default2, 688 actions: actions_exports, 689 selectors: selectors_exports 690 }); 691 (0, import_data4.register)(store); 692 693 // packages/interface/build-module/components/complementary-area-toggle/index.mjs 694 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 695 function roleSupportsCheckedState(role) { 696 return [ 697 "checkbox", 698 "option", 699 "radio", 700 "switch", 701 "menuitemcheckbox", 702 "menuitemradio", 703 "treeitem" 704 ].includes(role); 705 } 706 function ComplementaryAreaToggle({ 707 as = import_components.Button, 708 scope, 709 identifier: identifierProp, 710 icon: iconProp, 711 selectedIcon, 712 name: name2, 713 shortcut, 714 ...props 715 }) { 716 const ComponentToUse = as; 717 const context = (0, import_plugins.usePluginContext)(); 718 const icon = iconProp || context.icon; 719 const identifier = identifierProp || `$context.name}/$name2}`; 720 const isSelected = (0, import_data5.useSelect)( 721 (select) => select(store).getActiveComplementaryArea(scope) === identifier, 722 [identifier, scope] 723 ); 724 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data5.useDispatch)(store); 725 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 726 ComponentToUse, 727 { 728 icon: selectedIcon && isSelected ? selectedIcon : icon, 729 "aria-controls": identifier.replace("/", ":"), 730 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : void 0, 731 onClick: () => { 732 if (isSelected) { 733 disableComplementaryArea2(scope); 734 } else { 735 enableComplementaryArea2(scope, identifier); 736 } 737 }, 738 shortcut, 739 ...props 740 } 741 ); 742 } 743 744 // packages/interface/build-module/components/complementary-area-header/index.mjs 745 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 746 var ComplementaryAreaHeader = ({ 747 children, 748 className, 749 toggleButtonProps 750 }) => { 751 const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps }); 752 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)( 753 "div", 754 { 755 className: clsx_default( 756 "components-panel__header", 757 "interface-complementary-area-header", 758 className 759 ), 760 tabIndex: -1, 761 children: [ 762 children, 763 toggleButton 764 ] 765 } 766 ); 767 }; 768 var complementary_area_header_default = ComplementaryAreaHeader; 769 770 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs 771 var import_components3 = __toESM(require_components(), 1); 772 773 // packages/interface/build-module/components/action-item/index.mjs 774 var import_components2 = __toESM(require_components(), 1); 775 var import_element = __toESM(require_element(), 1); 776 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 777 var noop = () => { 778 }; 779 function ActionItemSlot({ 780 name: name2, 781 as: Component2 = import_components2.MenuGroup, 782 fillProps = {}, 783 bubblesVirtually, 784 ...props 785 }) { 786 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( 787 import_components2.Slot, 788 { 789 name: name2, 790 bubblesVirtually, 791 fillProps, 792 children: (fills) => { 793 if (!import_element.Children.toArray(fills).length) { 794 return null; 795 } 796 const initializedByPlugins = []; 797 import_element.Children.forEach( 798 fills, 799 ({ 800 props: { __unstableExplicitMenuItem, __unstableTarget } 801 }) => { 802 if (__unstableTarget && __unstableExplicitMenuItem) { 803 initializedByPlugins.push(__unstableTarget); 804 } 805 } 806 ); 807 const children = import_element.Children.map(fills, (child) => { 808 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes( 809 child.props.__unstableTarget 810 )) { 811 return null; 812 } 813 return child; 814 }); 815 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Component2, { ...props, children }); 816 } 817 } 818 ); 819 } 820 function ActionItem({ name: name2, as: Component2 = import_components2.Button, onClick, ...props }) { 821 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components2.Fill, { name: name2, children: ({ onClick: fpOnClick }) => { 822 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( 823 Component2, 824 { 825 onClick: onClick || fpOnClick ? (...args) => { 826 (onClick || noop)(...args); 827 (fpOnClick || noop)(...args); 828 } : void 0, 829 ...props 830 } 831 ); 832 } }); 833 } 834 ActionItem.Slot = ActionItemSlot; 835 var action_item_default = ActionItem; 836 837 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs 838 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 839 var PluginsMenuItem = ({ 840 // Menu item is marked with unstable prop for backward compatibility. 841 // They are removed so they don't leak to DOM elements. 842 // @see https://github.com/WordPress/gutenberg/issues/14457 843 __unstableExplicitMenuItem, 844 __unstableTarget, 845 ...restProps 846 }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_components3.MenuItem, { ...restProps }); 847 function ComplementaryAreaMoreMenuItem({ 848 scope, 849 target, 850 __unstableExplicitMenuItem, 851 ...props 852 }) { 853 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 854 ComplementaryAreaToggle, 855 { 856 as: (toggleProps) => { 857 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 858 action_item_default, 859 { 860 __unstableExplicitMenuItem, 861 __unstableTarget: `$scope}/$target}`, 862 as: PluginsMenuItem, 863 name: `$scope}/plugin-more-menu`, 864 ...toggleProps 865 } 866 ); 867 }, 868 role: "menuitemcheckbox", 869 selectedIcon: check_default, 870 name: target, 871 scope, 872 ...props 873 } 874 ); 875 } 876 877 // packages/interface/build-module/components/pinned-items/index.mjs 878 var import_components4 = __toESM(require_components(), 1); 879 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 880 function PinnedItems({ scope, ...props }) { 881 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components4.Fill, { name: `PinnedItems/$scope}`, ...props }); 882 } 883 function PinnedItemsSlot({ scope, className, ...props }) { 884 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components4.Slot, { name: `PinnedItems/$scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)( 885 "div", 886 { 887 className: clsx_default( 888 className, 889 "interface-pinned-items" 890 ), 891 children: fills 892 } 893 ) }); 894 } 895 PinnedItems.Slot = PinnedItemsSlot; 896 var pinned_items_default = PinnedItems; 897 898 // packages/interface/build-module/components/complementary-area/index.mjs 899 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 900 var ANIMATION_DURATION = 0.3; 901 function ComplementaryAreaSlot({ scope, ...props }) { 902 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Slot, { name: `ComplementaryArea/$scope}`, ...props }); 903 } 904 var SIDEBAR_WIDTH = 280; 905 var variants = { 906 open: { width: SIDEBAR_WIDTH }, 907 closed: { width: 0 }, 908 mobileOpen: { width: "100vw" } 909 }; 910 function ComplementaryAreaFill({ 911 activeArea, 912 isActive, 913 scope, 914 children, 915 className, 916 id 917 }) { 918 const disableMotion = (0, import_compose.useReducedMotion)(); 919 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 920 const previousActiveArea = (0, import_compose.usePrevious)(activeArea); 921 const previousIsActive = (0, import_compose.usePrevious)(isActive); 922 const [, setState] = (0, import_element2.useState)({}); 923 (0, import_element2.useEffect)(() => { 924 setState({}); 925 }, [isActive]); 926 const transition = { 927 type: "tween", 928 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION, 929 ease: [0.6, 0, 0.4, 1] 930 }; 931 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Fill, { name: `ComplementaryArea/$scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 932 import_components5.__unstableMotion.div, 933 { 934 variants, 935 initial: "closed", 936 animate: isMobileViewport ? "mobileOpen" : "open", 937 exit: "closed", 938 transition, 939 className: "interface-complementary-area__fill", 940 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 941 "div", 942 { 943 id, 944 className, 945 style: { 946 width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH 947 }, 948 children 949 } 950 ) 951 } 952 ) }) }); 953 } 954 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) { 955 const previousIsSmallRef = (0, import_element2.useRef)(false); 956 const shouldOpenWhenNotSmallRef = (0, import_element2.useRef)(false); 957 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data6.useDispatch)(store); 958 (0, import_element2.useEffect)(() => { 959 if (isActive && isSmall && !previousIsSmallRef.current) { 960 disableComplementaryArea2(scope); 961 shouldOpenWhenNotSmallRef.current = true; 962 } else if ( 963 // If there is a flag indicating the complementary area should be 964 // enabled when we go from small to big window size and we are going 965 // from a small to big window size. 966 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current 967 ) { 968 shouldOpenWhenNotSmallRef.current = false; 969 enableComplementaryArea2(scope, identifier); 970 } else if ( 971 // If the flag is indicating the current complementary should be 972 // reopened but another complementary area becomes active, remove 973 // the flag. 974 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier 975 ) { 976 shouldOpenWhenNotSmallRef.current = false; 977 } 978 if (isSmall !== previousIsSmallRef.current) { 979 previousIsSmallRef.current = isSmall; 980 } 981 }, [ 982 isActive, 983 isSmall, 984 scope, 985 identifier, 986 activeArea, 987 disableComplementaryArea2, 988 enableComplementaryArea2 989 ]); 990 } 991 function ComplementaryArea({ 992 children, 993 className, 994 closeLabel = (0, import_i18n.__)("Close plugin"), 995 identifier: identifierProp, 996 header, 997 headerClassName, 998 icon: iconProp, 999 isPinnable = true, 1000 panelClassName, 1001 scope, 1002 name: name2, 1003 title, 1004 toggleShortcut, 1005 isActiveByDefault 1006 }) { 1007 const context = (0, import_plugins2.usePluginContext)(); 1008 const icon = iconProp || context.icon; 1009 const identifier = identifierProp || `$context.name}/$name2}`; 1010 const [isReady, setIsReady] = (0, import_element2.useState)(false); 1011 const { 1012 isLoading, 1013 isActive, 1014 isPinned, 1015 activeArea, 1016 isSmall, 1017 isLarge, 1018 showIconLabels 1019 } = (0, import_data6.useSelect)( 1020 (select) => { 1021 const { 1022 getActiveComplementaryArea: getActiveComplementaryArea2, 1023 isComplementaryAreaLoading: isComplementaryAreaLoading2, 1024 isItemPinned: isItemPinned2 1025 } = select(store); 1026 const { get } = select(import_preferences3.store); 1027 const _activeArea = getActiveComplementaryArea2(scope); 1028 return { 1029 isLoading: isComplementaryAreaLoading2(scope), 1030 isActive: _activeArea === identifier, 1031 isPinned: isItemPinned2(scope, identifier), 1032 activeArea: _activeArea, 1033 isSmall: select(import_viewport.store).isViewportMatch("< medium"), 1034 isLarge: select(import_viewport.store).isViewportMatch("large"), 1035 showIconLabels: get("core", "showIconLabels") 1036 }; 1037 }, 1038 [identifier, scope] 1039 ); 1040 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 1041 useAdjustComplementaryListener( 1042 scope, 1043 identifier, 1044 activeArea, 1045 isActive, 1046 isSmall 1047 ); 1048 const { 1049 enableComplementaryArea: enableComplementaryArea2, 1050 disableComplementaryArea: disableComplementaryArea2, 1051 pinItem: pinItem2, 1052 unpinItem: unpinItem2 1053 } = (0, import_data6.useDispatch)(store); 1054 (0, import_element2.useEffect)(() => { 1055 if (isActiveByDefault && activeArea === void 0 && !isSmall) { 1056 enableComplementaryArea2(scope, identifier); 1057 } else if (activeArea === void 0 && isSmall) { 1058 disableComplementaryArea2(scope, identifier); 1059 } 1060 setIsReady(true); 1061 }, [ 1062 activeArea, 1063 isActiveByDefault, 1064 scope, 1065 identifier, 1066 isSmall, 1067 enableComplementaryArea2, 1068 disableComplementaryArea2 1069 ]); 1070 if (!isReady) { 1071 return; 1072 } 1073 return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [ 1074 isPinnable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1075 ComplementaryAreaToggle, 1076 { 1077 scope, 1078 identifier, 1079 isPressed: isActive && (!showIconLabels || isLarge), 1080 "aria-expanded": isActive, 1081 "aria-disabled": isLoading, 1082 label: title, 1083 icon: showIconLabels ? check_default : icon, 1084 showTooltip: !showIconLabels, 1085 variant: showIconLabels ? "tertiary" : void 0, 1086 size: "compact", 1087 shortcut: toggleShortcut 1088 } 1089 ) }), 1090 name2 && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1091 ComplementaryAreaMoreMenuItem, 1092 { 1093 target: name2, 1094 scope, 1095 icon, 1096 identifier, 1097 children: title 1098 } 1099 ), 1100 /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)( 1101 ComplementaryAreaFill, 1102 { 1103 activeArea, 1104 isActive, 1105 className: clsx_default("interface-complementary-area", className), 1106 scope, 1107 id: identifier.replace("/", ":"), 1108 children: [ 1109 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1110 complementary_area_header_default, 1111 { 1112 className: headerClassName, 1113 closeLabel, 1114 onClose: () => disableComplementaryArea2(scope), 1115 toggleButtonProps: { 1116 label: closeLabel, 1117 size: "compact", 1118 shortcut: toggleShortcut, 1119 scope, 1120 identifier 1121 }, 1122 children: header || /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [ 1123 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }), 1124 isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1125 import_components5.Button, 1126 { 1127 className: "interface-complementary-area__pin-unpin-item", 1128 icon: isPinned ? star_filled_default : star_empty_default, 1129 label: isPinned ? (0, import_i18n.__)("Unpin from toolbar") : (0, import_i18n.__)("Pin to toolbar"), 1130 onClick: () => (isPinned ? unpinItem2 : pinItem2)( 1131 scope, 1132 identifier 1133 ), 1134 isPressed: isPinned, 1135 "aria-expanded": isPinned, 1136 size: "compact" 1137 } 1138 ) 1139 ] }) 1140 } 1141 ), 1142 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Panel, { className: panelClassName, children }) 1143 ] 1144 } 1145 ) 1146 ] }); 1147 } 1148 ComplementaryArea.Slot = ComplementaryAreaSlot; 1149 var complementary_area_default = ComplementaryArea; 1150 1151 // packages/admin-ui/build-module/navigable-region/index.mjs 1152 var import_element3 = __toESM(require_element(), 1); 1153 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 1154 var NavigableRegion = (0, import_element3.forwardRef)( 1155 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 1156 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)( 1157 Tag, 1158 { 1159 ref, 1160 className: clsx_default("admin-ui-navigable-region", className), 1161 "aria-label": ariaLabel, 1162 role: "region", 1163 tabIndex: "-1", 1164 ...props, 1165 children 1166 } 1167 ); 1168 } 1169 ); 1170 NavigableRegion.displayName = "NavigableRegion"; 1171 var navigable_region_default = NavigableRegion; 1172 1173 // packages/interface/build-module/components/interface-skeleton/index.mjs 1174 var import_element4 = __toESM(require_element(), 1); 1175 var import_components6 = __toESM(require_components(), 1); 1176 var import_i18n2 = __toESM(require_i18n(), 1); 1177 var import_compose2 = __toESM(require_compose(), 1); 1178 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 1179 var ANIMATION_DURATION2 = 0.25; 1180 var commonTransition = { 1181 type: "tween", 1182 duration: ANIMATION_DURATION2, 1183 ease: [0.6, 0, 0.4, 1] 1184 }; 1185 function useHTMLClass(className) { 1186 (0, import_element4.useEffect)(() => { 1187 const element = document && document.querySelector(`html:not(.$className})`); 1188 if (!element) { 1189 return; 1190 } 1191 element.classList.toggle(className); 1192 return () => { 1193 element.classList.toggle(className); 1194 }; 1195 }, [className]); 1196 } 1197 var headerVariants = { 1198 hidden: { opacity: 1, marginTop: -60 }, 1199 visible: { opacity: 1, marginTop: 0 }, 1200 distractionFreeHover: { 1201 opacity: 1, 1202 marginTop: 0, 1203 transition: { 1204 ...commonTransition, 1205 delay: 0.2, 1206 delayChildren: 0.2 1207 } 1208 }, 1209 distractionFreeHidden: { 1210 opacity: 0, 1211 marginTop: -60 1212 }, 1213 distractionFreeDisabled: { 1214 opacity: 0, 1215 marginTop: 0, 1216 transition: { 1217 ...commonTransition, 1218 delay: 0.8, 1219 delayChildren: 0.8 1220 } 1221 } 1222 }; 1223 function InterfaceSkeleton({ 1224 isDistractionFree, 1225 footer, 1226 header, 1227 editorNotices, 1228 sidebar, 1229 secondarySidebar, 1230 content, 1231 actions, 1232 labels, 1233 className 1234 }, ref) { 1235 const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose2.useResizeObserver)(); 1236 const isMobileViewport = (0, import_compose2.useViewportMatch)("medium", "<"); 1237 const disableMotion = (0, import_compose2.useReducedMotion)(); 1238 const defaultTransition = { 1239 type: "tween", 1240 duration: disableMotion ? 0 : ANIMATION_DURATION2, 1241 ease: [0.6, 0, 0.4, 1] 1242 }; 1243 useHTMLClass("interface-interface-skeleton__html-container"); 1244 const defaultLabels = { 1245 /* translators: accessibility text for the top bar landmark region. */ 1246 header: (0, import_i18n2._x)("Header", "header landmark area"), 1247 /* translators: accessibility text for the content landmark region. */ 1248 body: (0, import_i18n2.__)("Content"), 1249 /* translators: accessibility text for the secondary sidebar landmark region. */ 1250 secondarySidebar: (0, import_i18n2.__)("Block Library"), 1251 /* translators: accessibility text for the settings landmark region. */ 1252 sidebar: (0, import_i18n2._x)("Settings", "settings landmark area"), 1253 /* translators: accessibility text for the publish landmark region. */ 1254 actions: (0, import_i18n2.__)("Publish"), 1255 /* translators: accessibility text for the footer landmark region. */ 1256 footer: (0, import_i18n2.__)("Footer") 1257 }; 1258 const mergedLabels = { ...defaultLabels, ...labels }; 1259 return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)( 1260 "div", 1261 { 1262 ref, 1263 className: clsx_default( 1264 className, 1265 "interface-interface-skeleton", 1266 !!footer && "has-footer" 1267 ), 1268 children: [ 1269 /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [ 1270 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components6.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1271 navigable_region_default, 1272 { 1273 as: import_components6.__unstableMotion.div, 1274 className: "interface-interface-skeleton__header", 1275 "aria-label": mergedLabels.header, 1276 initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden", 1277 whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible", 1278 animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible", 1279 exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden", 1280 variants: headerVariants, 1281 transition: defaultTransition, 1282 children: header 1283 } 1284 ) }), 1285 isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }), 1286 /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "interface-interface-skeleton__body", children: [ 1287 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components6.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1288 navigable_region_default, 1289 { 1290 className: "interface-interface-skeleton__secondary-sidebar", 1291 ariaLabel: mergedLabels.secondarySidebar, 1292 as: import_components6.__unstableMotion.div, 1293 initial: "closed", 1294 animate: "open", 1295 exit: "closed", 1296 variants: { 1297 open: { width: secondarySidebarSize.width }, 1298 closed: { width: 0 } 1299 }, 1300 transition: defaultTransition, 1301 children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)( 1302 import_components6.__unstableMotion.div, 1303 { 1304 style: { 1305 position: "absolute", 1306 width: isMobileViewport ? "100vw" : "fit-content", 1307 height: "100%", 1308 left: 0 1309 }, 1310 variants: { 1311 open: { x: 0 }, 1312 closed: { x: "-100%" } 1313 }, 1314 transition: defaultTransition, 1315 children: [ 1316 secondarySidebarResizeListener, 1317 secondarySidebar 1318 ] 1319 } 1320 ) 1321 } 1322 ) }), 1323 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1324 navigable_region_default, 1325 { 1326 className: "interface-interface-skeleton__content", 1327 ariaLabel: mergedLabels.body, 1328 children: content 1329 } 1330 ), 1331 !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1332 navigable_region_default, 1333 { 1334 className: "interface-interface-skeleton__sidebar", 1335 ariaLabel: mergedLabels.sidebar, 1336 children: sidebar 1337 } 1338 ), 1339 !!actions && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1340 navigable_region_default, 1341 { 1342 className: "interface-interface-skeleton__actions", 1343 ariaLabel: mergedLabels.actions, 1344 children: actions 1345 } 1346 ) 1347 ] }) 1348 ] }), 1349 !!footer && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1350 navigable_region_default, 1351 { 1352 className: "interface-interface-skeleton__footer", 1353 ariaLabel: mergedLabels.footer, 1354 children: footer 1355 } 1356 ) 1357 ] 1358 } 1359 ); 1360 } 1361 var interface_skeleton_default = (0, import_element4.forwardRef)(InterfaceSkeleton); 1362 1363 // packages/edit-widgets/build-module/store/actions.mjs 1364 var import_widgets2 = __toESM(require_widgets(), 1); 1365 var import_core_data = __toESM(require_core_data(), 1); 1366 var import_block_editor = __toESM(require_block_editor(), 1); 1367 1368 // packages/edit-widgets/build-module/store/transformers.mjs 1369 var import_blocks = __toESM(require_blocks(), 1); 1370 var import_widgets = __toESM(require_widgets(), 1); 1371 function transformWidgetToBlock(widget) { 1372 if (widget.id_base === "block") { 1373 const parsedBlocks = (0, import_blocks.parse)(widget.instance.raw.content, { 1374 __unstableSkipAutop: true 1375 }); 1376 if (!parsedBlocks.length) { 1377 return (0, import_widgets.addWidgetIdToBlock)( 1378 (0, import_blocks.createBlock)("core/paragraph", {}, []), 1379 widget.id 1380 ); 1381 } 1382 return (0, import_widgets.addWidgetIdToBlock)(parsedBlocks[0], widget.id); 1383 } 1384 let attributes; 1385 if (widget._embedded.about[0].is_multi) { 1386 attributes = { 1387 idBase: widget.id_base, 1388 instance: widget.instance 1389 }; 1390 } else { 1391 attributes = { 1392 id: widget.id 1393 }; 1394 } 1395 return (0, import_widgets.addWidgetIdToBlock)( 1396 (0, import_blocks.createBlock)("core/legacy-widget", attributes, []), 1397 widget.id 1398 ); 1399 } 1400 function transformBlockToWidget(block, relatedWidget = {}) { 1401 let widget; 1402 const isValidLegacyWidgetBlock = block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance); 1403 if (isValidLegacyWidgetBlock) { 1404 widget = { 1405 ...relatedWidget, 1406 id: block.attributes.id ?? relatedWidget.id, 1407 id_base: block.attributes.idBase ?? relatedWidget.id_base, 1408 instance: block.attributes.instance ?? relatedWidget.instance 1409 }; 1410 } else { 1411 widget = { 1412 ...relatedWidget, 1413 id_base: "block", 1414 instance: { 1415 raw: { 1416 content: (0, import_blocks.serialize)(block) 1417 } 1418 } 1419 }; 1420 } 1421 delete widget.rendered; 1422 delete widget.rendered_form; 1423 return widget; 1424 } 1425 1426 // packages/edit-widgets/build-module/store/utils.mjs 1427 var KIND = "root"; 1428 var WIDGET_AREA_ENTITY_TYPE = "sidebar"; 1429 var POST_TYPE = "postType"; 1430 var buildWidgetAreaPostId = (widgetAreaId) => `widget-area-$widgetAreaId}`; 1431 var buildWidgetAreasPostId = () => `widget-areas`; 1432 function buildWidgetAreasQuery() { 1433 return { 1434 per_page: -1 1435 }; 1436 } 1437 function buildWidgetsQuery() { 1438 return { 1439 per_page: -1, 1440 _embed: "about" 1441 }; 1442 } 1443 var createStubPost = (id, blocks) => ({ 1444 id, 1445 slug: id, 1446 status: "draft", 1447 type: "page", 1448 blocks, 1449 meta: { 1450 widgetAreaId: id 1451 } 1452 }); 1453 1454 // packages/edit-widgets/build-module/store/constants.mjs 1455 var STORE_NAME2 = "core/edit-widgets"; 1456 1457 // packages/edit-widgets/build-module/store/actions.mjs 1458 var persistStubPost = (id, blocks) => ({ registry }) => { 1459 const stubPost = createStubPost(id, blocks); 1460 registry.dispatch(import_core_data.store).receiveEntityRecords( 1461 KIND, 1462 POST_TYPE, 1463 stubPost, 1464 { id: stubPost.id }, 1465 false 1466 ); 1467 return stubPost; 1468 }; 1469 var saveEditedWidgetAreas = () => async ({ select, dispatch: dispatch2, registry }) => { 1470 const editedWidgetAreas = select.getEditedWidgetAreas(); 1471 if (!editedWidgetAreas?.length) { 1472 return; 1473 } 1474 try { 1475 await dispatch2.saveWidgetAreas(editedWidgetAreas); 1476 registry.dispatch(import_notices.store).createSuccessNotice((0, import_i18n3.__)("Widgets saved."), { 1477 type: "snackbar" 1478 }); 1479 } catch (e) { 1480 registry.dispatch(import_notices.store).createErrorNotice( 1481 /* translators: %s: The error message. */ 1482 (0, import_i18n3.sprintf)((0, import_i18n3.__)("There was an error. %s"), e.message), 1483 { 1484 type: "snackbar" 1485 } 1486 ); 1487 } 1488 }; 1489 var saveWidgetAreas = (widgetAreas) => async ({ dispatch: dispatch2, registry }) => { 1490 try { 1491 for (const widgetArea of widgetAreas) { 1492 await dispatch2.saveWidgetArea(widgetArea.id); 1493 } 1494 } finally { 1495 await registry.dispatch(import_core_data.store).finishResolution( 1496 "getEntityRecord", 1497 KIND, 1498 WIDGET_AREA_ENTITY_TYPE, 1499 buildWidgetAreasQuery() 1500 ); 1501 } 1502 }; 1503 var saveWidgetArea = (widgetAreaId) => async ({ dispatch: dispatch2, select, registry }) => { 1504 const widgets = select.getWidgets(); 1505 const post = registry.select(import_core_data.store).getEditedEntityRecord( 1506 KIND, 1507 POST_TYPE, 1508 buildWidgetAreaPostId(widgetAreaId) 1509 ); 1510 const areaWidgets = Object.values(widgets).filter( 1511 ({ sidebar }) => sidebar === widgetAreaId 1512 ); 1513 const usedReferenceWidgets = []; 1514 const widgetsBlocks = post.blocks.filter((block) => { 1515 const { id } = block.attributes; 1516 if (block.name === "core/legacy-widget" && id) { 1517 if (usedReferenceWidgets.includes(id)) { 1518 return false; 1519 } 1520 usedReferenceWidgets.push(id); 1521 } 1522 return true; 1523 }); 1524 const deletedWidgets = []; 1525 for (const widget of areaWidgets) { 1526 const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id); 1527 if (!widgetsNewArea) { 1528 deletedWidgets.push(widget); 1529 } 1530 } 1531 const batchMeta = []; 1532 const batchTasks = []; 1533 const sidebarWidgetsIds = []; 1534 for (let i = 0; i < widgetsBlocks.length; i++) { 1535 const block = widgetsBlocks[i]; 1536 const widgetId = (0, import_widgets2.getWidgetIdFromBlock)(block); 1537 const oldWidget = widgets[widgetId]; 1538 const widget = transformBlockToWidget(block, oldWidget); 1539 sidebarWidgetsIds.push(widgetId); 1540 if (oldWidget) { 1541 registry.dispatch(import_core_data.store).editEntityRecord( 1542 "root", 1543 "widget", 1544 widgetId, 1545 { 1546 ...widget, 1547 sidebar: widgetAreaId 1548 }, 1549 { undoIgnore: true } 1550 ); 1551 const hasEdits = registry.select(import_core_data.store).hasEditsForEntityRecord("root", "widget", widgetId); 1552 if (!hasEdits) { 1553 continue; 1554 } 1555 batchTasks.push( 1556 ({ saveEditedEntityRecord }) => saveEditedEntityRecord("root", "widget", widgetId) 1557 ); 1558 } else { 1559 batchTasks.push( 1560 ({ saveEntityRecord }) => saveEntityRecord("root", "widget", { 1561 ...widget, 1562 sidebar: widgetAreaId 1563 }) 1564 ); 1565 } 1566 batchMeta.push({ 1567 block, 1568 position: i, 1569 clientId: block.clientId 1570 }); 1571 } 1572 for (const widget of deletedWidgets) { 1573 batchTasks.push( 1574 ({ deleteEntityRecord }) => deleteEntityRecord("root", "widget", widget.id, { 1575 force: true 1576 }) 1577 ); 1578 } 1579 const records = await registry.dispatch(import_core_data.store).__experimentalBatch(batchTasks); 1580 const preservedRecords = records.filter( 1581 (record) => !record.hasOwnProperty("deleted") 1582 ); 1583 const failedWidgetNames = []; 1584 for (let i = 0; i < preservedRecords.length; i++) { 1585 const widget = preservedRecords[i]; 1586 const { block, position } = batchMeta[i]; 1587 post.blocks[position].attributes.__internalWidgetId = widget.id; 1588 const error = registry.select(import_core_data.store).getLastEntitySaveError("root", "widget", widget.id); 1589 if (error) { 1590 failedWidgetNames.push(block.attributes?.name || block?.name); 1591 } 1592 if (!sidebarWidgetsIds[position]) { 1593 sidebarWidgetsIds[position] = widget.id; 1594 } 1595 } 1596 if (failedWidgetNames.length) { 1597 throw new Error( 1598 (0, import_i18n3.sprintf)( 1599 /* translators: %s: List of widget names */ 1600 (0, import_i18n3.__)("Could not save the following widgets: %s."), 1601 failedWidgetNames.join(", ") 1602 ) 1603 ); 1604 } 1605 registry.dispatch(import_core_data.store).editEntityRecord( 1606 KIND, 1607 WIDGET_AREA_ENTITY_TYPE, 1608 widgetAreaId, 1609 { 1610 widgets: sidebarWidgetsIds 1611 }, 1612 { undoIgnore: true } 1613 ); 1614 dispatch2(trySaveWidgetArea(widgetAreaId)); 1615 registry.dispatch(import_core_data.store).receiveEntityRecords(KIND, POST_TYPE, post, void 0); 1616 }; 1617 var trySaveWidgetArea = (widgetAreaId) => ({ registry }) => { 1618 registry.dispatch(import_core_data.store).saveEditedEntityRecord( 1619 KIND, 1620 WIDGET_AREA_ENTITY_TYPE, 1621 widgetAreaId, 1622 { 1623 throwOnError: true 1624 } 1625 ); 1626 }; 1627 function setWidgetIdForClientId(clientId, widgetId) { 1628 return { 1629 type: "SET_WIDGET_ID_FOR_CLIENT_ID", 1630 clientId, 1631 widgetId 1632 }; 1633 } 1634 function setWidgetAreasOpenState(widgetAreasOpenState2) { 1635 return { 1636 type: "SET_WIDGET_AREAS_OPEN_STATE", 1637 widgetAreasOpenState: widgetAreasOpenState2 1638 }; 1639 } 1640 function setIsWidgetAreaOpen(clientId, isOpen) { 1641 return { 1642 type: "SET_IS_WIDGET_AREA_OPEN", 1643 clientId, 1644 isOpen 1645 }; 1646 } 1647 function setIsInserterOpened(value) { 1648 return { 1649 type: "SET_IS_INSERTER_OPENED", 1650 value 1651 }; 1652 } 1653 function setIsListViewOpened(isOpen) { 1654 return { 1655 type: "SET_IS_LIST_VIEW_OPENED", 1656 isOpen 1657 }; 1658 } 1659 var closeGeneralSidebar = () => ({ registry }) => { 1660 registry.dispatch(store).disableComplementaryArea(STORE_NAME2); 1661 }; 1662 var moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({ dispatch: dispatch2, select, registry }) => { 1663 const sourceRootClientId = registry.select(import_block_editor.store).getBlockRootClientId(clientId); 1664 const widgetAreas = registry.select(import_block_editor.store).getBlocks(); 1665 const destinationWidgetAreaBlock = widgetAreas.find( 1666 ({ attributes }) => attributes.id === widgetAreaId 1667 ); 1668 const destinationRootClientId = destinationWidgetAreaBlock.clientId; 1669 const destinationInnerBlocksClientIds = registry.select(import_block_editor.store).getBlockOrder(destinationRootClientId); 1670 const destinationIndex = destinationInnerBlocksClientIds.length; 1671 const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen( 1672 destinationRootClientId 1673 ); 1674 if (!isDestinationWidgetAreaOpen) { 1675 dispatch2.setIsWidgetAreaOpen(destinationRootClientId, true); 1676 } 1677 registry.dispatch(import_block_editor.store).moveBlocksToPosition( 1678 [clientId], 1679 sourceRootClientId, 1680 destinationRootClientId, 1681 destinationIndex 1682 ); 1683 }; 1684 function unlockWidgetSaving(lockName) { 1685 return { 1686 type: "UNLOCK_WIDGET_SAVING", 1687 lockName 1688 }; 1689 } 1690 function lockWidgetSaving(lockName) { 1691 return { 1692 type: "LOCK_WIDGET_SAVING", 1693 lockName 1694 }; 1695 } 1696 1697 // packages/edit-widgets/build-module/store/resolvers.mjs 1698 var getWidgetAreas = () => async ({ dispatch: dispatch2, registry }) => { 1699 const query = buildWidgetAreasQuery(); 1700 const widgetAreas = await registry.resolveSelect(import_core_data2.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query); 1701 const widgetAreaBlocks = []; 1702 const sortedWidgetAreas = widgetAreas.sort((a, b) => { 1703 if (a.id === "wp_inactive_widgets") { 1704 return 1; 1705 } 1706 if (b.id === "wp_inactive_widgets") { 1707 return -1; 1708 } 1709 return 0; 1710 }); 1711 for (const widgetArea of sortedWidgetAreas) { 1712 widgetAreaBlocks.push( 1713 (0, import_blocks2.createBlock)("core/widget-area", { 1714 id: widgetArea.id, 1715 name: widgetArea.name 1716 }) 1717 ); 1718 if (!widgetArea.widgets.length) { 1719 dispatch2( 1720 persistStubPost( 1721 buildWidgetAreaPostId(widgetArea.id), 1722 [] 1723 ) 1724 ); 1725 } 1726 } 1727 const widgetAreasOpenState2 = {}; 1728 widgetAreaBlocks.forEach((widgetAreaBlock, index) => { 1729 widgetAreasOpenState2[widgetAreaBlock.clientId] = index === 0; 1730 }); 1731 dispatch2(setWidgetAreasOpenState(widgetAreasOpenState2)); 1732 dispatch2( 1733 persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks) 1734 ); 1735 }; 1736 var getWidgets = () => async ({ dispatch: dispatch2, registry }) => { 1737 const query = buildWidgetsQuery(); 1738 const widgets = await registry.resolveSelect(import_core_data2.store).getEntityRecords("root", "widget", query); 1739 const groupedBySidebar = {}; 1740 for (const widget of widgets) { 1741 const block = transformWidgetToBlock(widget); 1742 groupedBySidebar[widget.sidebar] = groupedBySidebar[widget.sidebar] || []; 1743 groupedBySidebar[widget.sidebar].push(block); 1744 } 1745 for (const sidebarId in groupedBySidebar) { 1746 if (groupedBySidebar.hasOwnProperty(sidebarId)) { 1747 dispatch2( 1748 persistStubPost( 1749 buildWidgetAreaPostId(sidebarId), 1750 groupedBySidebar[sidebarId] 1751 ) 1752 ); 1753 } 1754 } 1755 }; 1756 1757 // packages/edit-widgets/build-module/store/selectors.mjs 1758 var selectors_exports2 = {}; 1759 __export(selectors_exports2, { 1760 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint, 1761 canInsertBlockInWidgetArea: () => canInsertBlockInWidgetArea, 1762 getEditedWidgetAreas: () => getEditedWidgetAreas, 1763 getIsWidgetAreaOpen: () => getIsWidgetAreaOpen, 1764 getParentWidgetAreaBlock: () => getParentWidgetAreaBlock, 1765 getReferenceWidgetBlocks: () => getReferenceWidgetBlocks, 1766 getWidget: () => getWidget, 1767 getWidgetAreaForWidgetId: () => getWidgetAreaForWidgetId, 1768 getWidgetAreas: () => getWidgetAreas2, 1769 getWidgets: () => getWidgets2, 1770 isInserterOpened: () => isInserterOpened, 1771 isListViewOpened: () => isListViewOpened, 1772 isSavingWidgetAreas: () => isSavingWidgetAreas, 1773 isWidgetSavingLocked: () => isWidgetSavingLocked 1774 }); 1775 var import_data7 = __toESM(require_data(), 1); 1776 var import_widgets3 = __toESM(require_widgets(), 1); 1777 var import_core_data3 = __toESM(require_core_data(), 1); 1778 var import_block_editor2 = __toESM(require_block_editor(), 1); 1779 var EMPTY_INSERTION_POINT = { 1780 rootClientId: void 0, 1781 insertionIndex: void 0 1782 }; 1783 var getWidgets2 = (0, import_data7.createRegistrySelector)( 1784 (select) => (0, import_data7.createSelector)( 1785 () => { 1786 const widgets = select(import_core_data3.store).getEntityRecords( 1787 "root", 1788 "widget", 1789 buildWidgetsQuery() 1790 ); 1791 return ( 1792 // Key widgets by their ID. 1793 widgets?.reduce( 1794 (allWidgets, widget) => ({ 1795 ...allWidgets, 1796 [widget.id]: widget 1797 }), 1798 {} 1799 ) ?? {} 1800 ); 1801 }, 1802 () => [ 1803 select(import_core_data3.store).getEntityRecords( 1804 "root", 1805 "widget", 1806 buildWidgetsQuery() 1807 ) 1808 ] 1809 ) 1810 ); 1811 var getWidget = (0, import_data7.createRegistrySelector)( 1812 (select) => (state, id) => { 1813 const widgets = select(STORE_NAME2).getWidgets(); 1814 return widgets[id]; 1815 } 1816 ); 1817 var getWidgetAreas2 = (0, import_data7.createRegistrySelector)((select) => () => { 1818 const query = buildWidgetAreasQuery(); 1819 return select(import_core_data3.store).getEntityRecords( 1820 KIND, 1821 WIDGET_AREA_ENTITY_TYPE, 1822 query 1823 ); 1824 }); 1825 var getWidgetAreaForWidgetId = (0, import_data7.createRegistrySelector)( 1826 (select) => (state, widgetId) => { 1827 const widgetAreas = select(STORE_NAME2).getWidgetAreas(); 1828 return widgetAreas.find((widgetArea) => { 1829 const post = select(import_core_data3.store).getEditedEntityRecord( 1830 KIND, 1831 POST_TYPE, 1832 buildWidgetAreaPostId(widgetArea.id) 1833 ); 1834 const blockWidgetIds = post.blocks.map( 1835 (block) => (0, import_widgets3.getWidgetIdFromBlock)(block) 1836 ); 1837 return blockWidgetIds.includes(widgetId); 1838 }); 1839 } 1840 ); 1841 var getParentWidgetAreaBlock = (0, import_data7.createRegistrySelector)( 1842 (select) => (state, clientId) => { 1843 const { getBlock, getBlockName, getBlockParents } = select(import_block_editor2.store); 1844 const blockParents = getBlockParents(clientId); 1845 const widgetAreaClientId = blockParents.find( 1846 (parentClientId) => getBlockName(parentClientId) === "core/widget-area" 1847 ); 1848 return getBlock(widgetAreaClientId); 1849 } 1850 ); 1851 var getEditedWidgetAreas = (0, import_data7.createRegistrySelector)( 1852 (select) => (state, ids) => { 1853 let widgetAreas = select(STORE_NAME2).getWidgetAreas(); 1854 if (!widgetAreas) { 1855 return []; 1856 } 1857 if (ids) { 1858 widgetAreas = widgetAreas.filter( 1859 ({ id }) => ids.includes(id) 1860 ); 1861 } 1862 return widgetAreas.filter( 1863 ({ id }) => select(import_core_data3.store).hasEditsForEntityRecord( 1864 KIND, 1865 POST_TYPE, 1866 buildWidgetAreaPostId(id) 1867 ) 1868 ).map( 1869 ({ id }) => select(import_core_data3.store).getEditedEntityRecord( 1870 KIND, 1871 WIDGET_AREA_ENTITY_TYPE, 1872 id 1873 ) 1874 ); 1875 } 1876 ); 1877 var getReferenceWidgetBlocks = (0, import_data7.createRegistrySelector)( 1878 (select) => (state, referenceWidgetName = null) => { 1879 const results = []; 1880 const widgetAreas = select(STORE_NAME2).getWidgetAreas(); 1881 for (const _widgetArea of widgetAreas) { 1882 const post = select(import_core_data3.store).getEditedEntityRecord( 1883 KIND, 1884 POST_TYPE, 1885 buildWidgetAreaPostId(_widgetArea.id) 1886 ); 1887 for (const block of post.blocks) { 1888 if (block.name === "core/legacy-widget" && (!referenceWidgetName || block.attributes?.referenceWidgetName === referenceWidgetName)) { 1889 results.push(block); 1890 } 1891 } 1892 } 1893 return results; 1894 } 1895 ); 1896 var isSavingWidgetAreas = (0, import_data7.createRegistrySelector)((select) => () => { 1897 const widgetAreasIds = select(STORE_NAME2).getWidgetAreas()?.map(({ id }) => id); 1898 if (!widgetAreasIds) { 1899 return false; 1900 } 1901 for (const id of widgetAreasIds) { 1902 const isSaving = select(import_core_data3.store).isSavingEntityRecord( 1903 KIND, 1904 WIDGET_AREA_ENTITY_TYPE, 1905 id 1906 ); 1907 if (isSaving) { 1908 return true; 1909 } 1910 } 1911 const widgetIds = [ 1912 ...Object.keys(select(STORE_NAME2).getWidgets()), 1913 void 0 1914 // account for new widgets without an ID 1915 ]; 1916 for (const id of widgetIds) { 1917 const isSaving = select(import_core_data3.store).isSavingEntityRecord( 1918 "root", 1919 "widget", 1920 id 1921 ); 1922 if (isSaving) { 1923 return true; 1924 } 1925 } 1926 return false; 1927 }); 1928 var getIsWidgetAreaOpen = (state, clientId) => { 1929 const { widgetAreasOpenState: widgetAreasOpenState2 } = state; 1930 return !!widgetAreasOpenState2[clientId]; 1931 }; 1932 function isInserterOpened(state) { 1933 return !!state.blockInserterPanel; 1934 } 1935 function __experimentalGetInsertionPoint(state) { 1936 if (typeof state.blockInserterPanel === "boolean") { 1937 return EMPTY_INSERTION_POINT; 1938 } 1939 return state.blockInserterPanel; 1940 } 1941 var canInsertBlockInWidgetArea = (0, import_data7.createRegistrySelector)( 1942 (select) => (state, blockName) => { 1943 const widgetAreas = select(import_block_editor2.store).getBlocks(); 1944 const [firstWidgetArea] = widgetAreas; 1945 return select(import_block_editor2.store).canInsertBlockType( 1946 blockName, 1947 firstWidgetArea.clientId 1948 ); 1949 } 1950 ); 1951 function isListViewOpened(state) { 1952 return state.listViewPanel; 1953 } 1954 function isWidgetSavingLocked(state) { 1955 return Object.keys(state.widgetSavingLock).length > 0; 1956 } 1957 1958 // packages/edit-widgets/build-module/store/private-selectors.mjs 1959 var private_selectors_exports = {}; 1960 __export(private_selectors_exports, { 1961 getInserterSidebarToggleRef: () => getInserterSidebarToggleRef, 1962 getListViewToggleRef: () => getListViewToggleRef 1963 }); 1964 function getListViewToggleRef(state) { 1965 return state.listViewToggleRef; 1966 } 1967 function getInserterSidebarToggleRef(state) { 1968 return state.inserterSidebarToggleRef; 1969 } 1970 1971 // packages/edit-widgets/build-module/lock-unlock.mjs 1972 var import_private_apis = __toESM(require_private_apis(), 1); 1973 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1974 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1975 "@wordpress/edit-widgets" 1976 ); 1977 1978 // packages/edit-widgets/build-module/store/index.mjs 1979 var storeConfig = { 1980 reducer: reducer_default, 1981 selectors: selectors_exports2, 1982 resolvers: resolvers_exports, 1983 actions: actions_exports2 1984 }; 1985 var store2 = (0, import_data8.createReduxStore)(STORE_NAME2, storeConfig); 1986 (0, import_data8.register)(store2); 1987 import_api_fetch.default.use(function(options, next) { 1988 if (options.path?.indexOf("/wp/v2/types/widget-area") === 0) { 1989 return Promise.resolve({}); 1990 } 1991 return next(options); 1992 }); 1993 unlock(store2).registerPrivateSelectors(private_selectors_exports); 1994 1995 // packages/edit-widgets/build-module/filters/move-to-widget-area.mjs 1996 var import_block_editor3 = __toESM(require_block_editor(), 1); 1997 var import_compose3 = __toESM(require_compose(), 1); 1998 var import_data9 = __toESM(require_data(), 1); 1999 var import_hooks = __toESM(require_hooks(), 1); 2000 var import_widgets4 = __toESM(require_widgets(), 1); 2001 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 2002 var withMoveToWidgetAreaToolbarItem = (0, import_compose3.createHigherOrderComponent)( 2003 (BlockEdit) => (props) => { 2004 const { clientId, name: blockName } = props; 2005 const { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea: canInsertBlockInWidgetArea2 } = (0, import_data9.useSelect)( 2006 (select) => { 2007 if (blockName === "core/widget-area") { 2008 return {}; 2009 } 2010 const selectors = select(store2); 2011 const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId); 2012 return { 2013 widgetAreas: selectors.getWidgetAreas(), 2014 currentWidgetAreaId: widgetAreaBlock?.attributes?.id, 2015 canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName) 2016 }; 2017 }, 2018 [clientId, blockName] 2019 ); 2020 const { moveBlockToWidgetArea: moveBlockToWidgetArea2 } = (0, import_data9.useDispatch)(store2); 2021 const hasMultipleWidgetAreas = widgetAreas?.length > 1; 2022 const isMoveToWidgetAreaVisible = blockName !== "core/widget-area" && hasMultipleWidgetAreas && canInsertBlockInWidgetArea2; 2023 return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [ 2024 /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BlockEdit, { ...props }, "edit"), 2025 isMoveToWidgetAreaVisible && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor3.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)( 2026 import_widgets4.MoveToWidgetArea, 2027 { 2028 widgetAreas, 2029 currentWidgetAreaId, 2030 onSelect: (widgetAreaId) => { 2031 moveBlockToWidgetArea2( 2032 props.clientId, 2033 widgetAreaId 2034 ); 2035 } 2036 } 2037 ) }) 2038 ] }); 2039 }, 2040 "withMoveToWidgetAreaToolbarItem" 2041 ); 2042 (0, import_hooks.addFilter)( 2043 "editor.BlockEdit", 2044 "core/edit-widgets/block-edit", 2045 withMoveToWidgetAreaToolbarItem 2046 ); 2047 2048 // packages/edit-widgets/build-module/filters/replace-media-upload.mjs 2049 var import_hooks2 = __toESM(require_hooks(), 1); 2050 var import_media_utils = __toESM(require_media_utils(), 1); 2051 var replaceMediaUpload = () => import_media_utils.MediaUpload; 2052 (0, import_hooks2.addFilter)( 2053 "editor.MediaUpload", 2054 "core/edit-widgets/replace-media-upload", 2055 replaceMediaUpload 2056 ); 2057 2058 // packages/edit-widgets/build-module/blocks/widget-area/index.mjs 2059 var widget_area_exports = {}; 2060 __export(widget_area_exports, { 2061 metadata: () => block_default, 2062 name: () => name, 2063 settings: () => settings 2064 }); 2065 var import_i18n4 = __toESM(require_i18n(), 1); 2066 2067 // packages/edit-widgets/build-module/blocks/widget-area/block.json 2068 var block_default = { 2069 $schema: "https://schemas.wp.org/trunk/block.json", 2070 apiVersion: 3, 2071 name: "core/widget-area", 2072 title: "Widget Area", 2073 category: "widgets", 2074 attributes: { 2075 id: { 2076 type: "string" 2077 }, 2078 name: { 2079 type: "string" 2080 } 2081 }, 2082 supports: { 2083 html: false, 2084 inserter: false, 2085 customClassName: false, 2086 reusable: false, 2087 renaming: false, 2088 visibility: false, 2089 __experimentalToolbar: false, 2090 __experimentalParentSelector: false, 2091 __experimentalDisableBlockOverlay: true 2092 }, 2093 editorStyle: "wp-block-widget-area-editor", 2094 style: "wp-block-widget-area" 2095 }; 2096 2097 // packages/edit-widgets/build-module/blocks/widget-area/edit/index.mjs 2098 var import_element7 = __toESM(require_element(), 1); 2099 var import_data10 = __toESM(require_data(), 1); 2100 var import_core_data5 = __toESM(require_core_data(), 1); 2101 var import_components7 = __toESM(require_components(), 1); 2102 var import_block_editor5 = __toESM(require_block_editor(), 1); 2103 2104 // packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.mjs 2105 var import_core_data4 = __toESM(require_core_data(), 1); 2106 var import_block_editor4 = __toESM(require_block_editor(), 1); 2107 var import_element6 = __toESM(require_element(), 1); 2108 2109 // packages/edit-widgets/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs 2110 var import_element5 = __toESM(require_element(), 1); 2111 var useIsDraggingWithin = (elementRef) => { 2112 const [isDraggingWithin, setIsDraggingWithin] = (0, import_element5.useState)(false); 2113 (0, import_element5.useEffect)(() => { 2114 const { ownerDocument } = elementRef.current; 2115 function handleDragStart(event) { 2116 handleDragEnter(event); 2117 } 2118 function handleDragEnd() { 2119 setIsDraggingWithin(false); 2120 } 2121 function handleDragEnter(event) { 2122 if (elementRef.current.contains(event.target)) { 2123 setIsDraggingWithin(true); 2124 } else { 2125 setIsDraggingWithin(false); 2126 } 2127 } 2128 ownerDocument.addEventListener("dragstart", handleDragStart); 2129 ownerDocument.addEventListener("dragend", handleDragEnd); 2130 ownerDocument.addEventListener("dragenter", handleDragEnter); 2131 return () => { 2132 ownerDocument.removeEventListener("dragstart", handleDragStart); 2133 ownerDocument.removeEventListener("dragend", handleDragEnd); 2134 ownerDocument.removeEventListener("dragenter", handleDragEnter); 2135 }; 2136 }, []); 2137 return isDraggingWithin; 2138 }; 2139 var use_is_dragging_within_default = useIsDraggingWithin; 2140 2141 // packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.mjs 2142 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 2143 function WidgetAreaInnerBlocks({ id }) { 2144 const [blocks, onInput, onChange] = (0, import_core_data4.useEntityBlockEditor)( 2145 "root", 2146 "postType" 2147 ); 2148 const innerBlocksRef = (0, import_element6.useRef)(); 2149 const isDraggingWithinInnerBlocks = use_is_dragging_within_default(innerBlocksRef); 2150 const shouldHighlightDropZone = isDraggingWithinInnerBlocks; 2151 const innerBlocksProps = (0, import_block_editor4.useInnerBlocksProps)( 2152 { ref: innerBlocksRef }, 2153 { 2154 value: blocks, 2155 onInput, 2156 onChange, 2157 templateLock: false, 2158 renderAppender: import_block_editor4.InnerBlocks.ButtonBlockAppender 2159 } 2160 ); 2161 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( 2162 "div", 2163 { 2164 "data-widget-area-id": id, 2165 className: clsx_default( 2166 "wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper", 2167 { 2168 "wp-block-widget-area__highlight-drop-zone": shouldHighlightDropZone 2169 } 2170 ), 2171 children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...innerBlocksProps }) 2172 } 2173 ); 2174 } 2175 2176 // packages/edit-widgets/build-module/blocks/widget-area/edit/index.mjs 2177 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 2178 function WidgetAreaEdit({ 2179 clientId, 2180 attributes: { id, name: name2 } 2181 }) { 2182 const isOpen = (0, import_data10.useSelect)( 2183 (select) => select(store2).getIsWidgetAreaOpen(clientId), 2184 [clientId] 2185 ); 2186 const { setIsWidgetAreaOpen: setIsWidgetAreaOpen2 } = (0, import_data10.useDispatch)(store2); 2187 const wrapper = (0, import_element7.useRef)(); 2188 const setOpen = (0, import_element7.useCallback)( 2189 (openState) => setIsWidgetAreaOpen2(clientId, openState), 2190 [clientId] 2191 ); 2192 const isDragging = useIsDragging(wrapper); 2193 const isDraggingWithin = use_is_dragging_within_default(wrapper); 2194 const [openedWhileDragging, setOpenedWhileDragging] = (0, import_element7.useState)(false); 2195 (0, import_element7.useEffect)(() => { 2196 if (!isDragging) { 2197 setOpenedWhileDragging(false); 2198 return; 2199 } 2200 if (isDraggingWithin && !isOpen) { 2201 setOpen(true); 2202 setOpenedWhileDragging(true); 2203 } else if (!isDraggingWithin && isOpen && openedWhileDragging) { 2204 setOpen(false); 2205 } 2206 }, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]); 2207 const blockProps = (0, import_block_editor5.useBlockProps)(); 2208 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components7.Panel, { ref: wrapper, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 2209 import_components7.PanelBody, 2210 { 2211 title: name2, 2212 opened: isOpen, 2213 onToggle: () => { 2214 setIsWidgetAreaOpen2(clientId, !isOpen); 2215 }, 2216 scrollAfterOpen: !isDragging, 2217 children: ({ opened }) => ( 2218 // This is required to ensure LegacyWidget blocks are not 2219 // unmounted when the panel is collapsed. Unmounting legacy 2220 // widgets may have unintended consequences (e.g. TinyMCE 2221 // not being properly reinitialized) 2222 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 2223 import_components7.__unstableDisclosureContent, 2224 { 2225 className: "wp-block-widget-area__panel-body-content", 2226 visible: opened, 2227 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 2228 import_core_data5.EntityProvider, 2229 { 2230 kind: "root", 2231 type: "postType", 2232 id: `widget-area-$id}`, 2233 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WidgetAreaInnerBlocks, { id }) 2234 } 2235 ) 2236 } 2237 ) 2238 ) 2239 } 2240 ) }) }); 2241 } 2242 var useIsDragging = (elementRef) => { 2243 const [isDragging, setIsDragging] = (0, import_element7.useState)(false); 2244 (0, import_element7.useEffect)(() => { 2245 const { ownerDocument } = elementRef.current; 2246 function handleDragStart() { 2247 setIsDragging(true); 2248 } 2249 function handleDragEnd() { 2250 setIsDragging(false); 2251 } 2252 ownerDocument.addEventListener("dragstart", handleDragStart); 2253 ownerDocument.addEventListener("dragend", handleDragEnd); 2254 return () => { 2255 ownerDocument.removeEventListener("dragstart", handleDragStart); 2256 ownerDocument.removeEventListener("dragend", handleDragEnd); 2257 }; 2258 }, []); 2259 return isDragging; 2260 }; 2261 2262 // packages/edit-widgets/build-module/blocks/widget-area/index.mjs 2263 var { name } = block_default; 2264 var settings = { 2265 title: (0, import_i18n4.__)("Widget Area"), 2266 description: (0, import_i18n4.__)("A widget area container."), 2267 __experimentalLabel: ({ name: label }) => label, 2268 edit: WidgetAreaEdit 2269 }; 2270 2271 // packages/edit-widgets/build-module/components/layout/index.mjs 2272 var import_i18n21 = __toESM(require_i18n(), 1); 2273 var import_data31 = __toESM(require_data(), 1); 2274 var import_plugins3 = __toESM(require_plugins(), 1); 2275 var import_notices4 = __toESM(require_notices(), 1); 2276 var import_components22 = __toESM(require_components(), 1); 2277 2278 // packages/edit-widgets/build-module/components/error-boundary/index.mjs 2279 var import_element8 = __toESM(require_element(), 1); 2280 var import_i18n5 = __toESM(require_i18n(), 1); 2281 var import_components8 = __toESM(require_components(), 1); 2282 var import_block_editor6 = __toESM(require_block_editor(), 1); 2283 var import_compose4 = __toESM(require_compose(), 1); 2284 var import_hooks3 = __toESM(require_hooks(), 1); 2285 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 2286 function CopyButton({ text, children }) { 2287 const ref = (0, import_compose4.useCopyToClipboard)(text); 2288 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components8.Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children }); 2289 } 2290 function ErrorBoundaryWarning({ message, error }) { 2291 const actions = [ 2292 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopyButton, { text: error.stack, children: (0, import_i18n5.__)("Copy Error") }, "copy-error") 2293 ]; 2294 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_block_editor6.Warning, { className: "edit-widgets-error-boundary", actions, children: message }); 2295 } 2296 var ErrorBoundary = class extends import_element8.Component { 2297 constructor() { 2298 super(...arguments); 2299 this.state = { 2300 error: null 2301 }; 2302 } 2303 componentDidCatch(error) { 2304 (0, import_hooks3.doAction)("editor.ErrorBoundary.errorLogged", error); 2305 } 2306 static getDerivedStateFromError(error) { 2307 return { error }; 2308 } 2309 render() { 2310 if (!this.state.error) { 2311 return this.props.children; 2312 } 2313 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( 2314 ErrorBoundaryWarning, 2315 { 2316 message: (0, import_i18n5.__)( 2317 "The editor has encountered an unexpected error." 2318 ), 2319 error: this.state.error 2320 } 2321 ); 2322 } 2323 }; 2324 2325 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs 2326 var import_components9 = __toESM(require_components(), 1); 2327 var import_compose5 = __toESM(require_compose(), 1); 2328 var import_media_utils2 = __toESM(require_media_utils(), 1); 2329 var import_data13 = __toESM(require_data(), 1); 2330 var import_core_data8 = __toESM(require_core_data(), 1); 2331 var import_element10 = __toESM(require_element(), 1); 2332 var import_block_editor8 = __toESM(require_block_editor(), 1); 2333 var import_patterns = __toESM(require_patterns(), 1); 2334 var import_preferences4 = __toESM(require_preferences(), 1); 2335 var import_block_library = __toESM(require_block_library(), 1); 2336 2337 // packages/edit-widgets/build-module/components/keyboard-shortcuts/index.mjs 2338 var import_element9 = __toESM(require_element(), 1); 2339 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1); 2340 var import_keycodes = __toESM(require_keycodes(), 1); 2341 var import_data11 = __toESM(require_data(), 1); 2342 var import_i18n6 = __toESM(require_i18n(), 1); 2343 var import_core_data6 = __toESM(require_core_data(), 1); 2344 function KeyboardShortcuts() { 2345 const { redo, undo } = (0, import_data11.useDispatch)(import_core_data6.store); 2346 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data11.useDispatch)(store2); 2347 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/undo", (event) => { 2348 undo(); 2349 event.preventDefault(); 2350 }); 2351 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/redo", (event) => { 2352 redo(); 2353 event.preventDefault(); 2354 }); 2355 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/save", (event) => { 2356 event.preventDefault(); 2357 saveEditedWidgetAreas2(); 2358 }); 2359 return null; 2360 } 2361 function KeyboardShortcutsRegister() { 2362 const { registerShortcut } = (0, import_data11.useDispatch)(import_keyboard_shortcuts.store); 2363 (0, import_element9.useEffect)(() => { 2364 registerShortcut({ 2365 name: "core/edit-widgets/undo", 2366 category: "global", 2367 description: (0, import_i18n6.__)("Undo your last changes."), 2368 keyCombination: { 2369 modifier: "primary", 2370 character: "z" 2371 } 2372 }); 2373 registerShortcut({ 2374 name: "core/edit-widgets/redo", 2375 category: "global", 2376 description: (0, import_i18n6.__)("Redo your last undo."), 2377 keyCombination: { 2378 modifier: "primaryShift", 2379 character: "z" 2380 }, 2381 // Disable on Apple OS because it conflicts with the browser's 2382 // history shortcut. It's a fine alias for both Windows and Linux. 2383 // Since there's no conflict for Ctrl+Shift+Z on both Windows and 2384 // Linux, we keep it as the default for consistency. 2385 aliases: (0, import_keycodes.isAppleOS)() ? [] : [ 2386 { 2387 modifier: "primary", 2388 character: "y" 2389 } 2390 ] 2391 }); 2392 registerShortcut({ 2393 name: "core/edit-widgets/save", 2394 category: "global", 2395 description: (0, import_i18n6.__)("Save your changes."), 2396 keyCombination: { 2397 modifier: "primary", 2398 character: "s" 2399 } 2400 }); 2401 registerShortcut({ 2402 name: "core/edit-widgets/keyboard-shortcuts", 2403 category: "main", 2404 description: (0, import_i18n6.__)("Display these keyboard shortcuts."), 2405 keyCombination: { 2406 modifier: "access", 2407 character: "h" 2408 } 2409 }); 2410 registerShortcut({ 2411 name: "core/edit-widgets/next-region", 2412 category: "global", 2413 description: (0, import_i18n6.__)("Navigate to the next part of the editor."), 2414 keyCombination: { 2415 modifier: "ctrl", 2416 character: "`" 2417 }, 2418 aliases: [ 2419 { 2420 modifier: "access", 2421 character: "n" 2422 } 2423 ] 2424 }); 2425 registerShortcut({ 2426 name: "core/edit-widgets/previous-region", 2427 category: "global", 2428 description: (0, import_i18n6.__)("Navigate to the previous part of the editor."), 2429 keyCombination: { 2430 modifier: "ctrlShift", 2431 character: "`" 2432 }, 2433 aliases: [ 2434 { 2435 modifier: "access", 2436 character: "p" 2437 }, 2438 { 2439 modifier: "ctrlShift", 2440 character: "~" 2441 } 2442 ] 2443 }); 2444 }, [registerShortcut]); 2445 return null; 2446 } 2447 KeyboardShortcuts.Register = KeyboardShortcutsRegister; 2448 var keyboard_shortcuts_default = KeyboardShortcuts; 2449 2450 // packages/edit-widgets/build-module/hooks/use-last-selected-widget-area.mjs 2451 var import_data12 = __toESM(require_data(), 1); 2452 var import_block_editor7 = __toESM(require_block_editor(), 1); 2453 var import_core_data7 = __toESM(require_core_data(), 1); 2454 var useLastSelectedWidgetArea = () => (0, import_data12.useSelect)((select) => { 2455 const { getBlockSelectionEnd, getBlockName } = select(import_block_editor7.store); 2456 const selectionEndClientId = getBlockSelectionEnd(); 2457 if (getBlockName(selectionEndClientId) === "core/widget-area") { 2458 return selectionEndClientId; 2459 } 2460 const { getParentWidgetAreaBlock: getParentWidgetAreaBlock2 } = select(store2); 2461 const widgetAreaBlock = getParentWidgetAreaBlock2(selectionEndClientId); 2462 const widgetAreaBlockClientId = widgetAreaBlock?.clientId; 2463 if (widgetAreaBlockClientId) { 2464 return widgetAreaBlockClientId; 2465 } 2466 const { getEntityRecord } = select(import_core_data7.store); 2467 const widgetAreasPost = getEntityRecord( 2468 KIND, 2469 POST_TYPE, 2470 buildWidgetAreasPostId() 2471 ); 2472 return widgetAreasPost?.blocks[0]?.clientId; 2473 }, []); 2474 var use_last_selected_widget_area_default = useLastSelectedWidgetArea; 2475 2476 // packages/edit-widgets/build-module/constants.mjs 2477 var ALLOW_REUSABLE_BLOCKS = false; 2478 2479 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs 2480 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 2481 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor8.privateApis); 2482 var { PatternsMenuItems } = unlock(import_patterns.privateApis); 2483 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis); 2484 var EMPTY_ARRAY = []; 2485 function WidgetAreasBlockEditorProvider({ 2486 blockEditorSettings, 2487 children, 2488 ...props 2489 }) { 2490 const isLargeViewport = (0, import_compose5.useViewportMatch)("medium"); 2491 const { 2492 hasUploadPermissions, 2493 reusableBlocks, 2494 isFixedToolbarActive, 2495 keepCaretInsideBlock, 2496 pageOnFront, 2497 pageForPosts 2498 } = (0, import_data13.useSelect)((select) => { 2499 const { canUser, getEntityRecord, getEntityRecords } = select(import_core_data8.store); 2500 const siteSettings = canUser("read", { 2501 kind: "root", 2502 name: "site" 2503 }) ? getEntityRecord("root", "site") : void 0; 2504 return { 2505 hasUploadPermissions: canUser("create", { 2506 kind: "postType", 2507 name: "attachment" 2508 }) ?? true, 2509 reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords("postType", "wp_block") : EMPTY_ARRAY, 2510 isFixedToolbarActive: !!select(import_preferences4.store).get( 2511 "core/edit-widgets", 2512 "fixedToolbar" 2513 ), 2514 keepCaretInsideBlock: !!select(import_preferences4.store).get( 2515 "core/edit-widgets", 2516 "keepCaretInsideBlock" 2517 ), 2518 pageOnFront: siteSettings?.page_on_front, 2519 pageForPosts: siteSettings?.page_for_posts 2520 }; 2521 }, []); 2522 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data13.useDispatch)(store2); 2523 const settings2 = (0, import_element10.useMemo)(() => { 2524 let mediaUploadBlockEditor; 2525 if (hasUploadPermissions) { 2526 mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => { 2527 (0, import_media_utils2.uploadMedia)({ 2528 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes, 2529 onError: ({ message }) => onError(message), 2530 ...argumentsObject 2531 }); 2532 }; 2533 } 2534 return { 2535 ...blockEditorSettings, 2536 __experimentalReusableBlocks: reusableBlocks, 2537 hasFixedToolbar: isFixedToolbarActive || !isLargeViewport, 2538 keepCaretInsideBlock, 2539 mediaUpload: mediaUploadBlockEditor, 2540 templateLock: "all", 2541 __experimentalSetIsInserterOpened: setIsInserterOpened2, 2542 pageOnFront, 2543 pageForPosts, 2544 editorTool: "edit" 2545 }; 2546 }, [ 2547 hasUploadPermissions, 2548 blockEditorSettings, 2549 isFixedToolbarActive, 2550 isLargeViewport, 2551 keepCaretInsideBlock, 2552 reusableBlocks, 2553 setIsInserterOpened2, 2554 pageOnFront, 2555 pageForPosts 2556 ]); 2557 const widgetAreaId = use_last_selected_widget_area_default(); 2558 const [blocks, onInput, onChange] = (0, import_core_data8.useEntityBlockEditor)( 2559 KIND, 2560 POST_TYPE, 2561 { id: buildWidgetAreasPostId() } 2562 ); 2563 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_components9.SlotFillProvider, { children: [ 2564 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(keyboard_shortcuts_default.Register, {}), 2565 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BlockKeyboardShortcuts, {}), 2566 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)( 2567 ExperimentalBlockEditorProvider, 2568 { 2569 value: blocks, 2570 onInput, 2571 onChange, 2572 settings: settings2, 2573 useSubRegistry: false, 2574 ...props, 2575 children: [ 2576 children, 2577 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PatternsMenuItems, { rootClientId: widgetAreaId }) 2578 ] 2579 } 2580 ) 2581 ] }); 2582 } 2583 2584 // packages/edit-widgets/build-module/components/sidebar/index.mjs 2585 var import_element12 = __toESM(require_element(), 1); 2586 var import_i18n8 = __toESM(require_i18n(), 1); 2587 var import_block_editor10 = __toESM(require_block_editor(), 1); 2588 var import_components11 = __toESM(require_components(), 1); 2589 var import_data15 = __toESM(require_data(), 1); 2590 2591 // packages/edit-widgets/build-module/components/sidebar/widget-areas.mjs 2592 var import_data14 = __toESM(require_data(), 1); 2593 var import_element11 = __toESM(require_element(), 1); 2594 var import_block_editor9 = __toESM(require_block_editor(), 1); 2595 var import_components10 = __toESM(require_components(), 1); 2596 var import_i18n7 = __toESM(require_i18n(), 1); 2597 var import_url = __toESM(require_url(), 1); 2598 var import_dom = __toESM(require_dom(), 1); 2599 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 2600 function WidgetAreas({ selectedWidgetAreaId }) { 2601 const widgetAreas = (0, import_data14.useSelect)( 2602 (select) => select(store2).getWidgetAreas(), 2603 [] 2604 ); 2605 const selectedWidgetArea = (0, import_element11.useMemo)( 2606 () => selectedWidgetAreaId && widgetAreas?.find( 2607 (widgetArea) => widgetArea.id === selectedWidgetAreaId 2608 ), 2609 [selectedWidgetAreaId, widgetAreas] 2610 ); 2611 let description; 2612 if (!selectedWidgetArea) { 2613 description = (0, import_i18n7.__)( 2614 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 2615 "Widget Areas are global parts in your site\u2019s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer." 2616 ); 2617 } else if (selectedWidgetAreaId === "wp_inactive_widgets") { 2618 description = (0, import_i18n7.__)( 2619 "Blocks in this Widget Area will not be displayed in your site." 2620 ); 2621 } else { 2622 description = selectedWidgetArea.description; 2623 } 2624 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "edit-widgets-widget-areas", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "edit-widgets-widget-areas__top-container", children: [ 2625 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_block_editor9.BlockIcon, { icon: block_default_default }), 2626 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [ 2627 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)( 2628 "p", 2629 { 2630 dangerouslySetInnerHTML: { 2631 __html: (0, import_dom.safeHTML)(description) 2632 } 2633 } 2634 ), 2635 widgetAreas?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: (0, import_i18n7.__)( 2636 "Your theme does not contain any Widget Areas." 2637 ) }), 2638 !selectedWidgetArea && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)( 2639 import_components10.Button, 2640 { 2641 __next40pxDefaultSize: true, 2642 href: (0, import_url.addQueryArgs)("customize.php", { 2643 "autofocus[panel]": "widgets", 2644 return: window.location.pathname 2645 }), 2646 variant: "tertiary", 2647 children: (0, import_i18n7.__)("Manage with live preview") 2648 } 2649 ) 2650 ] }) 2651 ] }) }); 2652 } 2653 2654 // packages/edit-widgets/build-module/components/sidebar/index.mjs 2655 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 2656 var SIDEBAR_ACTIVE_BY_DEFAULT = import_element12.Platform.select({ 2657 web: true, 2658 native: false 2659 }); 2660 var BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector"; 2661 var WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas"; 2662 var { Tabs } = unlock(import_components11.privateApis); 2663 function SidebarHeader({ selectedWidgetAreaBlock }) { 2664 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.TabList, { children: [ 2665 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: WIDGET_AREAS_IDENTIFIER, children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0, import_i18n8.__)("Widget Areas") }), 2666 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: BLOCK_INSPECTOR_IDENTIFIER, children: (0, import_i18n8.__)("Block") }) 2667 ] }); 2668 } 2669 function SidebarContent({ 2670 hasSelectedNonAreaBlock, 2671 currentArea, 2672 isGeneralSidebarOpen, 2673 selectedWidgetAreaBlock 2674 }) { 2675 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store); 2676 (0, import_element12.useEffect)(() => { 2677 if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) { 2678 enableComplementaryArea2( 2679 "core/edit-widgets", 2680 BLOCK_INSPECTOR_IDENTIFIER 2681 ); 2682 } 2683 if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) { 2684 enableComplementaryArea2( 2685 "core/edit-widgets", 2686 WIDGET_AREAS_IDENTIFIER 2687 ); 2688 } 2689 }, [hasSelectedNonAreaBlock, enableComplementaryArea2]); 2690 const tabsContextValue = (0, import_element12.useContext)(Tabs.Context); 2691 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2692 complementary_area_default, 2693 { 2694 className: "edit-widgets-sidebar", 2695 header: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2696 SidebarHeader, 2697 { 2698 selectedWidgetAreaBlock 2699 } 2700 ) }), 2701 headerClassName: "edit-widgets-sidebar__panel-tabs", 2702 title: (0, import_i18n8.__)("Settings"), 2703 closeLabel: (0, import_i18n8.__)("Close Settings"), 2704 scope: "core/edit-widgets", 2705 identifier: currentArea, 2706 icon: (0, import_i18n8.isRTL)() ? drawer_left_default : drawer_right_default, 2707 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT, 2708 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.Context.Provider, { value: tabsContextValue, children: [ 2709 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2710 Tabs.TabPanel, 2711 { 2712 tabId: WIDGET_AREAS_IDENTIFIER, 2713 focusable: false, 2714 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2715 WidgetAreas, 2716 { 2717 selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id 2718 } 2719 ) 2720 } 2721 ), 2722 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2723 Tabs.TabPanel, 2724 { 2725 tabId: BLOCK_INSPECTOR_IDENTIFIER, 2726 focusable: false, 2727 children: hasSelectedNonAreaBlock ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_block_editor10.BlockInspector, {}) : ( 2728 // Pretend that Widget Areas are part of the UI by not 2729 // showing the Block Inspector when one is selected. 2730 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "block-editor-block-inspector__no-blocks", children: (0, import_i18n8.__)("No block selected.") }) 2731 ) 2732 } 2733 ) 2734 ] }) 2735 } 2736 ); 2737 } 2738 function Sidebar() { 2739 const { 2740 currentArea, 2741 hasSelectedNonAreaBlock, 2742 isGeneralSidebarOpen, 2743 selectedWidgetAreaBlock 2744 } = (0, import_data15.useSelect)((select) => { 2745 const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(import_block_editor10.store); 2746 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select(store); 2747 const selectedBlock = getSelectedBlock(); 2748 const activeArea = getActiveComplementaryArea2(store2.name); 2749 let currentSelection = activeArea; 2750 if (!currentSelection) { 2751 if (selectedBlock) { 2752 currentSelection = BLOCK_INSPECTOR_IDENTIFIER; 2753 } else { 2754 currentSelection = WIDGET_AREAS_IDENTIFIER; 2755 } 2756 } 2757 let widgetAreaBlock; 2758 if (selectedBlock) { 2759 if (selectedBlock.name === "core/widget-area") { 2760 widgetAreaBlock = selectedBlock; 2761 } else { 2762 widgetAreaBlock = getBlock( 2763 getBlockParentsByBlockName( 2764 selectedBlock.clientId, 2765 "core/widget-area" 2766 )[0] 2767 ); 2768 } 2769 } 2770 return { 2771 currentArea: currentSelection, 2772 hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"), 2773 isGeneralSidebarOpen: !!activeArea, 2774 selectedWidgetAreaBlock: widgetAreaBlock 2775 }; 2776 }, []); 2777 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store); 2778 const onTabSelect = (0, import_element12.useCallback)( 2779 (newSelectedTabId) => { 2780 if (!!newSelectedTabId) { 2781 enableComplementaryArea2( 2782 store2.name, 2783 newSelectedTabId 2784 ); 2785 } 2786 }, 2787 [enableComplementaryArea2] 2788 ); 2789 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2790 Tabs, 2791 { 2792 selectedTabId: isGeneralSidebarOpen ? currentArea : null, 2793 onSelect: onTabSelect, 2794 selectOnMove: false, 2795 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 2796 SidebarContent, 2797 { 2798 hasSelectedNonAreaBlock, 2799 currentArea, 2800 isGeneralSidebarOpen, 2801 selectedWidgetAreaBlock 2802 } 2803 ) 2804 } 2805 ); 2806 } 2807 2808 // packages/edit-widgets/build-module/components/layout/interface.mjs 2809 var import_compose12 = __toESM(require_compose(), 1); 2810 var import_block_editor17 = __toESM(require_block_editor(), 1); 2811 var import_element22 = __toESM(require_element(), 1); 2812 var import_data28 = __toESM(require_data(), 1); 2813 var import_i18n18 = __toESM(require_i18n(), 1); 2814 var import_preferences8 = __toESM(require_preferences(), 1); 2815 2816 // packages/edit-widgets/build-module/components/header/index.mjs 2817 var import_block_editor12 = __toESM(require_block_editor(), 1); 2818 var import_data22 = __toESM(require_data(), 1); 2819 var import_element18 = __toESM(require_element(), 1); 2820 var import_i18n16 = __toESM(require_i18n(), 1); 2821 var import_components19 = __toESM(require_components(), 1); 2822 var import_compose8 = __toESM(require_compose(), 1); 2823 var import_preferences6 = __toESM(require_preferences(), 1); 2824 2825 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs 2826 var import_data18 = __toESM(require_data(), 1); 2827 var import_i18n11 = __toESM(require_i18n(), 1); 2828 var import_components14 = __toESM(require_components(), 1); 2829 var import_block_editor11 = __toESM(require_block_editor(), 1); 2830 var import_element15 = __toESM(require_element(), 1); 2831 var import_compose6 = __toESM(require_compose(), 1); 2832 2833 // packages/edit-widgets/build-module/components/header/undo-redo/undo.mjs 2834 var import_i18n9 = __toESM(require_i18n(), 1); 2835 var import_components12 = __toESM(require_components(), 1); 2836 var import_data16 = __toESM(require_data(), 1); 2837 var import_keycodes2 = __toESM(require_keycodes(), 1); 2838 var import_core_data9 = __toESM(require_core_data(), 1); 2839 var import_element13 = __toESM(require_element(), 1); 2840 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 2841 function UndoButton(props, ref) { 2842 const hasUndo = (0, import_data16.useSelect)( 2843 (select) => select(import_core_data9.store).hasUndo(), 2844 [] 2845 ); 2846 const { undo } = (0, import_data16.useDispatch)(import_core_data9.store); 2847 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 2848 import_components12.Button, 2849 { 2850 ...props, 2851 ref, 2852 icon: !(0, import_i18n9.isRTL)() ? undo_default : redo_default, 2853 label: (0, import_i18n9.__)("Undo"), 2854 shortcut: import_keycodes2.displayShortcut.primary("z"), 2855 "aria-disabled": !hasUndo, 2856 onClick: hasUndo ? undo : void 0, 2857 size: "compact" 2858 } 2859 ); 2860 } 2861 var undo_default2 = (0, import_element13.forwardRef)(UndoButton); 2862 2863 // packages/edit-widgets/build-module/components/header/undo-redo/redo.mjs 2864 var import_i18n10 = __toESM(require_i18n(), 1); 2865 var import_components13 = __toESM(require_components(), 1); 2866 var import_data17 = __toESM(require_data(), 1); 2867 var import_keycodes3 = __toESM(require_keycodes(), 1); 2868 var import_core_data10 = __toESM(require_core_data(), 1); 2869 var import_element14 = __toESM(require_element(), 1); 2870 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 2871 function RedoButton(props, ref) { 2872 const shortcut = (0, import_keycodes3.isAppleOS)() ? import_keycodes3.displayShortcut.primaryShift("z") : import_keycodes3.displayShortcut.primary("y"); 2873 const hasRedo = (0, import_data17.useSelect)( 2874 (select) => select(import_core_data10.store).hasRedo(), 2875 [] 2876 ); 2877 const { redo } = (0, import_data17.useDispatch)(import_core_data10.store); 2878 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 2879 import_components13.Button, 2880 { 2881 ...props, 2882 ref, 2883 icon: !(0, import_i18n10.isRTL)() ? redo_default : undo_default, 2884 label: (0, import_i18n10.__)("Redo"), 2885 shortcut, 2886 "aria-disabled": !hasRedo, 2887 onClick: hasRedo ? redo : void 0, 2888 size: "compact" 2889 } 2890 ); 2891 } 2892 var redo_default2 = (0, import_element14.forwardRef)(RedoButton); 2893 2894 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs 2895 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 2896 function DocumentTools() { 2897 const isMediumViewport = (0, import_compose6.useViewportMatch)("medium"); 2898 const { 2899 isInserterOpen, 2900 isListViewOpen, 2901 inserterSidebarToggleRef: inserterSidebarToggleRef2, 2902 listViewToggleRef: listViewToggleRef2 2903 } = (0, import_data18.useSelect)((select) => { 2904 const { 2905 isInserterOpened: isInserterOpened2, 2906 getInserterSidebarToggleRef: getInserterSidebarToggleRef2, 2907 isListViewOpened: isListViewOpened2, 2908 getListViewToggleRef: getListViewToggleRef2 2909 } = unlock(select(store2)); 2910 return { 2911 isInserterOpen: isInserterOpened2(), 2912 isListViewOpen: isListViewOpened2(), 2913 inserterSidebarToggleRef: getInserterSidebarToggleRef2(), 2914 listViewToggleRef: getListViewToggleRef2() 2915 }; 2916 }, []); 2917 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data18.useDispatch)(store2); 2918 const toggleListView = (0, import_element15.useCallback)( 2919 () => setIsListViewOpened2(!isListViewOpen), 2920 [setIsListViewOpened2, isListViewOpen] 2921 ); 2922 const toggleInserterSidebar = (0, import_element15.useCallback)( 2923 () => setIsInserterOpened2(!isInserterOpen), 2924 [setIsInserterOpened2, isInserterOpen] 2925 ); 2926 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)( 2927 import_block_editor11.NavigableToolbar, 2928 { 2929 className: "edit-widgets-header-toolbar", 2930 "aria-label": (0, import_i18n11.__)("Document tools"), 2931 variant: "unstyled", 2932 children: [ 2933 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2934 import_components14.ToolbarItem, 2935 { 2936 ref: inserterSidebarToggleRef2, 2937 as: import_components14.Button, 2938 className: "edit-widgets-header-toolbar__inserter-toggle", 2939 variant: "primary", 2940 isPressed: isInserterOpen, 2941 onMouseDown: (event) => { 2942 event.preventDefault(); 2943 }, 2944 onClick: toggleInserterSidebar, 2945 icon: plus_default, 2946 label: (0, import_i18n11._x)( 2947 "Block Inserter", 2948 "Generic label for block inserter button" 2949 ), 2950 size: "compact" 2951 } 2952 ), 2953 isMediumViewport && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [ 2954 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: undo_default2 }), 2955 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: redo_default2 }), 2956 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2957 import_components14.ToolbarItem, 2958 { 2959 as: import_components14.Button, 2960 className: "edit-widgets-header-toolbar__list-view-toggle", 2961 icon: list_view_default, 2962 isPressed: isListViewOpen, 2963 label: (0, import_i18n11.__)("List View"), 2964 onClick: toggleListView, 2965 ref: listViewToggleRef2, 2966 size: "compact" 2967 } 2968 ) 2969 ] }) 2970 ] 2971 } 2972 ); 2973 } 2974 var document_tools_default = DocumentTools; 2975 2976 // packages/edit-widgets/build-module/components/save-button/index.mjs 2977 var import_components15 = __toESM(require_components(), 1); 2978 var import_i18n12 = __toESM(require_i18n(), 1); 2979 var import_data19 = __toESM(require_data(), 1); 2980 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 2981 function SaveButton() { 2982 const { hasEditedWidgetAreaIds, isSaving, isWidgetSaveLocked } = (0, import_data19.useSelect)( 2983 (select) => { 2984 const { 2985 getEditedWidgetAreas: getEditedWidgetAreas2, 2986 isSavingWidgetAreas: isSavingWidgetAreas2, 2987 isWidgetSavingLocked: isWidgetSavingLocked2 2988 } = select(store2); 2989 return { 2990 hasEditedWidgetAreaIds: getEditedWidgetAreas2()?.length > 0, 2991 isSaving: isSavingWidgetAreas2(), 2992 isWidgetSaveLocked: isWidgetSavingLocked2() 2993 }; 2994 }, 2995 [] 2996 ); 2997 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data19.useDispatch)(store2); 2998 const isDisabled = isWidgetSaveLocked || isSaving || !hasEditedWidgetAreaIds; 2999 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 3000 import_components15.Button, 3001 { 3002 variant: "primary", 3003 isBusy: isSaving, 3004 "aria-disabled": isDisabled, 3005 onClick: isDisabled ? void 0 : saveEditedWidgetAreas2, 3006 size: "compact", 3007 children: isSaving ? (0, import_i18n12.__)("Saving\u2026") : (0, import_i18n12.__)("Update") 3008 } 3009 ); 3010 } 3011 var save_button_default = SaveButton; 3012 3013 // packages/edit-widgets/build-module/components/more-menu/index.mjs 3014 var import_components18 = __toESM(require_components(), 1); 3015 var import_element17 = __toESM(require_element(), 1); 3016 var import_i18n15 = __toESM(require_i18n(), 1); 3017 var import_preferences5 = __toESM(require_preferences(), 1); 3018 var import_keycodes5 = __toESM(require_keycodes(), 1); 3019 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts(), 1); 3020 var import_compose7 = __toESM(require_compose(), 1); 3021 3022 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs 3023 var import_components16 = __toESM(require_components(), 1); 3024 var import_i18n14 = __toESM(require_i18n(), 1); 3025 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1); 3026 var import_data21 = __toESM(require_data(), 1); 3027 3028 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/config.mjs 3029 var import_i18n13 = __toESM(require_i18n(), 1); 3030 var textFormattingShortcuts = [ 3031 { 3032 keyCombination: { modifier: "primary", character: "b" }, 3033 description: (0, import_i18n13.__)("Make the selected text bold.") 3034 }, 3035 { 3036 keyCombination: { modifier: "primary", character: "i" }, 3037 description: (0, import_i18n13.__)("Make the selected text italic.") 3038 }, 3039 { 3040 keyCombination: { modifier: "primary", character: "k" }, 3041 description: (0, import_i18n13.__)("Convert the selected text into a link.") 3042 }, 3043 { 3044 keyCombination: { modifier: "primaryShift", character: "k" }, 3045 description: (0, import_i18n13.__)("Remove a link.") 3046 }, 3047 { 3048 keyCombination: { character: "[[" }, 3049 description: (0, import_i18n13.__)("Insert a link to a post or page.") 3050 }, 3051 { 3052 keyCombination: { modifier: "primary", character: "u" }, 3053 description: (0, import_i18n13.__)("Underline the selected text.") 3054 }, 3055 { 3056 keyCombination: { modifier: "access", character: "d" }, 3057 description: (0, import_i18n13.__)("Strikethrough the selected text.") 3058 }, 3059 { 3060 keyCombination: { modifier: "access", character: "x" }, 3061 description: (0, import_i18n13.__)("Make the selected text inline code.") 3062 }, 3063 { 3064 keyCombination: { 3065 modifier: "access", 3066 character: "0" 3067 }, 3068 aliases: [ 3069 { 3070 modifier: "access", 3071 character: "7" 3072 } 3073 ], 3074 description: (0, import_i18n13.__)("Convert the current heading to a paragraph.") 3075 }, 3076 { 3077 keyCombination: { modifier: "access", character: "1-6" }, 3078 description: (0, import_i18n13.__)( 3079 "Convert the current paragraph or heading to a heading of level 1 to 6." 3080 ) 3081 }, 3082 { 3083 keyCombination: { modifier: "primaryShift", character: "SPACE" }, 3084 description: (0, import_i18n13.__)("Add non breaking space.") 3085 } 3086 ]; 3087 3088 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs 3089 var import_element16 = __toESM(require_element(), 1); 3090 var import_keycodes4 = __toESM(require_keycodes(), 1); 3091 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 3092 function KeyCombination({ keyCombination, forceAriaLabel }) { 3093 const shortcut = keyCombination.modifier ? import_keycodes4.displayShortcutList[keyCombination.modifier]( 3094 keyCombination.character 3095 ) : keyCombination.character; 3096 const ariaLabel = keyCombination.modifier ? import_keycodes4.shortcutAriaLabel[keyCombination.modifier]( 3097 keyCombination.character 3098 ) : keyCombination.character; 3099 const shortcuts = Array.isArray(shortcut) ? shortcut : [shortcut]; 3100 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 3101 "kbd", 3102 { 3103 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination", 3104 "aria-label": forceAriaLabel || ariaLabel, 3105 children: shortcuts.map((character, index) => { 3106 if (character === "+") { 3107 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element16.Fragment, { children: character }, index); 3108 } 3109 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 3110 "kbd", 3111 { 3112 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key", 3113 children: character 3114 }, 3115 index 3116 ); 3117 }) 3118 } 3119 ); 3120 } 3121 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) { 3122 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [ 3123 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description", children: description }), 3124 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term", children: [ 3125 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 3126 KeyCombination, 3127 { 3128 keyCombination, 3129 forceAriaLabel: ariaLabel 3130 } 3131 ), 3132 aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 3133 KeyCombination, 3134 { 3135 keyCombination: alias, 3136 forceAriaLabel: ariaLabel 3137 }, 3138 index 3139 )) 3140 ] }) 3141 ] }); 3142 } 3143 var shortcut_default = Shortcut; 3144 3145 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs 3146 var import_data20 = __toESM(require_data(), 1); 3147 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1); 3148 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 3149 function DynamicShortcut({ name: name2 }) { 3150 const { keyCombination, description, aliases } = (0, import_data20.useSelect)( 3151 (select) => { 3152 const { 3153 getShortcutKeyCombination, 3154 getShortcutDescription, 3155 getShortcutAliases 3156 } = select(import_keyboard_shortcuts3.store); 3157 return { 3158 keyCombination: getShortcutKeyCombination(name2), 3159 aliases: getShortcutAliases(name2), 3160 description: getShortcutDescription(name2) 3161 }; 3162 }, 3163 [name2] 3164 ); 3165 if (!keyCombination) { 3166 return null; 3167 } 3168 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 3169 shortcut_default, 3170 { 3171 keyCombination, 3172 description, 3173 aliases 3174 } 3175 ); 3176 } 3177 var dynamic_shortcut_default = DynamicShortcut; 3178 3179 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs 3180 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 3181 var ShortcutList = ({ shortcuts }) => ( 3182 /* 3183 * Disable reason: The `list` ARIA role is redundant but 3184 * Safari+VoiceOver won't announce the list otherwise. 3185 */ 3186 /* eslint-disable jsx-a11y/no-redundant-roles */ 3187 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3188 "ul", 3189 { 3190 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list", 3191 role: "list", 3192 children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3193 "li", 3194 { 3195 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut", 3196 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(shortcut_default, { ...shortcut }) 3197 }, 3198 index 3199 )) 3200 } 3201 ) 3202 ); 3203 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)( 3204 "section", 3205 { 3206 className: clsx_default( 3207 "edit-widgets-keyboard-shortcut-help-modal__section", 3208 className 3209 ), 3210 children: [ 3211 !!title && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h2", { className: "edit-widgets-keyboard-shortcut-help-modal__section-title", children: title }), 3212 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ShortcutList, { shortcuts }) 3213 ] 3214 } 3215 ); 3216 var ShortcutCategorySection = ({ 3217 title, 3218 categoryName, 3219 additionalShortcuts = [] 3220 }) => { 3221 const categoryShortcuts = (0, import_data21.useSelect)( 3222 (select) => { 3223 return select(import_keyboard_shortcuts4.store).getCategoryShortcuts( 3224 categoryName 3225 ); 3226 }, 3227 [categoryName] 3228 ); 3229 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3230 ShortcutSection, 3231 { 3232 title, 3233 shortcuts: categoryShortcuts.concat(additionalShortcuts) 3234 } 3235 ); 3236 }; 3237 function KeyboardShortcutHelpModal({ 3238 isModalActive: isModalActive2, 3239 toggleModal 3240 }) { 3241 (0, import_keyboard_shortcuts4.useShortcut)("core/edit-widgets/keyboard-shortcuts", toggleModal, { 3242 bindGlobal: true 3243 }); 3244 if (!isModalActive2) { 3245 return null; 3246 } 3247 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)( 3248 import_components16.Modal, 3249 { 3250 className: "edit-widgets-keyboard-shortcut-help-modal", 3251 title: (0, import_i18n14.__)("Keyboard shortcuts"), 3252 onRequestClose: toggleModal, 3253 children: [ 3254 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3255 ShortcutSection, 3256 { 3257 className: "edit-widgets-keyboard-shortcut-help-modal__main-shortcuts", 3258 shortcuts: ["core/edit-widgets/keyboard-shortcuts"] 3259 } 3260 ), 3261 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3262 ShortcutCategorySection, 3263 { 3264 title: (0, import_i18n14.__)("Global shortcuts"), 3265 categoryName: "global" 3266 } 3267 ), 3268 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3269 ShortcutCategorySection, 3270 { 3271 title: (0, import_i18n14.__)("Selection shortcuts"), 3272 categoryName: "selection" 3273 } 3274 ), 3275 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3276 ShortcutCategorySection, 3277 { 3278 title: (0, import_i18n14.__)("Block shortcuts"), 3279 categoryName: "block", 3280 additionalShortcuts: [ 3281 { 3282 keyCombination: { character: "/" }, 3283 description: (0, import_i18n14.__)( 3284 "Change the block type after adding a new paragraph." 3285 ), 3286 /* translators: The forward-slash character. e.g. '/'. */ 3287 ariaLabel: (0, import_i18n14.__)("Forward-slash") 3288 } 3289 ] 3290 } 3291 ), 3292 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3293 ShortcutSection, 3294 { 3295 title: (0, import_i18n14.__)("Text formatting"), 3296 shortcuts: textFormattingShortcuts 3297 } 3298 ), 3299 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 3300 ShortcutCategorySection, 3301 { 3302 title: (0, import_i18n14.__)("List View shortcuts"), 3303 categoryName: "list-view" 3304 } 3305 ) 3306 ] 3307 } 3308 ); 3309 } 3310 3311 // packages/edit-widgets/build-module/components/more-menu/tools-more-menu-group.mjs 3312 var import_components17 = __toESM(require_components(), 1); 3313 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 3314 var { Fill: ToolsMoreMenuGroup, Slot: Slot4 } = (0, import_components17.createSlotFill)( 3315 "EditWidgetsToolsMoreMenuGroup" 3316 ); 3317 ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Slot4, { fillProps, children: (fills) => fills.length > 0 && fills }); 3318 var tools_more_menu_group_default = ToolsMoreMenuGroup; 3319 3320 // packages/edit-widgets/build-module/components/more-menu/index.mjs 3321 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 3322 function MoreMenu() { 3323 const [ 3324 isKeyboardShortcutsModalActive, 3325 setIsKeyboardShortcutsModalVisible 3326 ] = (0, import_element17.useState)(false); 3327 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive); 3328 (0, import_keyboard_shortcuts5.useShortcut)( 3329 "core/edit-widgets/keyboard-shortcuts", 3330 toggleKeyboardShortcutsModal 3331 ); 3332 const isLargeViewport = (0, import_compose7.useViewportMatch)("medium"); 3333 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [ 3334 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3335 import_components18.DropdownMenu, 3336 { 3337 icon: more_vertical_default, 3338 label: (0, import_i18n15.__)("Options"), 3339 popoverProps: { 3340 placement: "bottom-end", 3341 className: "more-menu-dropdown__content" 3342 }, 3343 toggleProps: { 3344 tooltipPosition: "bottom", 3345 size: "compact" 3346 }, 3347 children: (onClose) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [ 3348 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components18.MenuGroup, { label: (0, import_i18n15._x)("View", "noun"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3349 import_preferences5.PreferenceToggleMenuItem, 3350 { 3351 scope: "core/edit-widgets", 3352 name: "fixedToolbar", 3353 label: (0, import_i18n15.__)("Top toolbar"), 3354 info: (0, import_i18n15.__)( 3355 "Access all block and document tools in a single place" 3356 ), 3357 messageActivated: (0, import_i18n15.__)( 3358 "Top toolbar activated" 3359 ), 3360 messageDeactivated: (0, import_i18n15.__)( 3361 "Top toolbar deactivated" 3362 ) 3363 } 3364 ) }), 3365 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Tools"), children: [ 3366 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3367 import_components18.MenuItem, 3368 { 3369 onClick: () => { 3370 setIsKeyboardShortcutsModalVisible(true); 3371 }, 3372 shortcut: import_keycodes5.displayShortcut.access("h"), 3373 children: (0, import_i18n15.__)("Keyboard shortcuts") 3374 } 3375 ), 3376 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3377 import_preferences5.PreferenceToggleMenuItem, 3378 { 3379 scope: "core/edit-widgets", 3380 name: "welcomeGuide", 3381 label: (0, import_i18n15.__)("Welcome Guide") 3382 } 3383 ), 3384 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)( 3385 import_components18.MenuItem, 3386 { 3387 role: "menuitem", 3388 icon: external_default, 3389 href: (0, import_i18n15.__)( 3390 "https://wordpress.org/documentation/article/block-based-widgets-editor/" 3391 ), 3392 target: "_blank", 3393 rel: "noopener noreferrer", 3394 children: [ 3395 (0, import_i18n15.__)("Help"), 3396 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components18.VisuallyHidden, { 3397 as: "span", 3398 /* translators: accessibility text */ 3399 children: (0, import_i18n15.__)("(opens in a new tab)") 3400 }) 3401 ] 3402 } 3403 ), 3404 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3405 tools_more_menu_group_default.Slot, 3406 { 3407 fillProps: { onClose } 3408 } 3409 ) 3410 ] }), 3411 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Preferences"), children: [ 3412 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3413 import_preferences5.PreferenceToggleMenuItem, 3414 { 3415 scope: "core/edit-widgets", 3416 name: "keepCaretInsideBlock", 3417 label: (0, import_i18n15.__)( 3418 "Contain text cursor inside block" 3419 ), 3420 info: (0, import_i18n15.__)( 3421 "Aids screen readers by stopping text caret from leaving blocks." 3422 ), 3423 messageActivated: (0, import_i18n15.__)( 3424 "Contain text cursor inside block activated" 3425 ), 3426 messageDeactivated: (0, import_i18n15.__)( 3427 "Contain text cursor inside block deactivated" 3428 ) 3429 } 3430 ), 3431 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3432 import_preferences5.PreferenceToggleMenuItem, 3433 { 3434 scope: "core/edit-widgets", 3435 name: "themeStyles", 3436 info: (0, import_i18n15.__)( 3437 "Make the editor look like your theme." 3438 ), 3439 label: (0, import_i18n15.__)("Use theme styles") 3440 } 3441 ), 3442 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3443 import_preferences5.PreferenceToggleMenuItem, 3444 { 3445 scope: "core/edit-widgets", 3446 name: "showBlockBreadcrumbs", 3447 label: (0, import_i18n15.__)("Display block breadcrumbs"), 3448 info: (0, import_i18n15.__)( 3449 "Shows block breadcrumbs at the bottom of the editor." 3450 ), 3451 messageActivated: (0, import_i18n15.__)( 3452 "Display block breadcrumbs activated" 3453 ), 3454 messageDeactivated: (0, import_i18n15.__)( 3455 "Display block breadcrumbs deactivated" 3456 ) 3457 } 3458 ) 3459 ] }) 3460 ] }) 3461 } 3462 ), 3463 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3464 KeyboardShortcutHelpModal, 3465 { 3466 isModalActive: isKeyboardShortcutsModalActive, 3467 toggleModal: toggleKeyboardShortcutsModal 3468 } 3469 ) 3470 ] }); 3471 } 3472 3473 // packages/edit-widgets/build-module/components/header/index.mjs 3474 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 3475 function Header() { 3476 const isLargeViewport = (0, import_compose8.useViewportMatch)("medium"); 3477 const blockToolbarRef = (0, import_element18.useRef)(); 3478 const { hasFixedToolbar } = (0, import_data22.useSelect)( 3479 (select) => ({ 3480 hasFixedToolbar: !!select(import_preferences6.store).get( 3481 "core/edit-widgets", 3482 "fixedToolbar" 3483 ) 3484 }), 3485 [] 3486 ); 3487 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header", children: [ 3488 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__navigable-toolbar-wrapper", children: [ 3489 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", { className: "edit-widgets-header__title", children: (0, import_i18n16.__)("Widgets") }), 3490 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3491 import_components19.VisuallyHidden, 3492 { 3493 as: "h1", 3494 className: "edit-widgets-header__title", 3495 children: (0, import_i18n16.__)("Widgets") 3496 } 3497 ), 3498 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(document_tools_default, {}), 3499 hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [ 3500 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "selected-block-tools-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_block_editor12.BlockToolbar, { hideDragHandle: true }) }), 3501 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3502 import_components19.Popover.Slot, 3503 { 3504 ref: blockToolbarRef, 3505 name: "block-toolbar" 3506 } 3507 ) 3508 ] }) 3509 ] }), 3510 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__actions", children: [ 3511 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(pinned_items_default.Slot, { scope: "core/edit-widgets" }), 3512 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(save_button_default, {}), 3513 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(MoreMenu, {}) 3514 ] }) 3515 ] }) }); 3516 } 3517 var header_default = Header; 3518 3519 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs 3520 var import_block_editor13 = __toESM(require_block_editor(), 1); 3521 var import_compose9 = __toESM(require_compose(), 1); 3522 var import_data23 = __toESM(require_data(), 1); 3523 var import_element19 = __toESM(require_element(), 1); 3524 var import_preferences7 = __toESM(require_preferences(), 1); 3525 3526 // packages/edit-widgets/build-module/components/notices/index.mjs 3527 var import_notices2 = __toESM(require_notices(), 1); 3528 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 3529 function Notices() { 3530 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [ 3531 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3532 import_notices2.InlineNotices, 3533 { 3534 pinnedNoticesClassName: "edit-widgets-notices__pinned", 3535 dismissibleNoticesClassName: "edit-widgets-notices__dismissible" 3536 } 3537 ), 3538 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_notices2.SnackbarNotices, { className: "edit-widgets-notices__snackbar" }) 3539 ] }); 3540 } 3541 var notices_default = Notices; 3542 3543 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs 3544 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 3545 function WidgetAreasBlockEditorContent({ 3546 blockEditorSettings 3547 }) { 3548 const hasThemeStyles = (0, import_data23.useSelect)( 3549 (select) => !!select(import_preferences7.store).get( 3550 "core/edit-widgets", 3551 "themeStyles" 3552 ), 3553 [] 3554 ); 3555 const isLargeViewport = (0, import_compose9.useViewportMatch)("medium"); 3556 const styles = (0, import_element19.useMemo)(() => { 3557 return hasThemeStyles ? blockEditorSettings.styles : []; 3558 }, [blockEditorSettings, hasThemeStyles]); 3559 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "edit-widgets-block-editor", children: [ 3560 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(notices_default, {}), 3561 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockToolbar, { hideDragHandle: true }), 3562 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_block_editor13.BlockTools, { children: [ 3563 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(keyboard_shortcuts_default, {}), 3564 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3565 import_block_editor13.__unstableEditorStyles, 3566 { 3567 styles, 3568 scope: ":where(.editor-styles-wrapper)" 3569 } 3570 ), 3571 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockSelectionClearer, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.WritingFlow, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockList, { className: "edit-widgets-main-block-list" }) }) }) 3572 ] }) 3573 ] }); 3574 } 3575 3576 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs 3577 var import_data27 = __toESM(require_data(), 1); 3578 3579 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs 3580 var import_block_editor15 = __toESM(require_block_editor(), 1); 3581 var import_compose10 = __toESM(require_compose(), 1); 3582 var import_element20 = __toESM(require_element(), 1); 3583 var import_data25 = __toESM(require_data(), 1); 3584 3585 // packages/edit-widgets/build-module/hooks/use-widget-library-insertion-point.mjs 3586 var import_data24 = __toESM(require_data(), 1); 3587 var import_block_editor14 = __toESM(require_block_editor(), 1); 3588 var import_core_data11 = __toESM(require_core_data(), 1); 3589 var useWidgetLibraryInsertionPoint = () => { 3590 const firstRootId = (0, import_data24.useSelect)((select) => { 3591 const { getEntityRecord } = select(import_core_data11.store); 3592 const widgetAreasPost = getEntityRecord( 3593 KIND, 3594 POST_TYPE, 3595 buildWidgetAreasPostId() 3596 ); 3597 return widgetAreasPost?.blocks[0]?.clientId; 3598 }, []); 3599 return (0, import_data24.useSelect)( 3600 (select) => { 3601 const { 3602 getBlockRootClientId, 3603 getBlockSelectionEnd, 3604 getBlockOrder, 3605 getBlockIndex 3606 } = select(import_block_editor14.store); 3607 const insertionPoint = select(store2).__experimentalGetInsertionPoint(); 3608 if (insertionPoint.rootClientId) { 3609 return insertionPoint; 3610 } 3611 const clientId = getBlockSelectionEnd() || firstRootId; 3612 const rootClientId = getBlockRootClientId(clientId); 3613 if (clientId && rootClientId === "") { 3614 return { 3615 rootClientId: clientId, 3616 insertionIndex: getBlockOrder(clientId).length 3617 }; 3618 } 3619 return { 3620 rootClientId, 3621 insertionIndex: getBlockIndex(clientId) + 1 3622 }; 3623 }, 3624 [firstRootId] 3625 ); 3626 }; 3627 var use_widget_library_insertion_point_default = useWidgetLibraryInsertionPoint; 3628 3629 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs 3630 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 3631 function InserterSidebar() { 3632 const isMobileViewport = (0, import_compose10.useViewportMatch)("medium", "<"); 3633 const { rootClientId, insertionIndex } = use_widget_library_insertion_point_default(); 3634 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data25.useDispatch)(store2); 3635 const closeInserter = (0, import_element20.useCallback)(() => { 3636 return setIsInserterOpened2(false); 3637 }, [setIsInserterOpened2]); 3638 const libraryRef = (0, import_element20.useRef)(); 3639 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "edit-widgets-layout__inserter-panel", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "edit-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 3640 import_block_editor15.__experimentalLibrary, 3641 { 3642 showInserterHelpPanel: true, 3643 shouldFocusBlock: isMobileViewport, 3644 rootClientId, 3645 __experimentalInsertionIndex: insertionIndex, 3646 ref: libraryRef, 3647 onClose: closeInserter 3648 } 3649 ) }) }); 3650 } 3651 3652 // packages/edit-widgets/build-module/components/secondary-sidebar/list-view-sidebar.mjs 3653 var import_block_editor16 = __toESM(require_block_editor(), 1); 3654 var import_components20 = __toESM(require_components(), 1); 3655 var import_compose11 = __toESM(require_compose(), 1); 3656 var import_data26 = __toESM(require_data(), 1); 3657 var import_element21 = __toESM(require_element(), 1); 3658 var import_i18n17 = __toESM(require_i18n(), 1); 3659 var import_keycodes6 = __toESM(require_keycodes(), 1); 3660 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 3661 function ListViewSidebar() { 3662 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data26.useDispatch)(store2); 3663 const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data26.useSelect)(store2)); 3664 const [dropZoneElement, setDropZoneElement] = (0, import_element21.useState)(null); 3665 const focusOnMountRef = (0, import_compose11.useFocusOnMount)("firstElement"); 3666 const closeListView = (0, import_element21.useCallback)(() => { 3667 setIsListViewOpened2(false); 3668 getListViewToggleRef2().current?.focus(); 3669 }, [getListViewToggleRef2, setIsListViewOpened2]); 3670 const closeOnEscape = (0, import_element21.useCallback)( 3671 (event) => { 3672 if (event.keyCode === import_keycodes6.ESCAPE && !event.defaultPrevented) { 3673 event.preventDefault(); 3674 closeListView(); 3675 } 3676 }, 3677 [closeListView] 3678 ); 3679 return ( 3680 // eslint-disable-next-line jsx-a11y/no-static-element-interactions 3681 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)( 3682 "div", 3683 { 3684 className: "edit-widgets-editor__list-view-panel", 3685 onKeyDown: closeOnEscape, 3686 children: [ 3687 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "edit-widgets-editor__list-view-panel-header", children: [ 3688 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: (0, import_i18n17.__)("List View") }), 3689 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3690 import_components20.Button, 3691 { 3692 icon: close_small_default, 3693 label: (0, import_i18n17.__)("Close"), 3694 onClick: closeListView, 3695 size: "compact" 3696 } 3697 ) 3698 ] }), 3699 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3700 "div", 3701 { 3702 className: "edit-widgets-editor__list-view-panel-content", 3703 ref: (0, import_compose11.useMergeRefs)([focusOnMountRef, setDropZoneElement]), 3704 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_block_editor16.__experimentalListView, { dropZoneElement }) 3705 } 3706 ) 3707 ] 3708 } 3709 ) 3710 ); 3711 } 3712 3713 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs 3714 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 3715 function SecondarySidebar() { 3716 const { isInserterOpen, isListViewOpen } = (0, import_data27.useSelect)((select) => { 3717 const { isInserterOpened: isInserterOpened2, isListViewOpened: isListViewOpened2 } = select(store2); 3718 return { 3719 isInserterOpen: isInserterOpened2(), 3720 isListViewOpen: isListViewOpened2() 3721 }; 3722 }, []); 3723 if (isInserterOpen) { 3724 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(InserterSidebar, {}); 3725 } 3726 if (isListViewOpen) { 3727 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ListViewSidebar, {}); 3728 } 3729 return null; 3730 } 3731 3732 // packages/edit-widgets/build-module/components/layout/interface.mjs 3733 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 3734 var interfaceLabels = { 3735 /* translators: accessibility text for the widgets screen top bar landmark region. */ 3736 header: (0, import_i18n18.__)("Widgets top bar"), 3737 /* translators: accessibility text for the widgets screen content landmark region. */ 3738 body: (0, import_i18n18.__)("Widgets and blocks"), 3739 /* translators: accessibility text for the widgets screen settings landmark region. */ 3740 sidebar: (0, import_i18n18.__)("Widgets settings"), 3741 /* translators: accessibility text for the widgets screen footer landmark region. */ 3742 footer: (0, import_i18n18.__)("Widgets footer") 3743 }; 3744 function Interface({ blockEditorSettings }) { 3745 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<"); 3746 const isHugeViewport = (0, import_compose12.useViewportMatch)("huge", ">="); 3747 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2, closeGeneralSidebar: closeGeneralSidebar2 } = (0, import_data28.useDispatch)(store2); 3748 const { 3749 hasBlockBreadCrumbsEnabled, 3750 hasSidebarEnabled, 3751 isInserterOpened: isInserterOpened2, 3752 isListViewOpened: isListViewOpened2 3753 } = (0, import_data28.useSelect)( 3754 (select) => ({ 3755 hasSidebarEnabled: !!select( 3756 store 3757 ).getActiveComplementaryArea(store2.name), 3758 isInserterOpened: !!select(store2).isInserterOpened(), 3759 isListViewOpened: !!select(store2).isListViewOpened(), 3760 hasBlockBreadCrumbsEnabled: !!select(import_preferences8.store).get( 3761 "core/edit-widgets", 3762 "showBlockBreadcrumbs" 3763 ) 3764 }), 3765 [] 3766 ); 3767 (0, import_element22.useEffect)(() => { 3768 if (hasSidebarEnabled && !isHugeViewport) { 3769 setIsInserterOpened2(false); 3770 setIsListViewOpened2(false); 3771 } 3772 }, [hasSidebarEnabled, isHugeViewport]); 3773 (0, import_element22.useEffect)(() => { 3774 if ((isInserterOpened2 || isListViewOpened2) && !isHugeViewport) { 3775 closeGeneralSidebar2(); 3776 } 3777 }, [isInserterOpened2, isListViewOpened2, isHugeViewport]); 3778 const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n18.__)("List View") : (0, import_i18n18.__)("Block Library"); 3779 const hasSecondarySidebar = isListViewOpened2 || isInserterOpened2; 3780 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 3781 interface_skeleton_default, 3782 { 3783 labels: { 3784 ...interfaceLabels, 3785 secondarySidebar: secondarySidebarLabel 3786 }, 3787 header: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(header_default, {}), 3788 secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SecondarySidebar, {}), 3789 sidebar: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(complementary_area_default.Slot, { scope: "core/edit-widgets" }), 3790 content: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 3791 WidgetAreasBlockEditorContent, 3792 { 3793 blockEditorSettings 3794 } 3795 ) }), 3796 footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "edit-widgets-layout__footer", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_block_editor17.BlockBreadcrumb, { rootLabelText: (0, import_i18n18.__)("Widgets") }) }) 3797 } 3798 ); 3799 } 3800 var interface_default = Interface; 3801 3802 // packages/edit-widgets/build-module/components/layout/unsaved-changes-warning.mjs 3803 var import_i18n19 = __toESM(require_i18n(), 1); 3804 var import_element23 = __toESM(require_element(), 1); 3805 var import_data29 = __toESM(require_data(), 1); 3806 function UnsavedChangesWarning() { 3807 const isDirty = (0, import_data29.useSelect)((select) => { 3808 const { getEditedWidgetAreas: getEditedWidgetAreas2 } = select(store2); 3809 const editedWidgetAreas = getEditedWidgetAreas2(); 3810 return editedWidgetAreas?.length > 0; 3811 }, []); 3812 (0, import_element23.useEffect)(() => { 3813 const warnIfUnsavedChanges = (event) => { 3814 if (isDirty) { 3815 event.returnValue = (0, import_i18n19.__)( 3816 "You have unsaved changes. If you proceed, they will be lost." 3817 ); 3818 return event.returnValue; 3819 } 3820 }; 3821 window.addEventListener("beforeunload", warnIfUnsavedChanges); 3822 return () => { 3823 window.removeEventListener("beforeunload", warnIfUnsavedChanges); 3824 }; 3825 }, [isDirty]); 3826 return null; 3827 } 3828 3829 // packages/edit-widgets/build-module/components/welcome-guide/index.mjs 3830 var import_data30 = __toESM(require_data(), 1); 3831 var import_components21 = __toESM(require_components(), 1); 3832 var import_i18n20 = __toESM(require_i18n(), 1); 3833 var import_element24 = __toESM(require_element(), 1); 3834 var import_preferences9 = __toESM(require_preferences(), 1); 3835 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 3836 function WelcomeGuide() { 3837 const isActive = (0, import_data30.useSelect)( 3838 (select) => !!select(import_preferences9.store).get( 3839 "core/edit-widgets", 3840 "welcomeGuide" 3841 ), 3842 [] 3843 ); 3844 const { toggle } = (0, import_data30.useDispatch)(import_preferences9.store); 3845 const widgetAreas = (0, import_data30.useSelect)( 3846 (select) => select(store2).getWidgetAreas({ per_page: -1 }), 3847 [] 3848 ); 3849 if (!isActive) { 3850 return null; 3851 } 3852 const isEntirelyBlockWidgets = widgetAreas?.every( 3853 (widgetArea) => widgetArea.id === "wp_inactive_widgets" || widgetArea.widgets.every( 3854 (widgetId) => widgetId.startsWith("block-") 3855 ) 3856 ); 3857 const numWidgetAreas = widgetAreas?.filter( 3858 (widgetArea) => widgetArea.id !== "wp_inactive_widgets" 3859 ).length ?? 0; 3860 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3861 import_components21.Guide, 3862 { 3863 className: "edit-widgets-welcome-guide", 3864 contentLabel: (0, import_i18n20.__)("Welcome to block Widgets"), 3865 finishButtonText: (0, import_i18n20.__)("Get started"), 3866 onFinish: () => toggle("core/edit-widgets", "welcomeGuide"), 3867 pages: [ 3868 { 3869 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3870 WelcomeGuideImage, 3871 { 3872 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg", 3873 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif" 3874 } 3875 ), 3876 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [ 3877 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Welcome to block Widgets") }), 3878 isEntirelyBlockWidgets ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.sprintf)( 3879 // Translators: %s: Number of block areas in the current theme. 3880 (0, import_i18n20._n)( 3881 "Your theme provides %s \u201Cblock\u201D area for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.", 3882 "Your theme provides %s different \u201Cblock\u201D areas for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.", 3883 numWidgetAreas 3884 ), 3885 numWidgetAreas 3886 ) }) }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [ 3887 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)( 3888 "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly." 3889 ) }), 3890 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "edit-widgets-welcome-guide__text", children: [ 3891 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("strong", { children: (0, import_i18n20.__)( 3892 "Want to stick with the old widgets?" 3893 ) }), 3894 " ", 3895 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3896 import_components21.ExternalLink, 3897 { 3898 href: (0, import_i18n20.__)( 3899 "https://wordpress.org/plugins/classic-widgets/" 3900 ), 3901 children: (0, import_i18n20.__)( 3902 "Get the Classic Widgets plugin." 3903 ) 3904 } 3905 ) 3906 ] }) 3907 ] }) 3908 ] }) 3909 }, 3910 { 3911 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3912 WelcomeGuideImage, 3913 { 3914 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg", 3915 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif" 3916 } 3917 ), 3918 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [ 3919 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Customize each block") }), 3920 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)( 3921 "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." 3922 ) }) 3923 ] }) 3924 }, 3925 { 3926 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3927 WelcomeGuideImage, 3928 { 3929 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg", 3930 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif" 3931 } 3932 ), 3933 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [ 3934 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Explore all blocks") }), 3935 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element24.createInterpolateElement)( 3936 (0, import_i18n20.__)( 3937 "All of the blocks available to you live in the block library. You\u2019ll find it wherever you see the <InserterIconImage /> icon." 3938 ), 3939 { 3940 InserterIconImage: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3941 "img", 3942 { 3943 className: "edit-widgets-welcome-guide__inserter-icon", 3944 alt: (0, import_i18n20.__)("inserter"), 3945 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" 3946 } 3947 ) 3948 } 3949 ) }) 3950 ] }) 3951 }, 3952 { 3953 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3954 WelcomeGuideImage, 3955 { 3956 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg", 3957 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif" 3958 } 3959 ), 3960 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [ 3961 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Learn more") }), 3962 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element24.createInterpolateElement)( 3963 (0, import_i18n20.__)( 3964 "New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>" 3965 ), 3966 { 3967 a: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3968 import_components21.ExternalLink, 3969 { 3970 href: (0, import_i18n20.__)( 3971 "https://wordpress.org/documentation/article/wordpress-block-editor/" 3972 ) 3973 } 3974 ) 3975 } 3976 ) }) 3977 ] }) 3978 } 3979 ] 3980 } 3981 ); 3982 } 3983 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) { 3984 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("picture", { className: "edit-widgets-welcome-guide__image", children: [ 3985 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 3986 "source", 3987 { 3988 srcSet: nonAnimatedSrc, 3989 media: "(prefers-reduced-motion: reduce)" 3990 } 3991 ), 3992 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" }) 3993 ] }); 3994 } 3995 3996 // packages/edit-widgets/build-module/components/layout/index.mjs 3997 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 3998 function Layout({ blockEditorSettings }) { 3999 const { createErrorNotice } = (0, import_data31.useDispatch)(import_notices4.store); 4000 function onPluginAreaError(name2) { 4001 createErrorNotice( 4002 (0, import_i18n21.sprintf)( 4003 /* translators: %s: plugin name */ 4004 (0, import_i18n21.__)( 4005 'The "%s" plugin has encountered an error and cannot be rendered.' 4006 ), 4007 name2 4008 ) 4009 ); 4010 } 4011 const navigateRegionsProps = (0, import_components22.__unstableUseNavigateRegions)(); 4012 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4013 "div", 4014 { 4015 className: navigateRegionsProps.className, 4016 ...navigateRegionsProps, 4017 ref: navigateRegionsProps.ref, 4018 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)( 4019 WidgetAreasBlockEditorProvider, 4020 { 4021 blockEditorSettings, 4022 children: [ 4023 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(interface_default, { blockEditorSettings }), 4024 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Sidebar, {}), 4025 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_plugins3.PluginArea, { onError: onPluginAreaError }), 4026 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(UnsavedChangesWarning, {}), 4027 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(WelcomeGuide, {}) 4028 ] 4029 } 4030 ) 4031 } 4032 ) }); 4033 } 4034 var layout_default = Layout; 4035 4036 // packages/edit-widgets/build-module/index.mjs 4037 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 4038 var disabledBlocks = [ 4039 "core/more", 4040 "core/freeform", 4041 "core/template-part", 4042 ...ALLOW_REUSABLE_BLOCKS ? [] : ["core/block"] 4043 ]; 4044 function initializeEditor(id, settings2) { 4045 const target = document.getElementById(id); 4046 const root = (0, import_element25.createRoot)(target); 4047 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter((block) => { 4048 return !(disabledBlocks.includes(block.name) || block.name.startsWith("core/post") || block.name.startsWith("core/query") || block.name.startsWith("core/site") || block.name.startsWith("core/navigation") || block.name.startsWith("core/term")); 4049 }); 4050 (0, import_data32.dispatch)(import_preferences10.store).setDefaults("core/edit-widgets", { 4051 fixedToolbar: false, 4052 welcomeGuide: true, 4053 showBlockBreadcrumbs: true, 4054 themeStyles: true 4055 }); 4056 (0, import_data32.dispatch)(import_blocks3.store).reapplyBlockTypeFilters(); 4057 (0, import_block_library2.registerCoreBlocks)(coreBlocks); 4058 (0, import_widgets5.registerLegacyWidgetBlock)(); 4059 if (false) { 4060 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({ 4061 enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS 4062 }); 4063 } 4064 (0, import_widgets5.registerLegacyWidgetVariations)(settings2); 4065 registerBlock(widget_area_exports); 4066 (0, import_widgets5.registerWidgetGroupBlock)(); 4067 settings2.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0, import_core_data12.__experimentalFetchLinkSuggestions)(search, searchOptions, settings2); 4068 (0, import_blocks3.setFreeformContentHandlerName)("core/html"); 4069 root.render( 4070 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_element25.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(layout_default, { blockEditorSettings: settings2 }) }) 4071 ); 4072 return root; 4073 } 4074 var initialize = initializeEditor; 4075 function reinitializeEditor() { 4076 (0, import_deprecated6.default)("wp.editWidgets.reinitializeEditor", { 4077 since: "6.2", 4078 version: "6.3" 4079 }); 4080 } 4081 var registerBlock = (block) => { 4082 if (!block) { 4083 return; 4084 } 4085 const { metadata, settings: settings2, name: name2 } = block; 4086 if (metadata) { 4087 (0, import_blocks3.unstable__bootstrapServerSideBlockDefinitions)({ [name2]: metadata }); 4088 } 4089 (0, import_blocks3.registerBlockType)(name2, settings2); 4090 }; 4091 return __toCommonJS(index_exports); 4092 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon Jun 29 08:20:12 2026 | Cross-referenced by PHPXref |