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